//回调函数的参数 是restart(CCNode* sender) 不能为空
void GameObjEnemy::restart(CCNode* sender)
{
mainbody->setVisible(true);
boom->setVisible(false);
CCSize size = CCDirector::sharedDirector()->getWinSize();
this->setPosition(ccp(size.width/4 * type,size.height+50));
islife = true;
mainbody->setVisible(true);
boom->setVisible(false);
this->movestart();
}
void GameObjEnemy::movestart()
{
islife = true;
int type = CCRANDOM_0_1() * 4;
//贝塞尔曲线移动
ccBezierConfig bezier2;
bezier2.controlPoint_1 = CCPointMake(this->getPosition().x - 400,330);
bezier2.controlPoint_2 = CCPointMake(this->getPosition().x + 400,280);
bezier2.endPosition = CCPointMake(this->getPosition().x,-70);
CCBezierTo * bezierBy2 = CCBezierTo::create(6, bezier2);
ccBezierConfig bezier1;
bezier1.controlPoint_1 = CCPointMake(this->getPosition().x + 400,330);
bezier1.controlPoint_2 = CCPointMake(this->getPosition().x - 400,280);
bezier1.endPosition = CCPointMake(this->getPosition().x,-70);
CCBezierTo * bezierBy1 = CCBezierTo::create(6, bezier1);
switch(type){
case 0:
case 1:
this->runAction(CCSequence::create(CCMoveBy::create(6,ccp(0,-600)),
CCCallFuncN::create(this, callfuncN_selector(GameObjEnemy::restart)),NULL));
break;
case 2:
this->runAction(CCSequence::create(bezierBy2,CCCallFuncN::create(this,
callfuncN_selector(GameObjEnemy::restart)),NULL));
break;
case 3:
this->runAction(CCSequence::create(bezierBy1,CCCallFuncN::create(this,
callfuncN_selector(GameObjEnemy::restart)),NULL));
break;
}
贝塞尔曲线移动 应用
最新推荐文章于 2022-09-04 17:16:15 发布