Extend a SKSpriteNode in One direction only

88 views Asked by At

I am working on a project in SpriteKit using swift and I can't seem to create a progress bar that will stretch in one direction. If I use the below it expands in both directions from it position.

    // Extend Bar (SKSpriteNode) on touch
    if touched {
        bar.size.height+=20
    } else if !touched && bar.size.height > 10 {
        bar.size.height-=20
    }

What is the best way to achieve this? I have also tried yScale with the same issue.

I thought of adding a new SKSpriteNode to a SKnode group to make the progress and then removing from the the array to go back down, but this seems overkill and I was hoping there was a simpler approach?

1

There are 1 answers

1
Epic Byte On BEST ANSWER

The answer is simple. Set the node's anchorPoint to (0,0) (or any of the other 3 corners).