auto sprite = Sprite::create("HelloWorld.png");
sprite->setAnchorPoint(Vec2(1,0));
sprite->setPosition(Vec2(visibleSize.width / 2 + origin.x, visibleSize.height / 2 + origin.y));
this->addChild(sprite, 4);
sprite->setRotation(45); //앵커포인트기준 45도 회전
sprite->setFlippedX(true); //x축반전
sprite->setOpacity(100); //알파블랜드
sprite->setVisible(false); //보여지지 않음
auto는 파이썬과 비슷하게 따로 변수타입을 지정하지 않아도 대입해주는 변수타입에 맞게 설정해준다
Sprite는 Api에서의 image와 비슷하다고 생각하면된다
setAngchorPoint 는 2점의 좌표를받는다 (0~1 좌측~우측 or 상단~하단)
받은 좌표를 기준으로 이미지가 뿌려지며 이는 회전할때 중심축이 된다.
setPosition은 실제 보여질 좌표인데 window프로그래밍과 다르게 우측하단이 0,0 기준이다
addChild를 해야만 보이는데 2번째 인자의 숫자는 Z-order의 정렬기준이된다.
'[과거 기록] 개발자 준비 여정 > cocos2d' 카테고리의 다른 글
cocos2d 씬전환 (0) | 2019.11.26 |
---|---|
cocos2d action (0) | 2019.11.21 |
cocos2d설치 (0) | 2019.11.18 |
댓글