版本: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 ..我應該與你分享我的代碼....所以你可以有更好的概述 –