Reputation: 1544
I have a problem with [setTexture:string]
because as you can see, sometimes the size of the sprite changes to a smaller one and there's not such that thing in my code. The only weird thing I have found is when I don't move the player, which is when I do touchesBegan()
and then touchesEnded()
without touchesMoved()
it doesn't change size of the sprite, but when I do touchesMoved()
and then release the finger, I have this bug and it's like random. Anybody got an idea of what it can be or if there is a bug with setTexture??
Upvotes: 0
Views: 57
Reputation: 28
I was having lots of trouble with this as well. But setting the size after setting the texture fixes the problem (even though the textures are the same size). The thing that caught me most off-gaurd is that even though the sprite becomes smaller, an NSLog of the size outputs the original size (not something smaller).
CGSize originalSize = mySprite.size;
mySprite.texture = [SKTexture textureWithImage:image];
mySprite.size = originalSize;
Upvotes: 1