版本:Cocos2D V3.4,Xcode 7.2.1,SpriteBuilder 1.4.9。在CCPhysicsNode上启用调试绘制会导致崩溃
你可以下载我的项目here。它是用SpriteBuilder创建的。
启用上CCPhysicsNode调试平局导致系统崩溃:
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];
错误:
Assertion failure in -[CCRenderStateGL initWithBlendMode:shader:shaderUniforms:copyUniforms:]
我的代码,以物理身体添加到CCSprite:
_PlayerSprite.physicsBody = [CCPhysicsBody bodyWithRect:(CGRect){CGPointZero, _PlayerSprite.contentSize} cornerRadius:0]; // 1
_PlayerSprite.physicsBody.collisionGroup = @"playerGroup"; // 2
[_PhysicsWorld addChild:lobjPlayerSprite
z:Z_ORDER_PLAYERS];
然后代码崩溃在CCRendererBasicTypes initWithBlendMode
:
-(instancetype)initWithBlendMode:(CCBlendMode *)blendMode shader:(CCShader *)shader shaderUniforms:(NSDictionary *)shaderUniforms copyUniforms:(BOOL)copyUniforms
crashes here:-
NSAssert(shader, @"CCRenderState: Shader is nil");
请解释其发生的原因 –
编辑您的问题的标题。它真的让我感到困惑。 – surajsn
这意味着它的工作u ..我应该与你分享我的代码....所以你可以有更好的概述 –