touches in cocos explanation
I am new to objective C and iPhone game development. I am having some difficulty in understanding the code of to implement touches in cocos. Could anyone give me some explanation please?
-(BOOL)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)events
{
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView: [touch view]];
CGPoint convertedLocation = [[Director sharedDirector] convertCoordinate:开发者_如何学Pythonlocation];
lady.position = convertedLocation;
return kEventHandled;
}
Please explain me these punch of code. I would like to know how it works one line by one line. Thanks in advance
UITouch ref http://developer.apple.com/iphone/library/documentation/UIKit/Reference/...
Example code that uses UITouch
You can probably google for more
It looks like standard UITouch
handling code.
- get any touch even from set of touches sent in the even
- get the location in given view - e.g. the location in view coordinates starting from 0,0 in the corner of this specific view
- then convert to 'Director' coordinates which is a shared object ... (no idea what object but you get the idea what they are doing)
- set position of something (
lady
) to the location of the touch event
精彩评论