You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 1, 2026. It is now read-only.
When alpha of a SKNode is set, all the children should multiply it's alpha's value.
Eg:
If a node has alpha 0.5 and it's child has 0.75 of alpha.
Any SKSpriteNode that is in node.children[0].children that has 1.0 of alpha should have (0.5 * 0.75 * 1.0) == 0.375.
That means that the rendering should respect the algorithm:
funcalculateParentsAlpha() : Float {
var accumulatedAlpha =0.0fvar parent =this.parent
while (parent !=null) {
accumulatedAlpha *= parent!!.alpha
parent = parent.parent
}
return accumulatedAlpha
}
val currentNodeAlpha =this.alpha *this.calculatedParentsAlpha()
That was just an example.
But there is an approach with better performance. That would be keep the alpha values of the children updated each time it's parent alpha value is changed.
If an alpha value of a node is changed, all the children of this node should be updated, recursively, with the multiplied value that has been changed. Of course it will require an backup alpha value for each node, otherwise the original value would be lost.
Just another thought about the solution. Open to discussions.
When alpha of a SKNode is set, all the children should multiply it's alpha's value.
Eg:
If a node has alpha 0.5 and it's child has 0.75 of alpha.
Any SKSpriteNode that is in
node.children[0].childrenthat has 1.0 of alpha should have(0.5 * 0.75 * 1.0) == 0.375.That means that the rendering should respect the algorithm:
That was just an example.
But there is an approach with better performance. That would be keep the alpha values of the children updated each time it's parent alpha value is changed.
If an alpha value of a node is changed, all the children of this node should be updated, recursively, with the multiplied value that has been changed. Of course it will require an backup alpha value for each node, otherwise the original value would be lost.
Just another thought about the solution. Open to discussions.