2012-04-03 4 views
0

私はcocos2dで初心者ですが、Objective-CとiphoneSdkでの経験があります。 私はアプリケーションに問題があります。何がエラーであるのか分かりません。エラーチェンジCCScene

私はCCLayer(アニメ)を持っています。 :

アニメ:私は文字のアニメーションを作成するためにCCSpriteFrameCacheを使用レベルで

-(id) init{ 

    if((self=[super init])) { 

CCSpriteFrameCache* frameCache = [CCSpriteFrameCache sharedSpriteFrameCache]; 
[frameCache addSpriteFramesWithFile:@"Anime.plist"]; 



CCSprite * backgound = [CCSprite spriteWithSpriteFrameName:@"Back.png"]; 
backgound.anchorPoint=ccp(0,0); 
[self addChild:backgound z:-1]; 


CCSprite *body = [CCSprite spriteWithSpriteFrameName:@"Body1.png"]; 
[self addChild:body z:0]; 

CCSprite *bMoved = [CCSprite spriteWithSpriteFrameName:@"Gigante1.png"]; 
[self addChild:bMoved z:1];  


NSMutableArray *nuvemAnim = [[NSMutableArray alloc] init]; 
     for (int i = 1; i < 41; i++) { 
      NSString *frameNames = [NSString stringWithFormat:@"Gigante%i.png",i]; 
      [nuvemAnim addObject:[[CCSpriteFrameCache sharedSpriteFrameCache] 
            spriteFrameByName:frameNames]]; 

     }  


     CCAnimation *gigAnim = [CCAnimation animationWithFrames:nuvemAnim delay:1.0f/24.0f]; 
     CCAnimate* animate = [CCAnimate actionWithAnimation:gigAnim]; 


     [bMoved runAction:[CCSequence actions: 
         [CCDelayTime actionWithDuration:1], 
         animate, 
         [CCDelayTime actionWithDuration:1], 
         [CCCallFunc actionWithTarget:self selector:@selector(changeCCScene)], 
          nil]]; 


    } 
return self; 

レベル:

-(id) init{ 
if((self=[super init])) { 

    self.isTouchEnabled=YES; 


    CCSpriteFrameCache* frameCache = [CCSpriteFrameCache sharedSpriteFrameCache]; 
    [frameCache addSpriteFramesWithFile:@"Level3.plist"]; 

    CCSprite * backgound = [CCSprite spriteWithSpriteFrameName:@"Fundo9.png"]; 
    backgound.anchorPoint=ccp(0,0); 
    [self addChild:backgound z:-1]; 


    CCSprite man = [CCSprite spriteWithSpriteFrameName:@"Man1.png"]; 
    [self man z:0]; 


    eAnim = [[NSMutableArray alloc] init]; 
    for (int i = 2; i < 178; i++) { 
     NSString *frameNames = [NSString stringWithFormat:@Man%i.png",i]; 
     [eAnim addObject:[[CCSpriteFrameCache sharedSpriteFrameCache] 
           spriteFrameByName:frameNames]]; 

    } 

が、すべてのフレーム

2012-04-03 23:37:51.987 GigV1[1432:10a03] cocos2d: WARNING: an alias with name Man12.png already exists 
2012-04-03 23:37:51.988 GigV1[1432:10a03] cocos2d: WARNING: an alias with name Man155.png already exists 

のために無限コンソールで私にこれが起こる理由を任意のideaiをこのタイプのエラーを与えます?

おかげ

答えて

1

前に、あなたはアニメからスプライトフレームをロードしています。 plistとLevel3.plist:

CCSpriteFrameCache* frameCache = [CCSpriteFrameCache sharedSpriteFrameCache]; 
[frameCache addSpriteFramesWithFile:@"Anime.plist"]; 

[frameCache addSpriteFramesWithFile:@"Level3.plist"]; 

この警告は、同じ名前を持つ多くのスプライトフレームを追加していることを示しています

WARNING: an alias with name Man12.png already exists 

これを解決するには次の3つのオプションがあります。

  1. を使用すると、同じスプライトフレームを使用していないことを確認してください別のテクスチャアトラスの名前(同じイメージ)
  2. 別のテクスチャアトラスからスプライトフレームをロードする前に不要なスプライトフレームをアンロードする
  3. 警告を無視する
+0

私の問題を解決できる...私はLevelのメソッド "OnEnter#それ自身のエラーが続きます。 ありがとう – DaSilva

1

あなたは、この行の引用符が不足している:

NSString *frameNames = [NSString stringWithFormat:@Man%i.png",i];

@後開口部の引用であるべきで、Man%i

+0

コードをコピーする際にエラーが発生しました...申し訳ありませんが、とにかくありがとうございます。 – DaSilva

関連する問題