使用Cocos2d和Box2d渲染纹理

时间:2011-07-02 11:06:12

标签: iphone cocos2d-iphone box2d

我有一个Cocos2d和Box2D应用程序。我有一个图像bubble.png。我想在用户滑动屏幕时绘制一串气泡。

谁能告诉我怎么做?

由于

2 个答案:

答案 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]; (也许这需要刷卡)