c语言sscanf函数的用法是什么
256
2022-11-07
Cocos2d-X 物体重复运动的实现
void Hook::runRotateAction() { this->setAnchorPoint(CCPointMake(0.5, 1)); CCActionInterval *action1 = CCRotateTo::create(2,-90.0); CCActionInterval *action2 = CCRotateTo::create(2, 90.0); float rotate = this->getRotation(); CCSequence *action3; if(rotate>0) { action3 = CCSequence::create(action1,action2,NULL); } else { action3 = CCSequence::create(action2,action1,NULL); } CCRepeatForever *repeat = CCRepeatForever::create(action3); this->runAction(repeat); } void Hook::runBack() { CCSize winSize = CCDirector::sharedDirector()->getWinSize(); CCActionInterval *action4 = CCMoveTo::create(2, ccp(winSize.width/2-2, winSize.height/2-20)); CCCallFunc *func = CCCallFunc::create(this, callfunc_selector(Hook::runRotateAction)); CCSequence *seq = CCSequence::create(action4,func,NULL); this->runAction(seq); } void Hook::runToPoint(CCPoint point) { this->stopAllActions(); CCPoint start = this->getPosition(); float distance = sqrtf((start.x-point.x)*(start.x-point.x) + (start.y-point.y)*(start.y-point.y)); float time = distance*0.01; CCActionInterval *actionTo = CCMoveTo::create(time, point); CCCallFunc *fun = CCCallFunc::create(this, callfunc_selector(Hook::runBack)); CCSequence *seq = CCSequence::create(actionTo,fun,NULL); this->runAction(seq); } void Hook::runTargetAction() { float x; float y; if(this->getRotation()>0) { if(this->getRotation()<=45) { y=0.0; x= 240-160*tan(this->getRotation()*3.1415/180); } else { y=160-240/tan(this->getRotation()*3.1415/180); x= 0.0; } } else if(this->getRotation()<0) { if(this->getRotation()<=-45) { y=160+240/tan(this->getRotation()*3.1415/180); x= 480; } else { y=0; x= 240-160*tan(this->getRotation()*3.1415/180); } } else if(this->getRotation() == 0) { x= 240; y= 160; } this->runToPoint(ccp(x, y)); }
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~