3

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");
Dion Larson
  • 868
  • 8
  • 14
  • 1
    please explain the reason why its happening – Udit Ajmera Mar 15 '16 at 07:13
  • edit the title of your question. It really freaks me out. – surajs1n Mar 15 '16 at 07:18
  • that means its working for u..shall i share my code with u....so u can have better overview – Udit Ajmera Mar 15 '16 at 07:41
  • Ok. do share but only the relevant part of code which you think is having error. – surajs1n Mar 15 '16 at 07:43
  • here is the link of the project :- https://github.com/ud230688/SpaceShooter.spritebuilder here are the relevant function name which code concerns :- [VisualWorld addPlayer] and [GamePlayScene initWithVisualWorld:(VisualWorld*)lobjVW resources:(NSArray*)larrayResources].....Please check and lemme know if you have any problem or query regarding code in project. @psyco – Udit Ajmera Mar 15 '16 at 08:29
  • hi, hope u able to download and check the code...- @psyco – Udit Ajmera Mar 15 '16 at 09:56

1 Answers1

1

Your project was created with SpriteBuilder which has not been updated since April 2015. The version of Cocos2D that SpriteBuilder ships with was released before Xcode 7 and does not include a few necessary fixes for Xcode 7 and iOS 9. You can read more about this here.

To fix this, you need to manually update Cocos2D. Follow the steps on the previous link or use this as a reference (it's more visual).

Dion Larson
  • 868
  • 8
  • 14