Animation: ability to configure whether to fade out or not
This commit is contained in:
parent
67c5c0f693
commit
a378a68567
4 changed files with 10 additions and 5 deletions
|
@ -4,7 +4,7 @@ require 'entities/entity'
|
|||
AnimationFrames = Class {
|
||||
frames = {},
|
||||
|
||||
init = function(self, basename, numFrames, fps)
|
||||
init = function(self, basename, numFrames, fps, fadeOut)
|
||||
for frame = 0, numFrames - 1 do
|
||||
self.frames[frame] = love.graphics.newImage(string.format(basename, frame))
|
||||
end
|
||||
|
@ -14,6 +14,7 @@ AnimationFrames = Class {
|
|||
self.width = self.frames[0]:getWidth();
|
||||
self.height = self.frames[0]:getHeight();
|
||||
self.quad = love.graphics.newQuad(0, 0, self.width, self.height, self.width, self.height)
|
||||
self.fadeOout = fadeOut
|
||||
end
|
||||
}
|
||||
|
||||
|
@ -34,7 +35,11 @@ Animation = Class{
|
|||
draw = function(self)
|
||||
local img = self.frames.frames[math.floor(self.curFrame)]
|
||||
if img then
|
||||
love.graphics.setColor(255, 255, 255, 255 * (1.0 - self.curFrame / self.frames.numFrames))
|
||||
if self.frames.fadeOout then
|
||||
love.graphics.setColor(255, 255, 255, 255 * (1.0 - self.curFrame / self.frames.numFrames))
|
||||
else
|
||||
love.graphics.setColor(255, 255, 255)
|
||||
end
|
||||
love.graphics.draw(img, self.frames.quad, self.x, self.y, self.angle, 1, 1, self.frames.width / 2, self.frames.width / 2)
|
||||
end
|
||||
end;
|
||||
|
|
|
@ -31,7 +31,7 @@ local max_motorPower = ENGINE_MAX
|
|||
local plane_area = 10.0
|
||||
local head_area = 1.0
|
||||
|
||||
local explosionFrames = AnimationFrames("resources/graphics/explosion-%04d.png", 36, 15)
|
||||
local explosionFrames = AnimationFrames("resources/graphics/explosion-%04d.png", 36, 15, true)
|
||||
|
||||
Plane = Class{
|
||||
__includes = PhysicsEntity,
|
||||
|
|
|
@ -4,7 +4,7 @@ require 'entities/animation'
|
|||
require 'settings'
|
||||
|
||||
local TINYSHOT_SOUND = love.audio.newSource("resources/audio/chaingun.mp3", "static")
|
||||
local explosionFrames = AnimationFrames("resources/graphics/miniexplosion-%04d.png", 4, 15)
|
||||
local explosionFrames = AnimationFrames("resources/graphics/miniexplosion-%04d.png", 4, 15, false)
|
||||
|
||||
TinyShot = Class{
|
||||
__includes = Rectangle,
|
||||
|
|
|
@ -3,7 +3,7 @@ require 'entities/physicsentity'
|
|||
require 'settings'
|
||||
|
||||
local VICKERS_SOUND = love.audio.newSource("resources/audio/vickers77.mp3", "static")
|
||||
local explosionFrames = AnimationFrames("resources/graphics/miniexplosion-%04d.png", 4, 15)
|
||||
local explosionFrames = AnimationFrames("resources/graphics/miniexplosion-%04d.png", 4, 15, false)
|
||||
|
||||
Vickers77 = Class{
|
||||
__includes = Rectangle,
|
||||
|
|
Loading…
Reference in a new issue