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,
|
__includes = Entity,
|
||||||
|
|
||||||
curFrame = 0,
|
curFrame = 0,
|
||||||
|
velX = 0,
|
||||||
|
velY = 0,
|
||||||
|
|
||||||
init = function(self, x, y, level, frames)
|
init = function(self, x, y, level, frames)
|
||||||
Entity.init(self, x, y, level)
|
Entity.init(self, x, y, level)
|
||||||
|
@ -32,6 +34,11 @@ Animation = Class{
|
||||||
self.y = y
|
self.y = y
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
setVelocity = function(self, velX, velY)
|
||||||
|
self.velX = velX
|
||||||
|
self.velY = velY
|
||||||
|
end;
|
||||||
|
|
||||||
draw = function(self)
|
draw = function(self)
|
||||||
local img = self.frames.frames[math.floor(self.curFrame)]
|
local img = self.frames.frames[math.floor(self.curFrame)]
|
||||||
if img then
|
if img then
|
||||||
|
@ -49,5 +56,7 @@ Animation = Class{
|
||||||
if self.curFrame >= self.frames.numFrames then
|
if self.curFrame >= self.frames.numFrames then
|
||||||
self:delete()
|
self:delete()
|
||||||
end
|
end
|
||||||
|
self.x = self.x + self.velX * dt
|
||||||
|
self.y = self.y + self.velY * dt
|
||||||
end;
|
end;
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,7 +188,11 @@ Plane = Class{
|
||||||
end
|
end
|
||||||
self.joyShooting = false
|
self.joyShooting = false
|
||||||
self.kbdShooting = 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:getOwner():setPlane(nil)
|
||||||
self.motorSound:stop()
|
self.motorSound:stop()
|
||||||
self:delete()
|
self:delete()
|
||||||
|
|
Loading…
Reference in a new issue