Problem occurs when using CCRepeatForever with CCJumpTo

Hello. I’m a newbie and now studying on how Action works. I just got stuck on a problem relating to CCJumpTo, CCJumpBy and CCRepeatForever.

I want my seeker to keep jumping again and again. First, I started by using CCJumpBy, and it worked fine.

CCJumpBy* jump;
jump = CCJumpBy::create(3, ccp(0, 0), 100, 1);
CCRepeatForever* repeatJump = CCRepeatForever::create(jump);

seeker~~>runAction;

However, when I changed the code to CCJumpTo, it didn’t work as expected. The jump was done well for the first time, but after that it started jumping toward the right of the screen.
CCJumpTo* jump;
jump = CCJumpTo::create, 300, 1);
CCRepeatForever* repeatJump = CCRepeatForever::create;
seeker~~>runAction(repeatJump);

Could anyone help clarify this problem for me? Did I implement anything wrong? or is it a cocos2dx bug? (I’ve searched on the internet and found some topic regarding this issue, but those were posted a year ago. So i dunno whether the bug still exists, or it is just a coding error.)

Thank you.

That because you use seeker->getPosition(). You should use a fixed point for example ccp(100, 100), then it will only jump to x: 100 and y:100.

Terry Bleger wrote:

That because you use seeker->getPosition(). You should use a fixed point for example ccp(100, 100), then it will only jump to x: 100 and y:100.

I’ve tried it, but the problem is still there.

CCJumpBy will make the object jump BY X pixels to the left or right and Y pixels above or below.
CCJumpTo will make the object jump TO the indicated location.

So on this code:

CCJumpTo* jump;
    jump = CCJumpTo::create(3, seeker->getPosition(), 300, 1);
    CCRepeatForever* repeatJump = CCRepeatForever::create(jump);
seeker->runAction(repeatJump);

You’re telling the seeker to jump TO it’s position. Using something like:

CCJumpTo* jump;
    jump = CCJumpTo::create(3, CCPointMake( 100, 100 ), 300, 1);
    CCRepeatForever* repeatJump = CCRepeatForever::create(jump);
seeker->runAction(repeatJump);

will tell the seeker to jump TO (100, 100)

I’m getting the same problem, the first loop through is fine. Then it starts to drop off the screen!

    CCJumpTo *jump0 = CCJumpTo::create(4,ccp(VisibleRect::right().x,VisibleRect::bottom().y + 65),120, 4);
    CCJumpTo *jump1 = CCJumpTo::create(4,ccp(VisibleRect::left().x,VisibleRect::bottom().y + 65),120, 4);

    CCSequence *sequence = CCSequence::create(jump0, jump1, NULL);
    inGameObj->runAction(CCRepeat::create(sequence,100));