文章出處

像素點跟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;
}


文章列表


不含病毒。www.avast.com
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 大師兄 的頭像
    大師兄

    IT工程師數位筆記本

    大師兄 發表在 痞客邦 留言(0) 人氣()