From b36a4cf35f76d151c1472017ba9fd96c580b75ab Mon Sep 17 00:00:00 2001 From: zhangbin Date: Wed, 9 Nov 2016 15:07:22 +0800 Subject: [PATCH] Solve the error calculation of the image object's position. --- native/cocos/2d/CCTMXObjectGroup.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/native/cocos/2d/CCTMXObjectGroup.cpp b/native/cocos/2d/CCTMXObjectGroup.cpp index 9cfe0e6cf3..e6b3b92fbd 100644 --- a/native/cocos/2d/CCTMXObjectGroup.cpp +++ b/native/cocos/2d/CCTMXObjectGroup.cpp @@ -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));