贝塞尔曲线移动 应用

//回调函数的参数 是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;
	}


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值