Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

9 slice scaling in Sprite Kit

Does Sprite Kit have an equivalent to 9 slice scaling for sprites?

I have tried googling, but not finding anything, but... it's often a feature that goes by different names in different frameworks. So I could be missing it.

like image 533
Confused Avatar asked Jan 01 '26 01:01

Confused


1 Answers

SpriteKit supports 9-slices.

https://developer.apple.com/library/ios/documentation/GraphicsAnimation/Conceptual/SpriteKit_PG/Sprites/Sprites.html#//apple_ref/doc/uid/TP40013043-CH9-SW10

The document doesn't tell you to set the size which won't work without it, so here it is:

SKSpriteNode *button = [SKSpriteNode spriteNodeWithImageNamed:@"stretchable_button.png"];
button.centerRect = CGRectMake(12.0/28.0, 12.0/28.0, 4.0/28.0, 4.0/28.0);
button.size = CGSizeMake(100.0, 50.0);
like image 185
Genki Avatar answered Jan 06 '26 08:01

Genki



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!