remove deprecated function

rename enum to static const member of class
remove hex tile map(we do not support it yet)
This commit is contained in:
Huabing.Xu 2014-06-27 18:00:06 +08:00
parent 33a8b6563f
commit 3771654e66
4 changed files with 41 additions and 72 deletions

View File

@ -49,10 +49,9 @@ THE SOFTWARE.
NS_CC_BEGIN NS_CC_BEGIN
namespace const int FastTMXLayer::FAST_TMX_ORIENTATION_ORTHO = 0;
{ const int FastTMXLayer::FAST_TMX_ORIENTATION_HEX = 1;
static const int MAX_QUADS_COUNT = 65536 / 6; const int FastTMXLayer::FAST_TMX_ORIENTATION_ISO = 2;
}
// FastTMXLayer - init & alloc & dealloc // FastTMXLayer - init & alloc & dealloc
FastTMXLayer * FastTMXLayer::create(TMXTilesetInfo *tilesetInfo, TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo) FastTMXLayer * FastTMXLayer::create(TMXTilesetInfo *tilesetInfo, TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo)
@ -114,7 +113,7 @@ FastTMXLayer::FastTMXLayer()
, _mapTileSize(Size::ZERO) , _mapTileSize(Size::ZERO)
, _tiles(nullptr) , _tiles(nullptr)
, _tileSet(nullptr) , _tileSet(nullptr)
, _layerOrientation(FastTMXOrientationOrtho) , _layerOrientation(FAST_TMX_ORIENTATION_ORTHO)
,_texture(nullptr) ,_texture(nullptr)
, _vertexZvalue(0) , _vertexZvalue(0)
, _useAutomaticVertexZ(false) , _useAutomaticVertexZ(false)
@ -216,7 +215,7 @@ void FastTMXLayer::updateTiles(const Rect& culledRect)
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 == FastTMXOrientationOrtho) if (_layerOrientation == FAST_TMX_ORIENTATION_ORTHO)
{ {
tilesOverX = ceil(tileSizeMax / mapTileSize.width) - 1; tilesOverX = ceil(tileSizeMax / mapTileSize.width) - 1;
tilesOverY = ceil(tileSizeMax / mapTileSize.height) - 1; tilesOverY = ceil(tileSizeMax / mapTileSize.height) - 1;
@ -224,7 +223,7 @@ void FastTMXLayer::updateTiles(const Rect& culledRect)
if (tilesOverX < 0) tilesOverX = 0; if (tilesOverX < 0) tilesOverX = 0;
if (tilesOverY < 0) tilesOverY = 0; if (tilesOverY < 0) tilesOverY = 0;
} }
else if(_layerOrientation == FastTMXOrientationIso) else if(_layerOrientation == FAST_TMX_ORIENTATION_ISO)
{ {
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;
@ -234,6 +233,11 @@ void FastTMXLayer::updateTiles(const Rect& culledRect)
tilesOverX = ceil(overTileRect.origin.x + overTileRect.size.width) - floor(overTileRect.origin.x); tilesOverX = ceil(overTileRect.origin.x + overTileRect.size.width) - floor(overTileRect.origin.x);
tilesOverY = ceil(overTileRect.origin.y + overTileRect.size.height) - floor(overTileRect.origin.y); tilesOverY = ceil(overTileRect.origin.y + overTileRect.size.height) - floor(overTileRect.origin.y);
} }
else
{
//do nothing, do not support
CCASSERT(0, "TMX invalid value");
}
_indicesVertexZNumber.clear(); _indicesVertexZNumber.clear();
@ -327,18 +331,18 @@ void FastTMXLayer::setupTiles()
switch (_layerOrientation) switch (_layerOrientation)
{ {
case FastTMXOrientationOrtho: case FAST_TMX_ORIENTATION_ORTHO:
_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 FastTMXOrientationIso: case FAST_TMX_ORIENTATION_ISO:
_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 FastTMXOrientationHex: case FAST_TMX_ORIENTATION_HEX:
default: default:
CCLOGERROR("FastTMX does not support type %d", _layerOrientation); CCLOGERROR("FastTMX does not support type %d", _layerOrientation);
break; break;
@ -356,7 +360,7 @@ Mat4 FastTMXLayer::tileToNodeTransform()
switch(_layerOrientation) switch(_layerOrientation)
{ {
case FastTMXOrientationOrtho: case FAST_TMX_ORIENTATION_ORTHO:
{ {
_tileToNodeTransform = Mat4 _tileToNodeTransform = Mat4
( (
@ -368,7 +372,7 @@ Mat4 FastTMXLayer::tileToNodeTransform()
return _tileToNodeTransform; return _tileToNodeTransform;
} }
case FastTMXOrientationIso: case FAST_TMX_ORIENTATION_ISO:
{ {
float offX = (_layerSize.width - 1) * w / 2; float offX = (_layerSize.width - 1) * w / 2;
_tileToNodeTransform = Mat4 _tileToNodeTransform = Mat4
@ -380,7 +384,7 @@ Mat4 FastTMXLayer::tileToNodeTransform()
); );
return _tileToNodeTransform; return _tileToNodeTransform;
} }
case FastTMXOrientationHex: case FAST_TMX_ORIENTATION_HEX:
{ {
_tileToNodeTransform = Mat4::IDENTITY; _tileToNodeTransform = Mat4::IDENTITY;
return _tileToNodeTransform; return _tileToNodeTransform;
@ -604,14 +608,14 @@ int FastTMXLayer::getVertexZForPos(const Vec2& pos)
{ {
switch (_layerOrientation) switch (_layerOrientation)
{ {
case FastTMXOrientationIso: case FAST_TMX_ORIENTATION_ISO:
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 FastTMXOrientationOrtho: case FAST_TMX_ORIENTATION_ORTHO:
ret = static_cast<int>(-(_layerSize.height-pos.y)); ret = static_cast<int>(-(_layerSize.height-pos.y));
break; break;
case FastTMXOrientationHex: case FAST_TMX_ORIENTATION_HEX:
CCASSERT(0, "TMX Hexa zOrder not supported"); CCASSERT(0, "TMX Hexa zOrder not supported");
break; break;
default: default:
@ -713,15 +717,16 @@ Vec2 FastTMXLayer::calculateLayerOffset(const Vec2& pos)
Vec2 ret = Vec2::ZERO; Vec2 ret = Vec2::ZERO;
switch (_layerOrientation) switch (_layerOrientation)
{ {
case FastTMXOrientationOrtho: case FAST_TMX_ORIENTATION_ORTHO:
ret = Vec2( pos.x * _mapTileSize.width, -pos.y *_mapTileSize.height); ret = Vec2( pos.x * _mapTileSize.width, -pos.y *_mapTileSize.height);
break; break;
case FastTMXOrientationIso: case FAST_TMX_ORIENTATION_ISO:
ret = Vec2((_mapTileSize.width /2) * (pos.x - pos.y), ret = Vec2((_mapTileSize.width /2) * (pos.x - pos.y),
(_mapTileSize.height /2 ) * (-pos.x - pos.y)); (_mapTileSize.height /2 ) * (-pos.x - pos.y));
break; break;
case FastTMXOrientationHex: case FAST_TMX_ORIENTATION_HEX:
CCASSERT(pos.equals(Vec2::ZERO), "offset for hexagonal map not implemented yet"); default:
CCASSERT(pos.equals(Vec2::ZERO), "offset for this map not implemented yet");
break; break;
} }
return ret; return ret;

View File

@ -24,8 +24,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#ifndef __CCTMX_LAYER2_H__ #ifndef __CC_FAST_TMX_LAYER_H__
#define __CCTMX_LAYER2_H__ #define __CC_FAST_TMX_LAYER_H__
#include "CCTMXObjectGroup.h" #include "CCTMXObjectGroup.h"
#include "CCTMXXMLParser.h" #include "CCTMXXMLParser.h"
@ -73,10 +73,7 @@ For further information, please see the programming guide:
http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:tiled_maps http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:tiled_maps
@since v0.8.1 @since v3.2
Tiles can have tile flags for additional properties. At the moment only flip horizontal and flip vertical are used. These bit flags are defined in TMXXMLParser.h.
@since 1.1
*/ */
class CC_DLL FastTMXLayer : public Node class CC_DLL FastTMXLayer : public Node
@ -97,9 +94,6 @@ public:
/** returns the tile gid at a given tile coordinate. It also returns the tile flags. /** returns the tile gid at a given tile coordinate. It also returns the tile flags.
*/ */
int getTileGIDAt(const Vec2& tileCoordinate, TMXTileFlags* flags = nullptr); int getTileGIDAt(const Vec2& tileCoordinate, TMXTileFlags* flags = nullptr);
CC_DEPRECATED_ATTRIBUTE int tileGIDAt(const Vec2& tileCoordinate, TMXTileFlags* flags = nullptr){
return getTileGIDAt(tileCoordinate, flags);
};
/** sets the tile gid (gid = tile global id) at a given tile coordinate. /** sets the tile gid (gid = tile global id) at a given tile coordinate.
The Tile GID can be obtained by using the method "tileGIDAt" or by using the TMX editor -> Tileset Mgr +1. The Tile GID can be obtained by using the method "tileGIDAt" or by using the TMX editor -> Tileset Mgr +1.
@ -121,11 +115,9 @@ public:
/** returns the position in points of a given tile coordinate */ /** returns the position in points of a given tile coordinate */
Vec2 getPositionAt(const Vec2& tileCoordinate); Vec2 getPositionAt(const Vec2& tileCoordinate);
CC_DEPRECATED_ATTRIBUTE Vec2 positionAt(const Vec2& tileCoordinate) { return getPositionAt(tileCoordinate); };
/** return the value for the specific property name */ /** return the value for the specific property name */
Value getProperty(const std::string& propertyName) const; Value getProperty(const std::string& propertyName) const;
CC_DEPRECATED_ATTRIBUTE Value propertyNamed(const std::string& propertyName) const { return getProperty(propertyName); };
/** Creates the tiles */ /** Creates the tiles */
void setupTiles(); void setupTiles();
@ -254,6 +246,12 @@ protected:
std::unordered_map<int/*vertexZ*/, int/*number to quads*/> _indicesVertexZNumber; std::unordered_map<int/*vertexZ*/, int/*number to quads*/> _indicesVertexZNumber;
std::vector<CustomCommand> _renderCommands; std::vector<CustomCommand> _renderCommands;
bool _dirty; bool _dirty;
public:
/** Possible orientations of the TMX map */
static const int FAST_TMX_ORIENTATION_ORTHO;
static const int FAST_TMX_ORIENTATION_HEX;
static const int FAST_TMX_ORIENTATION_ISO;
}; };
// end of tilemap_parallax_nodes group // end of tilemap_parallax_nodes group

View File

@ -24,8 +24,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#ifndef __CCTMX_TILE_MAP2_H__ #ifndef __CC_FAST_TMX_TILEMAP_H__
#define __CCTMX_TILE_MAP2_H__ #define __CC_FAST_TMX_TILEMAP_H__
#include "CCNode.h" #include "CCNode.h"
#include "CCTMXObjectGroup.h" #include "CCTMXObjectGroup.h"
@ -38,24 +38,6 @@ class TMXLayerInfo;
class TMXTilesetInfo; class TMXTilesetInfo;
class TMXMapInfo; class TMXMapInfo;
/**
* @addtogroup tilemap_parallax_nodes
* @{
*/
/** Possible orientations of the TMX map */
enum
{
/** Orthogonal orientation */
FastTMXOrientationOrtho,
/** Hexagonal orientation */
FastTMXOrientationHex,
/** Isometric orientation */
FastTMXOrientationIso,
};
/** @brief FastTMXTiledMap knows how to parse and render a TMX map. /** @brief FastTMXTiledMap knows how to parse and render a TMX map.
It adds support for the TMX tiled map format used by http://www.mapeditor.org It adds support for the TMX tiled map format used by http://www.mapeditor.org
@ -105,7 +87,7 @@ layer->getProperty(name_of_the_property);
objectGroup->getProperty(name_of_the_property); objectGroup->getProperty(name_of_the_property);
object->getProperty(name_of_the_property); object->getProperty(name_of_the_property);
@since v0.8.1 @since v3.2
*/ */
class CC_DLL FastTMXTiledMap : public Node class CC_DLL FastTMXTiledMap : public Node
{ {
@ -118,31 +100,15 @@ public:
/** return the FastTMXLayer for the specific layer */ /** return the FastTMXLayer for the specific layer */
FastTMXLayer* getLayer(const std::string& layerName) const; FastTMXLayer* getLayer(const std::string& layerName) const;
/**
* @js NA
* @lua NA
*/
CC_DEPRECATED_ATTRIBUTE FastTMXLayer* layerNamed(const std::string& layerName) const { return getLayer(layerName); };
/** return the TMXObjectGroup for the specific group */ /** return the TMXObjectGroup for the specific group */
TMXObjectGroup* getObjectGroup(const std::string& groupName) const; TMXObjectGroup* getObjectGroup(const std::string& groupName) const;
/**
* @js NA
* @lua NA
*/
CC_DEPRECATED_ATTRIBUTE TMXObjectGroup* objectGroupNamed(const std::string& groupName) const { return getObjectGroup(groupName); };
/** return the value for the specific property name */ /** return the value for the specific property name */
Value getProperty(const std::string& propertyName) const; Value getProperty(const std::string& propertyName) const;
/**
* @js NA
* @lua NA
*/
CC_DEPRECATED_ATTRIBUTE Value propertyNamed(const char *propertyName) const { return getProperty(propertyName); };
/** return properties dictionary for tile GID */ /** return properties dictionary for tile GID */
Value getPropertiesForGID(int GID) const; Value getPropertiesForGID(int GID) const;
CC_DEPRECATED_ATTRIBUTE Value propertiesForGID(int GID) const { return getPropertiesForGID(GID); };
/** the map's size property measured in tiles */ /** the map's size property measured in tiles */
inline const Size& getMapSize() const { return _mapSize; }; inline const Size& getMapSize() const { return _mapSize; };
@ -164,7 +130,7 @@ public:
}; };
/** properties */ /** properties */
inline ValueMap& getProperties() { return _properties; }; inline const ValueMap& getProperties() const { return _properties; };
inline void setProperties(const ValueMap& properties) { inline void setProperties(const ValueMap& properties) {
_properties = properties; _properties = properties;
}; };

View File

@ -30,8 +30,6 @@ namespace
static int sceneIdx = -1; static int sceneIdx = -1;
#define MAX_LAYER 27
static std::function<Layer*()> createFunctions[] = { static std::function<Layer*()> createFunctions[] = {
CLN(TMXIsoZorderNew), CLN(TMXIsoZorderNew),
CLN(TMXOrthoZorderNew), CLN(TMXOrthoZorderNew),
@ -45,7 +43,7 @@ namespace
CLN(TMXIsoTest1New), CLN(TMXIsoTest1New),
CLN(TMXIsoTest2New), CLN(TMXIsoTest2New),
CLN(TMXUncompressedTestNew), CLN(TMXUncompressedTestNew),
CLN(TMXHexTestNew), //CLN(TMXHexTestNew),
CLN(TMXReadWriteTestNew), CLN(TMXReadWriteTestNew),
CLN(TMXTilesetTestNew), CLN(TMXTilesetTestNew),
CLN(TMXOrthoObjectsTestNew), CLN(TMXOrthoObjectsTestNew),
@ -65,6 +63,8 @@ namespace
}; };
#define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0]))
Layer* createTileMalayer(int nIndex) Layer* createTileMalayer(int nIndex)
{ {
return createFunctions[nIndex](); return createFunctions[nIndex]();