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 tryCodePudding user response:
Upstairs is the solution, you look at RotateTo realization you will understandCodePudding user response:
Have a built-in function very convenienthttp://bbs.9ria.com/thread-204010-1-1.html
CodePudding user response:
RotateBy + 1