I'm trying some animations, but i can't make the sprite rest. Any suggestions?
actor={}
actor.x=40
actor.y=30
actor.sprt=0
actor.spd=0.75
function move_d()
actor.sprt+=0.125
if actor.sprt>2.9 then
actor.sprt=1
end
end
function move_u()
actor.sprt+=0.125
if actor.sprt>18.9
or actor.sprt<17 then
actor.sprt=17
end
end
function move_r()
actor.sprt+=0.125
if actor.sprt>4.9
or actor.sprt<3 then
actor.sprt=3
end
end
function move_l()
actor.sprt+=0.125
if actor.sprt>20.9
or actor.sprt<19 then
actor.sprt=19
end
end
function _update()
if btn(3) then
move_d()
actor.y+=actor.spd
elseif not btn() then
actor.sprt=0
end
if btn(2) then
move_u()
actor.y-=actor.spd
elseif not btn() then
actor.sprt=0
end
if btn(1) then
move_r()
actor.x+=actor.spd
elseif not btn() then
actor.sprt=0
end
if btn(0) then
move_l()
actor.x-=actor.spd
elseif not btn() then
actor.sprt=0
end
end
function _draw()
cls()
spr(actor.sprt,actor.x,actor.y)
end
|
[Please log in to post a comment]




