module/world: take coin when the player collide to it

This commit is contained in:
Kazhnuz 2019-05-05 19:46:13 +02:00
parent dfc71eaebd
commit a1ce249e00
2 changed files with 11 additions and 0 deletions

View file

@ -6,4 +6,8 @@ function Coin:new(world, x, y)
self:setSprite("coin") self:setSprite("coin")
end end
function Coin:takeCoin(other)
self:destroy( )
end
return Coin return Coin

View file

@ -51,4 +51,11 @@ function Player:setDirection(direction)
end end
end end
function Player:collisionResponse(collision)
if collision.other.type == "coin" then
collision.other:takeCoin(self)
end
end
return Player return Player