implement LightBehavior:animateColor
(to show that animations do work, actually)
This commit is contained in:
parent
ab37f6816d
commit
26633db3c3
@ -2,6 +2,9 @@
|
|||||||
--- @field intensity number
|
--- @field intensity number
|
||||||
--- @field color Vec3
|
--- @field color Vec3
|
||||||
--- @field seed integer
|
--- @field seed integer
|
||||||
|
--- @field colorAnimationNode? AnimationNode
|
||||||
|
--- @field targetColor? Vec3
|
||||||
|
--- @field sourceColor? Vec3
|
||||||
local behavior = {}
|
local behavior = {}
|
||||||
behavior.__index = behavior
|
behavior.__index = behavior
|
||||||
behavior.id = "light"
|
behavior.id = "light"
|
||||||
@ -16,7 +19,18 @@ function behavior.new(values)
|
|||||||
}, behavior)
|
}, behavior)
|
||||||
end
|
end
|
||||||
|
|
||||||
function behavior:update()
|
function behavior:update(dt)
|
||||||
|
if not self.colorAnimationNode then return end
|
||||||
|
local delta = self.targetColor - self.sourceColor
|
||||||
|
self.color = self.sourceColor + delta * self.colorAnimationNode:getValue()
|
||||||
|
self.colorAnimationNode:update(dt)
|
||||||
|
end
|
||||||
|
|
||||||
|
function behavior:animateColor(targetColor, animationNode)
|
||||||
|
if self.colorAnimationNode then self.colorAnimationNode:finish() end
|
||||||
|
self.colorAnimationNode = animationNode
|
||||||
|
self.sourceColor = self.color
|
||||||
|
self.targetColor = targetColor
|
||||||
end
|
end
|
||||||
|
|
||||||
function behavior:draw()
|
function behavior:draw()
|
||||||
|
|||||||
@ -107,9 +107,10 @@ function regenerateMana:cast(caster, target)
|
|||||||
|
|
||||||
AnimationNode {
|
AnimationNode {
|
||||||
function(node)
|
function(node)
|
||||||
light:has(Tree.behaviors.residentsleeper):sleep(node)
|
light:has(Tree.behaviors.light):animateColor(Vec3 {}, node)
|
||||||
end,
|
end,
|
||||||
duration = 400,
|
easing = easing.easeInQuad,
|
||||||
|
duration = 800,
|
||||||
onEnd = function() light:die() end
|
onEnd = function() light:die() end
|
||||||
}:run()
|
}:run()
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user