issue #4437: config for android and linux.

This commit is contained in:
boyu0 2014-06-13 11:07:21 +08:00
parent acb87f414e
commit ee919b673f
5 changed files with 28 additions and 23 deletions

View File

@ -36,14 +36,13 @@ THE SOFTWARE.
*/ */
#include "CCTMXLayer2.h" #include "CCTMXLayer2.h"
#include "CCTMXXMLParser.h" #include "CCTMXXMLParser.h"
#include "CCTMXTiledMap.h" #include "CCTMXTiledMap2.h"
#include "CCSprite.h" #include "2d/CCSprite.h"
#include "CCTextureCache.h" #include "renderer/CCTextureCache.h"
#include "CCGLProgramCache.h" #include "renderer/CCGLProgramCache.h"
#include "CCGLProgram.h" #include "renderer/CCGLProgram.h"
#include "ccCArray.h" #include "base/CCDirector.h"
#include "CCDirector.h" #include "base/CCConfiguration.h"
#include "CCConfiguration.h"
#include "renderer/CCRenderer.h" #include "renderer/CCRenderer.h"
#include "deprecated/CCString.h" #include "deprecated/CCString.h"
@ -113,7 +112,7 @@ TMXLayer2::TMXLayer2()
,_mapTileSize(Size::ZERO) ,_mapTileSize(Size::ZERO)
,_tiles(nullptr) ,_tiles(nullptr)
,_tileSet(nullptr) ,_tileSet(nullptr)
,_layerOrientation(TMXOrientationOrtho) ,_layerOrientation(TMXOrientationOrtho2)
,_texture(nullptr) ,_texture(nullptr)
,_reusedTile(nullptr) ,_reusedTile(nullptr)
,_verticesToDraw(0) ,_verticesToDraw(0)
@ -236,7 +235,7 @@ int TMXLayer2::updateTiles(const Rect& culledRect, V2F_T2F_Quad *quads, GLushort
int tilesOverY = 0; int tilesOverY = 0;
// for diagonal oriention tiles // for diagonal oriention tiles
float tileSizeMax = std::max(tileSize.width, tileSize.height); float tileSizeMax = std::max(tileSize.width, tileSize.height);
if (_layerOrientation == TMXOrientationOrtho) if (_layerOrientation == TMXOrientationOrtho2)
{ {
tilesOverX = ceil(tileSizeMax / mapTileSize.width) - 1; tilesOverX = ceil(tileSizeMax / mapTileSize.width) - 1;
tilesOverY = ceil(tileSizeMax / mapTileSize.height) - 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 (tilesOverX < 0) tilesOverX = 0;
if (tilesOverY < 0) tilesOverY = 0; if (tilesOverY < 0) tilesOverY = 0;
} }
else if(_layerOrientation == TMXOrientationIso) else if(_layerOrientation == TMXOrientationIso2)
{ {
Rect overTileRect(0, 0, tileSizeMax - mapTileSize.width, tileSizeMax - mapTileSize.height); Rect overTileRect(0, 0, tileSizeMax - mapTileSize.width, tileSizeMax - mapTileSize.height);
if (overTileRect.size.width < 0) overTileRect.size.width = 0; if (overTileRect.size.width < 0) overTileRect.size.width = 0;
@ -424,18 +423,18 @@ void TMXLayer2::setupTiles()
switch (_layerOrientation) switch (_layerOrientation)
{ {
case TMXOrientationOrtho: case TMXOrientationOrtho2:
_screenGridSize.width = ceil(screenSize.width / _mapTileSize.width) + 1; _screenGridSize.width = ceil(screenSize.width / _mapTileSize.width) + 1;
_screenGridSize.height = ceil(screenSize.height / _mapTileSize.height) + 1; _screenGridSize.height = ceil(screenSize.height / _mapTileSize.height) + 1;
// tiles could be bigger than the grid, add additional rows if needed // tiles could be bigger than the grid, add additional rows if needed
_screenGridSize.height += _tileSet->_tileSize.height / _mapTileSize.height; _screenGridSize.height += _tileSet->_tileSize.height / _mapTileSize.height;
break; break;
case TMXOrientationIso: case TMXOrientationIso2:
_screenGridSize.width = ceil(screenSize.width / _mapTileSize.width) + 2; _screenGridSize.width = ceil(screenSize.width / _mapTileSize.width) + 2;
_screenGridSize.height = ceil(screenSize.height / (_mapTileSize.height/2)) + 4; _screenGridSize.height = ceil(screenSize.height / (_mapTileSize.height/2)) + 4;
break; break;
case TMXOrientationHex: case TMXOrientationHex2:
break; break;
} }
@ -452,7 +451,7 @@ Mat4 TMXLayer2::tileToNodeTransform()
switch(_layerOrientation) switch(_layerOrientation)
{ {
case TMXOrientationOrtho: case TMXOrientationOrtho2:
{ {
_tileToNodeTransform = Mat4 _tileToNodeTransform = Mat4
( (
@ -464,7 +463,7 @@ Mat4 TMXLayer2::tileToNodeTransform()
return _tileToNodeTransform; return _tileToNodeTransform;
} }
case TMXOrientationIso: case TMXOrientationIso2:
{ {
float offX = (_layerSize.width - 1) * w / 2; float offX = (_layerSize.width - 1) * w / 2;
_tileToNodeTransform = Mat4 _tileToNodeTransform = Mat4
@ -476,7 +475,7 @@ Mat4 TMXLayer2::tileToNodeTransform()
); );
return _tileToNodeTransform; return _tileToNodeTransform;
} }
case TMXOrientationHex: case TMXOrientationHex2:
{ {
_tileToNodeTransform = Mat4::IDENTITY; _tileToNodeTransform = Mat4::IDENTITY;
return _tileToNodeTransform; return _tileToNodeTransform;
@ -570,14 +569,14 @@ int TMXLayer2::getVertexZForPos(const Point& pos)
{ {
switch (_layerOrientation) switch (_layerOrientation)
{ {
case TMXOrientationIso: case TMXOrientationIso2:
maxVal = static_cast<int>(_layerSize.width + _layerSize.height); maxVal = static_cast<int>(_layerSize.width + _layerSize.height);
ret = static_cast<int>(-(maxVal - (pos.x + pos.y))); ret = static_cast<int>(-(maxVal - (pos.x + pos.y)));
break; break;
case TMXOrientationOrtho: case TMXOrientationOrtho2:
ret = static_cast<int>(-(_layerSize.height-pos.y)); ret = static_cast<int>(-(_layerSize.height-pos.y));
break; break;
case TMXOrientationHex: case TMXOrientationHex2:
CCASSERT(0, "TMX Hexa zOrder not supported"); CCASSERT(0, "TMX Hexa zOrder not supported");
break; break;
default: default:
@ -681,14 +680,14 @@ Point TMXLayer2::calculateLayerOffset(const Point& pos)
Point ret = Point::ZERO; Point ret = Point::ZERO;
switch (_layerOrientation) switch (_layerOrientation)
{ {
case TMXOrientationOrtho: case TMXOrientationOrtho2:
ret = Point( pos.x * _mapTileSize.width, -pos.y *_mapTileSize.height); ret = Point( pos.x * _mapTileSize.width, -pos.y *_mapTileSize.height);
break; break;
case TMXOrientationIso: case TMXOrientationIso2:
ret = Point((_mapTileSize.width /2) * (pos.x - pos.y), ret = Point((_mapTileSize.width /2) * (pos.x - pos.y),
(_mapTileSize.height /2 ) * (-pos.x - pos.y)); (_mapTileSize.height /2 ) * (-pos.x - pos.y));
break; break;
case TMXOrientationHex: case TMXOrientationHex2:
CCASSERT(pos.equals(Point::ZERO), "offset for hexagonal map not implemented yet"); CCASSERT(pos.equals(Point::ZERO), "offset for hexagonal map not implemented yet");
break; break;
} }

View File

@ -65,8 +65,10 @@ set(COCOS_2D_SRC
2d/CCTextFieldTTF.cpp 2d/CCTextFieldTTF.cpp
2d/CCTileMapAtlas.cpp 2d/CCTileMapAtlas.cpp
2d/CCTMXLayer.cpp 2d/CCTMXLayer.cpp
2d/CCTMXLayer2.cpp
2d/CCTMXObjectGroup.cpp 2d/CCTMXObjectGroup.cpp
2d/CCTMXTiledMap.cpp 2d/CCTMXTiledMap.cpp
2d/CCTMXTiledMap2.cpp
2d/CCTMXXMLParser.cpp 2d/CCTMXXMLParser.cpp
2d/CCTransition.cpp 2d/CCTransition.cpp
2d/CCTransitionPageTurn.cpp 2d/CCTransitionPageTurn.cpp

View File

@ -62,8 +62,10 @@ cocos2d.cpp \
2d/CCSpriteFrame.cpp \ 2d/CCSpriteFrame.cpp \
2d/CCSpriteFrameCache.cpp \ 2d/CCSpriteFrameCache.cpp \
2d/CCTMXLayer.cpp \ 2d/CCTMXLayer.cpp \
2d/CCTMXLayer2.cpp \
2d/CCTMXObjectGroup.cpp \ 2d/CCTMXObjectGroup.cpp \
2d/CCTMXTiledMap.cpp \ 2d/CCTMXTiledMap.cpp \
2d/CCTMXTiledMap2.cpp \
2d/CCTMXXMLParser.cpp \ 2d/CCTMXXMLParser.cpp \
2d/CCTextFieldTTF.cpp \ 2d/CCTextFieldTTF.cpp \
2d/CCTileMapAtlas.cpp \ 2d/CCTileMapAtlas.cpp \

View File

@ -169,6 +169,7 @@ Classes/Texture2dTest/Texture2dTest.cpp \
Classes/TextureCacheTest/TextureCacheTest.cpp \ Classes/TextureCacheTest/TextureCacheTest.cpp \
Classes/TexturePackerEncryptionTest/TextureAtlasEncryptionTest.cpp \ Classes/TexturePackerEncryptionTest/TextureAtlasEncryptionTest.cpp \
Classes/TileMapTest/TileMapTest.cpp \ Classes/TileMapTest/TileMapTest.cpp \
Classes/TileMapTest/TileMapTest2.cpp \
Classes/TouchesTest/Ball.cpp \ Classes/TouchesTest/Ball.cpp \
Classes/TouchesTest/Paddle.cpp \ Classes/TouchesTest/Paddle.cpp \
Classes/TouchesTest/TouchesTest.cpp \ Classes/TouchesTest/TouchesTest.cpp \

View File

@ -162,6 +162,7 @@ set(SAMPLE_SRC
Classes/TexturePackerEncryptionTest/TextureAtlasEncryptionTest.cpp Classes/TexturePackerEncryptionTest/TextureAtlasEncryptionTest.cpp
Classes/TextureCacheTest/TextureCacheTest.cpp Classes/TextureCacheTest/TextureCacheTest.cpp
Classes/TileMapTest/TileMapTest.cpp Classes/TileMapTest/TileMapTest.cpp
Classes/TileMapTest/TileMapTest2.cpp
Classes/TouchesTest/Ball.cpp Classes/TouchesTest/Ball.cpp
Classes/TouchesTest/Paddle.cpp Classes/TouchesTest/Paddle.cpp
Classes/TouchesTest/TouchesTest.cpp Classes/TouchesTest/TouchesTest.cpp