I am making a survival game in which the character moves via joystick, i want it so that when he moves, 2 images go back and forth every half second or so making it appear as he is walking, how can i do that?
Have a simple timer that goes up and resets after say, .3 of a second or so, then when the timer resets, alternate the image of your hero walking
if i only want him to alternate while walking, would i put the timer in draw and the alternating images in touch?
This may not work, im on my phone:
function setup()
timer = 0
--whatever other setup stuff here
end
function draw()
if Timer > 10 then
sprite('ImgHere',WhateverXvaluehere,WhateverYvaluehere)
elseif
Timer > 20 then
Timer = 0
end
end
end
function touched(t)
if t.state == BEGAN or MOVING then
Timer = Timer + 1
--WhateverTouchstuffhere
end
end
thanks, that worked!
for your timer, you can also use a tween()