0

I am trying to make sprite sheet animation work with another Action. For this purpose i've a Sprite sheet .png file without any .plist file. My problem is that the spritesheet animation works but with other action like this one in following code block it just doesn't. It will first move it to the destination and then animates it but all i want it to move while animating itself.

void animatespritesheet()
{
     for(i=0;i<10;i++)
         {

            _spriteFrame=CCSpriteFrame::create("bulb_f.png",CCRectMake(i*75,0,75,75));

            _anims->addObject(_spriteFrame);
         }

    _animation=CCAnimation::createWithSpriteFrames(_anims,1.0f);

    CCSprite* sprite = CCSprite::createWithSpriteFrame(_spriteFrame);
    //sprite->setPosition(ccp(256,256));

    CCAction* axn = CCRepeatForever::create(CCAnimate::create(_animation));
    /*CCAction *axn1 = CCMoveTo::create(1.0f,CCPoint(200,200));
    CCMoveTo* move = CCMoveTo::create(1.0f,CCPoint(200.0,200.0));*/
    _spriteBatch->addChild(sprite);
    sprite->runAction(axn);
    //sprite->runAction(move);
    //sprite->runAction(CCSequence::Create(move,axn,NULL);
   }

_anims is a CCArray. the png file is 75*750 file which contains 10 frames. I just can't get this thing done by myself. Please Help me out on this. I Really need help on it.

1 Answer 1

1

Use a CCSpawn to run both actions at the same time (this examples assumes cocos 3.0).

[CCActionSpawn actions:action1, action2, nil];
1
  • Allen, strictly speaking in this instance OP can just run two animations on the same object. CCActionSpawn is mandatory when you need to fork two paths mid-flight in a sequence ... if i recall correctly.
    – YvesLeBorg
    Sep 15, 2014 at 19:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.