From 5d5b962f381cc20dd9b9065c255590acaa2f024d Mon Sep 17 00:00:00 2001 From: Rene Klacan Date: Thu, 4 Jul 2013 13:28:54 +0200 Subject: [PATCH] removed extra _currentTileIndex --- cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp | 14 ++++++++++---- cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.h | 1 - 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp b/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp index fd717c6b32..cb762ccdd1 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp @@ -72,7 +72,6 @@ TMXLayerInfo::TMXLayerInfo() , _minGID(100000) , _maxGID(0) , _offset(PointZero) -, _currentTileIndex(0) { _properties= new Dictionary();; } @@ -408,9 +407,16 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) if (pTMXMapInfo->getParentElement() == TMXPropertyLayer) { TMXLayerInfo* layer = (TMXLayerInfo*)pTMXMapInfo->getLayers()->lastObject(); + Size layerSize = layer->_layerSize; unsigned int gid = (unsigned int)atoi(valueForKey("gid", attributeDict)); - layer->_tiles[layer->_currentTileIndex] = gid; - layer->_currentTileIndex++; + int tilesAmount = layerSize.width*layerSize.height; + int currentTileIndex = layer->_tiles[tilesAmount - 1]; + layer->_tiles[currentTileIndex] = gid; + + if (currentTileIndex != tilesAmount - 1) + { + layer->_tiles[tilesAmount - 1] = currentTileIndex + 1; + } } else { @@ -503,7 +509,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) int *tiles = (int *) malloc(tilesAmount*sizeof(int)); for (int i = 0; i < tilesAmount; i++) - tiles[i] = -1; + tiles[i] = 0; layer->_tiles = (unsigned int*) tiles; } diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.h b/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.h index ea459d6084..ea5e73c3da 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.h +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.h @@ -99,7 +99,6 @@ public: unsigned int _minGID; unsigned int _maxGID; Point _offset; - unsigned int _currentTileIndex; public: TMXLayerInfo(); virtual ~TMXLayerInfo();