module/world: take coin when the player collide to it
This commit is contained in:
parent
dfc71eaebd
commit
a1ce249e00
2 changed files with 11 additions and 0 deletions
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue