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")
end
function Coin:takeCoin(other)
self:destroy( )
end
return Coin

View File

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