1

I am trying to make a jump a sprite using ccTouchesBegan and move using ccTouchesMoved . It jumps when I use Touchesbegan But when I try to move the sprite using TouchesMoved it moves but also jumps. How to fix the problem? plz help.

Zahidul
  • 389
  • 5
  • 15
  • If you could show your methods, that would make it much easier to answer this question. – Job Feb 03 '12 at 13:49
  • @Override public boolean ccTouchesBegan(MotionEvent e) { CGSize winSize = CCDirector.sharedDirector().displaySize(); //CGPoint p = CCDirector.sharedDirector().convertToGL(CGPoint.ccp(e.getX(), e.getY())); hero.runAction(CCJumpTo.action(.2f, hero.getPosition(), 50, 1)); return CCTouchDispatcher.kEventHandled; } – Zahidul Feb 04 '12 at 04:14
  • @Override public boolean ccTouchesMoved(MotionEvent e){ CGSize winSize = CCDirector.sharedDirector().displaySize(); CGPoint p = CCDirector.sharedDirector().convertToGL(CGPoint.ccp(e.getX(), e.getY())); hero.setPosition(CGPoint.ccp(p.x, p.y)); return CCTouchDispatcher.kEventHandled; } – Zahidul Feb 04 '12 at 04:24
  • Edit your question with some code please, i cannot help you with see it – vgonisanz Nov 09 '12 at 11:11

1 Answers1

0

I can give you an idea...not sure if it will work or not...:D

** if touch moved than do nothing in the touchEnd else Jump your sprite in touchEnd method.
** you can keep a boolean to keep track if touches moved or not.

xibic
  • 27
  • 10
  • but I want to make the sprite jumped using touchesBegan method and I tried to use boolean but it did not work – Zahidul Feb 04 '12 at 07:32
  • it will get complicated process for that i think, if you use touchesBegan. For boolean : BOOL moved = FALSE; when touchesMoved and you did some action in touchesMoved set it to TRUE and check if "moved" true or false in touchesEnd. if true then no action if false then jump. – xibic Feb 05 '12 at 12:53