触及科科斯的解释

时间:2009-11-23 03:20:47

标签: objective-c

我是客观C和iPhone游戏开发的新手。我在理解在cocos中实现触摸的代码时遇到了一些困难。请问有人给我一些解释吗?

-(BOOL)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)events
{

    UITouch *touch = [touches anyObject];
    CGPoint location = [touch locationInView: [touch view]];
    CGPoint convertedLocation = [[Director sharedDirector] convertCoordinate:location];
    lady.position = convertedLocation;

    return kEventHandled;
}

请解释这些代码。我想知道它是如何一行一行的。 提前致谢

1 个答案:

答案 0 :(得分:0)

UITouch ref http://developer.apple.com/iphone/library/documentation/UIKit/Reference/...

Example code使用UITouch

您可以google获取更多

它看起来像标准UITouch处理代码。

  • 即使是在偶数
  • 中发送的一组触摸也能获得任何触摸
  • 在给定视图中获取位置 - 例如视图坐标中的位置从此特定视图角落的0,0开始
  • 然后转换为'Director'坐标,这是一个共享对象......(不知道是什么对象,但你知道他们在做什么)
  • 将某些内容(lady)的位置设置为触摸事件的位置