vgo*_*anz 9 android ccsprite cocos2d-x
早上好.
我在linux上,使用cocos2d-x Android.
我创建了一个计算圆值的函数.
// Circle point updateCircle()
// x = number of iteration · SamplingPeriod |-|-|-|
// y = A · sine ( 2 · PI · number of iteration · SamplingPeriod / Period )
int iterations = this->getNumberOfIterations();
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( 2 * M_PI * iterations * this->getSamplingPeriod() * this->getFrequency() );
_newPoint = ccp( x, y );
// Create Array Actions
CCArray *myActionsArray = new CCArray(3);
// Set action move
CCAction *actionMove1 = CCMoveTo::create(this->getSamplingPeriod(), newPoint); // Move to next point
CCAction *actionMove2 = CCCallFuncN::create(this, callfuncN_selector(GameObject::updateCircle)); // call again this function
// Insert Objects
myActionsArray->insertObject(actionMove1, 0);
myActionsArray->insertObject(actionMove2, 1);
// Create Sequence
CCAction *action = CCSequence::create(myActionsArray);
// Set Tags
action->setTag(kActionMove);
// Run
this->runAction(action);
// Set new call to put new point in SamplingFrequency ms
iterations += 1;
static const int maxIterationCycle = 1 / (this->getSamplingPeriod() * this->getFrequency());
if (iterations >= maxIterationCycle)
{
iterations = 1;
}
this->setNumberOfIterations(iterations);
CCLog("texttx Iterations %d/%d", iterations, maxIterationCycle);
另外,我试过:
// Set action move
CCAction *actionMove1 = CCCallFuncN::create(this, callfuncN_selector(GameObject::macroSetNewPoint));
CCAction *actionMove2 = CCDelayTime::create(this->getSamplingPeriod());
CCAction *actionMove3 = CCCallFuncN::create(this, callfuncN_selector(GameObject::updateCircle));
和
// Set action move
CCAction *actionMove1 = CCMoveTo::create(this->getSamplingPeriod(), _newPoint);
CCAction *actionMove2 = CCDelayTime::create(this->getSamplingPeriod());
CCAction *actionMove3 = CCCallFuncN::create(this, callfuncN_selector(GameObject::updateCircle));
问题是我的游戏对象在圆圈中移动,但是在大约1000次迭代之后,它会消失,并在几秒钟内再次出现.我不知道发生了什么 - 积分是正确计算的(我认为)
也许moveto需要更多时间来执行?我怎么能计算出一个数学赞助人来移动我的精灵呢?
| 归档时间: |
|
| 查看次数: |
1304 次 |
| 最近记录: |