In CocosBuilder, I have a custom class named TextInput
used for user input, then I want add a max_length
value to limit the length of user input.
It looks like below:
But when I run, I got the following error:
Cocos2d: Unexpected property: 'max_length'!
I tried to add int max_length;
into TextInput.h
. But nothing changed.
Here is my relative code.
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
So my question is what is the correct way to use 'Custom Properties' feature?