Hello all,
I'm trying to drag a sprite (that's the child of a 'canvas' sprite) around, however it won't move :(
I have the following code:
-(void)ccTouchMoved:(UITouch *)touch withEvent:(UIEvent *)event
{
CGPoint touchLocation = [self convertTouchToNodeSpace:touch];
if(CGRectContainsPoint ([activePart boundingBox], touchLocation))
{
CGPoint oldTouchLocation = [touch previousLocationInView:touch.view];
oldTouchLocation = [[CCDirector sharedDirector] convertToGL:oldTouchLocation];
oldTouchLocation = [self convertToNodeSpace:oldTouchLocation];
CGPoint translation = ccpSub(touchLocation, oldTouchLocation);
CGPoint newPos = ccpAdd(activePart.position, translation);
activePart.position = newPos;
NSLog(@"Reached function");
}
}
... but I haven't added the code to stop it from leaving the boundingBox of the canvas, because I don't know how to do that :( Can I have some help please?? :)
Thanks :)