Home > other >  MoveTo move the elves to the target location how to obtain elves coordinates
MoveTo move the elves to the target location how to obtain elves coordinates

Time:09-17

Everyone a great god, and I use moveTo move the elves to the target location, and then get the current coordinates, display or location before moving, I then setposition it in target location, or will go wrong, how can I solve?

CodePudding user response:

Everyone a great god please inform, thank you thank you thank you very much!

CodePudding user response:

You need to write a sequence action sequences, a callback function is executed after moveto, capture or set in the callback function you need the spirit of coordinates

CodePudding user response:

Error code and paste it

CodePudding user response:

Sure is that after the move, is likely to be at the time of runAction take coordinates, so in the first position, join in runAction obtain the coordinates of the code

CodePudding user response:

Code stick, before or after moving coordinates? Impossible!

CodePudding user response:

In fact you when deciding how much to move, knew that the location of the object

CodePudding user response:

X: runaction (cc. Seq (cc) moveTo (x, x), cc. Callfunc (fcuntion () print x: getposition () end)));

CodePudding user response:

You must be obtained before moving coordinates, the cocos the underlying principle is that each frame of mobile elves sets the position of the elves, impossible to move after getPosition is before moving

CodePudding user response:

refer to the eighth floor z153300230 response:
you must be obtained before moving coordinates, the cocos the underlying principle is that each frame of mobile elves sets the position of the elves, impossible to move after getPosition is before moving coordinate


Will you get before the object is to move the current position of the elves, check their order

CodePudding user response:

3. I remember getting function changed after x x: getpositionX (), x: getpositionY (), you can look at this?

CodePudding user response:

Whether the animation of execution of the elves the next line of code that is access to elves current position? If so, it must be so; Because the heart of the animation will take time, it is a process, two code execution almost instant finished; If you want to get the position of the animation after, reference method, 4/f

CodePudding user response:

The
reference 11 floor w775198287 reply:
is the animation of execution of the elves the next line of code that is access to elves current position? If so, it must be so; Because the heart of the animation will take time, it is a process, two code execution almost instant finished; If you want to get the position of the animation after, reference method, 4/f

Sure is that after the move, is likely to be at the time of runAction take coordinates, so in the first position, add access to coordinate in runAction code
Met the same wrong, please help to see, or the old coordinates, unless their setposition
Is this set?
CCCallFunc * callFunc=CCCallFunc: : create (this, SEL_CallFunc (& amp; Ball: : getballxy));
CCSequence * sequence=CCSequence: : create (moveTo callFunc, NULL);//constructs an animation sequence
RunAction (sequence);

Void Ball: : getballxy ()
{
Return _ballsp - & gt; GetPosition ();
}

CodePudding user response:

refer to 12 floor loni718 reply:
Quote: reference 11 floor w775198287 response:

Whether the animation of execution of the elves the next line of code that is access to elves current position? If so, it must be so; Because the heart of the animation will take time, it is a process, two code execution almost instant finished; If you want to get the position of the animation after, reference method, 4/f

Sure is that after the move, is likely to be at the time of runAction take coordinates, so in the first position, add access to coordinate in runAction code
Met the same wrong, please help to see, or the old coordinates, unless their setposition
Is this set?
CCCallFunc * callFunc=CCCallFunc: : create (this, SEL_CallFunc (& amp; Ball: : getballxy));
CCSequence * sequence=CCSequence: : create (moveTo callFunc, NULL);//constructs an animation sequence
RunAction (sequence);

Void Ball: : getballxy ()
{
Return _ballsp - & gt; GetPosition ();
}
runAction (sequence); In front of this action is the node execution, there should be this node, depending on your code that should be _ballsp this node, if there is no execution _ballsp runAction (sequence); Certainly does not change the location of it, you try runAction (sequence); Instead of ballsp - & gt; RunAction (sequence); In the implementation and see
  • Related