0
votes

I have been toying with this on and off for days, and I still cannot do it…

Does anyone know what the equivalent of the below code would be in Sprite Kit??

I use this snippet of code literally thousands of times in all my games… and if it is 'unconvertible' I am not even going to attempt Sprite Kit at all….

CCTexture2D *hintA7Vert = [[CCTexture2D alloc]initWithImage:[UIImage imageNamed:pipeName]  resolutionType: kCCResolutionUnknown];
[movablePipeHintVertA7 setTexture: hintA7Vert];
[hintA7Vert release];
1

1 Answers

1
votes

Have you looked in the API reference?

SKTexture* texture = [SKTexture textureWithImage:[UIImage imageNamed:pipeName]];

// or more directly without the (unnecessary) conversion through UIImage
SKTexture* texture = [SKTexture textureWithImageNamed:pipeName];

// then use the texture
yourSprite.texture = texture;
// or
SKSpriteNode* sprite = [SKSpriteNode spriteNodeWithTexture:texture];

Your HD resolution image should have the @2x suffix btw, not cocos2d's -hd.