does anybody know the code you need to change animation
Im trying to do where when you move right the sprite changes to sprite 4 and the when you move left it changes to sprite 3 If someone could help me that could be great.
Im trying to do where when you move right the sprite changes to sprite 4 and the when you move left it changes to sprite 3 If someone could help me that could be great.
if I knew how I would honestly
update = function()
direction = 0
if keyboard.D then
// movement stuff
direction = 1
end
if keyboard.A then
//more movement stuff
direction = 0
end
if direction == 1 then
sprite = "right"
elsif direction == 0 then
sprite = "left"
else
sprite = "neutral"
end
end
that last "neutral" part is optional if you want an idle drawing. And if the left and right sprites are the same, you can just:
update = function()
direction = 0
if keyboard.D then
// movement stuff
direction = 1
end
if keyboard.A then
//more movement stuff
direction = 0
end
if direction != 0 then
sprite = "moving"
end
end
draw = function()
screen.setDrawScale(direction)
screen.drawSprite(sprite,x,y,w,h)
screen.setDrawScale(direction)
this will simply flip the player, so that you don't need 2 sprites for every action
Thanks so much