sprite wont swap and setSequence

after a minute i wanted to swap Sequence but not working, but during the 1st play the jump was playing but i i set name = walking_1

code

  1. local characterdata={
  2.         name=“walking_1”,start=1,count=6,time=1000,loopCount = 0,loopDirection = “forward”,
  3.         name=“jump”,start=1,count=6,time=100,loopCount = 0,loopDirection = “forward”,
  4.     }
  5.     obj.character = display.newSprite( sprite.charsheet, characterdata )
  6.     obj.character.x = display.contentWidth*0.3
  7.     obj.character.y = obj.goundline.y - obj.character.height*0.5
  8.     obj.character:setSequence( “walking_1” )
  9.     obj.character:play()
  10. timer.performWithDelay(3000, function (event)
  11.             obj.character:pause()
  12.             obj.character:setSequence( “jump” )
  13.             obj.character:play()
  14.            
  15.         end, 1)

Hi @domskie13,

This is a simple syntax error. You need to put each sequence in its own table. Right now, you have everything in one table, so Lua doesn’t know which key-value pair you’re referring to.

So, instead of what you have:

[lua]

local characterdata={

        name=“walking_1”,start=1,count=6,time=1000,loopCount = 0,loopDirection = “forward”,

        name=“jump”,start=1,count=6,time=100,loopCount = 0,loopDirection = “forward”,

    }

[/lua]

You should have:

[lua]

local characterdata = {

   { name=“walking_1”, start=1, count=6, time=1000, loopCount=0, loopDirection=“forward” },

   { name=“jump”, start=1, count=6, time=100, loopCount=0, loopDirection=“forward” },

}

[/lua]

Take care,

Brent

thanks Brent :smiley:

Hi @domskie13,

This is a simple syntax error. You need to put each sequence in its own table. Right now, you have everything in one table, so Lua doesn’t know which key-value pair you’re referring to.

So, instead of what you have:

[lua]

local characterdata={

        name=“walking_1”,start=1,count=6,time=1000,loopCount = 0,loopDirection = “forward”,

        name=“jump”,start=1,count=6,time=100,loopCount = 0,loopDirection = “forward”,

    }

[/lua]

You should have:

[lua]

local characterdata = {

   { name=“walking_1”, start=1, count=6, time=1000, loopCount=0, loopDirection=“forward” },

   { name=“jump”, start=1, count=6, time=100, loopCount=0, loopDirection=“forward” },

}

[/lua]

Take care,

Brent

thanks Brent :smiley: