「Cocos2dx/EditBox」の版間の差分
提供: 初心者エンジニアの簡易メモ
行26: | 行26: | ||
cocos2d::ui::EditBox* _editPassword = ui::EditBox::create(editBoxSize, "extensions/orange_edit.png"); | cocos2d::ui::EditBox* _editPassword = ui::EditBox::create(editBoxSize, "extensions/orange_edit.png"); | ||
_editPassword->setPosition(Vec2(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/2)); | _editPassword->setPosition(Vec2(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/2)); | ||
− | _editPassword->setFont("American Typewriter", | + | _editPassword->setFont("American Typewriter", 10); |
_editPassword->setFontColor(Color3B::GREEN); | _editPassword->setFontColor(Color3B::GREEN); | ||
_editPassword->setPlaceHolder("Password:"); | _editPassword->setPlaceHolder("Password:"); |
2017年4月11日 (火) 16:38時点における版
EditBoxとは
入力欄のこと
サンプル
HelloworldScene.h
#include "ui/CocosGUI.h" class HelloWorld : public cocos2d::Layer, cocos2d::ui::EditBoxDelegate { public: static cocos2d::Scene* createScene(); virtual bool init(); CREATE_FUNC(HelloWorld); private: virtual void editBoxEditingDidBegin(cocos2d::ui::EditBox* editBox); virtual void editBoxEditingDidEnd(cocos2d::ui::EditBox* editBox); virtual void editBoxTextChanged(cocos2d::ui::EditBox* editBox, const std::string& text); virtual void editBoxReturn(cocos2d::ui::EditBox* editBox); };
HelloworldScene.cpp
USING_NS_CC; using namespace ui; // 略 bool HelloWorld::init() { // 略 cocos2d::ui::EditBox* _editPassword = ui::EditBox::create(editBoxSize, "extensions/orange_edit.png"); _editPassword->setPosition(Vec2(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/2)); _editPassword->setFont("American Typewriter", 10); _editPassword->setFontColor(Color3B::GREEN); _editPassword->setPlaceHolder("Password:"); _editPassword->setMaxLength(6); _editPassword->setInputFlag(ui::EditBox::InputFlag::PASSWORD); _editPassword->setInputMode(ui::EditBox::InputMode::SINGLE_LINE); _editPassword->setDelegate(this); addChild(_editPassword); return true; } void HelloWorld::editBoxEditingDidBegin(EditBox *editBox) { } void HelloWorld::editBoxEditingDidEnd(EditBox *editBox) { } void HelloWorld::editBoxTextChanged(EditBox *editBox, const std::string& text) { } void HelloWorld::editBoxReturn(EditBox *editBox) { }
Extensionは非推奨
cocos2d-x ui::EditBoxを使う