Yonkee
Yonkee

Reputation: 1883

Extend a SKSpriteNode in One direction only

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?

Upvotes: 0

Views: 85

Answers (1)

Epic Byte
Epic Byte

Reputation: 33968

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

Upvotes: 1

Related Questions