cocos2d에서 멀티 터치를 사용하고 싶습니다. 어떻게해야합니까? 아래의 코드와 같은 각 터치 이벤트를 테스트하고 싶습니다. 도와주세요.멀티 터치 사용 방법 cocos2d
-(void) ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *myTouch = [touches anyObject];
CGPoint location = [myTouch locationInView:[myTouch view]];
location = [[CCDirector sharedDirector] convertToGL:location];
b2Vec2 locationWorld = b2Vec2(location.x/PTM_RATIO, location.y/PTM_RATIO);
CGSize screenSize = [CCDirector sharedDirector].winSize;
if (locationWorld.x >= screenSize.width*2/5/PTM_RATIO && locationWorld.x <= screenSize.width*3.25/5/PTM_RATIO) {
cannonballTouch1 = 1;
float force = 6;
b2Vec2 direction = cannonballBody->GetWorldCenter() - cannonBody->GetWorldCenter();
b2Vec2 iforce = b2Vec2(1.0f/direction.x * force, 1.0f/direction.y * force);
NSLog(@"%.2f", direction.y);
NSLog(@"%.2f", iforce.y);
b2Vec2 force1 = b2Vec2(0, iforce.y);
cannonballBody->ApplyLinearImpulse(force1, cannonballBody->GetPosition());
}
if (locationWorld.x > screenSize.width*3.25/5/PTM_RATIO) {
cannonballTouch2 = 1;
float force = 6;
b2Vec2 direction = cannonballBody2->GetWorldCenter() - cannonBody2->GetWorldCenter();
b2Vec2 iforce = b2Vec2(1.0f/direction.x * force, 1.0f/direction.y * force);
NSLog(@"%.2f", direction.y);
NSLog(@"%.2f", iforce.y);
b2Vec2 force1 = b2Vec2(0, iforce.y);
cannonballBody2->ApplyLinearImpulse(force1, cannonballBody2->GetPosition());
}
}