Game Development Reference
In-Depth Information
Time for action - creating the
implementation
The implementation is a text file with the .cpp extension:
1. Create a new text file and save it as HelloWorld.cpp . At the top, let's start by
including our header file:
#include "HelloWorld.h"
2. Next, we implement our constructor and destructor:
HelloWorld::HelloWorld () {
//constructor
}
HelloWorld::~HelloWorld () {
//destructor
}
3. Then comes our static method:
Scene* HelloWorld::scene() {
auto scene = Scene::create();
auto layer = HelloWorld::create();
scene->addChild(layer);
return scene;
}
4. And then come our two remaining public methods:
bool HelloWorld::init() {
// call to super
if ( !Layer:: init() )
{
return false;
Search WWH ::




Custom Search