开发者

Render texture using Cocos 2d and Box 2d

开发者 https://www.devze.com 2023-03-16 17:55 出处:网络
I have a Cocos2d and Box2D app开发者_开发技巧lication. I have a image bubble.png. I want to draw a chain of bubbles when the user swipes the screen.

I have a Cocos2d and Box2D app开发者_开发技巧lication. I have a image bubble.png. I want to draw a chain of bubbles when the user swipes the screen.

Can anyone tell me how to do this ?

Thanks


- (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];
        }
}


You need to register with the touchdispatcher I think... ( [layer registerWithTouchDispatcher] )

[glView setMultipleTouchEnabled:YES]; (Maybe this is needed for swiping)

0

精彩评论

暂无评论...
验证码 换一张
取 消