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.
Asked
Active
Viewed 650 times
2
-
see this http://developer.android.com/reference/android/view/View.OnTouchListener.html – NagarjunaReddy Feb 03 '12 at 05:08
-
thanks but I need to use CCjumpTo in Cocos2d-android. – Zahidul Feb 03 '12 at 06:24
1 Answers
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