IT/- 프로그래밍
Cocos 보이게, 보이지 않게하는 액션기능 (Show, Hide)
혁준7519
2017. 2. 12. 16:17
보이게, 보이지 않게하는 액션기능 (Show, Hide)
c++)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | #include "test120.hpp" USING_NS_CC; Scene* Test120::createScene() { auto scene = Scene::create(); auto layer = Test120::create(); scene->addChild(layer); return scene; } bool Test120::init() { if ( !Layer::init()) { return false; } auto spriteShow = Sprite::create("testimage.png"); spriteShow->setPosition(Point(100,100)); spriteShow->setVisible(true); //보이게 설정 auto spriteHide = Sprite::create("testimage2.png"); spriteHide->setPosition(Point(200,200)); spriteHide->setVisible(false); //보이지 않게 설정 this->addChild(spriteShow); this->addChild(spriteHide); //Show::create() : 보이게 설정 auto actionHide = Hide::create(); spriteShow->runAction(actionHide); //보이다 -> 보이지 않게 설정 //Hide::create() : 보이지 않게 설정 auto actionShow = Show::create(); spriteHide->runAction(actionShow); //안보이다 -> 보이게 설정 return true; } | cs |
결과
testimage1은 보이지 않고 testimage2는 보인다