moving sprite

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
pimple*>LastTouchPosition.y;
this below code is in loop:

cocos2d::CCSprite **target =**it;
cocos2d::CCPoint pp = target~~>getPosition;
target~~>setPosition(ccp(pp.x+diffX,pp.y+diffY));

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));
spriteObj~~>runAction;
or if you just wish to place the object there without motion.
just set the position to the touch position.
spriteObj~~>setPosition(ccp(touchPoint.x,touchPoint.y));

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