(Deleted my old topic, to clarify a new one)
Hi I am having trouble switching sheets, because my sequences are inside my json file. Is there a way to switch sheets, without needing the sheet variable to be included in the sequence table? and instead switched outside the sequence table?
I am creating the sheets(not with texturepacker, just a general spritesheet), then using the Corona’s lua library to receive the sprites. every sprite is the same width. Which you can see in the data for the sheets.
I am using
Sheets = json.decode( jsonFile( "data/animations.json" ) ) \_speechSheet1 = graphics.newImageSheet( "images/game/sheet\_speech1.png", Sheets.main.speech1\_sheet )
\_punchSheet = graphics.newImageSheet( "images/game/sheet\_punch.png", Sheets.main.punch\_sheet )
tAnimations = json.decode( jsonFile( "data/animations.json" ) ) tAnimations = tAnimations.main.Animations tAnimation = display.newSprite( \_speechSheet1, tAnimations ) tAnimation.x = \_CW \*0.5; tAnimation.y = \_CH \*0.62 tAnimation:setSequence( "speech\_"..math.random(1) ); tAnimation:play() sceneGroup:insert( tAnimation )
Then I want to change the sheet when the following code fires.
tAnimation:setSequence( "punch\_"..math.random(2) ) tAnimation:play()
this is my json file
{ "main":{ "punch\_sheet":{ "width": 519, "height": 906, "numFrames": 30, "sheetContentWidth": 3111, "sheetContentHeight": 5436 }, "dodge\_sheet":{ "width": 519, "height": 906, "numFrames": 16, "sheetContentWidth": 2593, "sheetContentHeight": 3624 }, "speech1\_sheet":{ "width": 519, "height": 906, "numFrames": 84, "sheetContentWidth": 4148, "sheetContentHeight": 10872 }, "speech2\_sheet":{ "width": 519, "height": 906, "numFrames": 104, "sheetContentWidth": 4667, "sheetContentHeight": 11778 }, "Animations":[{ "name":"speech\_1", "start": 1, "count":67, "time":600, "loopCount":1, "loopDirection":"forward" },{ "name":"punch\_1", "frames":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20], "time": 280, "loopCount": 1, "loopDirection": "forward" },{ "name":"punch\_2", "frames":[21,22,23,24,25,26], "time": 280, "loopCount": 1, "loopDirection": "forward" },{ "name":"dodge\_1", "frames":[1,2,3,4,5,6,7,8,9,10], "time": 280, "loopCount": 1, "loopDirection": "forward" } ] } }