Can't change sequence on Sprite Object

I have set up a multi-sequence multi-imageSheet animation using the new Sprite APIs, but have found that I am unable to change a sequence after I initially use “spriteObject:setSequence( seq )”.

I have posted some code below. A few things to note: Whichever sequence I use initially, is the sequence that will persist no matter what I put in the setSequence function. It appears that some of the properties of the sequence are changing (time, loopCount, etc) when I change sequence, but the actual frames do not.

–Sprite Creation
[lua] local ljh_file = require(“spriteData.player_ljh@”…scale…“x”)
local ljh_data = { spriteSheetFrames = ljh_file.getSpriteSheetData().frames }
local ljh_sheet = graphics.newImageSheet( “images/fight/player/player_ljh@”…scale…“x.png”, ljh_data )

local ljl_file = require(“spriteData.player_ljl@”…scale…“x”)
local ljl_data = { spriteSheetFrames = ljl_file.getSpriteSheetData().frames }
local ljl_sheet = graphics.newImageSheet( “images/fight/player/player_ljl@”…scale…“x.png”, ljl_data )

local lrdy_file = require(“spriteData.player_lrdy@”…scale…“x”)
local lrdy_data = { spriteSheetFrames = lrdy_file.getSpriteSheetData().frames }
local lrdy_sheet = graphics.newImageSheet( “images/fight/player/player_lrdy@”…scale…“x.png”, lrdy_data )

local lju_file = require(“spriteData.player_lju@”…scale…“x”)
local lju_data = { spriteSheetFrames = lju_file.getSpriteSheetData().frames }
local lju_sheet = graphics.newImageSheet( “images/fight/player/player_lju@”…scale…“x.png”, lju_data )

local player_left_sequence =
{
{ sheet = lrdy_sheet, name = “lrdy”, frames = { 1, 2, 3, 4, 5, 6 }, time = 1000, loopCount = 0 },
{ sheet = ljh_sheet, name = “ljh”, frames = { 1, 2, 3, 4, 5, 6, 1}, time = 1000, loopCount = 1 },
{ sheet = ljl_sheet, name = “ljl”, frames = { 1, 2, 3, 4, 5, 6, 7, 1 }, time = 1000, loopCount = 1 },
{ sheet = lju_sheet, name = “lju”, frames = { 1, 2, 3, 4, 5, 6, 1 }, time = 1000, loopCount = 1 },
}
local player_left = display.newSprite( lrdy_sheet, player_left_sequence )[/lua]

Sample data file (generated from TexturePacker) (uses Trimming):
[lua]local SpriteSheet = {}
SpriteSheet.getSpriteSheetData = function ()
return {
frames = {
{
spriteColorRect = { x = 234, y = 195, width = 518, height = 536 },
textureRect = { x = 2, y = 2, width = 518, height = 536 },
spriteSourceSize = { width = 894, height = 764 },
spriteTrimmed = true,
textureRotated = false
},
{
spriteColorRect = { x = 234, y = 197, width = 518, height = 536 },
textureRect = { x = 2, y = 2, width = 518, height = 536 },
spriteSourceSize = { width = 894, height = 764 },
spriteTrimmed = true,
textureRotated = false
},
{
spriteColorRect = { x = 234, y = 199, width = 518, height = 536 },
textureRect = { x = 2, y = 2, width = 518, height = 536 },
spriteSourceSize = { width = 894, height = 764 },
spriteTrimmed = true,
textureRotated = false
},
{
spriteColorRect = { x = 234, y = 201, width = 518, height = 536 },
textureRect = { x = 2, y = 2, width = 518, height = 536 },
spriteSourceSize = { width = 894, height = 764 },
spriteTrimmed = true,
textureRotated = false
},
{
spriteColorRect = { x = 234, y = 199, width = 518, height = 536 },
textureRect = { x = 2, y = 2, width = 518, height = 536 },
spriteSourceSize = { width = 894, height = 764 },
spriteTrimmed = true,
textureRotated = false
},
{
spriteColorRect = { x = 234, y = 198, width = 518, height = 536 },
textureRect = { x = 2, y = 2, width = 518, height = 536 },
spriteSourceSize = { width = 894, height = 764 },
spriteTrimmed = true,
textureRotated = false
},
}
}
end
return SpriteSheet[/lua]

And finally, the code I am using to change sequences
[lua]player_left:setSequence(“lrdy”)
player_left:play()
–Not really what I have in my code, but this is easier than copying my whole project.
–Just waiting 30 seconds and trying to change the sequence.
timer.performWithDelay( 30000, function() player_left:prepare( “ljh” ); player_left:play() end )[/lua]

Regards,
Brian Reinhart
Feel free to email me as well Brian at velluminteractive dot com [import]uid: 158289 topic_id: 29774 reply_id: 329774[/import]

Hi All,

Just a bit more info for you all. I have set up an event to the sprite, and successfully print out the correct sequence name. It appears that it is changing sequences, but not the frames. My guess is that it loads the imageSheet associated with the first sequence set, and then fails to change to the new imageSheet when a new sequence is called.

Here is my event listener code.

[lua]local function playerAnimationEvent( event )

if event.phase == “ended” then
print(“sequence : “…event.target.sequence…” : ended.”)
if event.target == player.left then
playSequence(event.target, “lrdy”)
else
playSequence(event.target, “rrdy”)
end
end
end[/lua]
This code will print out the correct sequence name, but the sequence being played is always the same.

Has anyone been able to get Multi Image Sheet sequences to work in the new Sprite API?

Regards,
Brian [import]uid: 158289 topic_id: 29774 reply_id: 119539[/import]

bump - Still unable to figure this out. Any guidance or acknowledgment would help.
-Brian [import]uid: 158289 topic_id: 29774 reply_id: 119633[/import]

This is the code you posted:

player\_left:setSequence("lrdy")  
player\_left:play()  
--Not really what I have in my code, but this is easier than copying my whole project.   
--Just waiting 30 seconds and trying to change the sequence.  
timer.performWithDelay( 30000, function() player\_left:prepare( "ljh" ); player\_left:play() end )  

The error is clear if you compare the two below snippets.

player\_left:setSequence("lrdy")  
player\_left:play()  
--Not really what I have in my code, but this is easier than copying my whole project.   
--Just waiting 30 seconds and trying to change the sequence.  
timer.performWithDelay( 30000, function() player\_left:prepare( "ljh" ) player\_left:play() end ) --\<\<\<\<\<\<\<  

Should be:

player\_left:setSequence("lrdy") player\_left:play() --Not really what I have in my code, but this is easier than copying my whole project. --Just waiting 30 seconds and trying to change the sequence. timer.performWithDelay( 30000, function() player\_left:setSequence( "ljh" ); player\_left:play() end ) --\<\<\<\<\<\<\<\< [import]uid: 84637 topic_id: 29774 reply_id: 119650[/import]

Danny, Yes, that is definitely a bug in what I posted. Unfortunately, that was code I just added to the post for simplicity.

I am not using prepare() anywhere in my actual code. Would it help if I posted the source somewhere for you to look at?

Regards,
Brian [import]uid: 158289 topic_id: 29774 reply_id: 119652[/import]

Sure, post it up :slight_smile:

Edit: Scratch that. I see the issue now.

Your using a multi sprite set, but not using the multi sprite api:

See these documents for how to use it.

http://developer.coronalabs.com/sites/default/files/corona/2012.863/CoronaApiDocs-2012.863.zip

Also you will need daily build 863 or later

http://developer.coronalabs.com/release/2012/863/ [import]uid: 84637 topic_id: 29774 reply_id: 119653[/import]

main game loop:
[lua]local function playSequence(plyr, seq)

–plyr:pause()
–timer.performWithDelay( 33, function() plyr:prepare( seq ); plyr:play() end )
plyr:setSequence(seq)
plyr:play()

end

–PLAYER EVENTS

local function playerAnimationEvent( event )

if event.phase == “ended” then
print(“sequence : “…event.target.sequence…” : ended.”)
if event.target == player.left then
playSequence(event.target, “lrdy”)
else
playSequence(event.target, “rrdy”)
end
end
end

–RUNTIME EVENTS

local function screenTouched(event)
local eventY, eventX, startY, startX = event.y - offsetY, event.x - offsetX, event.yStart - offsetY, event.xStart - offsetX

if event.phase == “began” then
if eventX >= halfW then
if eventY >= halfH then
touch.right.low = true
else
touch.right.high = true
end
else
if eventY >= halfH then
touch.left.low = true
else
touch.left.high = true
end
end
determineAction()
elseif event.phase == “ended” then
if eventX >= halfW then
if eventY >= halfH then
touch.right.low = false
print (“Jab Right Low”)
playSequence(player.right, “rjl”)
else
touch.right.high = false
if startY >= halfH and startX >= halfW then
print (“Right UpperCut”)
touch.right.low = false
playSequence(player.right, “rju”)
else
print (“Right Jab High”)
playSequence(player.right, “rjh”)
end
end
else
if eventY >= halfH then
touch.left.low = false
print(“Jab Left Low”)
playSequence(player.left, “ljl”)
else
touch.left.high = false
if startY >= halfH and startX <= halfW then
print (“Left UpperCut”)
touch.left.low = false
–playSequence(player.left, “lju”)
player.left:setSequence(“lju”)
player.left:play()
else
print( “left Jab High” )
playSequence(player.left, “ljh”)
end
end
end
determineAction()
end

end[/lua]

player.left and player.right are the two sprites returned from the spriteLoader class:
[lua]local spriteLoader = {}

spriteLoader.loadPlayerAnimations = function()

local player_left_set, player_right_set

local ljh_file = require(“spriteData.player_ljh@”…scale…“x”)
local ljh_data = { spriteSheetFrames = ljh_file.getSpriteSheetData().frames }
local ljh_sheet = graphics.newImageSheet( “images/fight/player/player_ljh@”…scale…“x.png”, ljh_data )

local ljl_file = require(“spriteData.player_ljl@”…scale…“x”)
local ljl_data = { spriteSheetFrames = ljl_file.getSpriteSheetData().frames }
local ljl_sheet = graphics.newImageSheet( “images/fight/player/player_ljl@”…scale…“x.png”, ljl_data )

local lrdy_file = require(“spriteData.player_lrdy@”…scale…“x”)
local lrdy_data = { spriteSheetFrames = lrdy_file.getSpriteSheetData().frames }
local lrdy_sheet = graphics.newImageSheet( “images/fight/player/player_lrdy@”…scale…“x.png”, lrdy_data )

local lju_file = require(“spriteData.player_lju@”…scale…“x”)
local lju_data = { spriteSheetFrames = lju_file.getSpriteSheetData().frames }
local lju_sheet = graphics.newImageSheet( “images/fight/player/player_lju@”…scale…“x.png”, lju_data )

local player_left_sequence =
{
{ name = “lrdy”, sheet = lrdy_sheet, frames = { 1, 2, 3, 4, 5, 6 }, time = 1000, loopCount = 0 },
{ name = “ljh”, sheet = ljh_sheet, frames = { 1, 2, 3, 4, 5, 6, 1}, time = 1000, loopCount = 1 },
{ name = “ljl”, sheet = ljl_sheet, frames = { 1, 2, 3, 4, 5, 6, 7, 1 }, time = 1000, loopCount = 1 },
{ name = “lju”, sheet = lju_sheet, frames = { 1, 2, 3, 4, 5, 6, 1 }, time = 1000, loopCount = 1 },
}

– sprite.add( player_left_set, “ljh”, 1,7, 1000, 1 )
– sprite.add( player_left_set, “ljl”, 8,8, 1000, 1 )
– sprite.add( player_left_set, “lju”, 16,7, 1000, 1 )
– sprite.add( player_left_set, “lrdy”, 23,6, 1000, 0 )

local rjh_file = require(“spriteData.player_rjh@”…scale…“x”)
local rjh_data = { spriteSheetFrames = rjh_file.getSpriteSheetData().frames }
local rjh_sheet = graphics.newImageSheet( “images/fight/player/player_rjh@”…scale…“x.png”, rjh_data )

local rjl_file = require(“spriteData.player_rjl@”…scale…“x”)
local rjl_data = { spriteSheetFrames = rjl_file.getSpriteSheetData().frames }
local rjl_sheet = graphics.newImageSheet( “images/fight/player/player_rjl@”…scale…“x.png”, rjl_data )

local rju_file = require(“spriteData.player_rju@”…scale…“x”)
local rju_data = { spriteSheetFrames = rju_file.getSpriteSheetData().frames }
local rju_sheet = graphics.newImageSheet( “images/fight/player/player_rju@”…scale…“x.png”, rju_data )

local rrdy_file = require(“spriteData.player_rrdy@”…scale…“x”)
local rrdy_data = rrdy_file.getSpriteSheetData()
local rrdy_sheet = graphics.newImageSheet( “images/fight/player/player_rrdy@”…scale…“x.png”, rrdy_data )

local player_right_sequence =
{
{ sheet = rjh_sheet, name = “rjh”, frames = { 1, 2, 3, 4, 5, 6, 1}, time = 1000, loopCount = 1 },
{ sheet = rjl_sheet, name = “rjl”, frames = { 1, 2, 3, 4, 5, 6, 7, 1 }, time = 1000, loopCount = 1 },
{ sheet = rju_sheet, name = “rju”, frames = { 1, 2, 3, 4, 5, 6, 1 }, time = 1000, loopCount = 1 },
{ sheet = rrdy_sheet, name = “rrdy”, frames = { 1, 2, 3, 4, 5, 6 }, time = 1000, loopCount = 0 },
}

– sprite.add( player_right_set, “rjh”, 1,7, 1000, 1 )
– sprite.add( player_right_set, “rjl”, 8,8, 1000, 1 )
– sprite.add( player_right_set, “rju”, 16,7, 1000, 1 )
– sprite.add( player_right_set, “rrdy”, 23,6, 1000, 0 )

local player_left = display.newSprite( lrdy_sheet, player_left_sequence )
local player_right = display.newSprite( rjh_sheet, player_right_sequence )

local s = 1/scale
player_left:scale( s,s )
player_right:scale( s,s )

return player_left, player_right

end

return spriteLoader[/lua]

Here are the sheet data files. You can see on line 62, I am loading the file a bit differently. I tried loading them both ways (using texturepacker’s default output, or creating a new sprite API sequence data table).
The following is using the new sequence data table format.
[lua]local SpriteSheet = {}
SpriteSheet.getSpriteSheetData = function ()
return {
frames = {
{
x = 2,
y = 2,
width = 518,
height = 536,
sourceWidth = 894,
sourceHeight = 764,
sourceX = 232,
sourceY = 193
},
{
x = 2,
y = 2,
width = 518,
height = 536,
sourceWidth = 894,
sourceHeight = 764,
sourceX = 232,
sourceY = 195
},
{
x = 2,
y = 2,
width = 518,
height = 536,
sourceWidth = 894,
sourceHeight = 764,
sourceX = 232,
sourceY = 197
},
{
x = 2,
y = 2,
width = 518,
height = 536,
sourceWidth = 894,
sourceHeight = 764,
sourceX = 232,
sourceY = 199
},
{
x = 2,
y = 2,
width = 518,
height = 536,
sourceWidth = 894,
sourceHeight = 764,
sourceX = 232,
sourceY = 197
},
{
x = 2,
y = 2,
width = 518,
height = 536,
sourceWidth = 894,
sourceHeight = 764,
sourceX = 232,
sourceY = 196
},
– frames = {
– {
– spriteColorRect = { x = 234, y = 195, width = 518, height = 536 },
– textureRect = { x = 2, y = 2, width = 518, height = 536 },
– spriteSourceSize = { width = 894, height = 764 },
– spriteTrimmed = true,
– textureRotated = false
– },
– {
– spriteColorRect = { x = 234, y = 197, width = 518, height = 536 },
– textureRect = { x = 2, y = 2, width = 518, height = 536 },
– spriteSourceSize = { width = 894, height = 764 },
– spriteTrimmed = true,
– textureRotated = false
– },
– {
– spriteColorRect = { x = 234, y = 199, width = 518, height = 536 },
– textureRect = { x = 2, y = 2, width = 518, height = 536 },
– spriteSourceSize = { width = 894, height = 764 },
– spriteTrimmed = true,
– textureRotated = false
– },
– {
– spriteColorRect = { x = 234, y = 201, width = 518, height = 536 },
– textureRect = { x = 2, y = 2, width = 518, height = 536 },
– spriteSourceSize = { width = 894, height = 764 },
– spriteTrimmed = true,
– textureRotated = false
– },
– {
– spriteColorRect = { x = 234, y = 199, width = 518, height = 536 },
– textureRect = { x = 2, y = 2, width = 518, height = 536 },
– spriteSourceSize = { width = 894, height = 764 },
– spriteTrimmed = true,
– textureRotated = false
– },
– {
– spriteColorRect = { x = 234, y = 198, width = 518, height = 536 },
– textureRect = { x = 2, y = 2, width = 518, height = 536 },
– spriteSourceSize = { width = 894, height = 764 },
– spriteTrimmed = true,
– textureRotated = false
– },
– }
}
}
end
return SpriteSheet[/lua]
Now using the old Texturepacker format. (this is the format used for all the imageSheets except for the ‘rrdy’ on line 62.
[lua]local SpriteSheet = {}
SpriteSheet.getSpriteSheetData = function ()
return {
frames = {
{
name = “Rup_frame_1@4x.png”,
spriteColorRect = { x = 213, y = 258, width = 512, height = 506 },
textureRect = { x = 2, y = 542, width = 512, height = 506 },
spriteSourceSize = { width = 894, height = 764 },
spriteTrimmed = true,
textureRotated = false
},
{
name = “Rup_frame_2@4x.png”,
spriteColorRect = { x = 11, y = 406, width = 644, height = 358 },
textureRect = { x = 2, y = 1534, width = 644, height = 358 },
spriteSourceSize = { width = 894, height = 764 },
spriteTrimmed = true,
textureRotated = false
},
{
name = “Rup_frame_3@4x.png”,
spriteColorRect = { x = 2, y = 282, width = 584, height = 482 },
textureRect = { x = 2, y = 1050, width = 584, height = 482 },
spriteSourceSize = { width = 894, height = 764 },
spriteTrimmed = true,
textureRotated = false
},
{
name = “Rup_frame_4@4x.png”,
spriteColorRect = { x = 11, y = 169, width = 456, height = 538 },
textureRect = { x = 2, y = 2, width = 456, height = 538 },
spriteSourceSize = { width = 894, height = 764 },
spriteTrimmed = true,
textureRotated = false
},
{
name = “Rup_frame_5@4x.png”,
spriteColorRect = { x = 20, y = 15, width = 322, height = 358 },
textureRect = { x = 516, y = 474, width = 322, height = 358 },
spriteSourceSize = { width = 894, height = 764 },
spriteTrimmed = true,
textureRotated = false
},
{
name = “Rup_frame_6@4x.png”,
spriteColorRect = { x = 159, y = 153, width = 440, height = 470 },
textureRect = { x = 460, y = 2, width = 440, height = 470 },
spriteSourceSize = { width = 894, height = 764 },
spriteTrimmed = true,
textureRotated = false
},
}
}
end
return SpriteSheet[/lua]
Let me know if you need more code or resource files. I can zip them up and send them wherever.

Thanks for looking into this.

Regards,
Brian [import]uid: 158289 topic_id: 29774 reply_id: 119654[/import]

I am using the mutli sprite API as defined in the latest build docs. I am on build 878. The new API states that you should use the “sheet” parameter in the sequence data. You can see that in my spriteLoader class, I am providing the sheet parameter.

snippet from documentation:

For each sequence, you can specify a different image sheet instead of using the default image sheet. You do this by using the optional sheet parameter in a sequenceData table (see ‘Format for sequenceData’ below).

Regards,
Brian [import]uid: 158289 topic_id: 29774 reply_id: 119656[/import]

bump. I still believe this is a bug. Can someone confirm this?

Regards,
Brian Reinhart [import]uid: 158289 topic_id: 29774 reply_id: 119758[/import]

Hey Vellum, sorry for the delayed reply.

Walter confirmed this was a bug and a fix should be available in one of the upcoming daily builds. [import]uid: 84637 topic_id: 29774 reply_id: 119866[/import]

Thank you Danny and Walter!

I will definitely be checking the daily builds for any progress. I appreciate it!

Brian Reinhart
Vellum Interactive
velluminteractive.com [import]uid: 158289 topic_id: 29774 reply_id: 119900[/import]

Hi Danny,

I see that the latest daily build changeLog shows that the setSequence function was fixed, but I am still having the same issue.

Can you confirm that the fix was deployed in build 2012.881

Regards,
Brian Reinhart

[import]uid: 158289 topic_id: 29774 reply_id: 119923[/import]

Hey Vellum, sorry to hear that.

Would you mind posting a bug report here: http://developer.coronalabs.com/content/bug-submission
Please read this guideline first: http://www.coronalabs.com/products/corona-sdk/rules-for-issue-submission/

So that I can investigate it and also so we have something proper to track?
Reference my name in the bug description section and I will check it out.

Thanks [import]uid: 84637 topic_id: 29774 reply_id: 120055[/import]

Hi Danny,

I submitted the buy request. I tried to make it as barebones as possible.

Also, I just noticed that I forgot to mention your name in the description.
Regards,
Brian [import]uid: 158289 topic_id: 29774 reply_id: 120081[/import]

Hi All,

Just a bit more info for you all. I have set up an event to the sprite, and successfully print out the correct sequence name. It appears that it is changing sequences, but not the frames. My guess is that it loads the imageSheet associated with the first sequence set, and then fails to change to the new imageSheet when a new sequence is called.

Here is my event listener code.

[lua]local function playerAnimationEvent( event )

if event.phase == “ended” then
print(“sequence : “…event.target.sequence…” : ended.”)
if event.target == player.left then
playSequence(event.target, “lrdy”)
else
playSequence(event.target, “rrdy”)
end
end
end[/lua]
This code will print out the correct sequence name, but the sequence being played is always the same.

Has anyone been able to get Multi Image Sheet sequences to work in the new Sprite API?

Regards,
Brian [import]uid: 158289 topic_id: 29774 reply_id: 119539[/import]

bump - Still unable to figure this out. Any guidance or acknowledgment would help.
-Brian [import]uid: 158289 topic_id: 29774 reply_id: 119633[/import]

This is the code you posted:

player\_left:setSequence("lrdy")  
player\_left:play()  
--Not really what I have in my code, but this is easier than copying my whole project.   
--Just waiting 30 seconds and trying to change the sequence.  
timer.performWithDelay( 30000, function() player\_left:prepare( "ljh" ); player\_left:play() end )  

The error is clear if you compare the two below snippets.

player\_left:setSequence("lrdy")  
player\_left:play()  
--Not really what I have in my code, but this is easier than copying my whole project.   
--Just waiting 30 seconds and trying to change the sequence.  
timer.performWithDelay( 30000, function() player\_left:prepare( "ljh" ) player\_left:play() end ) --\<\<\<\<\<\<\<  

Should be:

player\_left:setSequence("lrdy") player\_left:play() --Not really what I have in my code, but this is easier than copying my whole project. --Just waiting 30 seconds and trying to change the sequence. timer.performWithDelay( 30000, function() player\_left:setSequence( "ljh" ); player\_left:play() end ) --\<\<\<\<\<\<\<\< [import]uid: 84637 topic_id: 29774 reply_id: 119650[/import]

Danny, Yes, that is definitely a bug in what I posted. Unfortunately, that was code I just added to the post for simplicity.

I am not using prepare() anywhere in my actual code. Would it help if I posted the source somewhere for you to look at?

Regards,
Brian [import]uid: 158289 topic_id: 29774 reply_id: 119652[/import]

Sure, post it up :slight_smile:

Edit: Scratch that. I see the issue now.

Your using a multi sprite set, but not using the multi sprite api:

See these documents for how to use it.

http://developer.coronalabs.com/sites/default/files/corona/2012.863/CoronaApiDocs-2012.863.zip

Also you will need daily build 863 or later

http://developer.coronalabs.com/release/2012/863/ [import]uid: 84637 topic_id: 29774 reply_id: 119653[/import]

main game loop:
[lua]local function playSequence(plyr, seq)

–plyr:pause()
–timer.performWithDelay( 33, function() plyr:prepare( seq ); plyr:play() end )
plyr:setSequence(seq)
plyr:play()

end

–PLAYER EVENTS

local function playerAnimationEvent( event )

if event.phase == “ended” then
print(“sequence : “…event.target.sequence…” : ended.”)
if event.target == player.left then
playSequence(event.target, “lrdy”)
else
playSequence(event.target, “rrdy”)
end
end
end

–RUNTIME EVENTS

local function screenTouched(event)
local eventY, eventX, startY, startX = event.y - offsetY, event.x - offsetX, event.yStart - offsetY, event.xStart - offsetX

if event.phase == “began” then
if eventX >= halfW then
if eventY >= halfH then
touch.right.low = true
else
touch.right.high = true
end
else
if eventY >= halfH then
touch.left.low = true
else
touch.left.high = true
end
end
determineAction()
elseif event.phase == “ended” then
if eventX >= halfW then
if eventY >= halfH then
touch.right.low = false
print (“Jab Right Low”)
playSequence(player.right, “rjl”)
else
touch.right.high = false
if startY >= halfH and startX >= halfW then
print (“Right UpperCut”)
touch.right.low = false
playSequence(player.right, “rju”)
else
print (“Right Jab High”)
playSequence(player.right, “rjh”)
end
end
else
if eventY >= halfH then
touch.left.low = false
print(“Jab Left Low”)
playSequence(player.left, “ljl”)
else
touch.left.high = false
if startY >= halfH and startX <= halfW then
print (“Left UpperCut”)
touch.left.low = false
–playSequence(player.left, “lju”)
player.left:setSequence(“lju”)
player.left:play()
else
print( “left Jab High” )
playSequence(player.left, “ljh”)
end
end
end
determineAction()
end

end[/lua]

player.left and player.right are the two sprites returned from the spriteLoader class:
[lua]local spriteLoader = {}

spriteLoader.loadPlayerAnimations = function()

local player_left_set, player_right_set

local ljh_file = require(“spriteData.player_ljh@”…scale…“x”)
local ljh_data = { spriteSheetFrames = ljh_file.getSpriteSheetData().frames }
local ljh_sheet = graphics.newImageSheet( “images/fight/player/player_ljh@”…scale…“x.png”, ljh_data )

local ljl_file = require(“spriteData.player_ljl@”…scale…“x”)
local ljl_data = { spriteSheetFrames = ljl_file.getSpriteSheetData().frames }
local ljl_sheet = graphics.newImageSheet( “images/fight/player/player_ljl@”…scale…“x.png”, ljl_data )

local lrdy_file = require(“spriteData.player_lrdy@”…scale…“x”)
local lrdy_data = { spriteSheetFrames = lrdy_file.getSpriteSheetData().frames }
local lrdy_sheet = graphics.newImageSheet( “images/fight/player/player_lrdy@”…scale…“x.png”, lrdy_data )

local lju_file = require(“spriteData.player_lju@”…scale…“x”)
local lju_data = { spriteSheetFrames = lju_file.getSpriteSheetData().frames }
local lju_sheet = graphics.newImageSheet( “images/fight/player/player_lju@”…scale…“x.png”, lju_data )

local player_left_sequence =
{
{ name = “lrdy”, sheet = lrdy_sheet, frames = { 1, 2, 3, 4, 5, 6 }, time = 1000, loopCount = 0 },
{ name = “ljh”, sheet = ljh_sheet, frames = { 1, 2, 3, 4, 5, 6, 1}, time = 1000, loopCount = 1 },
{ name = “ljl”, sheet = ljl_sheet, frames = { 1, 2, 3, 4, 5, 6, 7, 1 }, time = 1000, loopCount = 1 },
{ name = “lju”, sheet = lju_sheet, frames = { 1, 2, 3, 4, 5, 6, 1 }, time = 1000, loopCount = 1 },
}

– sprite.add( player_left_set, “ljh”, 1,7, 1000, 1 )
– sprite.add( player_left_set, “ljl”, 8,8, 1000, 1 )
– sprite.add( player_left_set, “lju”, 16,7, 1000, 1 )
– sprite.add( player_left_set, “lrdy”, 23,6, 1000, 0 )

local rjh_file = require(“spriteData.player_rjh@”…scale…“x”)
local rjh_data = { spriteSheetFrames = rjh_file.getSpriteSheetData().frames }
local rjh_sheet = graphics.newImageSheet( “images/fight/player/player_rjh@”…scale…“x.png”, rjh_data )

local rjl_file = require(“spriteData.player_rjl@”…scale…“x”)
local rjl_data = { spriteSheetFrames = rjl_file.getSpriteSheetData().frames }
local rjl_sheet = graphics.newImageSheet( “images/fight/player/player_rjl@”…scale…“x.png”, rjl_data )

local rju_file = require(“spriteData.player_rju@”…scale…“x”)
local rju_data = { spriteSheetFrames = rju_file.getSpriteSheetData().frames }
local rju_sheet = graphics.newImageSheet( “images/fight/player/player_rju@”…scale…“x.png”, rju_data )

local rrdy_file = require(“spriteData.player_rrdy@”…scale…“x”)
local rrdy_data = rrdy_file.getSpriteSheetData()
local rrdy_sheet = graphics.newImageSheet( “images/fight/player/player_rrdy@”…scale…“x.png”, rrdy_data )

local player_right_sequence =
{
{ sheet = rjh_sheet, name = “rjh”, frames = { 1, 2, 3, 4, 5, 6, 1}, time = 1000, loopCount = 1 },
{ sheet = rjl_sheet, name = “rjl”, frames = { 1, 2, 3, 4, 5, 6, 7, 1 }, time = 1000, loopCount = 1 },
{ sheet = rju_sheet, name = “rju”, frames = { 1, 2, 3, 4, 5, 6, 1 }, time = 1000, loopCount = 1 },
{ sheet = rrdy_sheet, name = “rrdy”, frames = { 1, 2, 3, 4, 5, 6 }, time = 1000, loopCount = 0 },
}

– sprite.add( player_right_set, “rjh”, 1,7, 1000, 1 )
– sprite.add( player_right_set, “rjl”, 8,8, 1000, 1 )
– sprite.add( player_right_set, “rju”, 16,7, 1000, 1 )
– sprite.add( player_right_set, “rrdy”, 23,6, 1000, 0 )

local player_left = display.newSprite( lrdy_sheet, player_left_sequence )
local player_right = display.newSprite( rjh_sheet, player_right_sequence )

local s = 1/scale
player_left:scale( s,s )
player_right:scale( s,s )

return player_left, player_right

end

return spriteLoader[/lua]

Here are the sheet data files. You can see on line 62, I am loading the file a bit differently. I tried loading them both ways (using texturepacker’s default output, or creating a new sprite API sequence data table).
The following is using the new sequence data table format.
[lua]local SpriteSheet = {}
SpriteSheet.getSpriteSheetData = function ()
return {
frames = {
{
x = 2,
y = 2,
width = 518,
height = 536,
sourceWidth = 894,
sourceHeight = 764,
sourceX = 232,
sourceY = 193
},
{
x = 2,
y = 2,
width = 518,
height = 536,
sourceWidth = 894,
sourceHeight = 764,
sourceX = 232,
sourceY = 195
},
{
x = 2,
y = 2,
width = 518,
height = 536,
sourceWidth = 894,
sourceHeight = 764,
sourceX = 232,
sourceY = 197
},
{
x = 2,
y = 2,
width = 518,
height = 536,
sourceWidth = 894,
sourceHeight = 764,
sourceX = 232,
sourceY = 199
},
{
x = 2,
y = 2,
width = 518,
height = 536,
sourceWidth = 894,
sourceHeight = 764,
sourceX = 232,
sourceY = 197
},
{
x = 2,
y = 2,
width = 518,
height = 536,
sourceWidth = 894,
sourceHeight = 764,
sourceX = 232,
sourceY = 196
},
– frames = {
– {
– spriteColorRect = { x = 234, y = 195, width = 518, height = 536 },
– textureRect = { x = 2, y = 2, width = 518, height = 536 },
– spriteSourceSize = { width = 894, height = 764 },
– spriteTrimmed = true,
– textureRotated = false
– },
– {
– spriteColorRect = { x = 234, y = 197, width = 518, height = 536 },
– textureRect = { x = 2, y = 2, width = 518, height = 536 },
– spriteSourceSize = { width = 894, height = 764 },
– spriteTrimmed = true,
– textureRotated = false
– },
– {
– spriteColorRect = { x = 234, y = 199, width = 518, height = 536 },
– textureRect = { x = 2, y = 2, width = 518, height = 536 },
– spriteSourceSize = { width = 894, height = 764 },
– spriteTrimmed = true,
– textureRotated = false
– },
– {
– spriteColorRect = { x = 234, y = 201, width = 518, height = 536 },
– textureRect = { x = 2, y = 2, width = 518, height = 536 },
– spriteSourceSize = { width = 894, height = 764 },
– spriteTrimmed = true,
– textureRotated = false
– },
– {
– spriteColorRect = { x = 234, y = 199, width = 518, height = 536 },
– textureRect = { x = 2, y = 2, width = 518, height = 536 },
– spriteSourceSize = { width = 894, height = 764 },
– spriteTrimmed = true,
– textureRotated = false
– },
– {
– spriteColorRect = { x = 234, y = 198, width = 518, height = 536 },
– textureRect = { x = 2, y = 2, width = 518, height = 536 },
– spriteSourceSize = { width = 894, height = 764 },
– spriteTrimmed = true,
– textureRotated = false
– },
– }
}
}
end
return SpriteSheet[/lua]
Now using the old Texturepacker format. (this is the format used for all the imageSheets except for the ‘rrdy’ on line 62.
[lua]local SpriteSheet = {}
SpriteSheet.getSpriteSheetData = function ()
return {
frames = {
{
name = “Rup_frame_1@4x.png”,
spriteColorRect = { x = 213, y = 258, width = 512, height = 506 },
textureRect = { x = 2, y = 542, width = 512, height = 506 },
spriteSourceSize = { width = 894, height = 764 },
spriteTrimmed = true,
textureRotated = false
},
{
name = “Rup_frame_2@4x.png”,
spriteColorRect = { x = 11, y = 406, width = 644, height = 358 },
textureRect = { x = 2, y = 1534, width = 644, height = 358 },
spriteSourceSize = { width = 894, height = 764 },
spriteTrimmed = true,
textureRotated = false
},
{
name = “Rup_frame_3@4x.png”,
spriteColorRect = { x = 2, y = 282, width = 584, height = 482 },
textureRect = { x = 2, y = 1050, width = 584, height = 482 },
spriteSourceSize = { width = 894, height = 764 },
spriteTrimmed = true,
textureRotated = false
},
{
name = “Rup_frame_4@4x.png”,
spriteColorRect = { x = 11, y = 169, width = 456, height = 538 },
textureRect = { x = 2, y = 2, width = 456, height = 538 },
spriteSourceSize = { width = 894, height = 764 },
spriteTrimmed = true,
textureRotated = false
},
{
name = “Rup_frame_5@4x.png”,
spriteColorRect = { x = 20, y = 15, width = 322, height = 358 },
textureRect = { x = 516, y = 474, width = 322, height = 358 },
spriteSourceSize = { width = 894, height = 764 },
spriteTrimmed = true,
textureRotated = false
},
{
name = “Rup_frame_6@4x.png”,
spriteColorRect = { x = 159, y = 153, width = 440, height = 470 },
textureRect = { x = 460, y = 2, width = 440, height = 470 },
spriteSourceSize = { width = 894, height = 764 },
spriteTrimmed = true,
textureRotated = false
},
}
}
end
return SpriteSheet[/lua]
Let me know if you need more code or resource files. I can zip them up and send them wherever.

Thanks for looking into this.

Regards,
Brian [import]uid: 158289 topic_id: 29774 reply_id: 119654[/import]