moving sprite

moving sprite
0.0 0


hi dudes,

In my code sprite is moving, but when I click the mouse button then the cursor position goes to sprite origin.But that is not good. So I want to move the sprite where I click the mouse

from that position to sprite is move.

float diffX = location.x - pimple*>LastTouchPosition.x;
float diffY = location.y
this below code is in loop:

cocos2d::CCSprite **target =**it;
cocos2d::CCPoint pp = target~~>getPosition;

please help me,

I am the beginner on cocos2d-x and c++.


You don’t need to do all this.
You can either call
CCMoveTo to get the object to new position.

CCMoveTo *moveAction = CCMoveTo::actionWithDuration(0.2f,ccp(touchPoint.x,touchPoint.y));
or if you just wish to place the object there without motion.
just set the position to the touch position.

do check the co-ordinate system for the touch point.