Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is the solution I figure it out.</p> <p>If you make sprite sheet from plist and want your animation sheet to add to the body make sure first add your sprite object to the body then add the sprite to the sheet.</p> <p>here is the right code</p> <pre><code>//================== making animating sprite [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile: @"framelist.plist"]; CCSpriteBatchNode *spriteSheet = [CCSpriteBatchNode batchNodeWithFile:@"frames.png"]; [self addChild:spriteSheet]; NSMutableArray *walkAnimFrames = [NSMutableArray array]; for(int i = 1; i &lt;= 2; ++i) { [walkAnimFrames addObject: [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName: [NSString stringWithFormat:@"frame%d.png", i]]]; } CCAnimation *walkAnim = [CCAnimation animationWithFrames:walkAnimFrames delay:0.1f]; //_frameSprite is CC Sprite _frameSprite = [CCSprite spriteWithBatchNode:spriteSheet rect:CGRectMake(0,0,48,48)]; _frameSprite.position = ccp(winSize.width + 60, winSize.height/2); _flyAction = [CCRepeatForever actionWithAction: [CCAnimate actionWithAnimation:walkAnim restoreOriginalFrame:NO]]; [_frameSprite runAction:_flyAction]; b2BodyDef frameBodyDef; frameBodyDef.type = b2_staticBody; frameBodyDef.position.Set(160/PTM_RATIO, 200/PTM_RATIO); frameBodyDef.userData = _frameSprite; //================first add the sprite to body frameBody = _world-&gt;CreateBody(&amp;frameBodyDef); [spriteSheet addChild:_frameSprite]; //======second add sprite to the sheet </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload