CCPoint HelloWorld::positionToTileCoord(CCPoint pos) { int x = pos.x / map->getTileSize().width; int y = ((map->getMapSize().height * map->getTileSize().height) - pos.y) / map->getTileSize().height; return ccp(x,y); } CCPoint HelloWorld::tilecoordToPosition(CCPoint tileCoord) { int x=tileCoord.x * map->getTileSize().width + map->getTileSize().width/2; int y=map->getMapSize().height * map->getTileSize().height - tileCoord.y * map->getTileSize().height - map->getTileSize().height/2; return ccp(x, y); }
已验证
时间: 2024-10-29 19:13:28