我有一个Cocos2d和Box2D应用程序。我有一个图像bubble.png。我想在用户滑动屏幕时绘制一串气泡。
谁能告诉我怎么做?
由于
答案 0 :(得分: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];
}
}
答案 1 :(得分:0)
你需要注册touchdispatcher我认为......([layer registerWithTouchDispatcher])
[glView setMultipleTouchEnabled:YES]; (也许这需要刷卡)