ios - 无法使用并找到 setTexture :resize SpriteKit

标签 ios objective-c sprite-kit sktexture

我在 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”已缩放,与应有的效果相比,您会发现效果不佳。

来自 Apple 文档,https://developer.apple.com/library/ios/documentation/SpriteKit/Reference/SKAction_Ref/Reference/Reference.html#//apple_ref/occ/clm/SKAction/setTexture:resize :

应该有方法:setTexture:resize:

但是正如你从我放的图片中看到的,这个方法不存在.. enter image description here

我错过了什么?

谢谢大家

最佳答案

我认为 [SKAction setTexture:resize:] 仅适用于 iOS 7.1。看看 API Differences .

如果您运行的是旧版本,可以将 Xcode 更新到最新版本 (5.1)。

关于ios - 无法使用并找到 setTexture :resize SpriteKit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22330491/

相关文章:

ios - 节点未出现

使用 kCCAlgorithmAES128 的 iOS CCCrypt kCCDecrypt

ios - 如何编写正则表达式?

ios - iOS中的正则表达式(单词,字母和特殊字符)

ios - 我应该如何在 PinchGestureRecognizer 上保持缩放比例?

ios - 如何在 Swift 中为 SpriteKit 定义类别位掩码枚举?

ios - 如何更改 SKAction 序列中的变量?

ios - 模态视图的工具栏被遮挡。 MFMailComposeViewController

ios - 使用 NSAutolayout 概念如何在 ios 中的同一位置显示所有版本的按钮

ios - 按位右移 >> 在 Objective-C 中