despawn projectiles offscreen
This commit is contained in:
parent
6a251b3619
commit
8be9c21ba2
1 changed files with 6 additions and 0 deletions
|
|
@ -30,6 +30,12 @@ function Projectile:update(dt)
|
|||
|
||||
-- move collision area
|
||||
self.collider:moveTo(self.x, self.y)
|
||||
|
||||
-- offscreen despawn
|
||||
if self.x < 0 then self:kill() end
|
||||
if self.y < 0 then self:kill() end
|
||||
if self.x > gw then self:kill() end
|
||||
if self.y > gh then self:kill() end
|
||||
end
|
||||
|
||||
---Draws Projectile
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue