Ios 为什么我的SKSpriteNode中的纹理在它';动画制作完成了吗?

Ios 为什么我的SKSpriteNode中的纹理在它';动画制作完成了吗?,ios,objective-c,sprite-kit,Ios,Objective C,Sprite Kit,我有一个SKSpriteNode,我正在尝试在我的触摸开始时对它进行动画制作,动画效果很好,但是当它完成动画制作后,我的SKSpriteNode的默认纹理就消失了。我的R.atlas包含名为R1、R2..R7的图像,我做错了什么?非常感谢 @interface MyScene() { SKSpriteNode * rightTubeNode; } @property NSArray* rightTubeAnimationArray; @end @implementation MyScene -

我有一个SKSpriteNode,我正在尝试在我的
触摸开始时对它进行动画制作,动画效果很好,但是当它完成动画制作后,我的SKSpriteNode的默认纹理就消失了。我的R.atlas包含名为R1、R2..R7的图像,我做错了什么?非常感谢

@interface MyScene()
{
SKSpriteNode * rightTubeNode;
}
@property NSArray* rightTubeAnimationArray;
@end

@implementation MyScene
-(id)initWithSize:(CGSize)size {
    if (self = [super initWithSize:size]) {
       SKTextureAtlas *rightTubeAtlas = [SKTextureAtlas atlasNamed:@"R"];
       rightTubeTexture = [rightTubeAtlas textureNamed:@"R1"];
       NSMutableArray *rightAnimFrames = [NSMutableArray array];
       for (int i = 1; i <= rightTubeAtlas.textureNames.count; ++i){
           NSString *texture =[NSString stringWithFormat:@"R%d",i];
           [rightAnimFrames addObject:[rightTubeAtlas textureNamed:texture]];
           }
       self.rightTubeAnimationArray = rightAnimFrames;
       rightTubeNode = [self createRightTubeNode];
       rightTubeNode.position = CGPointMake(self.frame.size.width/2+rightTubeNode.frame.size.width/2,50);
       rightTubeNode.zPosition = 0.1;
       [self addChild:rightTubeNode];
    }
  return self;
}
- (SKSpriteNode *)createRightTubeNode
{
     SKSpriteNode *rightTube = [SKSpriteNode spriteNodeWithTexture:rightTubeTexture];
     rightTube = [SKSpriteNode spriteNodeWithTexture:rightTubeTexture];
     rightTube.name = @"rightTubeNode";
     return rightTube;
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
       for (UITouch *touch in touches) {
           CGPoint location = [touch locationInNode:self];
           CGPoint nodesLocation = CGPointMake(location.x,self.frame.size.height/2);

           if (nodesLocation.x>self.frame.size.width/2) {
              SKNode *archerNode = [self childNodeWithName:@"rightTubeNode"];
              if (archerNode != nil){
                 SKAction *animate = [SKAction animateWithTextures:self.rightTubeAnimationArray
                                             timePerFrame: 0.02];
                 [archerNode runAction:animate];
              }
           }
       }
  }
@interface MyScene()
{
SKSpriteNode*右管节点;
}
@属性NSArray*rightTubeAnimationArray;
@结束
@MyScene的实现
-(id)initWithSize:(CGSize)大小{
if(self=[super initWithSize:size]){
SKTextureAtlas*rightTubeAtlas=[SKTextureAtlas atlasNamed:@“R”];
rightTubeTexture=[rightTubeAtlas TextureName:@“R1”];
NSMutableArray*rightAnimFrames=[NSMutableArray];
对于(int i=1;i self.frame.size.width/2){
SKNode*archerNode=[self childNodeWithName:@“rightTubeNode”];
if(archerNode!=nil){
SKAction*animate=[SKAction animateWithTextures:self.rightTubeAnimationArray
时间性能:0.02];
[节点运行动作:设置动画];
}
}
}
}

由于@Whirlwind,重新添加R.atlas(选中“创建组选项”框)而不做任何进一步的更改,成功了。

您所说的“消失”是什么意思?动画完成后,节点的纹理将为R7。你到底看到了什么纹理?缺少资源,好的。首先,检查纹理名称,然后清除模拟器的内容和设置(模拟器->重置内容和设置),然后重试。另外,如何创建您的atlas(使用.atlas文件夹或资产目录)?好的,让我尝试复制它。同时,删除派生数据,清理项目,从设备中删除应用程序,然后重新构建并运行。这对我很有用。我创建了一个新项目,创建了一个名为R1@2x.png,R2,R3等,并将atlas拖到项目中(“如果需要,复制项目”和“已选中创建组选项”)。因为我能想到的最后一件事是重新添加您的atlas。在此之前,您应该从项目中删除旧的atlas(右键单击atlas,移动到垃圾箱)。然后,清理项目。这是重要的部分。所以,删除、清理、重新添加。