博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
tilemap坐标转换
阅读量:4567 次
发布时间:2019-06-08

本文共 568 字,大约阅读时间需要 1 分钟。

像素点跟tile的索引之间的转换

//从cocos2d-x坐标转换为Tilemap坐标
CCPoint GameMap::tileCoordForPosition(CCPoint position)
{
int x = position.x / this->getTileSize().width;
int y = (((this->getMapSize().height) * this->getTileSize().height) - position.y) / this->getTileSize().height;
return ccp(x, y);
}

//从Tilemap坐标转换为cocos2d-x坐标

CCPoint GameMap::positionForTileCoord(CCPoint tileCoord)
{
CCPoint pos = ccp((tileCoord.x * this->getTileSize().width),
((this->getMapSize().height - tileCoord.y) * this->getTileSize().height));
return pos;
}

转载于:https://www.cnblogs.com/rexzhao/p/3867811.html

你可能感兴趣的文章
Fuchsia OS入门官方文档
查看>>
[LeetCode] 1. Two Sum
查看>>
【转】直方图中bins的理解及处理
查看>>
bzoj2595 [Wc2008]游览计划
查看>>
noip2009 潜伏者
查看>>
HDU3986 SPFA
查看>>
Vue.js 响应式原理
查看>>
pwa
查看>>
GPU卡掉卡
查看>>
Javascript中的异步
查看>>
redis.config 配置文件,附上我知道的理解
查看>>
FISCO-BCOS平台共识
查看>>
Android OpenGL ES(三)----编程框架
查看>>
python基础-字符串操作
查看>>
Codevs No.1163 访问艺术馆
查看>>
缓存穿透,缓存击穿,缓存雪崩解决方案分析
查看>>
docker入门学习(二)mysql安装
查看>>
吴裕雄--天生自然 JAVASCRIPT开发学习:函数调用
查看>>
吴裕雄 PYTHON 神经网络——TENSORFLOW 无监督学习处理MNIST手写数字数据集
查看>>
吴裕雄--天生自然 JAVASCRIPT开发学习:函数
查看>>