-
-
Save tks2shimizu/f400cb5266f341ba2153 to your computer and use it in GitHub Desktop.
カラーピッカー
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "HelloWorldScene.h" | |
USING_NS_CC; | |
USING_NS_CC_EXT; | |
CCScene* HelloWorld::scene() | |
{ | |
CCScene *scene = CCScene::create(); | |
HelloWorld *layer = HelloWorld::create(); | |
scene->addChild(layer); | |
return scene; | |
} | |
bool HelloWorld::init() | |
{ | |
if ( !CCLayer::init() ) | |
{ | |
return false; | |
} | |
CCSize winSize = CCDirector::sharedDirector()->getWinSize(); | |
CCControlColourPicker* color = CCControlColourPicker::create(); | |
color->setPosition(ccp(winSize.width / 2, winSize.height / 2)); | |
color->setColor(ccc3(37, 46, 252)); | |
color->addTargetWithActionForControlEvents(this, | |
cccontrol_selector(HelloWorld::valueChanged), | |
CCControlEventValueChanged); | |
this->addChild(color); | |
return true; | |
} | |
void HelloWorld::valueChanged(CCNode *pSender, CCControlEvent pControlEvent) | |
{ | |
CCControlColourPicker* pPicker = (CCControlColourPicker*)pSender; | |
CCLog("valueChanged value: #%02X%02X%02X", pPicker->getColor().r, pPicker->getColor().g, pPicker->getColor().b); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef __HELLOWORLD_SCENE_H__ | |
#define __HELLOWORLD_SCENE_H__ | |
#include "cocos2d.h" | |
#include "CCControlExtensions.h" | |
class HelloWorld : public cocos2d::CCLayer | |
{ | |
public: | |
virtual bool init(); | |
static cocos2d::CCScene* scene(); | |
void valueChanged(CCNode *pSender, cocos2d::extension::CCControlEvent pControlEvent); | |
CREATE_FUNC(HelloWorld); | |
}; | |
#endif // __HELLOWORLD_SCENE_H__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment