Hi everybody,
Im creating a turn based war game.
For animate the troop, I created a sprite with the moves of each troop:
sheetSettings =
{
width = 24,
height = 31,
numFrames = 128
}
sheet = graphics.newImageSheet(“images/Germany.png”,sheetSettings)
animationData =
{
{ name=“TroopR”, start=1, count=4, time=500, loopCount = 1},
{ name=“TroopL”, start=5, count=4, time=500, loopCount = 1},
{ name=“TroopD”, start=9, count=4, time=500, loopCount = 1},
{ name=“TroopU”, start=13, count=4, time=500, loopCount = 1},
{ name=“BazookaR”, start=17, count=4, time=500, loopCount = 1},
{ name=“BazookaL”, start=21, count=4, time=500, loopCount = 1},
{ name=“BazookaD”, start=24, count=4, time=500, loopCount = 1},
{ name=“BazookaU”, start=27, count=4, time=500, loopCount = 1},
{ name=“GranadeR”, start=31, count=4, time=500, loopCount = 1},
{ name=“GranadeL”, start=35, count=4, time=500, loopCount = 1},
{ name=“GranadeD”, start=39, count=4, time=500, loopCount = 1},
{ name=“GranadeU”, start=43, count=4, time=500, loopCount = 1},
{ name=“SniperR”, start=47, count=4, time=500, loopCount = 1},
{ name=“SniperL”, start=51, count=4, time=500, loopCount = 1},
{ name=“SniperD”, start=55, count=4, time=500, loopCount = 1},
{ name=“SniperU”, start=59, count=4, time=500, loopCount = 1},
{ name=“PlaneR”, start=63, count=4, time=500, loopCount = 1},
{ name=“PlaneL”, start=67, count=4, time=500, loopCount = 1},
{ name=“PlaneD”, start=71, count=4, time=500, loopCount = 1},
{ name=“PlaneU”, start=75, count=4, time=500, loopCount = 1},
{ name=“TankLR”, start=79, count=4, time=500, loopCount = 1},
{ name=“TankLL”, start=84, count=4, time=500, loopCount = 1},
{ name=“TankLD”, start=89, count=4, time=500, loopCount = 1},
{ name=“TankLU”, start=93, count=4, time=500, loopCount = 1},
{ name=“TankHR”, start=97, count=4, time=500, loopCount = 1},
{ name=“TankHL”, start=101, count=4, time=500, loopCount = 1},
{ name=“TankHD”, start=105, count=4, time=500, loopCount = 1},
{ name=“TankHU”, start=109, count=4, time=500, loopCount = 1},
{ name=“ObusR”, start=113, count=4, time=500, loopCount = 1},
{ name=“ObusL”, start=117, count=4, time=500, loopCount = 1},
{ name=“ObusD”, start=121, count=4, time=500, loopCount = 1},
{ name=“ObusU”, start=125, count=4, time=500, loopCount = 1}
}
and cerate the sprite
sprite = display.newSprite(sheet,animationData)
When I move one troop I call MoveY(old_X_position,old_Y_position,new_X_position,new_Y_position) for move the troop
Inside the function I look for the appropiate troop for choose the correct sprite y launch the animation
– Soldier is the name of the troop, TankL, TankH,…
sprite:setSequence(tostring(soldier…“R”))
The problems is that always use the first script for all the troop and all the moves
Why?
I dont know why dont funtion the “names” of the animationData
Thanks in advance for your help
Regards!