When a plane explodes mid-air, the explosion has the same movement vector
This commit is contained in:
parent
d39aba0fd2
commit
2d85044042
2 changed files with 14 additions and 1 deletions
|
@ -22,6 +22,8 @@ Animation = Class{
|
|||
__includes = Entity,
|
||||
|
||||
curFrame = 0,
|
||||
velX = 0,
|
||||
velY = 0,
|
||||
|
||||
init = function(self, x, y, level, frames)
|
||||
Entity.init(self, x, y, level)
|
||||
|
@ -32,6 +34,11 @@ Animation = Class{
|
|||
self.y = y
|
||||
end;
|
||||
|
||||
setVelocity = function(self, velX, velY)
|
||||
self.velX = velX
|
||||
self.velY = velY
|
||||
end;
|
||||
|
||||
draw = function(self)
|
||||
local img = self.frames.frames[math.floor(self.curFrame)]
|
||||
if img then
|
||||
|
@ -49,5 +56,7 @@ Animation = Class{
|
|||
if self.curFrame >= self.frames.numFrames then
|
||||
self:delete()
|
||||
end
|
||||
self.x = self.x + self.velX * dt
|
||||
self.y = self.y + self.velY * dt
|
||||
end;
|
||||
}
|
||||
|
|
|
@ -188,7 +188,11 @@ Plane = Class{
|
|||
end
|
||||
self.joyShooting = false
|
||||
self.kbdShooting = false
|
||||
Animation(self.body:getX(), self.body:getY(), self.level, explosionFrames)
|
||||
local animation = Animation(self.body:getX(), self.body:getY(), self.level, explosionFrames)
|
||||
if not self.contactingGround then
|
||||
local velX, velY = self.body:getLinearVelocity()
|
||||
animation:setVelocity(velX, velY)
|
||||
end
|
||||
self:getOwner():setPlane(nil)
|
||||
self.motorSound:stop()
|
||||
self:delete()
|
||||
|
|
Loading…
Reference in a new issue