이미지를 이용한 메뉴 버튼 생성하기
c++)
Resources 폴더에 이미지파일 추가
메뉴아이템 생성 -> 메뉴에 추가 -> 화면레이어에 추가
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 48 49 50 51 | #include "test91.hpp" USING_NS_CC; Scene* Test91::createScene() { auto scene = Scene::create(); auto layer = Test91::create(); scene->addChild(layer); return scene; } bool Test91::init() { if ( !Layer::init()) { return false; } //메뉴1 //MenuItemImage::create(일반 이미지, 클릭시 이미지, 클릭시 콜백함수) auto item1 = MenuItemImage::create("btn-play-normal.png", "btn-play-selected.png", CC_CALLBACK_1(Test91::menuCallback, this)); //메뉴2 auto item2 = MenuItemImage::create("btn-highscores-normal.png", "btn-highscores-selected.png", CC_CALLBACK_1(Test91::menuCallback, this)); //메뉴3 auto item3 = MenuItemImage::create("btn-about-normal.png", "btn-about-selected.png", CC_CALLBACK_1(Test91::menuCallback, this)); //메뉴아이템 추가 auto menu = Menu::create(item1, item2, item3, NULL); menu -> alignItemsVertically(); //화면레이어에 메뉴 추가 this->addChild(menu); return true; } //콜백함수 void Test91::menuCallback(Ref* sender){ CCLOG("menu callback"); } | cs |
결과
'IT > - 프로그래밍' 카테고리의 다른 글
Cocos Label을 이용한 메뉴 생성하기 (0) | 2017.01.31 |
---|---|
Cocos 폰트를 이용한 메뉴 생성하기 (0) | 2017.01.26 |
코코스 CharMap 폰트 사용하기 (0) | 2017.01.23 |
코코스 BMFont 사용하기 (0) | 2017.01.20 |
코코스 외부 TTF Fonts 사용하기 (0) | 2017.01.19 |