1.9.3 on Mac using Nova Editor
Hey everybody. I'm having trouble understanding sprite animation. I have an imageTable set up with 6 frames to coincide with 6 crankTicks. By itself the imagetable loop works fine, and by itself the crankTicks work fine, however, I'm trying to make the animation frame follow the current crankTick but I don't know how to update or change the players frame so it matches. Any and all animation tips are welcome.
I was able to keep the sprite's image, from an image table, in sync with the crank ticks like this:
local currentImage = 1
local numberTable = gfx.imagetable.new('images/number')
local numberOneImage = numberTable:getImage(currentImage)
local numberSprite = gfx.sprite.new(numberOneImage)
--- This update method is called once per frame.
local ticksPerRevolution = 6
local crankChange = playdate.getCrankTicks(ticksPerRevolution)
if crankChange ~= 0 then
currentImage += crankChange
if currentImage <= 0 then
currentImage = #numberTable
elseif currentImage > #numberTable then
currentImage = 1
And you can see it in action:
test-rotate-imagetable.zip (67.7 KB)
Thank you Chris! This was a big help in understanding what goes on with :setImage. It seems to occasionally skip the 5th tick and goes straight from 4 - 6 (even when going slow but not while going backwards), but I will work on massaging that and see if I can solve what's going on there.
This is what I've got going on so far.
Now for my next challenge, changing the sprite so the "Shadowboxer" can punch! I'll update how that goes and if I'm able to accomplish it.