Hello World 및 이미지 추가하기
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 48 49 50 51 52 53 54 55 56 | #include "HelloWorldScene.h" #include "SimpleAudioEngine.h" USING_NS_CC; 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 visibleSize = Director::getInstance()->getVisibleSize(); Vec2 origin = Director::getInstance()->getVisibleOrigin(); /** Hello World 출력하기 */ //Hello World 라벨객체 auto label = Label::createWithTTF("Hello World", "fonts/Marker Felt.ttf", 24); //위치지정 label->setPosition(Vec2(origin.x + visibleSize.width/2, origin.y + visibleSize.height - label->getContentSize().height)); //레이어에 추가 this->addChild(label, 1); /** Image 추가하기 */ //create("추가할 이미지 파일명") auto spr = Sprite::create("testimage.png"); //메모리 관리 Cocos에서 직접관리 //Anchor Point 지정 spr -> setAnchorPoint(Point(0.5,0.5)); //이미지 위치 지정 (Anchor Point의 위치) spr -> setPosition(Point(100,100)); //레이어에 추가 this -> addChild(spr); //이미지의 가운데 위치가 100,100으로 지정 return true; } | cs |
결과
'IT > - 프로그래밍' 카테고리의 다른 글
안드로이드 Error:java.lang.OutOfMemoryError: GC overhead limit exceeded 에러 (0) | 2017.01.09 |
---|---|
코코스 전체 이미지중 일부 이미지만 보여주기 및 레이어 이동하기 (0) | 2017.01.06 |
코코스 Cocos 설치하기 (0) | 2017.01.04 |
자바 두 날짜사이의 차이 계산 (0) | 2017.01.03 |
자바 split() 함수를 사용하여 .(마침표) /(슬래시) \\(역슬래시) 로 구분하기 (0) | 2017.01.02 |