Cocos2dx/method
提供: 初心者エンジニアの簡易メモ
サンプルコード(staticメソッド)
HelloWorld::custom1()のstaticメソッドを追加する場合
-Classes/HelloWorldScene.h
class HelloWorld : public cocos2d::Layer
{
public:
static cocos2d::Scene* createScene();
virtual bool init();
const char* custom1();
CREATE_FUNC(HelloWorld);
};
-Classes/HelloWorldScene.cpp
const char* HelloWorld::custom1()
{
const char *hoge = "custom1";
return hoge;
}
カスタム関数呼び出し(適当な場所で) -Classes/HelloWorldScene.cpp
const char *b = HelloWorld::custom1();
log("%s", b);
