Problem with cocos2D for iPhone and touch detection

后端 未结 7 1010
后悔当初
后悔当初 2021-02-01 09:03

I just don\'t get it. I use cocos2d for development of a small game on the iPhone/Pod. The framework is just great, but I fail at touch detection. I read that you just need to o

7条回答
  •  闹比i
    闹比i (楼主)
    2021-02-01 09:50

    - (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
    {
    
            //Add a new body/atlas sprite at the touched location
            CGPoint tapPosition;
            for( UITouch *touch in touches ) {
                CGPoint location = [touch locationInView: [touch view]];
    
                tapPosition = [self convertToNodeSpace:[[CCDirector sharedDirector] convertToGL:location]];     // get the tapped position
    
    
    
    
    
        }
    }
    

    think this can help you....

提交回复
热议问题