Render texture using Cocos 2d and Box 2d
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)
精彩评论