CocosBuilderには、ユーザー入力に使用されるという名前のカスタムクラスがあります。次に、ユーザー入力の長さを制限TextInput
する値を追加します。max_length
以下のようになります。
しかし、実行すると、次のエラーが発生しました。
Cocos2d: Unexpected property: 'max_length'!
に追加int max_length;
してみましたTextInput.h
。しかし、何も変わりませんでした。
これが私の相対的なコードです。
TextInput.h
#ifndef __CrossKaiser__TextInput__
#define __CrossKaiser__TextInput__
#include "cocos2d.h"
#include "cocos-ext.h"
using namespace cocos2d;
using namespace cocos2d::extension;
class TextInput : public CCTextFieldTTF
{
public:
CREATE_FUNC(TextInput);
TextInput();
virtual ~TextInput();
virtual bool init();
virtual void onEnter();
virtual void insertText(const char * text, int len);
virtual void deleteBackward();
int max_length;
};
#endif
TextInputLoader.h
#ifndef __CrossKaiser__TextInputLoader__
#define __CrossKaiser__TextInputLoader__
#include "TextInput.h"
/* Forward declaration. */
class CCBReader;
class TextInputLoader : public cocos2d::extension::CCLabelTTFLoader{
public:
CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(TextInputLoader, loader);
protected:
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(TextInput);
};
#endif
だから私の質問は、「カスタムプロパティ」機能を使用する正しい方法は何ですか?