I HAVE AN ANIMATIONNODE

I HAVE AN UPDATE
OHHHHHHHHHHHHHHHHHH
animationNode:update(dt)

I HAVE A TREE
I HAVE AND AUDIO
OHHHHHHHHHHHHHHHHHHHHH
Tree.audio

I HAVE AN animationNode:update(dt)
I HAVE A Tree.audio
OHHHHHHHHHGKHGKGHKGgghkgh
Tree.audio.animationNode:update(dt)

TUTUDUDUTUTUDUDUTUTUDUDUTUTUDUDUTUTUDUDUTUTUDUDUTUTUDUDUTUTUDUDUTUTUDUDUTUTUDUDUTUTUDUDUTUTUDUDUTUTUDUDUTUTUDUDUTUTUDUDUTUTUDUDUTUTUDUDUTUTUDUDUTUTUDUDUTUTUDUDUTUTUDUDUTUTUDUDUTUTUDUDUTUTUDUDUTUTUDUDUTUTUDUDUTUTUDUDUTUTUDUDUTUTUDUDUTUTUDUDUTUTUDUDUTUTUDUDUTUTUDUDU
This commit is contained in:
neckrat 2026-01-17 17:24:04 +03:00
parent 4ee7b62ae4
commit f900e89a82
3 changed files with 18 additions and 7 deletions

View File

@ -4,6 +4,7 @@ local AnimationNode = require "lib.animation_node"
--- @class Audio --- @class Audio
--- @field musicVolume number --- @field musicVolume number
--- @field soundVolume number --- @field soundVolume number
--- @field animationNode AnimationNode?
audio = {} audio = {}
audio.__index = audio audio.__index = audio
@ -15,6 +16,13 @@ local function new(musicVolume, soundVolume)
}, audio) }, audio)
end end
function audio:update(dt)
if self.animationNode then
self.animationNode:update(dt)
print(self.animationNode.t)
print(self.animationNode:getValue())
end
end
--- if from is nil, than we have fade in to; --- if from is nil, than we have fade in to;
--- if to is nil, than we have fade out from --- if to is nil, than we have fade out from
@ -22,7 +30,7 @@ end
--- also we should guarantee, that from and to have the same volume --- also we should guarantee, that from and to have the same volume
--- @param from love.Source --- @param from love.Source
--- @param to love.Source --- @param to love.Source
--- @param ms? number in milliseconds --- @param ms number? in milliseconds
function audio:crossfade(from, to, ms) function audio:crossfade(from, to, ms)
to:setVolume(0) to:setVolume(0)
to:play() to:play()
@ -46,13 +54,13 @@ end
--- also we should guarantee, that from and to have the same volume --- also we should guarantee, that from and to have the same volume
--- @param from love.Source --- @param from love.Source
--- @param to love.Source --- @param to love.Source
--- @param ms? number in milliseconds --- @param ms number? in milliseconds
function audio:crossfadeAnim(from, to, ms) function audio:crossfadeAnim(from, to, ms)
to:setVolume(0) to:setVolume(0)
to:play() to:play()
print(from:getVolume(), to:getVolume()) print(from:getVolume(), to:getVolume())
local t = 0 local t = 0
local anim = AnimationNode { self.animationNode = AnimationNode {
function(node) function(node)
from:setVolume(self.musicVolume - node:getValue() * self.musicVolume) from:setVolume(self.musicVolume - node:getValue() * self.musicVolume)
to:setVolume(node:getValue() * self.musicVolume) to:setVolume(node:getValue() * self.musicVolume)
@ -79,8 +87,8 @@ function audio:crossfadeAnim(from, to, ms)
-- } -- }
-- } -- }
} }
anim:run() self.animationNode:run()
anim:finish() -- anim:finish()
print(from:getVolume(), to:getVolume(), t, t, t) print(from:getVolume(), to:getVolume(), t, t, t)
end end

View File

@ -51,7 +51,9 @@ function walk:cast(caster, target)
local sprite = caster:has(Tree.behaviors.sprite) local sprite = caster:has(Tree.behaviors.sprite)
if not sprite then return true end if not sprite then return true end
AnimationNode { AnimationNode {
function(node) caster:has(Tree.behaviors.map):followPath(path, node) end, function(node)
caster:has(Tree.behaviors.map):followPath(path, node)
end,
onEnd = function() caster:has(Tree.behaviors.spellcaster):endCast() end, onEnd = function() caster:has(Tree.behaviors.spellcaster):endCast() end,
}:run() }:run()
@ -91,7 +93,7 @@ function regenerateMana:cast(caster, target)
local audioPath = Tree.assets.files.audio local audioPath = Tree.assets.files.audio
sprite:animate("hurt", node) sprite:animate("hurt", node)
Tree.audio:crossfadeAnim(audioPath.music.level1.battle, Tree.audio:crossfadeAnim(audioPath.music.level1.battle,
audioPath.music.level1.choral, 3000) audioPath.music.level1.choral, 2000)
end, end,
onEnd = function() caster:has(Tree.behaviors.spellcaster):endCast() end onEnd = function() caster:has(Tree.behaviors.spellcaster):endCast() end
}:run() }:run()

View File

@ -32,6 +32,7 @@ function love.update(dt)
testLayout:update(dt) -- потом UI, потому что нужно перехватить жесты и не пустить их дальше testLayout:update(dt) -- потом UI, потому что нужно перехватить жесты и не пустить их дальше
Tree.panning:update(dt) Tree.panning:update(dt)
Tree.level:update(dt) Tree.level:update(dt)
Tree.audio:update(dt)
Tree.controls:cache() Tree.controls:cache()