2015년 1월 12일 월요일

cocos2d-x tiled를 이용한 타일게임 제작 -cocos2d-x 에 타일맵 블루베리 먹기

이번엔 저번 충돌방식과 같은 방법으로 블루베리를 먹어볼것이다.

방법은 저번과 동일하다.

 case cocos2d::EventKeyboard::KeyCode::KEY_E:{

  CCPoint playerPos = sprPlayer->getPosition();

  CCPoint tileCoord = this->tileCoordForPosition(playerPos);

  int tileGid = _meta->tileGIDAt(tileCoord);

  auto properties = _tileMap->propertiesForGID(tileGid);

  ValueMap map = properties.asValueMap();

  String propertyValue = map["Eat"].asString();
  if (propertyValue.compare("True") == 0) { 
   _meta->removeTileAt(tileCoord);
   _tree->removeTileAt(tileCoord);

  }
break;
}

키보드 E를 눌렀을경우 적용시킨다.

타일의 id를 알고 타일의 Eat 이 True 일경우 그 타일을 삭제 시킨다.

댓글 없음:

댓글 쓰기