![cocos2dx tiledmap 45度地图 世界坐标转换 格子坐标,第1张 cocos2dx tiledmap 45度地图 世界坐标转换 格子坐标,第1张](/aiimages/cocos2dx+tiledmap+45%E5%BA%A6%E5%9C%B0%E5%9B%BE+%E4%B8%96%E7%95%8C%E5%9D%90%E6%A0%87%E8%BD%AC%E6%8D%A2+%E6%A0%BC%E5%AD%90%E5%9D%90%E6%A0%87.png)
概述Size mapSize = m_map->getMapSize(); Size tileSize = m_map->getTileSize(); Vec2 pos = position; float halfMapWidth = mapSize.width * 0.5f; float mapHeight = mapSize.height; float tileWidth = tileSize.w Size mapSize = m_map->getMapSize(); Size tileSize = m_map->getTileSize(); Vec2 pos = position; float halfMapWIDth = mapSize.wIDth * 0.5f; float mapHeight = mapSize.height; float tileWIDth = tileSize.wIDth; float tileHeight = tileSize.height; Vec2 tilePosdiv = CCPointMake(pos.x / tileWIDth,pos.y / tileHeight); float inverseTileY = mapHeight - tilePosdiv.y; // Cast to int makes sure that result is in whole numbers,tile coordinates will be used as array indices float posX = (int)(inverseTileY + tilePosdiv.x - halfMapWIDth); float posY = (int)(inverseTileY - tilePosdiv.x + halfMapWIDth); // make sure coordinates are within isomap bounds posX = MAX(0,posX); posX = MIN(mapSize.wIDth - 1,posX); posY = MAX(0,posY); posY = MIN(mapSize.height - 1,posY); pos = CCPointMake(posX,posY); 总结
以上是内存溢出为你收集整理的cocos2dx tiledmap 45度地图 世界坐标转换 格子坐标全部内容,希望文章能够帮你解决cocos2dx tiledmap 45度地图 世界坐标转换 格子坐标所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
评论列表(0条)