bool HelloWorld::init(){
...
//맵 불러오기
CCTMXTiledMap* tmap = CCTMXTiledMap::create("TestDesert.tmx");
this->addChild(tmap, 0, 11); //이름, zorder, tag
...
}
//터치로 맵 움직이기
void HelloWorld::ccTouchMoved(CCTouch *pTouch, CCEvent* event)
{
CCPoint diff = pTouch->getDelta();
CCNode* node = this->getChildByTag(11);
CCPoint currentPos = node->getPosition();
CCPoint newPos = ccpAdd(currentPos, diff);
if (newPos.x < -160) {
newPos.x = -160;
}
if (newPos.x > 0) {
newPos.x = 0;
}
newPos.y = 0;
node->setPosition( newPos );
}
댓글 없음:
댓글 쓰기