I’m trying to make a game with large isometric map and user should zoom and scrool that map, and also he should be able to place new sprites by touch. For that, I need to get tile coordinates from touch location. I tried to make it with this function:
And it is working fine until I include and start using CCLayerPanZoom extension (for zooming and scrolling). Then it shows weird coordinates. Can you please suggest me how to make large isometric map with scrolling and zoom avaliable, and also the way how I could place a new sprite with tapping map.
I left that method out because I thought it would be confusing the topic at hand. It doesn’t really matter which way you calculate it. My way might be bad, but here goes:
//
// this method gets a tileCoord from a ccp
//
CCPoint STERegionMap::tileCoordForPosition(cocos2d::CCPoint position)
{
int x = position.x / _tileMap->getTileSize().width;
int y = ((_tileMap->getMapSize().height * _tileMap->getTileSize().height) - position.y) / _tileMap->getTileSize().height;
//CCLog("tileCoordForPosition [X: %d, Y: %d]", x, y);
return ccp(x, y);
}
Also, I was not dealing with Zoom, only Pan. Should be a place to start tho.