diff --git a/examples/gameplay/plateform/actors/coin.lua b/examples/gameplay/plateform/actors/coin.lua index a4bdaa2..4e718e2 100644 --- a/examples/gameplay/plateform/actors/coin.lua +++ b/examples/gameplay/plateform/actors/coin.lua @@ -6,4 +6,8 @@ function Coin:new(world, x, y) self:setSprite("coin") end +function Coin:takeCoin(other) + self:destroy( ) +end + return Coin diff --git a/examples/gameplay/plateform/actors/player.lua b/examples/gameplay/plateform/actors/player.lua index f96059c..f519d12 100644 --- a/examples/gameplay/plateform/actors/player.lua +++ b/examples/gameplay/plateform/actors/player.lua @@ -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