Code example for multiple sequence sprite sheets?

Just wondering if there is a code example on how to use multiple sequence sprite sheets. Not so much the loading but the playback but a full example would be really helpful
[import]uid: 9371 topic_id: 4042 reply_id: 304042[/import]

Here’s mine in semi-pseudo code. Use it as a building block, it is not a working example.

[lua]–Load in the PNG & Data
local dominicSheet = sprite.newSpriteSheetFromData(
“playerSprite.png”,
require(“playerSprite”).getSpriteSheetData()
)
dominicSprite = sprite.newSpriteSet(dominicSheet, 1, 35)

–Assign sequences based on frame values and SPEEDs
–Simplified to up and down for example purposes, I actually have 5->8 directions.
sprite.add( dominicSprite, “down”, 1, 7, 400, -2)
sprite.add( dominicSprite, “downslow”, 1, 7, 600, -2)
sprite.add( dominicSprite, “downslower”, 1, 7, 800, -2)
sprite.add( dominicSprite, “up”, 29, 7, 400, -2)
sprite.add( dominicSprite, “upslow”, 29, 7, 600, -2)
sprite.add( dominicSprite, “upslower”, 29, 7, 800, -2)[/lua]

Then create instance of it.
[lua]dominic = sprite.newSprite(dominicSprite)

–Position sprite
dominic:setReferencePoint(display.BottomCenterReferencePoint)
dominic.x = gameDisplay:playerX(dominicX)
dominic.y = gameDisplay:playerY(dominicY)
dominic.z = 0

–Prepare sequence that matches starting state
dominic:prepare(“down”)
–Manually set frame without playing
dominic.currentFrame = 4[/lua]

Then when getting controls. Note that this example uses a function that collaborates with the joystick class.
[lua]–Create a string to hold speed values
local slowme = “”

–Based on how far you press the joystick, choose a state depending on speed
–Note that you should create a way to detect when the joystick is not active
–so you can set the sprite animation to rest state. For standing.
if (joystick.joyVector <= 0.2) then
slowme = “slower”
elseif (joystick.joyVector > 0.2) and (joystick.joyVector < 0.8) then
slowme = “slow”
end

–Now choose the direction and apply the speed
if (up) then
dominicDirection = “up”…slowme
elseif (down) then
dominicDirection = “down”…slowme
end

–Here if you want to conserve on texture memory you might include
–a mirror function to flip the sprite for left/right facing movement

–See if he’s not already facing that direction:
–Change it if he is. This is mandatory or else
–Animations will always appear to show frame 1 of the step
if not (dominic.sequence == dominicDirection) then
dominic:prepare(dominicDirection)
–Start Animation Sequence
dominic:play()
end

–Move sprite
dominic.x = dominic.x + xMove
dominic.y = dominic.y + xMove[/lua]
[import]uid: 11024 topic_id: 4042 reply_id: 12376[/import]

COOL! Thanks! [import]uid: 9371 topic_id: 4042 reply_id: 12382[/import]