Hi Everyone,
I’ve been trying to get on top of using the new Sprite API and I’m coming across one stumbling block. I know a lot of people were interested in having sprite sequences spread across multiple sprite sheets and I was wondering if anyone has managed this with the new API?
Here’s an example of code to explain what I’m trying to do:
[code]
local options =
{
width = 250,
height = 250,
numFrames = 45
}
local imageSheet1 = graphics.newImageSheet( “walking_running.png”, options )
local imageSheet2 = graphics.newImageSheet( “talking_jumping.png”, options )
local sequenceData = {
{ name=“walking”, start=1, count=45, loopCount=1, imageSheet=imageSheet1, time=2000 },
{ name=“running”, start=1, count=45, loopCount=1, imageSheet=imageSheet1, time=2000 },
{ name=“talking”, start=1, count=45, loopCount=1, imageSheet=imageSheet2, time=2000 },
{ name=“jumping”, start=1, count=45, loopCount=1, imageSheet=imageSheet2, time=2000 }
}
–After Character object (below) finishes an animation, play Talking sequence automatically
local function nextAnimation(event)
if event.phase == ‘ended’ then
– ** Change to another animation sequence here
event.target:setSequence(“talking”) – But this set of frames is on ImageSheet2
event.target:play()
end
end
local character = display.newSprite( imageSheet, sequenceData ) – ** What if I want to access frames on ImageSheet2?
character.x, character.y = 500, 500
character:addEventListener(“sprite”, nextAnimation)
character:setSequence(“walking”)
character:play()
[/code] [import]uid: 156990 topic_id: 32739 reply_id: 332739[/import]