FAQ Database Discussion Community

CCPhysicsBody Collision not working in cocos2d-swift v3.4

Here is code: @interface MainScene : CCNode<CCPhysicsCollisionDelegate> //.m -(void)onEnter { [super onEnter]; mPhysicsWorld = [CCPhysicsNode node]; mPhysicsWorld.gravity = ccp(0,0); mPhysicsWorld.debugDraw = YES; mPhysicsWorld.collisionDelegate = self; [self addChild:mPhysicsWorld]; //Body_A { CCSprite *sprite = [CCSprite spriteWithImageNamed:@"sprite_1.png"]; sprite.position = ccp(280, 220); sprite.rotation = 13; sprite.name = @"Body_A"; [email protected]"Group1"; [email protected]"typeA"; CGRect...

Create Dynamic Body using cocos 2d js and Chipmunk

I am fairly new to cocos 2d and chipmunk. So far i have managed to create a static object and add collision handler to it. But i want to create a dynamic.``this.space = space; this.sprite = new cc.PhysicsSprite("#rock.png"); var body = new cp.StaticBody(); body.setPos(pos); this.sprite.setBody(body); this.shape = new cp.BoxShape(body, this.sprite.getContentSize().width,...

Finding nearest points with Chipmunk and cocos2d

Using cocos2d and chipmunk, I try to get the different object around a sprite (for example a bomb) so that I can apply an impulse on these. I first added this on top of my project: #import "ObjectiveChipmunk/ObjectiveChipmunk.h" #import "CCPhysics+ObjectiveChipmunk.h" And then the code: ChipmunkSpace *space = [_physicsNode space]; cpVect...