Hi,
I just download V3.16 and create a new project for test.
cocos new -l cpp
I found some strange situation
- After project create, I just compile and run, then it shows correct screen.
- I modify HelloWorldScene.cpp
...
Scene* HelloWorld::createScene()
{
auto scene = HelloWorld::createWithPhysics();
scene->getPhysicsWorld()->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL);
return scene;
}
...
it shows blank screen.
3. Then I try to inherit from Layer, not like new template inherit from Scene.
It will show correct screen too.
HelloWorldScene.cpp
...
Scene* HelloWorld::createScene()
{
auto scene = Scene::createWithPhysics();
auto layer = HelloWorld::create();
scene->addChild(layer);
return scene;
}
// Print useful error message instead of segfaulting when files are not there.
static void problemLoading(const char* filename)
{
printf("Error while loading: %s\n", filename);
printf("Depending on how you compiled you might have to add 'Resources/' in front of filenames in HelloWorldScene.cpp\n");
}
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !Layer::init() )
{
return false;
}
...
HelloWorldScene.h
...
class HelloWorld : public cocos2d::Layer
{
public:
static cocos2d::Scene* createScene();
virtual bool init();
...
So, is there anything I miss to create a scene with Physics?
thank you.