2011-07-02 116 views

回答

1
- (void)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{ 
{ 
     //Add a new body/atlas sprite at the touched location 
     for(UITouch *touch in touches) { 

      CGPoint location = [touch locationInView: [touch view]]; 
      location = [[CCDirector sharedDirector] convertToGL: location]; 

      b2Vec2 locationWorld = b2Vec2(location.x/PTM_RATIO, location.y/PTM_RATIO); 

      CCSprite *mist=[CCSprite spriteWithFile:@"bubble.png"]; 
      mist.position=ccp(location.x,location.y); 

      [self addChild:mist]; 
     } 
} 
+0

什么所有类都需要导入。目前cocos2d.h是唯一导入的类。 –

+0

的#define PTM_RATIO 32 –

+0

#进口 “Box2D.h” #进口 “GLES-Render.h” –

0

您需要用touchdispatcher我想注册...([层registerWithTouchDispatcher])

[glView setMultipleTouchEnabled:YES]; (也许这是需要刷卡)