2014-02-13 3 views
2

제 게임에서 끝없는 애니메이션을 실행하는 SpriteNode가 있습니다. 사용자는 버튼을 눌러 애니메이션을 멈출 수 있습니다 (다시 시작). 애니메이션의 현재 프레임을 알아야하므로 (XML 파일에서) 애니메이션과 관련된 적절한 값을 읽을 수 있습니다. 애니메이션 텍스처가현재 애니메이션 프레임 - SKSpriteNode

SKAction *animateCircle = [SKAction 
         animateWithTextures:_animationTextures 
         timePerFrame: [self getAnimationSpeedAccordingToStage]]; 
    SKAction *repeatAnimation = [SKAction repeatActionForever:animateCircle]; 
    [shapeNode runAction:repeatAnimation withKey:@"shapeAnimation"]; 
    animationStartTime = [NSDate date]; 
    [self resumeShapeAnimation]; 
+0

가능한 중복 http://stackoverflow.com/questions/21698512/sktexture-get- 이미지 이름) – jackslash

답변

0

번호가 매겨집니다 : 여기

내 코드? 그들은 당신이 나 자신이 사용하는이 솔루션을 사용할 수 있습니다 textureNameNumber 같은 패턴을 따르는 경우 :

-(int) getAnimationFrameFromTexture: (SKTexture*) texture imageName:(NSString*) name 
{ 
    NSString* textureString = [NSString stringWithFormat:@"%@", texture]; 
    int i; 
    char numberStr[4]="000"; 
    for(i=0 ;i<[textureString length]; i++) 
    { 
     char character = [textureString characterAtIndex:i]; 
     if(character=='\'') 
      break; //found ' 
    } 
    //Adds length 
    i+=[name length]+1; 
    for(int j=0;i<[textureString length];i++, j++) 
    { 
     char character = [textureString characterAtIndex:i]; 
     numberStr[j]=character; 
     if(character=='\'') 
      break; 
    } 
    numberFromString=[NSString stringWithUTF8String:numberStr]; 
    int number = [numberFromString intValue]; 
    return number; 
} 
[SKTexture 얻을 이미지 이름] (의