noble animations
This commit is contained in:
@@ -1,24 +1,24 @@
|
||||
Baleba = {}
|
||||
class('Baleba').extends(AnimatedSprite)
|
||||
class('Baleba').extends(NobleSprite)
|
||||
|
||||
function randomFloat(lower, greater)
|
||||
return lower + math.random() * (greater - lower);
|
||||
return lower + math.random() * (greater - lower);
|
||||
end
|
||||
|
||||
local balebaImageTable = Graphics.imagetable.new("assets/sprites/baleba")
|
||||
|
||||
function Baleba:init(x, y, player, loop)
|
||||
Baleba.super.init(self, balebaImageTable)
|
||||
Baleba.super.init(self, "assets/sprites/baleba", true)
|
||||
|
||||
-- Animation properties
|
||||
self:addState("run", 1,4, {tickStep = 2})
|
||||
self:setDefaultState("run")
|
||||
self:playAnimation()
|
||||
self.animation:addState("run", 1, 4)
|
||||
self.animation.run.frameDuration = 2
|
||||
|
||||
self.animation:setState("run")
|
||||
|
||||
-- Collision properties
|
||||
self:setZIndex(11)
|
||||
self:setCollideRect(3, 25, 40, 15)
|
||||
self:setTag(154)
|
||||
self:setSize(64, 64)
|
||||
|
||||
-- Sprite properties
|
||||
self.standrate = randomFloat(0.3, 2)
|
||||
@@ -28,15 +28,13 @@ function Baleba:init(x, y, player, loop)
|
||||
|
||||
-- Danger properties
|
||||
self.danger = Danger(366, y, self)
|
||||
self.danger:add()
|
||||
|
||||
self:add()
|
||||
-- Move to initial position
|
||||
self:moveTo(x, y)
|
||||
end
|
||||
|
||||
function Baleba:update()
|
||||
self:updateAnimation()
|
||||
|
||||
-- Speedup when player is moving right
|
||||
if self.player == nil or self.player.isMovingRight() == false then
|
||||
self.xVelocity = self.standrate
|
||||
@@ -44,7 +42,7 @@ function Baleba:update()
|
||||
self.xVelocity = 2 + self.standrate
|
||||
end
|
||||
|
||||
self:moveTo(self.x-self.xVelocity, self.y)
|
||||
self:moveTo(self.x - self.xVelocity, self.y)
|
||||
|
||||
-- Danger arrow management
|
||||
if self.x < 430 and self.danger ~= nil then
|
||||
@@ -52,7 +50,6 @@ function Baleba:update()
|
||||
self.danger = nil
|
||||
elseif self.danger == nil and self.x > 430 then
|
||||
self.danger = Danger(366, self.y, self)
|
||||
self.danger:add()
|
||||
end
|
||||
|
||||
-- Lifeciycle management
|
||||
@@ -69,4 +66,4 @@ function Baleba:destroy()
|
||||
self.danger:remove()
|
||||
end
|
||||
self:remove()
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user