Skip to content

Commit

Permalink
Fixed instant color change of node (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
vldygrf authored Dec 28, 2023
1 parent fdc80aa commit 8992a20
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Sources/Spine/Animation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,13 @@ extension Animation {
let change = keyframe.value - lastValue
let timingFunction = keyframe.curve.timingFunction

let channelAction = SKAction.customAction(withDuration: duration) { [lastValue, change] node, time in
let channelAction = SKAction.customAction(withDuration: duration) { [lastValue, change, duration] node, time in

guard let spriteNode = node.children.compactMap({ $0 as? SKSpriteNode }).first else {
return
}

let deltaTime = duration > 0 ? Float(time) / Float(duration) : 0
let deltaTime = duration > 0 ? Float(time) / Float(duration) : 1
let delta = timingFunction(deltaTime)
let value = min(lastValue + change * CGFloat(delta), 1)

Expand Down

0 comments on commit 8992a20

Please sign in to comment.