Hello reader.
I am currently trying to make a zelda like game with animations for movement but have come to some problems, the animations play but at an abnormal frame rate and dont seem to stop when standing still. Here is my code
function init(self)
msg.post(".", "acquire_input_focus")
self.vel = vmath.vector3()
end
function update(self, dt)
local pos = go.get_position()
pos = pos + self.vel * dt
go.set_position(pos)
self.vel.x = 0
self.vel.y = 0
end
function on_input(self, action_id, action)
if action_id == hash("up") then
self.vel.y = 15
elseif action_id == hash("down") then
self.vel.y = -15
msg.post("#robo", "play_animation", {id = hash("down M")})
elseif action_id == hash("left") then
self.vel.x = -15
msg.post("#robo", "play_animation", {id = hash("left M")})
elseif action_id == hash("right") then
self.vel.x = 15
msg.post("#robo", "play_animation", {id = hash("right M")})
end
end
Any suggestions to how to fix this problem would be highly appreciated