running simultaneous actions invoked by touch

hi
i am trying to fire laser which is enabled by touch but when i double tap the screen the first action(laser) disappears and second laser completes its action , how can i change the following code so i can have two or more simultaneous running actions?

void HelloWorld::ccTouchesBegan(cocos2d::CCSet* touches, cocos2d::CCEvent* event)
{
CCSize winSize = CCDirector::sharedDirector()>getWinSize;
CCSprite *shipLaser = _shipLasers
>objectAtIndex(*nextShipLaser++);
if )
*nextShipLaser = 0;
shipLaser~~>setPosition, ccp.width/2, 0)));
shipLaser~~>setVisible(true);
shipLaser~~>stopAllActions;
shipLaser~~>runAction(CCSequence::create(CCMoveBy::create(0.5,ccp(winSize.width, 0)), CCCallFuncN::create(this, callfuncN_selector(HelloWorld::setInvisible)), NULL // DO NOT FORGET TO TERMINATE WITH NULL
));
}

You have to use CCSpawn() in the C++ world to get multiple actions to schedule at the same time.

thanks! you mean just change the last line like this ?

shipLaser->CCSpawn::create(runAction(CCSequence::create(CCMoveBy::create(0.5,ccp(winSize.width, 0)), CCCallFuncN::create(this, callfuncN_selector(HelloWorld::setInvisible)), NULL // DO NOT FORGET TO TERMINATE WITH NULL
)));

CCSpawn::Create(action1, action2, action3, …)

Each action is scheduled at the same time.

i want the same action to repeat and run simultaneously when invoked by touch on the screen

In the C*+ world you have to use the CCCallFuncN to spaw the RepeatForever action. Sorry but that’s the unnecessary limitation of the C*+ framework. We got rid of that in the c# version by changing the sequence object to know when there is an indefinite action and to use step() instead of update() to update the action progress.

Maybe Ricardo or Walzer can do that in the C*+ version. I am no expert in C*+ anymore … sorry

Hmmm… This should work, if I get what you mean.

// Create two actions
CCRotateBy * rotate = CCRotateBy::create( 0.50f, 40 );
CCScaleBy * scale = CCScaleBy::create( 0.50f, 0.50f );

// CCSpawn makes it possible to have two actions run at the same time
CCSpawn * spawn = CCSpawn::createWithTwoActions( rotate, scale );

// If you want to repeat, use CCRepeat. This will repeat the spawn action 5 times
CCRepeat * repeat = CCRepeat::create( spawn, 5 )

// Run the action
myObject -> runAction( repeat );