贝塞尔曲线移动 应用

来源:互联网 发布:淘宝店推广预算计划书 编辑:程序博客网 时间:2024/06/10 20:02
//回调函数的参数 是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;}

原创粉丝点击