From ee919b673f76c11d16808d573d6f5b49ea6ed58b Mon Sep 17 00:00:00 2001 From: boyu0 Date: Fri, 13 Jun 2014 11:07:21 +0800 Subject: [PATCH] issue #4437: config for android and linux. --- cocos/2d/CCTMXLayer2.cpp | 45 +++++++++++++++++----------------- cocos/2d/CMakeLists.txt | 2 ++ cocos/Android.mk | 2 ++ tests/cpp-tests/Android.mk | 1 + tests/cpp-tests/CMakeLists.txt | 1 + 5 files changed, 28 insertions(+), 23 deletions(-) diff --git a/cocos/2d/CCTMXLayer2.cpp b/cocos/2d/CCTMXLayer2.cpp index ba6367906d..9410c4ad9b 100644 --- a/cocos/2d/CCTMXLayer2.cpp +++ b/cocos/2d/CCTMXLayer2.cpp @@ -36,14 +36,13 @@ THE SOFTWARE. */ #include "CCTMXLayer2.h" #include "CCTMXXMLParser.h" -#include "CCTMXTiledMap.h" -#include "CCSprite.h" -#include "CCTextureCache.h" -#include "CCGLProgramCache.h" -#include "CCGLProgram.h" -#include "ccCArray.h" -#include "CCDirector.h" -#include "CCConfiguration.h" +#include "CCTMXTiledMap2.h" +#include "2d/CCSprite.h" +#include "renderer/CCTextureCache.h" +#include "renderer/CCGLProgramCache.h" +#include "renderer/CCGLProgram.h" +#include "base/CCDirector.h" +#include "base/CCConfiguration.h" #include "renderer/CCRenderer.h" #include "deprecated/CCString.h" @@ -113,7 +112,7 @@ TMXLayer2::TMXLayer2() ,_mapTileSize(Size::ZERO) ,_tiles(nullptr) ,_tileSet(nullptr) -,_layerOrientation(TMXOrientationOrtho) +,_layerOrientation(TMXOrientationOrtho2) ,_texture(nullptr) ,_reusedTile(nullptr) ,_verticesToDraw(0) @@ -236,7 +235,7 @@ int TMXLayer2::updateTiles(const Rect& culledRect, V2F_T2F_Quad *quads, GLushort int tilesOverY = 0; // for diagonal oriention tiles float tileSizeMax = std::max(tileSize.width, tileSize.height); - if (_layerOrientation == TMXOrientationOrtho) + if (_layerOrientation == TMXOrientationOrtho2) { tilesOverX = ceil(tileSizeMax / mapTileSize.width) - 1; tilesOverY = ceil(tileSizeMax / mapTileSize.height) - 1; @@ -244,7 +243,7 @@ int TMXLayer2::updateTiles(const Rect& culledRect, V2F_T2F_Quad *quads, GLushort if (tilesOverX < 0) tilesOverX = 0; if (tilesOverY < 0) tilesOverY = 0; } - else if(_layerOrientation == TMXOrientationIso) + else if(_layerOrientation == TMXOrientationIso2) { Rect overTileRect(0, 0, tileSizeMax - mapTileSize.width, tileSizeMax - mapTileSize.height); if (overTileRect.size.width < 0) overTileRect.size.width = 0; @@ -424,18 +423,18 @@ void TMXLayer2::setupTiles() switch (_layerOrientation) { - case TMXOrientationOrtho: + case TMXOrientationOrtho2: _screenGridSize.width = ceil(screenSize.width / _mapTileSize.width) + 1; _screenGridSize.height = ceil(screenSize.height / _mapTileSize.height) + 1; // tiles could be bigger than the grid, add additional rows if needed _screenGridSize.height += _tileSet->_tileSize.height / _mapTileSize.height; break; - case TMXOrientationIso: + case TMXOrientationIso2: _screenGridSize.width = ceil(screenSize.width / _mapTileSize.width) + 2; _screenGridSize.height = ceil(screenSize.height / (_mapTileSize.height/2)) + 4; break; - case TMXOrientationHex: + case TMXOrientationHex2: break; } @@ -452,7 +451,7 @@ Mat4 TMXLayer2::tileToNodeTransform() switch(_layerOrientation) { - case TMXOrientationOrtho: + case TMXOrientationOrtho2: { _tileToNodeTransform = Mat4 ( @@ -464,7 +463,7 @@ Mat4 TMXLayer2::tileToNodeTransform() return _tileToNodeTransform; } - case TMXOrientationIso: + case TMXOrientationIso2: { float offX = (_layerSize.width - 1) * w / 2; _tileToNodeTransform = Mat4 @@ -476,7 +475,7 @@ Mat4 TMXLayer2::tileToNodeTransform() ); return _tileToNodeTransform; } - case TMXOrientationHex: + case TMXOrientationHex2: { _tileToNodeTransform = Mat4::IDENTITY; return _tileToNodeTransform; @@ -570,14 +569,14 @@ int TMXLayer2::getVertexZForPos(const Point& pos) { switch (_layerOrientation) { - case TMXOrientationIso: + case TMXOrientationIso2: maxVal = static_cast(_layerSize.width + _layerSize.height); ret = static_cast(-(maxVal - (pos.x + pos.y))); break; - case TMXOrientationOrtho: + case TMXOrientationOrtho2: ret = static_cast(-(_layerSize.height-pos.y)); break; - case TMXOrientationHex: + case TMXOrientationHex2: CCASSERT(0, "TMX Hexa zOrder not supported"); break; default: @@ -681,14 +680,14 @@ Point TMXLayer2::calculateLayerOffset(const Point& pos) Point ret = Point::ZERO; switch (_layerOrientation) { - case TMXOrientationOrtho: + case TMXOrientationOrtho2: ret = Point( pos.x * _mapTileSize.width, -pos.y *_mapTileSize.height); break; - case TMXOrientationIso: + case TMXOrientationIso2: ret = Point((_mapTileSize.width /2) * (pos.x - pos.y), (_mapTileSize.height /2 ) * (-pos.x - pos.y)); break; - case TMXOrientationHex: + case TMXOrientationHex2: CCASSERT(pos.equals(Point::ZERO), "offset for hexagonal map not implemented yet"); break; } diff --git a/cocos/2d/CMakeLists.txt b/cocos/2d/CMakeLists.txt index 630aa69782..d5d7a0b044 100644 --- a/cocos/2d/CMakeLists.txt +++ b/cocos/2d/CMakeLists.txt @@ -65,8 +65,10 @@ set(COCOS_2D_SRC 2d/CCTextFieldTTF.cpp 2d/CCTileMapAtlas.cpp 2d/CCTMXLayer.cpp + 2d/CCTMXLayer2.cpp 2d/CCTMXObjectGroup.cpp 2d/CCTMXTiledMap.cpp + 2d/CCTMXTiledMap2.cpp 2d/CCTMXXMLParser.cpp 2d/CCTransition.cpp 2d/CCTransitionPageTurn.cpp diff --git a/cocos/Android.mk b/cocos/Android.mk index 1112b4abd9..eb8bc29f2a 100644 --- a/cocos/Android.mk +++ b/cocos/Android.mk @@ -62,8 +62,10 @@ cocos2d.cpp \ 2d/CCSpriteFrame.cpp \ 2d/CCSpriteFrameCache.cpp \ 2d/CCTMXLayer.cpp \ +2d/CCTMXLayer2.cpp \ 2d/CCTMXObjectGroup.cpp \ 2d/CCTMXTiledMap.cpp \ +2d/CCTMXTiledMap2.cpp \ 2d/CCTMXXMLParser.cpp \ 2d/CCTextFieldTTF.cpp \ 2d/CCTileMapAtlas.cpp \ diff --git a/tests/cpp-tests/Android.mk b/tests/cpp-tests/Android.mk index cedc1f75aa..d6abfe81e3 100644 --- a/tests/cpp-tests/Android.mk +++ b/tests/cpp-tests/Android.mk @@ -169,6 +169,7 @@ Classes/Texture2dTest/Texture2dTest.cpp \ Classes/TextureCacheTest/TextureCacheTest.cpp \ Classes/TexturePackerEncryptionTest/TextureAtlasEncryptionTest.cpp \ Classes/TileMapTest/TileMapTest.cpp \ +Classes/TileMapTest/TileMapTest2.cpp \ Classes/TouchesTest/Ball.cpp \ Classes/TouchesTest/Paddle.cpp \ Classes/TouchesTest/TouchesTest.cpp \ diff --git a/tests/cpp-tests/CMakeLists.txt b/tests/cpp-tests/CMakeLists.txt index 06a7413060..42a10d6eed 100644 --- a/tests/cpp-tests/CMakeLists.txt +++ b/tests/cpp-tests/CMakeLists.txt @@ -162,6 +162,7 @@ set(SAMPLE_SRC Classes/TexturePackerEncryptionTest/TextureAtlasEncryptionTest.cpp Classes/TextureCacheTest/TextureCacheTest.cpp Classes/TileMapTest/TileMapTest.cpp + Classes/TileMapTest/TileMapTest2.cpp Classes/TouchesTest/Ball.cpp Classes/TouchesTest/Paddle.cpp Classes/TouchesTest/TouchesTest.cpp