Sprite Kit相当于CCTexture2D

时间:2013-11-13 01:51:09

标签: sprite-kit

我已经连续几天玩弄它了,我仍然不能这样做......

有谁知道Sprite Kit中等效的以下代码是什么?

我在所有游戏中使用这段代码几千次......如果它是'不可转换的',我甚至都不会尝试使用Sprite Kit ......

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

1 个答案:

答案 0 :(得分:1)

你看过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];

你的高清分辨率图片应该有@2x后缀btw,而不是cocos2d的-hd