我在 SpriteKit 游戏中遇到纹理问题:
在 touchesBegan
中我这样做:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInNode:self];
SKNode *node = [self nodeAtPoint:location];
if ([node.name isEqualToString:@"worm"]) {
[node removeAllActions];
SKAction *change = [SKAction setTexture:[SKTexture textureWithImageNamed:@"worm2"]];
[node runAction:change];
此代码有效,但新纹理“worm2”已缩放,与应有的效果相比,您会发现效果不佳。
应该有方法:setTexture:resize:
但是正如你从我放的图片中看到的,这个方法不存在..
我错过了什么?
谢谢大家
最佳答案
我认为 [SKAction setTexture:resize:]
仅适用于 iOS 7.1。看看 API Differences .
如果您运行的是旧版本,可以将 Xcode 更新到最新版本 (5.1)。
关于ios - 无法使用并找到 setTexture :resize SpriteKit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22330491/