Code: Select all
--from main.lua, bump's main callback
function bump.collision(item1,item2,dx,dy)
item1:shouldCollide(item2,dx,dy)
item2:shouldCollide(item1,dx,dy)
end
--from player.lua, the Player:shouldCollide function for bump.collision
function Player:shouldCollide(other,dx,dy)
if dx~=0 then self.x=self.x+dx end
if dy~=0 then self.y=self.y+dy end
print(dx,dy)
end
I have a hunch that the problem lies with how I am using dx and dy so I also attached my player.lua and main.lua.