おはようございます。
私は Linux で cocos2d-x を使用していAndroidます。
円の値を計算する関数を作成しました。
// 円の点 updateCircle()
// x = 反復回数 · SamplingPeriod |-|-|-|
// y = A・sine ( 2・PI・反復回数・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 * 反復 * this->getSamplingPeriod() * this->getFrequency() );
_newPoint = ccp( x, y );
// 配列アクションを作成
CCArray *myActionsArray = new CCArray(3);
// アクションの移動を設定
CCAction *actionMove1 = CCMoveTo::create(this->getSamplingPeriod(), newPoint); // 次のポイントに移動
CCAction *actionMove2 = CCCallFuncN::create(this, callfuncN_selector(GameObject::updateCircle)); // この関数を再度呼び出します
// オブジェクトを挿入
myActionsArray->insertObject(actionMove1, 0);
myActionsArray->insertObject(actionMove2, 1);
// シーケンスを作成
CCAction *action = CCSequence::create(myActionsArray);
// タグを設定
action->setTag(kActionMove);
// 走る
this->runAction(アクション);
// SamplingFrequency ms に新しいポイントを入れる新しい呼び出しを設定します
反復 += 1;
static const int maxIterationCycle = 1 / (this->getSamplingPeriod() * this->getFrequency());
if (反復 >= maxIterationCycle)
{
反復 = 1;
}
this->setNumberOfIterations(反復);
CCLog("texttx Iterations %d/%d", iterations, maxIterationCycle);
代わりに、私は試しました:
// アクションの移動を設定
CCAction *actionMove1 = CCCallFuncN::create(this, callfuncN_selector(GameObject::macroSetNewPoint));
CCAction *actionMove2 = CCDelayTime::create(this->getSamplingPeriod());
CCAction *actionMove3 = CCCallFuncN::create(this, callfuncN_selector(GameObject::updateCircle));
と
// アクションの移動を設定
CCAction *actionMove1 = CCMoveTo::create(this->getSamplingPeriod(), _newPoint);
CCAction *actionMove2 = CCDelayTime::create(this->getSamplingPeriod());
CCAction *actionMove3 = CCCallFuncN::create(this, callfuncN_selector(GameObject::updateCircle));
問題は、ゲーム オブジェクトが円を描くように移動することですが、約 1000 回の反復の後、消えて数秒後に再び表示されます。何が起こっているのかわかりません-ポイントは正しく計算されています(私は思う)
moveto の実行に時間がかかるのではないでしょうか? 数学の常連客を計算して、それに続いてスプライトを移動するにはどうすればよいですか?