2

I am new to cocos2d-android. I want to add CCJumpTo using touch event in my code. But I don't know how to fix it. plz help.

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
Zahidul
  • 389
  • 5
  • 15

1 Answers1

3

override ccTouchesEnded in your CCLayer and create a point where you want the jump to go to like this

    public boolean ccTouchesEnded(MotionEvent event) {

        CGPoint touch = CCDirector.sharedDirector().convertToGL(
                CGPoint.ccp(event.getX(), event.getY()));
        CGSize winSize = CCDirector.sharedDirector().displaySize();


        aHero.runAction(CCJumpTo.action(2f, touch , 100, 1));

        return true;
    }

where aHero is the sprite you want to jump, it'll make the sprite jump [once] to the touched area and reach there in 2s with a jump height of 100

Jimmar
  • 4,194
  • 2
  • 28
  • 43