Reputation: 399
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.
Upvotes: 2
Views: 656
Reputation: 4449
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
Upvotes: 3