Home > other >  Rotate the COCOS elves
Rotate the COCOS elves

Time:09-23

Point headPos=m_head - & gt; GetPosition ();
CCActionInterval * actionTo=NULL;
The switch (m_dirType)
{
Case UP:
If (pos. X & gt; HeadPos. X) {
M_dirType=RIGHT;
ActionTo=CCRotateTo: : create (0.05, 90);
}
The else {
M_dirType=LEFT;
ActionTo=CCRotateTo: : create (0.001-90);
}
break;
The case DOWN:
If (pos. X & gt; HeadPos. X) {
M_dirType=RIGHT;
ActionTo=CCRotateTo: : create (0.001-90);
}
The else {
M_dirType=LEFT;
ActionTo=CCRotateTo: : create (0.001, 90);
}
break;
Case LEFT:
If (pos. Y & gt; HeadPos. Y) {
M_dirType=UP;
ActionTo=CCRotateTo: : create (0.001, 90);
}
The else
{
M_dirType=DOWN;
ActionTo=CCRotateTo: : create (0.001-90);
}
break;
Case RIGHT:
If (pos. Y & gt; HeadPos. Y) {
M_dirType=UP;
ActionTo=CCRotateTo: : create (0.001-90);
}
The else
{
M_dirType=DOWN;
ActionTo=CCRotateTo: : create (0.001, 90);

}
break;
}

M_head - & gt; RunAction (CCSequence: : create (actionTo, NULL));



Code, is going up at the beginning, if change to the right direction, turn 90 degrees clockwise, the 90 degrees counterclockwise to the left, but I like to write only clockwise or counterclockwise, a great god please help solve what the problem is this

CodePudding user response:

You use rotateBy give it a try

CodePudding user response:

Upstairs is the solution, you look at RotateTo realization you will understand

CodePudding user response:

Have a built-in function very convenient
http://bbs.9ria.com/thread-204010-1-1.html

CodePudding user response:

RotateBy + 1
  • Related