Good morning.
I have created a function that calculate circle values.
// Circle point updateCircle()
// x = number of iteration · SamplingPeriod ||||>getNumberOfIterations();
// y = A · sine
int iterations = this
CCPoint centerPoint = this~~>getCenter;
float x = centerPoint.x + this~~>getAmplitude() * cos( 2 * M_PI * iterations * this~~>getSamplingPeriod * this~~>getFrequency() );
float y = centerPoint.y + this~~>getAmplitude * sin * this~~>getFrequency() );
*newPoint = ccp;
// Create Array Actions
CCArray myActionsArray = new CCArray;
// Set action move
CCActionactionMove1 = CCMoveTo::create, newPoint); // Move to next point
CCAction actionMove2 = CCCallFuncN::create); // call again this function
// Insert Objects
myActionsArray~~>insertObject;
myActionsArray~~>insertObject;
// Create Sequence
CCActionaction = CCSequence::create;
// Set Tags
action~~>setTag;
// Run
this~~>runAction;
// Set new call to put new point in SamplingFrequency ms
iterations += 1;
static const int maxIterationCycle = 1 / * this~~>getFrequency);
if
{
iterations = 1;
}
this~~>setNumberOfIterations;
CCLog;
Alternativally, i have tried:
// Set action move
CCAction actionMove1 = CCCallFuncN::create);
CCActionactionMove2 = CCDelayTime::create);
CCAction actionMove3 = CCCallFuncN::create);
And
// Set action move
CCActionactionMove1 = CCMoveTo::create,*newPoint);
CCAction actionMove2 = CCDelayTime::create);
CCActionactionMove3 = CCCallFuncN::create(this, callfuncN_selector(GameObject::updateCircle));
The problem is, my game object move in a circle, but after 1000 iterations aprox, it dissapear, and appear again in a few seconds.
don’t know what is going on
- The points are correctly calculated (i think)
Maybe moveto need more time to execute?
How could i calculate a math patron to move my sprites following it?