2009-11-23 67 views
0

我是新來的客觀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; 
} 

請解釋一下這些代碼。我想知道它是如何工作的一行一行。 在此先感謝

回答

0

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

Example code使用UITouch

你或許可以google更多

它看起來像標準UITouch處理代碼。

  • 甚至從集合在偶數
  • 發送觸摸得到任何觸摸在給定的視圖獲得的位置 - 例如視圖座標從0,0開始在這個特定視圖的角落
  • 然後轉換爲'導演'座標這是一個共享對象...(不知道什麼對象,但你知道他們在做什麼)
  • 將東西的位置(lady)設置爲觸摸事件的位置