I'm developing a game for iPhone using COCOS2D.
In that, I need to draw a line when user drag his finger from a point to another. As far as my knowledge is concern I need to do this in Touches Moved method
from where I can get the points.
But I don't know how to do this. Can anybody help me on this?
- (void)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *theTouch = [touches anyObject];
CGPoint touchLocation = [theTouch locationInView:[theTouch view] ];
cgfloat x = touchLocation.x;
cgfloat y= touchLocation.y;
printf("move x=%f,y=%f",x,y);
}
Try the above code. It will get the coordinate points when touches moved
in iphone.
To draw line, use something like this:
-void draw
{
here is the code for line draw.
}
Update this function in update method.