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 | #include "HelloWorldScene.h" Scene* HelloWorld::createScene() { auto scene = Scene::create(); auto layer = HelloWorld::create(); scene->addChild(layer); return scene; } bool HelloWorld::init() { if (!Layer::init()) { return false; } auto spr_1_n = Sprite::create("btn-play-normal.png"); auto spr_1_s = Sprite::create("btn-play-selected.png"); auto spr_2_n = Sprite::create("btn-highscores-normal.png"); auto spr_2_s = Sprite::create("btn-highscores-selected.png"); auto spr_3_n = Sprite::create("btn-about-normal.png"); auto spr_3_s = Sprite::create("btn-about-selected.png"); spr_3_n->setScaleY(0.5); // spr_3_n의 스케일을 0.5로 수정하여 축소된 이미지가 출력됨 auto item_1 = MenuItemSprite::create(spr_1_n, spr_1_s, CC_CALLBACK_1(HelloWorld::menuCallback, this)); auto item_2 = MenuItemSprite::create(spr_2_n, spr_2_s, CC_CALLBACK_1(HelloWorld::menuCallback, this)); auto item_3 = MenuItemSprite::create(spr_3_n, spr_3_s, CC_CALLBACK_1(HelloWorld::menuCallback, this)); auto menu = Menu::create(item_1, item_2, item_3, NULL); menu->alignItemsVertically(); this->addChild(menu); return true; } void HelloWorld::menuCallback(Ref *sender) { CCLOG("menuCallback"); } | cs |
실행 결과