Skip to content
Download

Move an object

axis returns -1 to 1 for a pair of actions. Multiply by the speed, in pixels per step.

function onUpdate(self)
self.x = self.x + axis("esquerda", "direita") * 2
self.y = self.y + axis("cima", "baixo") * 2
end

Check Solid on the wall object and move with moveAndStop.

function onUpdate(self)
local dx = axis("esquerda", "direita") * 2
local dy = axis("cima", "baixo") * 2
self:moveAndStop(dx, dy)
end
if dx ~= 0 and dy ~= 0 then
dx = dx * 0.7071
dy = dy * 0.7071
end

Reference: Input, Movement.