I am currently working on animating an enemy. While i have the animation working, I need it moving and it is not. I don’t know why. Here is the code: any help would be great, thanks! [code] – tank animation
local sheet1 = sprite.newSpriteSheet( “tank_sprite_sheet.png”, 75, 125)
local spriteSet1 = sprite.newSpriteSet(sheet1, 1, 5)
sprite.add( spriteSet1, “tank”, 1, 5, 1000, 0 ) – plays non shooting frames every 1000 ms
local instance1 = sprite.newSprite( spriteSet1 )
instance1.x = display.contentWidth / 75
instance1.y = 125
–instance1.xScale = .5
–instance1.yScale = .5
instance1:prepare(“tank”)
instance1:play()
– A per-frame event to move the elements
local tPrevious = system.getTimer()
local function move(event)
local tDelta = event.time - tPrevious
tPrevious = event.time
–if (grass.x + grass.contentWidth) < 0 then
– grass:translate( 480 * 2, 0)
–end
tank = {}
for i = 1, #tank, 1 do
tank[i].x = tank[i].x - tank[i].dx * tDelta * 0.2
if (tank[i].x + tank[i].contentWidth) < 0 then
tank[i]:translate( 480 + tank[i].contentWidth * 2, 0 )
end
end
end
[import]uid: 94237 topic_id: 21559 reply_id: 321559[/import]
[import]uid: 52491 topic_id: 21559 reply_id: 86823[/import]