I have a SKNode that is a load bar. This bar is supposed to shrink from right to left. For doing this I use the following code:
let loadBarNode = self.childNodeWithName("loadBar")
if loadBarNode != nil{
let countdown = SKAction.scaleXTo(0, duration: 3)
loadBarNode?.runAction(countdown)
}
When I run this code, this happens:
I would like to know how to shrink the shape from right to left, like this:
Any help is appreciated!
I believe a simpler solution is to change the anchor of your node.
loadBarNode.anchorPoint = CGPointMake(0.0, 0.5)
Scaling is based on the anchorPoint of your node and this would cause it to expand to the right.
Make an SKAction sequence that has your countdown action, plus an SKAction which moves your X.
class func moveToX(_ x: CGFloat, duration sec: NSTimeInterval) -> SKAction
So as your load bar shrinks, you want to offset your X by half the shrunk distance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With