Canvas turns blank when calling director.setDisplayStats(false); to hide FPS counter

178 Views Asked by At

I'm new to Cocos2d-HTML5, but think I'm getting the basics well enough. However, while following this tutorial, I'm hitting a weird snag. Since I'm using Cocos2d-HTML5 v2.2.1, I updated the cocos2dApp class declaration as described in the comment section, and everything works fine.

But when I try to remove the FPS counter by using director.setDisplayStats(false), or just commenting out the director.setDisplayStats(true) line, the canvas goes totally black. The code is still running; console.log() statements added to the sprite objects are still getting called every frame. Also strange: adding a call to director.setDisplayStats(false) during a frame update does not result in a blank canvas.

So my question is, by leaving out setDisplayStats or setting it to false, am I somehow messing up the scene's layers or something? I've tried tracing my way through how the code is executed after that statement, and haven't found anything obvious yet.

1

There are 1 best solutions below

1
On

I change (in ccConfig.h)

#define CC_ENABLE_GL_STATE_CACHE 1

to

#define CC_ENABLE_GL_STATE_CACHE 0

It helps me to avoid the crash.