Note that there are some explanatory texts on larger screens.

plurals
  1. POCocos2d-x drag finger and sprite follows at a steady pace
    primarykey
    data
    text
    <p>I am trying get an effect like a flight control game. the user drags their finger on the screen, it stores that data in an array, then the item follows that path to where the finger was lifted.</p> <p>I have the code for this working, my problem is that i want it to be at a steady pace like in the games, when my sprite moves it varies in speed by how fast you move your finger.</p> <p>any help would be appreciated.</p> <p>im fairly certain it has to do with my CCMoveTo action, but i cant really think of any other way to do this.</p> <pre><code>void WavePrototypeInterface::ccTouchesBegan(CCSet* touches, CCEvent* event) { while (movementPath-&gt;count() != 0) { movementPath-&gt;removeControlPointAtIndex(0); } index=0; this-&gt;stopAllActions(); } void WavePrototypeInterface::ccTouchesMoved(CCSet* touches, CCEvent* event) { CCTouch* touch = (CCTouch*)( touches-&gt;anyObject() ); CCPoint location = touch-&gt;getLocationInView(); location = CCDirector::sharedDirector()-&gt;convertToGL(location); movementPath-&gt;addControlPoint(location); int xValue = movementPath-&gt;count(); } void WavePrototypeInterface::ccTouchesEnded(CCSet* touches, cocos2d::CCEvent* event) { if(!movementPath-&gt;count()&lt;=0) { goToPointWithIndex(); } } void WavePrototypeInterface::goToPointWithIndex() { CCPoint toPoint = movementPath-&gt;getControlPointAtIndex(index); if(index &lt; movementPath-&gt;count()) { index++; sprite-&gt;setPosition(toPoint); CCDelayTime * delay = CCDelayTime::create(0.1); CCCallFunc *func = CCCallFunc::create(this, callfunc_selector(WavePrototypeInterface::goToPointWithIndex)); CCSequence * seq = CCSequence::createWithTwoActions(delay, func); this-&gt;runAction(seq); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload