cocos2d-x怎样做抛物线运动???

cocos2d-x怎样做抛物线运动???,第1张

概述CCEaseInOut* createParabola(float t, CCPoint startPoint, CCPoint endPoint, float height /* = 0 */, float angle /* = 60 */){ // 把角度转换为弧度 float radian = angle*3.14159/180.0; // 第一个控制点为抛物线左半弧的中点 flo
CCEaseInOut* createParabola(float t,CCPoint startPoint,CCPoint endPoint,float height /* = 0 */,float angle /* = 60 */){	// 把角度转换为弧度	float radian = angle*3.14159/180.0;	// 第一个控制点为抛物线左半弧的中点	float q1x = startPoint.x+(endPoint.x - startPoint.x)/4.0;	CCPoint q1 = ccp(q1x,height + startPoint.y+cos(radian)*q1x);			// 第二个控制点为整个抛物线的中点	float q2x = startPoint.x + (endPoint.x - startPoint.x)/2.0;	CCPoint q2 = ccp(q2x,height + startPoint.y+cos(radian)*q2x);		//曲线配置	ccBezIErConfig cfg;	cfg.controlPoint_1 = q1;	cfg.controlPoint_2 = q2;	cfg.endposition = endPoint;	//使用CCEaseInOut让曲线运动有一个由慢到快的变化,显得更自然	return CCEaseInOut::create(CCBezIErTo::create(t,cfg),0.5); }


用法如下:

	CCSprite *s = CCSprite::create("battle_music_close.png");	this->addChild(s);	//moveParabola(s,ccp(0,0),ccp(300,640),0.5);	s->runAction(CCRepeatForever::create(CCRotateBy::create(0.2,360)));	s->runAction(createParabola(1,s->getposition(),ccp(450,-100),900,20));
总结

以上是内存溢出为你收集整理的cocos2d-x怎样做抛物线运动???全部内容,希望文章能够帮你解决cocos2d-x怎样做抛物线运动???所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1073475.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存