Game Development Reference
In-Depth Information
Time for action - creating the interface
The interface, or header file, is just a text file with the .h extension.
1. Create a new text file and save it as HelloWorld.h . Then, enter the following
lines at the top:
#ifndef __HELLOWORLD_H__
#define __HELLOWORLD_H__
#include "cocos2d.h"
2. Next, add the namespace declaration:
using namespace cocos2d;
3. Then, declare your class name and the name of any inherited classes:
class HelloWorld : public cocos2d::Layer {
4. Next, we add the properties and methods:
protected:
int _score;
public:
HelloWorld();
virtual ~HelloWorld();
virtual bool init();
static cocos2d::Scene* scene();
CREATE_FUNC(HelloWorld);
void update(float dt);
inline int addTwoIntegers (int one, int two) {
return one + two;
}
};
5. We finish by closing the #ifndef statement:
#endif // __HELLOWORLD_H__
Search WWH ::




Custom Search