Merge pull request #382 from natural-law/issue4644

Solve the error calculation of the image object's position.
This commit is contained in:
Wang Nan
2016-11-10 10:28:56 +08:00
committed by GitHub
+2 -1
View File
@@ -117,6 +117,7 @@ bool TMXObjectImage::_initWithMapInfo(TMXMapInfo* mapInfo)
{
return false;
}
useTileset->_imageSize = texture->getContentSizeInPixels();
auto rect = useTileset->getRectForGID(_container->getGid());
initWithTexture(texture, CC_RECT_PIXELS_TO_POINTS(rect));
setScale(_container->getObjectSize().width / rect.size.width, _container->getObjectSize().height / rect.size.height);
@@ -155,7 +156,7 @@ void TMXObjectImage::_initPosWithMapInfo(TMXMapInfo* mapInfo)
case TMXOrientationIso:
{
setAnchorPoint(Vec2(0.5, 0));
auto posIdx = Vec2(_container->getOffset().x / tileSize.width * 2, _container->getOffset().y / tileSize.height);
auto posIdx = Vec2(_container->getOffset().x / tileSize.height, _container->getOffset().y / tileSize.height);
auto pos = Vec2(tileSize.width / 2 * (mapSize.width + posIdx.x - posIdx.y),
tileSize.height / 2 * (mapSize.height * 2 - posIdx.x - posIdx.y));
setPosition(CC_POINT_PIXELS_TO_POINTS(pos));