mirror of https://github.com/axmolengine/axmol.git
Fixed #12918 : TMXXMLParser.cpp -- In the function getRectForGID have small errors
This commit is contained in:
parent
d6dc1e3e7a
commit
19c8f337da
|
@ -88,8 +88,13 @@ Rect TMXTilesetInfo::getRectForGID(uint32_t gid)
|
|||
rect.size = _tileSize;
|
||||
gid &= kTMXFlippedMask;
|
||||
gid = gid - _firstGid;
|
||||
int max_x = (int)((_imageSize.width - _margin*2 + _spacing) / (_tileSize.width + _spacing));
|
||||
// int max_y = (imageSize.height - margin*2 + spacing) / (tileSize.height + spacing);
|
||||
// max_x means the colum count in tile map
|
||||
// in the origin:
|
||||
// max_x = (int)((_imageSize.width - _margin*2 + _spacing) / (_tileSize.width + _spacing));
|
||||
// but in editor "Tield", _margin variable only effect the left side
|
||||
// for compatible with "Tield", change the max_x calculation
|
||||
int max_x = (int)((_imageSize.width - _margin + _spacing) / (_tileSize.width + _spacing));
|
||||
|
||||
rect.origin.x = (gid % max_x) * (_tileSize.width + _spacing) + _margin;
|
||||
rect.origin.y = (gid / max_x) * (_tileSize.height + _spacing) + _margin;
|
||||
return rect;
|
||||
|
|
Loading…
Reference in New Issue