mirror of
https://github.com/tanema/light_world.lua.git
synced 2024-12-24 20:24:19 +00:00
added move function to bodies
This commit is contained in:
parent
80b1f67f9b
commit
91996c4fc5
11
lib/body.lua
11
lib/body.lua
@ -109,6 +109,17 @@ function body:setPosition(x, y)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- move position
|
||||||
|
function body:move(x, y)
|
||||||
|
if x then
|
||||||
|
self.x = self.x + x
|
||||||
|
end
|
||||||
|
if y then
|
||||||
|
self.y = self.y + y
|
||||||
|
end
|
||||||
|
self:refresh()
|
||||||
|
end
|
||||||
|
|
||||||
-- get x position
|
-- get x position
|
||||||
function body:getPosition()
|
function body:getPosition()
|
||||||
return self.x, self.y
|
return self.x, self.y
|
||||||
|
Loading…
Reference in New Issue
Block a user