9
안녕하십니까.수학 함수의 값을 사용하여 cocos2d-x에서 렌더링
나는 리눅스에있어, Android
에 cocos2d-x를 사용하고있다.
원 값을 계산하는 함수를 만들었습니다.
// 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);
Alternativally는, 나는 시도했다 :
// 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));
문제를 약 1,000 반복, 그것은 사라져, 이후 내 게임 객체 서클 이동하지만,이 나타나는 것입니다 다시 몇 초 후에 무슨 일이 일어나고 있는지 모르겠다. - 포인트가 올바르게 계산 된 것 같습니다. (제 생각 엔)
moveto가 더 많은 시간을 실행해야합니까? 수학 수호자가 그것을 따르는 스프라이트를 어떻게 계산할 수 있습니까?