Enabling debug draw on CCPhysicsNode causes crash

Viewed 160

Versions: Cocos2D V3.4, Xcode 7.2.1, SpriteBuilder 1.4.9.

You can download my project here. It was created with SpriteBuilder.

Enabling debug draw on CCPhysicsNode causes a crash:

CCPhysicsNode *_physicsWorld;


_physicsWorld = [CCPhysicsNode node];
_physicsWorld.gravity = ccp(0,0);
_physicsWorld.debugDraw = YES;//if debugDraw set to NO, crash will not occur, it happens only when its set to YES
_physicsWorld.collisionDelegate = self;
[_scene addChild:_physicsWorld];

Error:

Assertion failure in -[CCRenderStateGL initWithBlendMode:shader:shaderUniforms:copyUniforms:]

My code to add physics body to the CCSprite:

  _PlayerSprite.physicsBody = [CCPhysicsBody bodyWithRect:(CGRect){CGPointZero, _PlayerSprite.contentSize} cornerRadius:0]; // 1 

  _PlayerSprite.physicsBody.collisionGroup = @"playerGroup"; // 2

  [_PhysicsWorld addChild:lobjPlayerSprite
                        z:Z_ORDER_PLAYERS];

Then code crashes at CCRendererBasicTypes initWithBlendMode:

-(instancetype)initWithBlendMode:(CCBlendMode *)blendMode shader:(CCShader *)shader shaderUniforms:(NSDictionary *)shaderUniforms copyUniforms:(BOOL)copyUniforms

crashes here:-
NSAssert(shader, @"CCRenderState: Shader is nil");
1 Answers
Related