2018-01-29 16:25:32 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
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
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2010-11-18 14:50:28 +08:00
|
|
|
#include "TileMapTest.h"
|
|
|
|
#include "../testResource.h"
|
2015-12-04 10:43:39 +08:00
|
|
|
|
2010-11-18 14:50:28 +08:00
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
USING_NS_CC;
|
|
|
|
|
2010-09-01 17:30:51 +08:00
|
|
|
enum
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
kTagTileMap = 1,
|
2010-11-18 14:50:28 +08:00
|
|
|
};
|
|
|
|
|
2014-02-05 09:59:21 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TileDemo
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
TileMapTests::TileMapTests()
|
|
|
|
{
|
|
|
|
ADD_TEST_CASE(TMXIsoZorder);
|
|
|
|
ADD_TEST_CASE(TMXOrthoZorder);
|
|
|
|
ADD_TEST_CASE(TMXStaggeredTest);
|
|
|
|
ADD_TEST_CASE(TMXIsoVertexZ);
|
|
|
|
ADD_TEST_CASE(TMXOrthoVertexZ);
|
|
|
|
ADD_TEST_CASE(TMXOrthoTest);
|
|
|
|
ADD_TEST_CASE(TMXOrthoTest2);
|
|
|
|
ADD_TEST_CASE(TMXOrthoTest3);
|
|
|
|
ADD_TEST_CASE(TMXOrthoTest4);
|
|
|
|
ADD_TEST_CASE(TMXIsoTest);
|
|
|
|
ADD_TEST_CASE(TMXIsoTest1);
|
|
|
|
ADD_TEST_CASE(TMXIsoTest2);
|
|
|
|
ADD_TEST_CASE(TMXUncompressedTest);
|
2016-04-13 03:51:09 +08:00
|
|
|
ADD_TEST_CASE(TMXCvsFormatTest);
|
2015-04-03 14:31:03 +08:00
|
|
|
ADD_TEST_CASE(TMXHexTest);
|
|
|
|
ADD_TEST_CASE(TMXReadWriteTest);
|
|
|
|
ADD_TEST_CASE(TMXTilesetTest);
|
|
|
|
ADD_TEST_CASE(TMXOrthoObjectsTest);
|
|
|
|
ADD_TEST_CASE(TMXIsoObjectsTest);
|
|
|
|
ADD_TEST_CASE(TMXResizeTest);
|
|
|
|
ADD_TEST_CASE(TMXIsoMoveLayer);
|
|
|
|
ADD_TEST_CASE(TMXOrthoMoveLayer);
|
|
|
|
ADD_TEST_CASE(TMXOrthoFlipTest);
|
|
|
|
ADD_TEST_CASE(TMXOrthoFlipRunTimeTest);
|
|
|
|
ADD_TEST_CASE(TMXOrthoFromXMLTest);
|
|
|
|
ADD_TEST_CASE(TMXOrthoXMLFormatTest);
|
|
|
|
ADD_TEST_CASE(TileMapTest);
|
|
|
|
ADD_TEST_CASE(TileMapEditTest);
|
|
|
|
ADD_TEST_CASE(TMXBug987);
|
|
|
|
ADD_TEST_CASE(TMXBug787);
|
|
|
|
ADD_TEST_CASE(TMXGIDObjectsTest);
|
2016-07-02 06:51:00 +08:00
|
|
|
ADD_TEST_CASE(TMXHexOddXTest);
|
|
|
|
ADD_TEST_CASE(TMXHexEvenXTest);
|
|
|
|
ADD_TEST_CASE(TMXHexOddYTest);
|
|
|
|
ADD_TEST_CASE(TMXHexEvenYTest);
|
2016-07-15 02:21:24 +08:00
|
|
|
ADD_TEST_CASE(TMXHexAxisXTest);
|
2016-07-20 13:55:05 +08:00
|
|
|
ADD_TEST_CASE(Issue16105Test);
|
2016-09-14 12:47:36 +08:00
|
|
|
ADD_TEST_CASE(Issue16512Test);
|
2014-02-05 09:59:21 +08:00
|
|
|
}
|
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
TileDemo::TileDemo()
|
2014-02-05 09:59:21 +08:00
|
|
|
{
|
2015-04-03 14:31:03 +08:00
|
|
|
// fix bug #486, #419.
|
|
|
|
// "test" is the default value in Director::setGLDefaultValues()
|
|
|
|
// but TransitionTest may setDepthTest(false), we should revert it here
|
2019-06-30 11:36:52 +08:00
|
|
|
Director::getInstance()->getRenderer()->setDepthTest(true);
|
|
|
|
Director::getInstance()->getRenderer()->setDepthWrite(true);
|
|
|
|
Director::getInstance()->getRenderer()->setDepthCompareFunction(backend::CompareFunction::LESS_EQUAL);
|
2014-02-05 09:59:21 +08:00
|
|
|
|
|
|
|
auto listener = EventListenerTouchAllAtOnce::create();
|
|
|
|
listener->onTouchesMoved = CC_CALLBACK_2(TileDemo::onTouchesMoved, this);
|
|
|
|
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
TileDemo::~TileDemo(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string TileDemo::title() const
|
|
|
|
{
|
|
|
|
return "No title";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string TileDemo::subtitle() const
|
|
|
|
{
|
|
|
|
return "drag the screen";
|
|
|
|
}
|
|
|
|
|
2014-04-11 16:47:35 +08:00
|
|
|
void TileDemo::onExit()
|
2014-04-11 16:30:25 +08:00
|
|
|
{
|
2015-04-03 14:31:03 +08:00
|
|
|
TestCase::onExit();
|
2019-06-30 11:36:52 +08:00
|
|
|
Director::getInstance()->getRenderer()->setDepthTest(false);
|
|
|
|
Director::getInstance()->getRenderer()->setDepthWrite(false);
|
2014-04-11 16:30:25 +08:00
|
|
|
}
|
2014-02-05 09:59:21 +08:00
|
|
|
|
|
|
|
void TileDemo::onTouchesMoved(const std::vector<Touch*>& touches, Event *event)
|
|
|
|
{
|
|
|
|
auto touch = touches[0];
|
|
|
|
|
|
|
|
auto diff = touch->getDelta();
|
|
|
|
auto node = getChildByTag(kTagTileMap);
|
|
|
|
auto currentPos = node->getPosition();
|
|
|
|
node->setPosition(currentPos + diff);
|
|
|
|
}
|
|
|
|
|
2010-09-01 17:30:51 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TileMapTest
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2010-11-18 14:50:28 +08:00
|
|
|
TileMapTest::TileMapTest()
|
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto map = TileMapAtlas::create(s_TilesPng, s_LevelMapTga, 16, 16);
|
2012-04-19 14:35:52 +08:00
|
|
|
// Convert it to "alias" (GL_LINEAR filtering)
|
|
|
|
map->getTexture()->setAntiAliasTexParameters();
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size CC_UNUSED s = map->getContentSize();
|
2012-06-11 14:44:32 +08:00
|
|
|
CCLOG("ContentSize: %f, %f", s.width,s.height);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// If you are not going to use the Map, you can free it now
|
|
|
|
// NEW since v0.7
|
|
|
|
map->releaseMap();
|
|
|
|
|
|
|
|
addChild(map, 0, kTagTileMap);
|
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
map->setAnchorPoint( Vec2(0, 0.5f) );
|
2011-02-23 16:47:25 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto scale = ScaleBy::create(4, 0.8f);
|
|
|
|
auto scaleBack = scale->reverse();
|
2011-05-12 10:52:10 +08:00
|
|
|
|
2014-07-10 00:45:27 +08:00
|
|
|
auto seq = Sequence::create(scale, scaleBack, nullptr);
|
2011-05-12 10:52:10 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
map->runAction(RepeatForever::create(seq));
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
2010-09-01 17:30:51 +08:00
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TileMapTest::title() const
|
2010-09-01 17:30:51 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "TileMapAtlas";
|
2010-09-01 17:30:51 +08:00
|
|
|
}
|
2010-11-18 14:50:28 +08:00
|
|
|
|
2010-09-01 17:30:51 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TileMapEditTest
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2010-11-18 14:50:28 +08:00
|
|
|
TileMapEditTest::TileMapEditTest()
|
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto map = TileMapAtlas::create(s_TilesPng, s_LevelMapTga, 16, 16);
|
2012-04-19 14:35:52 +08:00
|
|
|
// Create an Aliased Atlas
|
|
|
|
map->getTexture()->setAliasTexParameters();
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size CC_UNUSED s = map->getContentSize();
|
2012-06-11 14:44:32 +08:00
|
|
|
CCLOG("ContentSize: %f, %f", s.width,s.height);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// If you are not going to use the Map, you can free it now
|
|
|
|
// [tilemap releaseMap);
|
|
|
|
// And if you are going to use, it you can access the data with:
|
2014-10-04 00:38:36 +08:00
|
|
|
schedule(CC_SCHEDULE_SELECTOR(TileMapEditTest::updateMap), 0.2f);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
addChild(map, 0, kTagTileMap);
|
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
map->setAnchorPoint( Vec2(0, 0) );
|
|
|
|
map->setPosition( Vec2(-20,-200) );
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
2010-09-01 17:30:51 +08:00
|
|
|
|
2012-06-08 13:55:28 +08:00
|
|
|
void TileMapEditTest::updateMap(float dt)
|
2010-09-01 17:30:51 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
// IMPORTANT
|
|
|
|
// The only limitation is that you cannot change an empty, or assign an empty tile to a tile
|
|
|
|
// The value 0 not rendered so don't assign or change a tile with value 0
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto tilemap = (TileMapAtlas*) getChildByTag(kTagTileMap);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// For example you can iterate over all the tiles
|
|
|
|
// using this code, but try to avoid the iteration
|
|
|
|
// over all your tiles in every frame. It's very expensive
|
|
|
|
// for(int x=0; x < tilemap.tgaInfo->width; x++) {
|
|
|
|
// for(int y=0; y < tilemap.tgaInfo->height; y++) {
|
2013-07-12 14:30:26 +08:00
|
|
|
// Color3B c =[tilemap tileAt:Size(x,y));
|
2012-04-19 14:35:52 +08:00
|
|
|
// if( c.r != 0 ) {
|
2013-03-03 10:32:09 +08:00
|
|
|
// ////----CCLOG("%d,%d = %d", x,y,c.r);
|
2012-04-19 14:35:52 +08:00
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// NEW since v0.7
|
2014-05-15 01:07:09 +08:00
|
|
|
Color3B c = tilemap->getTileAt(Vec2(13,21));
|
2012-04-19 14:35:52 +08:00
|
|
|
c.r++;
|
|
|
|
c.r %= 50;
|
|
|
|
if( c.r==0)
|
|
|
|
c.r=1;
|
|
|
|
|
|
|
|
// NEW since v0.7
|
2014-05-15 01:07:09 +08:00
|
|
|
tilemap->setTile(c, Vec2(13,21) );
|
2010-09-01 17:30:51 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TileMapEditTest::title() const
|
2010-09-01 17:30:51 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "Editable TileMapAtlas";
|
2010-09-01 17:30:51 +08:00
|
|
|
}
|
2010-11-18 14:50:28 +08:00
|
|
|
|
2010-09-01 17:30:51 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TMXOrthoTest
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2010-11-18 14:50:28 +08:00
|
|
|
TMXOrthoTest::TMXOrthoTest()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
//
|
|
|
|
// Test orthogonal with 3d camera and anti-alias textures
|
|
|
|
//
|
|
|
|
// it should not flicker. No artifacts should appear
|
|
|
|
//
|
2013-08-16 16:05:27 +08:00
|
|
|
//auto color = LayerColor::create( Color4B(64,64,64,255) );
|
2012-04-19 14:35:52 +08:00
|
|
|
//addChild(color, -1);
|
|
|
|
|
2014-02-10 11:31:45 +08:00
|
|
|
auto map = TMXTiledMap::create("TileMaps/orthogonal-test2.tmx");
|
2014-02-07 10:47:45 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(map, 0, kTagTileMap);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size CC_UNUSED s = map->getContentSize();
|
2012-06-11 14:44:32 +08:00
|
|
|
CCLOG("ContentSize: %f, %f", s.width,s.height);
|
2014-02-06 11:51:24 +08:00
|
|
|
|
2014-03-24 10:12:40 +08:00
|
|
|
auto scale = ScaleBy::create(10, 0.1f);
|
2014-02-10 11:31:45 +08:00
|
|
|
auto back = scale->reverse();
|
2014-07-10 00:45:27 +08:00
|
|
|
auto seq = Sequence::create(scale, back, nullptr);
|
2014-02-10 11:31:45 +08:00
|
|
|
auto repeat = RepeatForever::create(seq);
|
|
|
|
map->runAction(repeat);
|
2010-09-01 17:30:51 +08:00
|
|
|
|
2013-12-21 08:33:31 +08:00
|
|
|
// float x, y, z;
|
|
|
|
// map->getCamera()->getEye(&x, &y, &z);
|
|
|
|
// map->getCamera()->setEye(x-200, y, z+300);
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
2010-09-01 17:30:51 +08:00
|
|
|
void TMXOrthoTest::onEnter()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
TileDemo::onEnter();
|
2010-09-01 17:30:51 +08:00
|
|
|
|
2013-07-26 04:36:19 +08:00
|
|
|
Director::getInstance()->setProjection(Director::Projection::_3D);
|
2010-09-01 17:30:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void TMXOrthoTest::onExit()
|
|
|
|
{
|
2014-04-02 17:12:09 +08:00
|
|
|
Director::getInstance()->setProjection(Director::Projection::DEFAULT);
|
2012-04-19 14:35:52 +08:00
|
|
|
TileDemo::onExit();
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
2010-09-01 17:30:51 +08:00
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXOrthoTest::title() const
|
2010-09-01 17:30:51 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "TMX Orthogonal test";
|
2010-09-01 17:30:51 +08:00
|
|
|
}
|
2010-11-18 14:50:28 +08:00
|
|
|
|
2014-10-11 15:09:58 +08:00
|
|
|
TMXStaggeredTest::TMXStaggeredTest()
|
|
|
|
{
|
|
|
|
|
|
|
|
auto map = TMXTiledMap::create("TileMaps/test-staggered.tmx");
|
|
|
|
|
|
|
|
addChild(map, 0, kTagTileMap);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void TMXStaggeredTest::onEnter()
|
|
|
|
{
|
|
|
|
TileDemo::onEnter();
|
|
|
|
|
|
|
|
Director::getInstance()->setProjection(Director::Projection::_3D);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TMXStaggeredTest::onExit()
|
|
|
|
{
|
|
|
|
Director::getInstance()->setProjection(Director::Projection::DEFAULT);
|
|
|
|
TileDemo::onExit();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string TMXStaggeredTest::title() const
|
|
|
|
{
|
|
|
|
return "TMX Staggered test";
|
|
|
|
}
|
|
|
|
|
2010-09-01 17:30:51 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TMXOrthoTest2
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2010-11-18 14:50:28 +08:00
|
|
|
TMXOrthoTest2::TMXOrthoTest2()
|
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto map = TMXTiledMap::create("TileMaps/orthogonal-test1.tmx");
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(map, 0, kTagTileMap);
|
2010-09-01 17:30:51 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size CC_UNUSED s = map->getContentSize();
|
2013-03-03 10:32:09 +08:00
|
|
|
CCLOG("ContentSize: %f, %f", s.width,s.height);
|
2010-09-01 17:30:51 +08:00
|
|
|
|
2013-12-17 17:45:29 +08:00
|
|
|
auto& children = map->getChildren();
|
2014-07-10 00:45:27 +08:00
|
|
|
SpriteBatchNode* child = nullptr;
|
2010-09-01 17:30:51 +08:00
|
|
|
|
2013-12-20 05:34:41 +08:00
|
|
|
for(const auto &obj : children) {
|
2013-11-29 10:37:40 +08:00
|
|
|
child = static_cast<SpriteBatchNode*>(obj);
|
2012-04-19 14:35:52 +08:00
|
|
|
child->getTexture()->setAntiAliasTexParameters();
|
2013-12-20 05:34:41 +08:00
|
|
|
}
|
2010-09-01 17:30:51 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
map->runAction( ScaleBy::create(2, 0.5f) ) ;
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
2010-09-01 17:30:51 +08:00
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXOrthoTest2::title() const
|
2010-09-01 17:30:51 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "TMX Ortho test2";
|
2010-09-01 17:30:51 +08:00
|
|
|
}
|
2010-11-18 14:50:28 +08:00
|
|
|
|
2010-09-01 17:30:51 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TMXOrthoTest3
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2010-11-18 14:50:28 +08:00
|
|
|
TMXOrthoTest3::TMXOrthoTest3()
|
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto map = TMXTiledMap::create("TileMaps/orthogonal-test3.tmx");
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(map, 0, kTagTileMap);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size CC_UNUSED s = map->getContentSize();
|
2013-03-03 10:32:09 +08:00
|
|
|
CCLOG("ContentSize: %f, %f", s.width,s.height);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-11-29 10:37:40 +08:00
|
|
|
auto& children = map->getChildren();
|
2014-07-10 00:45:27 +08:00
|
|
|
SpriteBatchNode* child = nullptr;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-12-20 05:34:41 +08:00
|
|
|
for(const auto &node : children) {
|
2013-11-29 10:37:40 +08:00
|
|
|
child = static_cast<SpriteBatchNode*>(node);
|
2012-04-19 14:35:52 +08:00
|
|
|
child->getTexture()->setAntiAliasTexParameters();
|
2013-12-20 05:34:41 +08:00
|
|
|
}
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
map->setScale(0.2f);
|
2014-05-15 01:07:09 +08:00
|
|
|
map->setAnchorPoint( Vec2(0.5f, 0.5f) );
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
2010-09-01 17:30:51 +08:00
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXOrthoTest3::title() const
|
2010-09-01 17:30:51 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "TMX anchorPoint test";
|
2010-09-01 17:30:51 +08:00
|
|
|
}
|
2010-11-18 14:50:28 +08:00
|
|
|
|
2010-09-01 17:30:51 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TMXOrthoTest4
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2010-11-18 14:50:28 +08:00
|
|
|
TMXOrthoTest4::TMXOrthoTest4()
|
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto map = TMXTiledMap::create("TileMaps/orthogonal-test4.tmx");
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(map, 0, kTagTileMap);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size CC_UNUSED s1 = map->getContentSize();
|
2013-03-03 10:32:09 +08:00
|
|
|
CCLOG("ContentSize: %f, %f", s1.width,s1.height);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-11-29 10:37:40 +08:00
|
|
|
SpriteBatchNode* child = nullptr;
|
2013-12-17 17:45:29 +08:00
|
|
|
|
|
|
|
auto& children = map->getChildren();
|
|
|
|
|
2013-12-20 05:34:41 +08:00
|
|
|
for(const auto &node : children) {
|
2013-11-29 10:37:40 +08:00
|
|
|
child = static_cast<SpriteBatchNode*>(node);
|
2012-04-19 14:35:52 +08:00
|
|
|
child->getTexture()->setAntiAliasTexParameters();
|
2013-12-20 05:34:41 +08:00
|
|
|
}
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
map->setAnchorPoint(Vec2(0, 0));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-24 06:20:22 +08:00
|
|
|
auto layer = map->getLayer("Layer 0");
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = layer->getLayerSize();
|
2016-04-13 03:51:09 +08:00
|
|
|
|
|
|
|
layer->setOpacity(128);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite* sprite;
|
2014-05-15 01:07:09 +08:00
|
|
|
sprite = layer->getTileAt(Vec2(0,0));
|
2012-04-19 14:35:52 +08:00
|
|
|
sprite->setScale(2);
|
2014-05-15 01:07:09 +08:00
|
|
|
sprite = layer->getTileAt(Vec2(s.width-1,0));
|
2012-04-19 14:35:52 +08:00
|
|
|
sprite->setScale(2);
|
2014-05-15 01:07:09 +08:00
|
|
|
sprite = layer->getTileAt(Vec2(0,s.height-1));
|
2012-04-19 14:35:52 +08:00
|
|
|
sprite->setScale(2);
|
2014-05-15 01:07:09 +08:00
|
|
|
sprite = layer->getTileAt(Vec2(s.width-1,s.height-1));
|
2012-04-19 14:35:52 +08:00
|
|
|
sprite->setScale(2);
|
|
|
|
|
2014-10-04 00:38:36 +08:00
|
|
|
schedule( CC_SCHEDULE_SELECTOR(TMXOrthoTest4::removeSprite), 2 );
|
2010-11-18 14:50:28 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-06-08 13:55:28 +08:00
|
|
|
void TMXOrthoTest4::removeSprite(float dt)
|
2010-11-18 14:50:28 +08:00
|
|
|
{
|
2014-10-04 00:38:36 +08:00
|
|
|
unschedule(CC_SCHEDULE_SELECTOR(TMXOrthoTest4::removeSprite));
|
2010-11-18 14:50:28 +08:00
|
|
|
|
2013-07-24 06:20:22 +08:00
|
|
|
auto map = static_cast<TMXTiledMap*>( getChildByTag(kTagTileMap) );
|
|
|
|
auto layer = map->getLayer("Layer 0");
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = layer->getLayerSize();
|
2010-11-18 14:50:28 +08:00
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
auto sprite = layer->getTileAt( Vec2(s.width-1,0) );
|
|
|
|
auto sprite2 = layer->getTileAt(Vec2(s.width-1, s.height-1));
|
2012-04-19 14:35:52 +08:00
|
|
|
layer->removeChild(sprite, true);
|
2014-05-15 01:07:09 +08:00
|
|
|
auto sprite3 = layer->getTileAt(Vec2(2, s.height-1));
|
2014-02-17 21:16:25 +08:00
|
|
|
layer->removeChild(sprite3, true);
|
|
|
|
layer->removeChild(sprite2, true);
|
2010-09-01 17:30:51 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXOrthoTest4::title() const
|
2010-09-01 17:30:51 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "TMX width/height test";
|
2010-09-01 17:30:51 +08:00
|
|
|
}
|
2010-11-18 14:50:28 +08:00
|
|
|
|
2010-09-01 17:30:51 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TMXReadWriteTest
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
enum
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
SID_UPDATECOL = 100,
|
|
|
|
SID_REPAINTWITHGID,
|
|
|
|
SID_REMOVETILES
|
2010-09-01 17:30:51 +08:00
|
|
|
};
|
|
|
|
|
2010-11-18 14:50:28 +08:00
|
|
|
TMXReadWriteTest::TMXReadWriteTest()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_gid = 0;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto map = TMXTiledMap::create("TileMaps/orthogonal-test2.tmx");
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(map, 0, kTagTileMap);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size CC_UNUSED s = map->getContentSize();
|
2013-03-03 10:32:09 +08:00
|
|
|
CCLOG("ContentSize: %f, %f", s.width,s.height);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto layer = map->getLayer("Layer 0");
|
2012-04-19 14:35:52 +08:00
|
|
|
layer->getTexture()->setAntiAliasTexParameters();
|
|
|
|
|
|
|
|
map->setScale( 1 );
|
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
auto tile0 = layer->getTileAt(Vec2(1,63));
|
|
|
|
auto tile1 = layer->getTileAt(Vec2(2,63));
|
|
|
|
auto tile2 = layer->getTileAt(Vec2(3,62));//Vec2(1,62));
|
|
|
|
auto tile3 = layer->getTileAt(Vec2(2,62));
|
|
|
|
tile0->setAnchorPoint( Vec2(0.5f, 0.5f) );
|
|
|
|
tile1->setAnchorPoint( Vec2(0.5f, 0.5f) );
|
|
|
|
tile2->setAnchorPoint( Vec2(0.5f, 0.5f) );
|
|
|
|
tile3->setAnchorPoint( Vec2(0.5f, 0.5f) );
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
auto move = MoveBy::create(0.5f, Vec2(0,160));
|
2013-08-16 16:05:27 +08:00
|
|
|
auto rotate = RotateBy::create(2, 360);
|
|
|
|
auto scale = ScaleBy::create(2, 5);
|
|
|
|
auto opacity = FadeOut::create(2);
|
|
|
|
auto fadein = FadeIn::create(2);
|
|
|
|
auto scaleback = ScaleTo::create(1, 1);
|
|
|
|
auto finish = CallFuncN::create(CC_CALLBACK_1(TMXReadWriteTest::removeSprite, this));
|
2014-07-10 00:45:27 +08:00
|
|
|
auto seq0 = Sequence::create(move, rotate, scale, opacity, fadein, scaleback, finish, nullptr);
|
2013-08-16 16:05:27 +08:00
|
|
|
auto seq1 = seq0->clone();
|
|
|
|
auto seq2 = seq0->clone();
|
|
|
|
auto seq3 = seq0->clone();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
tile0->runAction(seq0);
|
|
|
|
tile1->runAction(seq1);
|
|
|
|
tile2->runAction(seq2);
|
|
|
|
tile3->runAction(seq3);
|
|
|
|
|
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
_gid = layer->getTileGIDAt(Vec2(0,63));
|
2013-06-15 14:03:30 +08:00
|
|
|
////----CCLOG("Tile GID at:(0,63) is: %d", _gid);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2014-10-04 00:38:36 +08:00
|
|
|
schedule(CC_SCHEDULE_SELECTOR(TMXReadWriteTest::updateCol), 2.0f);
|
|
|
|
schedule(CC_SCHEDULE_SELECTOR(TMXReadWriteTest::repaintWithGID), 2.05f);
|
|
|
|
schedule(CC_SCHEDULE_SELECTOR(TMXReadWriteTest::removeTiles), 1.0f);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-03-03 10:32:09 +08:00
|
|
|
////----CCLOG("++++atlas quantity: %d", layer->textureAtlas()->getTotalQuads());
|
|
|
|
////----CCLOG("++++children: %d", layer->getChildren()->count() );
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_gid2 = 0;
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
2010-09-01 17:30:51 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
void TMXReadWriteTest::removeSprite(Node* sender)
|
2010-09-01 17:30:51 +08:00
|
|
|
{
|
2013-03-03 10:32:09 +08:00
|
|
|
////----CCLOG("removing tile: %x", sender);
|
2013-08-16 16:05:27 +08:00
|
|
|
auto p = ((Node*)sender)->getParent();
|
2010-09-01 17:30:51 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
if (p)
|
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
p->removeChild((Node*)sender, true);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-03-03 10:32:09 +08:00
|
|
|
//////----CCLOG("atlas quantity: %d", p->textureAtlas()->totalQuads());
|
2010-09-01 17:30:51 +08:00
|
|
|
}
|
|
|
|
|
2012-06-08 13:55:28 +08:00
|
|
|
void TMXReadWriteTest::updateCol(float dt)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto map = (TMXTiledMap*)getChildByTag(kTagTileMap);
|
|
|
|
auto layer = (TMXLayer*)map->getChildByTag(0);
|
2010-09-01 17:30:51 +08:00
|
|
|
|
2013-03-03 10:32:09 +08:00
|
|
|
////----CCLOG("++++atlas quantity: %d", layer->textureAtlas()->getTotalQuads());
|
|
|
|
////----CCLOG("++++children: %d", layer->getChildren()->count() );
|
2010-09-01 17:30:51 +08:00
|
|
|
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = layer->getLayerSize();
|
2010-09-01 17:30:51 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
for( int y=0; y< s.height; y++ )
|
|
|
|
{
|
2014-05-15 01:07:09 +08:00
|
|
|
layer->setTileGID(_gid2, Vec2((float)3, (float)y));
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_gid2 = (_gid2 + 1) % 80;
|
2010-09-01 17:30:51 +08:00
|
|
|
}
|
|
|
|
|
2012-06-08 13:55:28 +08:00
|
|
|
void TMXReadWriteTest::repaintWithGID(float dt)
|
2010-09-01 17:30:51 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
// unschedule:_cmd);
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto map = (TMXTiledMap*)getChildByTag(kTagTileMap);
|
|
|
|
auto layer = (TMXLayer*)map->getChildByTag(0);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = layer->getLayerSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
for( int x=0; x<s.width;x++)
|
|
|
|
{
|
|
|
|
int y = (int)s.height-1;
|
2014-05-15 01:07:09 +08:00
|
|
|
unsigned int tmpgid = layer->getTileGIDAt( Vec2((float)x, (float)y) );
|
|
|
|
layer->setTileGID(tmpgid+1, Vec2((float)x, (float)y));
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
2010-09-01 17:30:51 +08:00
|
|
|
}
|
|
|
|
|
2012-06-08 13:55:28 +08:00
|
|
|
void TMXReadWriteTest::removeTiles(float dt)
|
2010-09-01 17:30:51 +08:00
|
|
|
{
|
2014-10-04 00:38:36 +08:00
|
|
|
unschedule(CC_SCHEDULE_SELECTOR(TMXReadWriteTest::removeTiles));
|
2010-09-01 17:30:51 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto map = (TMXTiledMap*)getChildByTag(kTagTileMap);
|
|
|
|
auto layer = (TMXLayer*)map->getChildByTag(0);
|
|
|
|
auto s = layer->getLayerSize();
|
2010-09-01 17:30:51 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
for( int y=0; y< s.height; y++ )
|
|
|
|
{
|
2014-05-15 01:07:09 +08:00
|
|
|
layer->removeTileAt( Vec2(5.0, (float)y) );
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
2010-09-01 17:30:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXReadWriteTest::title() const
|
2010-09-01 17:30:51 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "TMX Read/Write test";
|
2010-09-01 17:30:51 +08:00
|
|
|
}
|
2010-11-18 14:50:28 +08:00
|
|
|
|
2010-09-01 17:30:51 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TMXHexTest
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2010-11-18 14:50:28 +08:00
|
|
|
TMXHexTest::TMXHexTest()
|
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto color = LayerColor::create( Color4B(64,64,64,255) );
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(color, -1);
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto map = TMXTiledMap::create("TileMaps/hexa-test.tmx");
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(map, 0, kTagTileMap);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size CC_UNUSED s = map->getContentSize();
|
2013-03-03 10:32:09 +08:00
|
|
|
CCLOG("ContentSize: %f, %f", s.width,s.height);
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
2010-09-01 17:30:51 +08:00
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXHexTest::title() const
|
2010-09-01 17:30:51 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "TMX Hex tes";
|
2010-09-01 17:30:51 +08:00
|
|
|
}
|
2010-11-18 14:50:28 +08:00
|
|
|
|
2010-09-01 17:30:51 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TMXIsoTest
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2010-11-18 14:50:28 +08:00
|
|
|
TMXIsoTest::TMXIsoTest()
|
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto color = LayerColor::create( Color4B(64,64,64,255) );
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(color, -1);
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto map = TMXTiledMap::create("TileMaps/iso-test.tmx");
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(map, 0, kTagTileMap);
|
|
|
|
|
|
|
|
// move map to the center of the screen
|
2013-08-16 16:05:27 +08:00
|
|
|
auto ms = map->getMapSize();
|
|
|
|
auto ts = map->getTileSize();
|
2014-05-15 01:07:09 +08:00
|
|
|
map->runAction( MoveTo::create(1.0f, Vec2( -ms.width * ts.width/2, -ms.height * ts.height/2 )) );
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
2010-09-01 17:30:51 +08:00
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXIsoTest::title() const
|
2010-09-01 17:30:51 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "TMX Isometric test 0";
|
2010-09-01 17:30:51 +08:00
|
|
|
}
|
2010-11-18 14:50:28 +08:00
|
|
|
|
2010-09-01 17:30:51 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TMXIsoTest1
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2010-11-18 14:50:28 +08:00
|
|
|
TMXIsoTest1::TMXIsoTest1()
|
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto color = LayerColor::create( Color4B(64,64,64,255) );
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(color, -1);
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto map = TMXTiledMap::create("TileMaps/iso-test1.tmx");
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(map, 0, kTagTileMap);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size CC_UNUSED s = map->getContentSize();
|
2013-03-03 10:32:09 +08:00
|
|
|
CCLOG("ContentSize: %f, %f", s.width,s.height);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
map->setAnchorPoint(Vec2(0.5f, 0.5f));
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
2010-09-01 17:30:51 +08:00
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXIsoTest1::title() const
|
2010-09-01 17:30:51 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "TMX Isometric test + anchorPoint";
|
2010-09-01 17:30:51 +08:00
|
|
|
}
|
2010-11-18 14:50:28 +08:00
|
|
|
|
2010-09-01 17:30:51 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TMXIsoTest2
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2010-11-18 14:50:28 +08:00
|
|
|
TMXIsoTest2::TMXIsoTest2()
|
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto color = LayerColor::create( Color4B(64,64,64,255) );
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(color, -1);
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto map = TMXTiledMap::create("TileMaps/iso-test2.tmx");
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(map, 0, kTagTileMap);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size CC_UNUSED s = map->getContentSize();
|
2013-03-03 10:32:09 +08:00
|
|
|
CCLOG("ContentSize: %f, %f", s.width,s.height);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// move map to the center of the screen
|
2013-08-16 16:05:27 +08:00
|
|
|
auto ms = map->getMapSize();
|
|
|
|
auto ts = map->getTileSize();
|
2014-05-15 01:07:09 +08:00
|
|
|
map->runAction( MoveTo::create(1.0f, Vec2( -ms.width * ts.width/2, -ms.height * ts.height/2 ) ));
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
2010-09-01 17:30:51 +08:00
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXIsoTest2::title() const
|
2010-09-01 17:30:51 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "TMX Isometric test 2";
|
2010-09-01 17:30:51 +08:00
|
|
|
}
|
2010-11-18 14:50:28 +08:00
|
|
|
|
2010-09-01 17:30:51 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TMXUncompressedTest
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2010-11-18 14:50:28 +08:00
|
|
|
TMXUncompressedTest::TMXUncompressedTest()
|
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto color = LayerColor::create( Color4B(64,64,64,255) );
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(color, -1);
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto map = TMXTiledMap::create("TileMaps/iso-test2-uncompressed.tmx");
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(map, 0, kTagTileMap);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size CC_UNUSED s = map->getContentSize();
|
2013-03-03 10:32:09 +08:00
|
|
|
CCLOG("ContentSize: %f, %f", s.width,s.height);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// move map to the center of the screen
|
2013-08-16 16:05:27 +08:00
|
|
|
auto ms = map->getMapSize();
|
|
|
|
auto ts = map->getTileSize();
|
2014-05-15 01:07:09 +08:00
|
|
|
map->runAction(MoveTo::create(1.0f, Vec2( -ms.width * ts.width/2, -ms.height * ts.height/2 ) ));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// testing release map
|
2013-06-20 14:17:10 +08:00
|
|
|
TMXLayer* layer;
|
2013-12-17 17:45:29 +08:00
|
|
|
|
|
|
|
auto& children = map->getChildren();
|
2013-12-20 05:34:41 +08:00
|
|
|
for(const auto &node : children) {
|
2013-11-29 10:37:40 +08:00
|
|
|
layer= static_cast<TMXLayer*>(node);
|
2012-04-19 14:35:52 +08:00
|
|
|
layer->releaseMap();
|
2013-12-20 05:34:41 +08:00
|
|
|
}
|
2010-09-01 17:30:51 +08:00
|
|
|
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
2010-09-01 17:30:51 +08:00
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXUncompressedTest::title() const
|
2010-09-01 17:30:51 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "TMX Uncompressed test";
|
2010-09-01 17:30:51 +08:00
|
|
|
}
|
2010-11-18 14:50:28 +08:00
|
|
|
|
2010-09-01 17:30:51 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TMXTilesetTest
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2010-11-18 14:50:28 +08:00
|
|
|
TMXTilesetTest::TMXTilesetTest()
|
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto map = TMXTiledMap::create("TileMaps/orthogonal-test5.tmx");
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(map, 0, kTagTileMap);
|
2016-04-13 03:51:09 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size CC_UNUSED s = map->getContentSize();
|
2013-03-03 10:32:09 +08:00
|
|
|
CCLOG("ContentSize: %f, %f", s.width,s.height);
|
2016-04-13 03:51:09 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
TMXLayer* layer;
|
2013-07-24 06:20:22 +08:00
|
|
|
layer = map->getLayer("Layer 0");
|
2012-04-19 14:35:52 +08:00
|
|
|
layer->getTexture()->setAntiAliasTexParameters();
|
2016-04-13 03:51:09 +08:00
|
|
|
|
2013-07-24 06:20:22 +08:00
|
|
|
layer = map->getLayer("Layer 1");
|
2012-04-19 14:35:52 +08:00
|
|
|
layer->getTexture()->setAntiAliasTexParameters();
|
2010-09-01 17:30:51 +08:00
|
|
|
|
2013-07-24 06:20:22 +08:00
|
|
|
layer = map->getLayer("Layer 2");
|
2012-04-19 14:35:52 +08:00
|
|
|
layer->getTexture()->setAntiAliasTexParameters();
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
2010-09-01 17:30:51 +08:00
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXTilesetTest::title() const
|
2010-09-01 17:30:51 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "TMX Tileset test";
|
2010-09-01 17:30:51 +08:00
|
|
|
}
|
2010-11-18 14:50:28 +08:00
|
|
|
|
2016-04-13 03:51:09 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TMXCvsFormatTest
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
|
|
|
|
TMXCvsFormatTest::TMXCvsFormatTest()
|
|
|
|
{
|
|
|
|
auto map = TMXTiledMap::create("TileMaps/orthogonal-test5-csv.tmx");
|
|
|
|
CCASSERT(map, "Map was not created. Probably failed to parse!");
|
|
|
|
addChild(map, 0, kTagTileMap);
|
|
|
|
|
|
|
|
Size CC_UNUSED s = map->getContentSize();
|
|
|
|
CCLOG("ContentSize: %f, %f", s.width,s.height);
|
|
|
|
|
|
|
|
TMXLayer* layer;
|
|
|
|
layer = map->getLayer("Layer 0");
|
|
|
|
layer->getTexture()->setAntiAliasTexParameters();
|
|
|
|
|
|
|
|
layer = map->getLayer("Layer 1");
|
|
|
|
layer->getTexture()->setAntiAliasTexParameters();
|
|
|
|
|
|
|
|
layer = map->getLayer("Layer 2");
|
|
|
|
layer->getTexture()->setAntiAliasTexParameters();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string TMXCvsFormatTest::title() const
|
|
|
|
{
|
|
|
|
return "TMX CSV Parsing test";
|
|
|
|
}
|
|
|
|
|
2010-09-01 17:30:51 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TMXOrthoObjectsTest
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2010-11-18 14:50:28 +08:00
|
|
|
TMXOrthoObjectsTest::TMXOrthoObjectsTest()
|
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto map = TMXTiledMap::create("TileMaps/ortho-objects.tmx");
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(map, -1, kTagTileMap);
|
2016-04-13 03:51:09 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size CC_UNUSED s = map->getContentSize();
|
2013-03-03 10:32:09 +08:00
|
|
|
CCLOG("ContentSize: %f, %f", s.width,s.height);
|
2016-04-13 03:51:09 +08:00
|
|
|
|
2013-07-24 06:20:22 +08:00
|
|
|
auto group = map->getObjectGroup("Object Group 1");
|
2013-12-03 14:47:35 +08:00
|
|
|
auto& objects = group->getObjects();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-12-18 16:03:07 +08:00
|
|
|
Value objectsVal = Value(objects);
|
|
|
|
CCLOG("%s", objectsVal.getDescription().c_str());
|
2013-12-26 11:19:09 +08:00
|
|
|
|
2014-09-11 15:39:56 +08:00
|
|
|
auto drawNode = DrawNode::create();
|
2016-04-13 03:51:09 +08:00
|
|
|
|
2013-12-03 14:47:35 +08:00
|
|
|
for (auto& obj : objects)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-12-04 17:46:57 +08:00
|
|
|
ValueMap& dict = obj.asValueMap();
|
2016-04-13 03:51:09 +08:00
|
|
|
|
2013-12-03 14:47:35 +08:00
|
|
|
float x = dict["x"].asFloat();
|
|
|
|
float y = dict["y"].asFloat();
|
|
|
|
float width = dict["width"].asFloat();
|
|
|
|
float height = dict["height"].asFloat();
|
2016-04-13 03:51:09 +08:00
|
|
|
|
2014-09-11 15:39:56 +08:00
|
|
|
Color4F color(1.0, 1.0, 1.0, 1.0);
|
2016-04-13 03:51:09 +08:00
|
|
|
|
2014-09-11 15:39:56 +08:00
|
|
|
drawNode->drawLine( Vec2(x, y), Vec2((x+width), y), color );
|
|
|
|
drawNode->drawLine( Vec2((x+width), y), Vec2((x+width), (y+height)), color );
|
|
|
|
drawNode->drawLine( Vec2((x+width), (y+height)), Vec2(x, (y+height)), color );
|
|
|
|
drawNode->drawLine( Vec2(x, (y+height)), Vec2(x, y), color );
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
2014-09-11 15:39:56 +08:00
|
|
|
map->addChild(drawNode);
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXOrthoObjectsTest::title() const
|
2010-11-18 14:50:28 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "TMX Ortho object test";
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXOrthoObjectsTest::subtitle() const
|
2010-11-18 14:50:28 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "You should see a white box around the 3 platforms";
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-01 17:30:51 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TMXIsoObjectsTest
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2010-11-18 14:50:28 +08:00
|
|
|
|
|
|
|
TMXIsoObjectsTest::TMXIsoObjectsTest()
|
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto map = TMXTiledMap::create("TileMaps/iso-test-objectgroup.tmx");
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(map, -1, kTagTileMap);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size CC_UNUSED s = map->getContentSize();
|
2013-03-03 10:32:09 +08:00
|
|
|
CCLOG("ContentSize: %f, %f", s.width,s.height);
|
2010-11-18 14:50:28 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto group = map->getObjectGroup("Object Group 1");
|
2010-11-18 14:50:28 +08:00
|
|
|
|
2013-12-03 14:47:35 +08:00
|
|
|
auto& objects = group->getObjects();
|
2013-12-18 16:03:07 +08:00
|
|
|
|
|
|
|
Value objectsVal = Value(objects);
|
|
|
|
CCLOG("%s", objectsVal.getDescription().c_str());
|
2014-09-11 15:39:56 +08:00
|
|
|
|
|
|
|
auto drawNode = DrawNode::create();
|
|
|
|
|
2013-12-03 14:47:35 +08:00
|
|
|
for (auto& obj : objects)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-12-04 17:46:57 +08:00
|
|
|
ValueMap& dict = obj.asValueMap();
|
2014-09-11 15:39:56 +08:00
|
|
|
|
2013-12-03 14:47:35 +08:00
|
|
|
float x = dict["x"].asFloat();
|
|
|
|
float y = dict["y"].asFloat();
|
|
|
|
float width = dict["width"].asFloat();
|
|
|
|
float height = dict["height"].asFloat();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2014-09-11 15:39:56 +08:00
|
|
|
Color4F color(1.0, 1.0, 1.0, 1.0);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2014-09-11 15:39:56 +08:00
|
|
|
drawNode->drawLine( Vec2(x, y), Vec2((x+width), y), color );
|
|
|
|
drawNode->drawLine( Vec2((x+width), y), Vec2((x+width), (y+height)), color );
|
|
|
|
drawNode->drawLine( Vec2((x+width), (y+height)), Vec2(x, (y+height)), color );
|
|
|
|
drawNode->drawLine( Vec2(x, (y+height)), Vec2(x, y), color );
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
2014-09-11 15:39:56 +08:00
|
|
|
map->addChild(drawNode, 10);
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXIsoObjectsTest::title() const
|
2010-11-18 14:50:28 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "TMX Iso object test";
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXIsoObjectsTest::subtitle() const
|
2010-11-18 14:50:28 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "You need to parse them manually. See bug #810";
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-01 17:30:51 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TMXResizeTest
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2010-11-18 14:50:28 +08:00
|
|
|
|
|
|
|
TMXResizeTest::TMXResizeTest()
|
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto map = TMXTiledMap::create("TileMaps/orthogonal-test5.tmx");
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(map, 0, kTagTileMap);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size CC_UNUSED s = map->getContentSize();
|
2013-03-03 10:32:09 +08:00
|
|
|
CCLOG("ContentSize: %f, %f", s.width,s.height);
|
2010-11-18 14:50:28 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
TMXLayer* layer;
|
2013-07-24 06:20:22 +08:00
|
|
|
layer = map->getLayer("Layer 0");
|
2010-11-18 14:50:28 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto ls = layer->getLayerSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
for (unsigned int y = 0; y < ls.height; y++)
|
|
|
|
{
|
|
|
|
for (unsigned int x = 0; x < ls.width; x++)
|
|
|
|
{
|
2014-05-15 01:07:09 +08:00
|
|
|
layer->setTileGID(1, Vec2( x, y ) );
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXResizeTest::title() const
|
2010-11-18 14:50:28 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "TMX resize test";
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXResizeTest::subtitle() const
|
2010-11-18 14:50:28 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "Should not crash. Testing issue #740";
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-01 17:30:51 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TMXIsoZorder
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2010-11-18 14:50:28 +08:00
|
|
|
TMXIsoZorder::TMXIsoZorder()
|
|
|
|
{
|
2019-06-30 11:36:52 +08:00
|
|
|
Director::getInstance()->getRenderer()->setDepthTest(false);
|
2013-08-16 16:05:27 +08:00
|
|
|
auto map = TMXTiledMap::create("TileMaps/iso-test-zorder.tmx");
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(map, 0, kTagTileMap);
|
2011-02-23 16:47:25 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = map->getContentSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
CCLOG("ContentSize: %f, %f", s.width,s.height);
|
2014-05-15 01:07:09 +08:00
|
|
|
map->setPosition(Vec2(-s.width/2,0));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-24 06:20:22 +08:00
|
|
|
_tamara = Sprite::create(s_pathSister1);
|
2014-03-20 16:24:55 +08:00
|
|
|
map->addChild(_tamara, (int)map->getChildren().size() );
|
2017-09-08 09:28:35 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_tamara->retain();
|
2012-04-19 14:35:52 +08:00
|
|
|
int mapWidth = map->getMapSize().width * map->getTileSize().width;
|
2014-05-15 01:07:09 +08:00
|
|
|
_tamara->setPosition(CC_POINT_PIXELS_TO_POINTS(Vec2( mapWidth/2,0)));
|
2017-09-08 09:28:35 +08:00
|
|
|
_tamara->setScale(0.5);
|
2014-05-15 01:07:09 +08:00
|
|
|
_tamara->setAnchorPoint(Vec2(0.5f,0));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
auto move = MoveBy::create(10, Vec2(300,250));
|
2013-08-16 16:05:27 +08:00
|
|
|
auto back = move->reverse();
|
2014-07-10 00:45:27 +08:00
|
|
|
auto seq = Sequence::create(move, back,nullptr);
|
2013-06-20 14:17:10 +08:00
|
|
|
_tamara->runAction( RepeatForever::create(seq) );
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2014-10-04 00:38:36 +08:00
|
|
|
schedule( CC_SCHEDULE_SELECTOR(TMXIsoZorder::repositionSprite) );
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TMXIsoZorder::~TMXIsoZorder()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_tamara->release();
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void TMXIsoZorder::onExit()
|
|
|
|
{
|
2014-10-04 00:38:36 +08:00
|
|
|
unschedule(CC_SCHEDULE_SELECTOR(TMXIsoZorder::repositionSprite));
|
2012-04-19 14:35:52 +08:00
|
|
|
TileDemo::onExit();
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
2012-06-08 13:55:28 +08:00
|
|
|
void TMXIsoZorder::repositionSprite(float dt)
|
2010-11-18 14:50:28 +08:00
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto p = _tamara->getPosition();
|
2012-04-19 14:35:52 +08:00
|
|
|
p = CC_POINT_POINTS_TO_PIXELS(p);
|
2013-08-16 16:05:27 +08:00
|
|
|
auto map = getChildByTag(kTagTileMap);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// there are only 4 layers. (grass and 3 trees layers)
|
2017-09-08 09:28:35 +08:00
|
|
|
// if tamara < 30, z=4
|
|
|
|
// if tamara < 60, z=3
|
|
|
|
// if tamara < 90,z=2
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2017-09-08 09:28:35 +08:00
|
|
|
int newZ = 4 - (static_cast<int>(p.y) / 30);
|
2013-12-19 03:45:30 +08:00
|
|
|
newZ = std::max(newZ,0);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
map->reorderChild(_tamara, newZ);
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXIsoZorder::title() const
|
2010-11-18 14:50:28 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "TMX Iso Zorder";
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXIsoZorder::subtitle() const
|
2010-11-18 14:50:28 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "Sprite should hide behind the trees";
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-01 17:30:51 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TMXOrthoZorder
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2010-11-18 14:50:28 +08:00
|
|
|
TMXOrthoZorder::TMXOrthoZorder()
|
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto map = TMXTiledMap::create("TileMaps/orthogonal-test-zorder.tmx");
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(map, 0, kTagTileMap);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size CC_UNUSED s = map->getContentSize();
|
2013-03-03 10:32:09 +08:00
|
|
|
CCLOG("ContentSize: %f, %f", s.width,s.height);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-24 06:20:22 +08:00
|
|
|
_tamara = Sprite::create(s_pathSister1);
|
2014-03-20 16:24:55 +08:00
|
|
|
map->addChild(_tamara, (int)map->getChildren().size());
|
2013-06-15 14:03:30 +08:00
|
|
|
_tamara->retain();
|
2014-05-15 01:07:09 +08:00
|
|
|
_tamara->setAnchorPoint(Vec2(0.5f,0));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
auto move = MoveBy::create(10, Vec2(400,450));
|
2013-08-16 16:05:27 +08:00
|
|
|
auto back = move->reverse();
|
2014-07-10 00:45:27 +08:00
|
|
|
auto seq = Sequence::create(move, back,nullptr);
|
2013-06-20 14:17:10 +08:00
|
|
|
_tamara->runAction( RepeatForever::create(seq));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2014-10-04 00:38:36 +08:00
|
|
|
schedule( CC_SCHEDULE_SELECTOR(TMXOrthoZorder::repositionSprite));
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TMXOrthoZorder::~TMXOrthoZorder()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_tamara->release();
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
2012-06-08 13:55:28 +08:00
|
|
|
void TMXOrthoZorder::repositionSprite(float dt)
|
2010-11-18 14:50:28 +08:00
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto p = _tamara->getPosition();
|
2012-04-19 14:35:52 +08:00
|
|
|
p = CC_POINT_POINTS_TO_PIXELS(p);
|
2013-08-16 16:05:27 +08:00
|
|
|
auto map = getChildByTag(kTagTileMap);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// there are only 4 layers. (grass and 3 trees layers)
|
|
|
|
// if tamara < 81, z=4
|
|
|
|
// if tamara < 162, z=3
|
|
|
|
// if tamara < 243,z=2
|
2010-11-18 14:50:28 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// -10: customization for this particular sample
|
|
|
|
int newZ = 4 - ( (p.y-10) / 81);
|
2013-12-19 03:45:30 +08:00
|
|
|
newZ = std::max(newZ,0);
|
2010-11-18 14:50:28 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
map->reorderChild(_tamara, newZ);
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXOrthoZorder::title() const
|
2010-11-18 14:50:28 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "TMX Ortho Zorder";
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXOrthoZorder::subtitle() const
|
2010-11-18 14:50:28 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "Sprite should hide behind the trees";
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-01 17:30:51 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TMXIsoVertexZ
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2010-11-18 14:50:28 +08:00
|
|
|
TMXIsoVertexZ::TMXIsoVertexZ()
|
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto map = TMXTiledMap::create("TileMaps/iso-test-vertexz.tmx");
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(map, 0, kTagTileMap);
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = map->getContentSize();
|
2014-05-15 01:07:09 +08:00
|
|
|
map->setPosition( Vec2(-s.width/2,0) );
|
2012-04-19 14:35:52 +08:00
|
|
|
CCLOG("ContentSize: %f, %f", s.width,s.height);
|
|
|
|
|
|
|
|
// because I'm lazy, I'm reusing a tile as an sprite, but since this method uses vertexZ, you
|
2013-06-20 14:17:10 +08:00
|
|
|
// can use any Sprite and it will work OK.
|
2013-08-16 16:05:27 +08:00
|
|
|
auto layer = map->getLayer("Trees");
|
2014-05-15 01:07:09 +08:00
|
|
|
_tamara = layer->getTileAt( Vec2(29,29) );
|
2013-06-15 14:03:30 +08:00
|
|
|
_tamara->retain();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
auto move = MoveBy::create(10, Vec2(300,250) * (1/CC_CONTENT_SCALE_FACTOR()));
|
2013-08-16 16:05:27 +08:00
|
|
|
auto back = move->reverse();
|
2014-07-10 00:45:27 +08:00
|
|
|
auto seq = Sequence::create(move, back,nullptr);
|
2013-06-20 14:17:10 +08:00
|
|
|
_tamara->runAction( RepeatForever::create(seq) );
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2014-10-04 00:38:36 +08:00
|
|
|
schedule( CC_SCHEDULE_SELECTOR(TMXIsoVertexZ::repositionSprite));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TMXIsoVertexZ::~TMXIsoVertexZ()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_tamara->release();
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
2012-06-08 13:55:28 +08:00
|
|
|
void TMXIsoVertexZ::repositionSprite(float dt)
|
2010-11-18 14:50:28 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
// tile height is 64x32
|
|
|
|
// map size: 30x30
|
2013-08-16 16:05:27 +08:00
|
|
|
auto p = _tamara->getPosition();
|
2012-04-19 14:35:52 +08:00
|
|
|
p = CC_POINT_POINTS_TO_PIXELS(p);
|
|
|
|
float newZ = -(p.y+32) /16;
|
2014-03-24 10:12:40 +08:00
|
|
|
_tamara->setPositionZ( newZ );
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void TMXIsoVertexZ::onEnter()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
TileDemo::onEnter();
|
|
|
|
|
|
|
|
// TIP: 2d projection should be used
|
2013-07-26 04:36:19 +08:00
|
|
|
Director::getInstance()->setProjection(Director::Projection::_2D);
|
2019-06-30 11:36:52 +08:00
|
|
|
Director::getInstance()->getRenderer()->setDepthTest(true);
|
|
|
|
Director::getInstance()->getRenderer()->setDepthWrite(true);
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void TMXIsoVertexZ::onExit()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
// At exit use any other projection.
|
2014-04-02 17:12:09 +08:00
|
|
|
Director::getInstance()->setProjection(Director::Projection::DEFAULT);
|
2019-06-30 11:36:52 +08:00
|
|
|
Director::getInstance()->getRenderer()->setDepthTest(false);
|
|
|
|
Director::getInstance()->getRenderer()->setDepthWrite(false);
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
TileDemo::onExit();
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXIsoVertexZ::title() const
|
2010-11-18 14:50:28 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "TMX Iso VertexZ";
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXIsoVertexZ::subtitle() const
|
2010-11-18 14:50:28 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "Sprite should hide behind the trees";
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-01 17:30:51 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TMXOrthoVertexZ
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2010-11-18 14:50:28 +08:00
|
|
|
TMXOrthoVertexZ::TMXOrthoVertexZ()
|
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto map = TMXTiledMap::create("TileMaps/orthogonal-test-vertexz.tmx");
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(map, 0, kTagTileMap);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size CC_UNUSED s = map->getContentSize();
|
2013-03-03 10:32:09 +08:00
|
|
|
CCLOG("ContentSize: %f, %f", s.width,s.height);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// because I'm lazy, I'm reusing a tile as an sprite, but since this method uses vertexZ, you
|
2013-06-20 14:17:10 +08:00
|
|
|
// can use any Sprite and it will work OK.
|
2013-08-16 16:05:27 +08:00
|
|
|
auto layer = map->getLayer("trees");
|
2014-05-15 01:07:09 +08:00
|
|
|
_tamara = layer->getTileAt(Vec2(0,11));
|
2014-03-24 10:12:40 +08:00
|
|
|
CCLOG("%p vertexZ: %f", _tamara, _tamara->getPositionZ());
|
2013-06-15 14:03:30 +08:00
|
|
|
_tamara->retain();
|
2010-11-18 14:50:28 +08:00
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
auto move = MoveBy::create(10, Vec2(400,450) * (1/CC_CONTENT_SCALE_FACTOR()));
|
2013-08-16 16:05:27 +08:00
|
|
|
auto back = move->reverse();
|
2014-07-10 00:45:27 +08:00
|
|
|
auto seq = Sequence::create(move, back,nullptr);
|
2013-06-20 14:17:10 +08:00
|
|
|
_tamara->runAction( RepeatForever::create(seq));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2014-10-04 00:38:36 +08:00
|
|
|
schedule(CC_SCHEDULE_SELECTOR(TMXOrthoVertexZ::repositionSprite));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TMXOrthoVertexZ::~TMXOrthoVertexZ()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_tamara->release();
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
2012-06-08 13:55:28 +08:00
|
|
|
void TMXOrthoVertexZ::repositionSprite(float dt)
|
2010-11-18 14:50:28 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
// tile height is 101x81
|
|
|
|
// map size: 12x12
|
2013-08-16 16:05:27 +08:00
|
|
|
auto p = _tamara->getPosition();
|
2012-04-19 14:35:52 +08:00
|
|
|
p = CC_POINT_POINTS_TO_PIXELS(p);
|
2014-03-24 10:12:40 +08:00
|
|
|
_tamara->setPositionZ( -( (p.y+81) /81) );
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void TMXOrthoVertexZ::onEnter()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
TileDemo::onEnter();
|
|
|
|
|
|
|
|
// TIP: 2d projection should be used
|
2013-07-26 04:36:19 +08:00
|
|
|
Director::getInstance()->setProjection(Director::Projection::_2D);
|
2019-06-30 11:36:52 +08:00
|
|
|
Director::getInstance()->getRenderer()->setDepthTest(true);
|
|
|
|
Director::getInstance()->getRenderer()->setDepthWrite(true);
|
|
|
|
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void TMXOrthoVertexZ::onExit()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
// At exit use any other projection.
|
2014-04-02 17:12:09 +08:00
|
|
|
Director::getInstance()->setProjection(Director::Projection::DEFAULT);
|
2019-06-30 11:36:52 +08:00
|
|
|
Director::getInstance()->getRenderer()->setDepthTest(false);
|
|
|
|
Director::getInstance()->getRenderer()->setDepthWrite(false);
|
2012-04-19 14:35:52 +08:00
|
|
|
TileDemo::onExit();
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXOrthoVertexZ::title() const
|
2010-11-18 14:50:28 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "TMX Ortho vertexZ";
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXOrthoVertexZ::subtitle() const
|
2010-11-18 14:50:28 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "Sprite should hide behind the trees";
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-01 17:30:51 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TMXIsoMoveLayer
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2010-11-18 14:50:28 +08:00
|
|
|
TMXIsoMoveLayer::TMXIsoMoveLayer()
|
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto map = TMXTiledMap::create("TileMaps/iso-test-movelayer.tmx");
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(map, 0, kTagTileMap);
|
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
map->setPosition(Vec2(-700,-50));
|
2010-11-18 14:50:28 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size CC_UNUSED s = map->getContentSize();
|
2013-03-03 10:32:09 +08:00
|
|
|
CCLOG("ContentSize: %f, %f", s.width,s.height);
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXIsoMoveLayer::title() const
|
2010-11-18 14:50:28 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "TMX Iso Move Layer";
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXIsoMoveLayer::subtitle() const
|
2010-11-18 14:50:28 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "Trees should be horizontally aligned";
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-01 17:30:51 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TMXOrthoMoveLayer
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2010-11-18 14:50:28 +08:00
|
|
|
TMXOrthoMoveLayer::TMXOrthoMoveLayer()
|
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto map = TMXTiledMap::create("TileMaps/orthogonal-test-movelayer.tmx");
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(map, 0, kTagTileMap);
|
2010-11-18 14:50:28 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size CC_UNUSED s = map->getContentSize();
|
2013-03-03 10:32:09 +08:00
|
|
|
CCLOG("ContentSize: %f, %f", s.width,s.height);
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXOrthoMoveLayer::title() const
|
2010-11-18 14:50:28 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "TMX Ortho Move Layer";
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXOrthoMoveLayer::subtitle() const
|
2010-11-18 14:50:28 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "Trees should be horizontally aligned";
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
2012-03-26 16:46:23 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TMXTilePropertyTest
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2012-04-08 14:16:29 +08:00
|
|
|
|
|
|
|
TMXTilePropertyTest::TMXTilePropertyTest()
|
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto map = TMXTiledMap::create("TileMaps/ortho-tile-property.tmx");
|
2012-04-08 14:16:29 +08:00
|
|
|
addChild(map ,0 ,kTagTileMap);
|
2019-03-13 15:06:30 +08:00
|
|
|
|
2012-04-08 14:16:29 +08:00
|
|
|
for(int i=1;i<=20;i++){
|
2013-12-30 11:33:41 +08:00
|
|
|
for(const auto& value : map->getPropertiesForGID(i).asValueMap())
|
|
|
|
{
|
|
|
|
log("GID:%i, Properties:%s, %s", i, value.first.c_str(), value.second.asString().c_str());
|
|
|
|
}
|
2012-04-08 14:16:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXTilePropertyTest::title() const
|
2012-04-08 14:16:29 +08:00
|
|
|
{
|
|
|
|
return "TMX Tile Property Test";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXTilePropertyTest::subtitle() const
|
2012-04-08 14:16:29 +08:00
|
|
|
{
|
|
|
|
return "In the console you should see tile properties";
|
|
|
|
}
|
|
|
|
|
2012-03-26 16:46:23 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TMXOrthoFlipTest
|
|
|
|
//
|
2012-04-08 14:16:29 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
|
|
|
|
TMXOrthoFlipTest::TMXOrthoFlipTest()
|
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto map = TMXTiledMap::create("TileMaps/ortho-rotation-test.tmx");
|
2012-04-08 14:16:29 +08:00
|
|
|
addChild(map, 0, kTagTileMap);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size CC_UNUSED s = map->getContentSize();
|
2013-07-24 06:20:22 +08:00
|
|
|
log("ContentSize: %f, %f", s.width,s.height);
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2013-12-17 17:45:29 +08:00
|
|
|
auto& children = map->getChildren();
|
2013-12-20 05:34:41 +08:00
|
|
|
for(const auto &node : children) {
|
2013-11-29 10:37:40 +08:00
|
|
|
auto child = static_cast<SpriteBatchNode*>(node);
|
2012-04-08 14:16:29 +08:00
|
|
|
child->getTexture()->setAntiAliasTexParameters();
|
2013-12-20 05:34:41 +08:00
|
|
|
}
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto action = ScaleBy::create(2, 0.5f);
|
2012-04-08 14:16:29 +08:00
|
|
|
map->runAction(action);
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXOrthoFlipTest::title() const
|
2012-04-08 14:16:29 +08:00
|
|
|
{
|
|
|
|
return "TMX tile flip test";
|
|
|
|
}
|
|
|
|
|
2012-03-26 16:46:23 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TMXOrthoFlipRunTimeTest
|
|
|
|
//
|
2012-04-08 14:16:29 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
|
|
|
|
TMXOrthoFlipRunTimeTest::TMXOrthoFlipRunTimeTest()
|
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto map = TMXTiledMap::create("TileMaps/ortho-rotation-test.tmx");
|
2012-04-08 14:16:29 +08:00
|
|
|
addChild(map, 0, kTagTileMap);
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = map->getContentSize();
|
2013-07-24 06:20:22 +08:00
|
|
|
log("ContentSize: %f, %f", s.width,s.height);
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2013-12-17 17:45:29 +08:00
|
|
|
auto& children = map->getChildren();
|
2013-12-20 05:34:41 +08:00
|
|
|
for(const auto &node : children) {
|
2013-11-29 10:37:40 +08:00
|
|
|
auto child = static_cast<SpriteBatchNode*>(node);
|
2012-04-08 14:16:29 +08:00
|
|
|
child->getTexture()->setAntiAliasTexParameters();
|
2013-12-20 05:34:41 +08:00
|
|
|
}
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto action = ScaleBy::create(2, 0.5f);
|
2012-04-08 14:16:29 +08:00
|
|
|
map->runAction(action);
|
|
|
|
|
2014-10-04 00:38:36 +08:00
|
|
|
schedule(CC_SCHEDULE_SELECTOR(TMXOrthoFlipRunTimeTest::flipIt), 1.0f);
|
2012-04-08 14:16:29 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXOrthoFlipRunTimeTest::title() const
|
2012-04-08 14:16:29 +08:00
|
|
|
{
|
|
|
|
return "TMX tile flip run time test";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXOrthoFlipRunTimeTest::subtitle() const
|
2012-04-08 14:16:29 +08:00
|
|
|
{
|
|
|
|
return "in 2 sec bottom left tiles will flip";
|
|
|
|
}
|
|
|
|
|
2012-06-08 13:55:28 +08:00
|
|
|
void TMXOrthoFlipRunTimeTest::flipIt(float dt)
|
2012-04-08 14:16:29 +08:00
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto map = (TMXTiledMap*) getChildByTag(kTagTileMap);
|
|
|
|
auto layer = map->getLayer("Layer 0");
|
2012-04-08 14:16:29 +08:00
|
|
|
|
|
|
|
//blue diamond
|
2014-05-15 01:07:09 +08:00
|
|
|
auto tileCoord = Vec2(1,10);
|
2012-04-08 14:16:29 +08:00
|
|
|
int flags;
|
2014-02-08 10:11:17 +08:00
|
|
|
unsigned int GID = layer->getTileGIDAt(tileCoord, (TMXTileFlags*)&flags);
|
2012-04-08 14:16:29 +08:00
|
|
|
// Vertical
|
2013-06-20 14:17:10 +08:00
|
|
|
if( flags & kTMXTileVerticalFlag )
|
|
|
|
flags &= ~kTMXTileVerticalFlag;
|
2012-04-08 14:16:29 +08:00
|
|
|
else
|
2013-06-20 14:17:10 +08:00
|
|
|
flags |= kTMXTileVerticalFlag;
|
2014-02-08 10:11:17 +08:00
|
|
|
layer->setTileGID(GID ,tileCoord, (TMXTileFlags)flags);
|
2012-04-08 14:16:29 +08:00
|
|
|
|
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
tileCoord = Vec2(1,8);
|
2014-02-08 10:11:17 +08:00
|
|
|
GID = layer->getTileGIDAt(tileCoord, (TMXTileFlags*)&flags);
|
2012-04-08 14:16:29 +08:00
|
|
|
// Vertical
|
2013-06-20 14:17:10 +08:00
|
|
|
if( flags & kTMXTileVerticalFlag )
|
|
|
|
flags &= ~kTMXTileVerticalFlag;
|
2012-04-08 14:16:29 +08:00
|
|
|
else
|
2013-06-20 14:17:10 +08:00
|
|
|
flags |= kTMXTileVerticalFlag;
|
2014-02-08 10:11:17 +08:00
|
|
|
layer->setTileGID(GID ,tileCoord, (TMXTileFlags)flags);
|
2012-04-08 14:16:29 +08:00
|
|
|
|
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
tileCoord = Vec2(2,8);
|
2014-02-08 10:11:17 +08:00
|
|
|
GID = layer->getTileGIDAt(tileCoord, (TMXTileFlags*)&flags);
|
2012-04-08 14:16:29 +08:00
|
|
|
// Horizontal
|
2013-06-20 14:17:10 +08:00
|
|
|
if( flags & kTMXTileHorizontalFlag )
|
|
|
|
flags &= ~kTMXTileHorizontalFlag;
|
2012-04-08 14:16:29 +08:00
|
|
|
else
|
2013-06-20 14:17:10 +08:00
|
|
|
flags |= kTMXTileHorizontalFlag;
|
2014-02-08 10:11:17 +08:00
|
|
|
layer->setTileGID(GID, tileCoord, (TMXTileFlags)flags);
|
2012-04-08 14:16:29 +08:00
|
|
|
}
|
2012-03-26 16:46:23 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TMXOrthoFromXMLTest
|
|
|
|
//
|
2012-04-08 14:16:29 +08:00
|
|
|
//------------------------------------------------------------------
|
2012-03-26 16:46:23 +08:00
|
|
|
|
|
|
|
TMXOrthoFromXMLTest::TMXOrthoFromXMLTest()
|
|
|
|
{
|
2013-12-19 03:45:30 +08:00
|
|
|
std::string resources = "TileMaps"; // partial paths are OK as resource paths.
|
|
|
|
std::string file = resources + "/orthogonal-test1.tmx";
|
2012-04-08 14:16:29 +08:00
|
|
|
|
metal support for cocos2d-x (#19305)
* remove deprecated files
* remove some deprecated codes
* remove more deprecated codes
* remove ui deprecated codes
* remove more deprecated codes
* remove deprecated codes in ccmenuitem
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes
* remove more deprecated codes
* remove more deprecated codes
* remove vr related codes and ignore some modules
* remove allocator
* remove some config
* 【Feature】add back-end project file
* [Feature] add back-end file
* add pipeline descriptor and shader cache
* [Feature] support sprite for backend
* [Feature] remove unneeded code
* [Feature] according to es2.0 spec, you must use clamp-to-edge as texture wrap mode, and no mipmapping for non-power-of-two texture
* [Feature] set texture wrap mode to clamp-to-edge, and no mipmapping for non-power-of-two texture
* [Feature] remove macro define to .cpp file
* [Feature] add log info
* [Feature] add PipelineDescriptor for TriangleCommand
* [Feature] add PipelineDescriptor object as member of TriangleCommand
* [Feature] add getPipelineDescriptor method
* add renderbackend
* complete pipeline descriptor
* [Feature] add viewport in RenderCommand
* set viewport when rendrering
* [Feature] occur error when using RendererBackend, to be fixed.
* a workaround to fix black screen on macOS 10.14 (#19090)
* add rendererbackend init function
* fix typo
* [Feature] modify testFile
* [BugFix] modify shader path
* [Feature] set default viewport
* fix projection
* [Feature] modify log info
* [BugFix] change viewport data type to int
* [BugFix] add BindGroup to PipelienDescriptor
* [BugFix] change a_position to vec3 in sprite.vert
* [BugFix] set vertexLayout according to V3F_C4B_T2F structure
* [Feature] revert a_position to vec4
* [Feature] renderer should not use gl codes directly
* [Feature] it's better not use default value parameter
* fix depth test setting
* rendererbackend -> renderer
* clear color and depth at begin
* add metal backend
* metal support normalized attribute
* simplify codes
* update external
* add render pass desctriptor in pipeline descriptor
* fix warnings
* fix crash and memeory leak
* refactor Texture2D
* put pipeline descriptor into render command
* simplify codes
* [Feature] update Sprite
* fix crash when closing app
* [Feature] update SpriteBatchNode and TextureAtlas
* support render texture(not finish)
* [Feature] remove unused code
* make tests work on mac
* fix download-deps path error
* make tests work on iOS
* [Feature] support ttf under normal label effect
* refactor triangle command processing
* let renderer handle more common commands
* refactor backend
* make render texture work
* [Feature] refactor backend for GL
* [Feature]Renaming to make it easy to understand
* [Feature] change warp mode to CLAMP_TO_EDGE
* fix ghost
* simplify visit render queue logic
* support progress timer without rial mode
* support partcile system
* Feature/update label (#149)
* [BugFix] fix compile error
* [Feature] support outline effect in ios
* [Feature] add shader file
* [BugFix] fix begin and end RenderPass
* [Feature] update CustomCommand
* [Feature] revert project.pbxproj
* [Feature] simplify codes
* [BugFix] pack AI88 to RGBA8888 only when outline enable
* [Feature] support shadow effect in Label
* [Feature] support BMFont
* [Feature] support glow effect
* [Feature] simplify shader files
* LabelAtlas work
* handle blend function correctly
* support tile map
* don't share buffer in metal
* alloc buffer size as needed
* support more tilemap
* Merge branch 'minggo/metal-support' into feature/updateLabel
* minggo/metal-support:
support tile map
handle blend function correctly
LabelAtlas work
Feature/update label (#149)
support partcile system
# Conflicts:
# cocos/2d/CCLabel.cpp
# cocos/2d/CCSprite.cpp
# cocos/2d/CCSpriteBatchNode.cpp
# cocos/renderer/CCQuadCommand.cpp
# cocos/renderer/CCQuadCommand.h
* render texture work without saving file
* use global viewport
* grid3d works
* remove grabber
* tiled3d works
* [BugFix] fix label bug
* [Feature] add updateSubData for buffer
* [Feature] remove setVertexCount
* support depth test
* add callback command
* [Feature] add UITest
* [Feature] update UITest
* [Feature] remove unneeded codes
* fix custom command issue
* fix layer color blend issue
* [BugFix] fix iOS compile error
* [Feature] remove unneeded codes
* [Feature] fix updateVertexBuffer
* layerradial works
* add draw test back
* fix batch issue
* fix compiling error
* [BugFix] support ETC1
* [BugFix] get the correct pipelineDescriptor
* [BugFix] skip draw when backendTexture nullptr
* clipping node support
* [Feature] add shader files
* fix stencil issue in metal
* [Feature] update UILayoutTest
* [BugFix] skip drawing when vertexCount is zero
* refactor renderer
* add set global z order for stencil manager commands
* fix warnings caused by type
* remove viewport in render command
* [Feature] fix warnings caused by type
* [BugFix] clear vertexCount and indexCount for CustomComand when needed
* [Feature] update clear for CustomCommand
* ios use metal
* fix viewport issue
* fix LayerColorGradient crash
* [cmake] transport to android and windows (#160)
* save point 1
* compile on windows
* run on android
* revert useless change
* android set CC_ENABLE_CACHE_TEXTURE_DATA to 1
* add initGlew
* fix android crash
* add TODO new-renderer
* review update
* revert onGLFWWindowPosCallback
* fix android compiling error
* Impl progress radial (#162)
* progresstimer add radial impl
* default drawType to element
* dec invoke times of createVertexBuffer (#163)
* support depth/stencil format for gl backend
* simplify progress timer codes
* support motionstreak, effect is wrong
* fix motionstreak issue
* [Feature] update Scissor Test (#161)
* [Feature] update Scissor Test
* [Feature] update ScissorTest
* [Feature] rename function
* [Feature] get constant reference if needed
* [Feature] show render status (#164)
* improve performance
* fix depth state
* fill error that triangle vertex/index number bigger than buffer
* fix compiline error in release mode
* fix buffer conflict between CPU and GPU on iOS/macOS
* Renderer refactor (#165)
* use one vertes/index buffer with opengl
* fix error on windows
* custom command support index format config
* CCLayer: compact vertex data structure
* update comment
* fix doc
* support fast tilemap
* pass index format instead
* fix some wrong effect
* fix render texture error
* fix texture per-element size
* fix texture format error
* BlendFunc type refactor, GLenum -> backend::BlendFactor (#167)
* BlendFunc use backend::BlendFactor as inner field
* update comments
* use int to replace GLenum
* update xcode project fiel
* rename to GLBlendConst
* add ccConstants.h
* update xcode project file
* update copyright
* remove primitive command
* remove CCPrimitive.cpp/.h
* remove deprecated files
* remove unneeded files
* remove multiple view support
* remove multiple view support
* remove the usage of frame buffer in camera
* director don't use frame buffer
* remove FrameBuffer
* remove BatchCommand
* add some api reference
* add physics2d back
* fix crash when close app on mac
* improve render texture
* fix rendertexture issue
* fix rendertexture issue
* simplify codes
* CMake support for mac & ios (#169)
* update cmake
* fix compile error
* update 3rd libs version
* remove CCThread.h/.cpp
* remove ccthread
* use audio engine to implement simple audio engine
* remove unneeded codes
* remove deprecated codes
* remove winrt macro
* remove CC_USE_WIC
* set partcile blend function in more elegant way
* remove unneeded codes
* remove unneeded codes
* cmake works on windows
* update project setting
* improve performance
* GLFloat -> float
* sync v3 cmake improvements into metal-support (#172)
* pick: modern cmake, compile definitions improvement (#19139)
* modern cmake, use target_compile_definitions partly
* simplify macro define, remove USE_*
* modern cmake, macro define
* add physics 2d macro define into ccConfig.h
* remove USE_CHIPMUNK macro in build.gradle
* remove CocosSelectModule.cmake
* shrink useless define
* simplify compile options config, re-add if necessary
* update external for tmp CI test
* un-quote target_compile_options value
* add "-g" parameter only when debug mode
* keep single build type when generator Xcode & VS projecy
* update external for tmp CI tes
* add static_cast<char>(-1), fix -Wc++11-narrowing
* simplify win32 compile define
* not modify code, only improve compile options
# Conflicts:
# .gitignore
# cmake/Modules/CocosConfigDepend.cmake
# cocos/CMakeLists.txt
# external/config.json
# tests/cpp-tests/CMakeLists.txt
* modern cmake, improve cmake_compiler_flags (#19145)
* cmake_compiler_flags
* Fix typo
* Fix typo2
* Remove chanages from Android.mk
* correct lua template cmake build (#19149)
* don't add -Wno-deprecated into jsb target
* correct lua template cmake build
* fix win32 lua template compile error
* prevent cmake in-source-build friendly (#19151)
* pick: Copy resources to "Resources/" on win32 like in linux configuration
* add "/Z7" for cpp-tests on windows
* [cmake] fix iOS xcode property setting failed (#19208)
* fix iOS xcode property setting failed
* use search_depend_libs_recursive at dlls collect
* fix typo
* [cmake] add find_host_library into iOS toolchain file (#19230)
* pick: [lua android] use luajit & template cmake update (#19239)
* increase cmake stability , remove tests/CMakeLists.txt (#19261)
* cmake win32 Precompiled header (#19273)
* Precompiled header
* Fix
* Precompiled header for cocos
* Precompiled header jscocos2d
* Fix for COCOS2D_DEBUG is always 1 on Android (#19291)
Related #19289
* little build fix, tests cpp-tests works on mac
* sync v3 build related codes into metal-support (#173)
* strict initialization for std::array
* remove proj.win32 project configs
* modern cmake, cmake_cleanup_remove_unused_variables (#19146)
* Switch travis CI to xenial (#19207)
* Switch travis CI to xenial
* Remove language: android
* Set language: cpp
* Fix java problem
* Update sdkmanager
* Fix sdkmanger
* next sdkmanager fix
* Remove xenial from android
* revert to sdk-tools-{system}-3859397
* Remove linux cmake install
* Update before-install.sh
* Update .travis.yml
* Simplify install-deps-linux.sh, tested on Ubuntu 16.04 (#19212)
* Simplify install-deps-linux.sh
* Cleanup
* pick: install ninja
* update cocos2d-console submodule
* for metal-support alpha release, we only test cpp
* add HelloCpp into project(Cocos2d-x) for tmp test
* update extenal metal-support-4
* update uniform setting
* [Feature] update BindGroup
* [Feature] empty-test
* [Feature] cpp-test
* [Feature] fix GL compiler error
* [Feature] fix GL crash
* [Feature] empty-test
* [Feature] cpp-tests
* [feature] improve frameRate
* [feature] fix opengl compile error
* [feature] fix opengl compile error
* [BugFix] fix compute maxLocation error
* [Feature] update setting unifrom
* [Feature] fix namespace
* [Feature] remove unneeded code
* [Bugfix] fix project file
* [Feature] update review
* [texture2d] impl texture format support (#175)
* texture update
* update
* update texture
* commit
* compile on windows
* ddd
* rename
* rename methods
* no crash
* save gl
* save
* save
* rename
* move out pixel format convert functions
* metal crash
* update
* update android
* support gles compressed texture format
* support more compress format
* add more conversion methods
* ss
* save
* update conversion methods
* add PVRTC format support
* reformat
* add marco linux
* fix GL marcro
* pvrtc supported only by ios 8.0+
* remove unused cmake
* revert change
* refactor Texture2D::initWithData
* fix conversion log
* refactor Texture2D::initWithData
* remove some OpenGL constants for PVRTC
* add todo
* fix typo
* AutoTest works on mac/iOS by disable part cases, sync v3 bug fix (#174)
* review cpp-tests, and fix part issues on start auto test
* sync png format fix: Node:Particle3D abnormal texture effects #19204
* fix cpp-tests SpritePolygon crash, wrong png format (#19170)
* fix wrong png convert format from sRGB to Gray
* erase plist index if all frames was erased
* test_A8.png have I8 format, fix it
* [CCSpriteCache] allow re-add plist & add testcase (#19175)
* allow re-add plist & add testcase
* remove comments/rename method/update testcase
* fix isSpriteFramesWithFileLoaded & add testcase
* remove used variable
* remove unused variable
* fix double free issues when js/lua-tests exit on iOS (#19236)
* disable part cases, AutoTest works without crash on mac
* update cocos2dx files json, to test cocos new next
* fix spritecache plist parsing issue (#19269)
* [linux] Fix FileUtils::getContents with folder (#19157)
* fix FileUtils::getContents on linux/mac
* use stat.st_mode
* simplify
* [CCFileUtils] win32 getFileSize (#19176)
* win32 getFileSize
* fix stat
* [cpp test-Android]20:FileUtils/2 change title (#19197)
* sync #19200
* sync #19231
* [android lua] improve performance of lua loader (#19234)
* [lua] improve performance of lua loader
* remove cache fix
* Revert "fix spritecache plist parsing issue (#19269)"
This reverts commit f3a85ece4307a7b90816c34489d1ed2c8fd11baf.
* remove win32 project files ref in template.json
* add metal framework lnk ref into cpp template
* test on iOS, and disable part cases
* alBufferData instead of alBufferDataStatic for small audio file on Apple (#19227)
* changes AudioCache to use alBufferData instead of alBufferDataStatic
(also makes test 19 faster to trigger openal bugs faster)
The original problem: CrashIfClientProvidedBogusAudioBufferList
https://github.com/cocos2d/cocos2d-x/issues/18948
is not happening anymore, but there's still a not very frequent issue
that makes OpenAL crash with a call stack like this.
AudioCache::readDataTask > alBufferData > CleanUpDeadBufferList
It happes more frequently when the device is "cold", which means after
half an hour of not using the device (locked).
I could not find the actual source code for iOS OpenAL, so I used the
macOS versions:
https://opensource.apple.com/source/OpenAL/OpenAL-48.7/Source/OpenAL/oalImp.cpp.auto.html
They seem to use CAGuard.h to make sure the dead buffer list
has no threading issues. I'm worried because the CAGuard code I found
has macos and win32 define but no iOS, so I'm not sure. I guess the
iOS version is different and has the guard.
I could not find a place in the code that's unprotected by the locks
except the InitializeBufferMap() which should not be called more than
once from cocos, and there's a workaround in AudioEngine-impl for it.
I reduced the occurence of the CleanUpDeadBufferList crash by moving
the guard in ~AudioCache to cover the alDeleteBuffers call.
* remove hack method "setTimeout" on audio
* AutoTest works on iOS
* support set ios deployment target for root project
* enable all texture2d cases, since Jiang have fixed
* add CCTextureUtils to xcode project file (#176)
* add leak cases for SpriteFrameCache (#177)
* re-add SpriteFrameCache cases
* update template file json
* Update SpriteFrameCacheTest.cpp
* fix compiling error
2019-01-18 15:08:25 +08:00
|
|
|
auto fileUtils = FileUtils::getInstance();
|
|
|
|
std::string str = fileUtils->getStringFromFile(fileUtils->fullPathForFilename(file.c_str()));
|
2012-04-08 14:16:29 +08:00
|
|
|
|
metal support for cocos2d-x (#19305)
* remove deprecated files
* remove some deprecated codes
* remove more deprecated codes
* remove ui deprecated codes
* remove more deprecated codes
* remove deprecated codes in ccmenuitem
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes
* remove more deprecated codes
* remove more deprecated codes
* remove vr related codes and ignore some modules
* remove allocator
* remove some config
* 【Feature】add back-end project file
* [Feature] add back-end file
* add pipeline descriptor and shader cache
* [Feature] support sprite for backend
* [Feature] remove unneeded code
* [Feature] according to es2.0 spec, you must use clamp-to-edge as texture wrap mode, and no mipmapping for non-power-of-two texture
* [Feature] set texture wrap mode to clamp-to-edge, and no mipmapping for non-power-of-two texture
* [Feature] remove macro define to .cpp file
* [Feature] add log info
* [Feature] add PipelineDescriptor for TriangleCommand
* [Feature] add PipelineDescriptor object as member of TriangleCommand
* [Feature] add getPipelineDescriptor method
* add renderbackend
* complete pipeline descriptor
* [Feature] add viewport in RenderCommand
* set viewport when rendrering
* [Feature] occur error when using RendererBackend, to be fixed.
* a workaround to fix black screen on macOS 10.14 (#19090)
* add rendererbackend init function
* fix typo
* [Feature] modify testFile
* [BugFix] modify shader path
* [Feature] set default viewport
* fix projection
* [Feature] modify log info
* [BugFix] change viewport data type to int
* [BugFix] add BindGroup to PipelienDescriptor
* [BugFix] change a_position to vec3 in sprite.vert
* [BugFix] set vertexLayout according to V3F_C4B_T2F structure
* [Feature] revert a_position to vec4
* [Feature] renderer should not use gl codes directly
* [Feature] it's better not use default value parameter
* fix depth test setting
* rendererbackend -> renderer
* clear color and depth at begin
* add metal backend
* metal support normalized attribute
* simplify codes
* update external
* add render pass desctriptor in pipeline descriptor
* fix warnings
* fix crash and memeory leak
* refactor Texture2D
* put pipeline descriptor into render command
* simplify codes
* [Feature] update Sprite
* fix crash when closing app
* [Feature] update SpriteBatchNode and TextureAtlas
* support render texture(not finish)
* [Feature] remove unused code
* make tests work on mac
* fix download-deps path error
* make tests work on iOS
* [Feature] support ttf under normal label effect
* refactor triangle command processing
* let renderer handle more common commands
* refactor backend
* make render texture work
* [Feature] refactor backend for GL
* [Feature]Renaming to make it easy to understand
* [Feature] change warp mode to CLAMP_TO_EDGE
* fix ghost
* simplify visit render queue logic
* support progress timer without rial mode
* support partcile system
* Feature/update label (#149)
* [BugFix] fix compile error
* [Feature] support outline effect in ios
* [Feature] add shader file
* [BugFix] fix begin and end RenderPass
* [Feature] update CustomCommand
* [Feature] revert project.pbxproj
* [Feature] simplify codes
* [BugFix] pack AI88 to RGBA8888 only when outline enable
* [Feature] support shadow effect in Label
* [Feature] support BMFont
* [Feature] support glow effect
* [Feature] simplify shader files
* LabelAtlas work
* handle blend function correctly
* support tile map
* don't share buffer in metal
* alloc buffer size as needed
* support more tilemap
* Merge branch 'minggo/metal-support' into feature/updateLabel
* minggo/metal-support:
support tile map
handle blend function correctly
LabelAtlas work
Feature/update label (#149)
support partcile system
# Conflicts:
# cocos/2d/CCLabel.cpp
# cocos/2d/CCSprite.cpp
# cocos/2d/CCSpriteBatchNode.cpp
# cocos/renderer/CCQuadCommand.cpp
# cocos/renderer/CCQuadCommand.h
* render texture work without saving file
* use global viewport
* grid3d works
* remove grabber
* tiled3d works
* [BugFix] fix label bug
* [Feature] add updateSubData for buffer
* [Feature] remove setVertexCount
* support depth test
* add callback command
* [Feature] add UITest
* [Feature] update UITest
* [Feature] remove unneeded codes
* fix custom command issue
* fix layer color blend issue
* [BugFix] fix iOS compile error
* [Feature] remove unneeded codes
* [Feature] fix updateVertexBuffer
* layerradial works
* add draw test back
* fix batch issue
* fix compiling error
* [BugFix] support ETC1
* [BugFix] get the correct pipelineDescriptor
* [BugFix] skip draw when backendTexture nullptr
* clipping node support
* [Feature] add shader files
* fix stencil issue in metal
* [Feature] update UILayoutTest
* [BugFix] skip drawing when vertexCount is zero
* refactor renderer
* add set global z order for stencil manager commands
* fix warnings caused by type
* remove viewport in render command
* [Feature] fix warnings caused by type
* [BugFix] clear vertexCount and indexCount for CustomComand when needed
* [Feature] update clear for CustomCommand
* ios use metal
* fix viewport issue
* fix LayerColorGradient crash
* [cmake] transport to android and windows (#160)
* save point 1
* compile on windows
* run on android
* revert useless change
* android set CC_ENABLE_CACHE_TEXTURE_DATA to 1
* add initGlew
* fix android crash
* add TODO new-renderer
* review update
* revert onGLFWWindowPosCallback
* fix android compiling error
* Impl progress radial (#162)
* progresstimer add radial impl
* default drawType to element
* dec invoke times of createVertexBuffer (#163)
* support depth/stencil format for gl backend
* simplify progress timer codes
* support motionstreak, effect is wrong
* fix motionstreak issue
* [Feature] update Scissor Test (#161)
* [Feature] update Scissor Test
* [Feature] update ScissorTest
* [Feature] rename function
* [Feature] get constant reference if needed
* [Feature] show render status (#164)
* improve performance
* fix depth state
* fill error that triangle vertex/index number bigger than buffer
* fix compiline error in release mode
* fix buffer conflict between CPU and GPU on iOS/macOS
* Renderer refactor (#165)
* use one vertes/index buffer with opengl
* fix error on windows
* custom command support index format config
* CCLayer: compact vertex data structure
* update comment
* fix doc
* support fast tilemap
* pass index format instead
* fix some wrong effect
* fix render texture error
* fix texture per-element size
* fix texture format error
* BlendFunc type refactor, GLenum -> backend::BlendFactor (#167)
* BlendFunc use backend::BlendFactor as inner field
* update comments
* use int to replace GLenum
* update xcode project fiel
* rename to GLBlendConst
* add ccConstants.h
* update xcode project file
* update copyright
* remove primitive command
* remove CCPrimitive.cpp/.h
* remove deprecated files
* remove unneeded files
* remove multiple view support
* remove multiple view support
* remove the usage of frame buffer in camera
* director don't use frame buffer
* remove FrameBuffer
* remove BatchCommand
* add some api reference
* add physics2d back
* fix crash when close app on mac
* improve render texture
* fix rendertexture issue
* fix rendertexture issue
* simplify codes
* CMake support for mac & ios (#169)
* update cmake
* fix compile error
* update 3rd libs version
* remove CCThread.h/.cpp
* remove ccthread
* use audio engine to implement simple audio engine
* remove unneeded codes
* remove deprecated codes
* remove winrt macro
* remove CC_USE_WIC
* set partcile blend function in more elegant way
* remove unneeded codes
* remove unneeded codes
* cmake works on windows
* update project setting
* improve performance
* GLFloat -> float
* sync v3 cmake improvements into metal-support (#172)
* pick: modern cmake, compile definitions improvement (#19139)
* modern cmake, use target_compile_definitions partly
* simplify macro define, remove USE_*
* modern cmake, macro define
* add physics 2d macro define into ccConfig.h
* remove USE_CHIPMUNK macro in build.gradle
* remove CocosSelectModule.cmake
* shrink useless define
* simplify compile options config, re-add if necessary
* update external for tmp CI test
* un-quote target_compile_options value
* add "-g" parameter only when debug mode
* keep single build type when generator Xcode & VS projecy
* update external for tmp CI tes
* add static_cast<char>(-1), fix -Wc++11-narrowing
* simplify win32 compile define
* not modify code, only improve compile options
# Conflicts:
# .gitignore
# cmake/Modules/CocosConfigDepend.cmake
# cocos/CMakeLists.txt
# external/config.json
# tests/cpp-tests/CMakeLists.txt
* modern cmake, improve cmake_compiler_flags (#19145)
* cmake_compiler_flags
* Fix typo
* Fix typo2
* Remove chanages from Android.mk
* correct lua template cmake build (#19149)
* don't add -Wno-deprecated into jsb target
* correct lua template cmake build
* fix win32 lua template compile error
* prevent cmake in-source-build friendly (#19151)
* pick: Copy resources to "Resources/" on win32 like in linux configuration
* add "/Z7" for cpp-tests on windows
* [cmake] fix iOS xcode property setting failed (#19208)
* fix iOS xcode property setting failed
* use search_depend_libs_recursive at dlls collect
* fix typo
* [cmake] add find_host_library into iOS toolchain file (#19230)
* pick: [lua android] use luajit & template cmake update (#19239)
* increase cmake stability , remove tests/CMakeLists.txt (#19261)
* cmake win32 Precompiled header (#19273)
* Precompiled header
* Fix
* Precompiled header for cocos
* Precompiled header jscocos2d
* Fix for COCOS2D_DEBUG is always 1 on Android (#19291)
Related #19289
* little build fix, tests cpp-tests works on mac
* sync v3 build related codes into metal-support (#173)
* strict initialization for std::array
* remove proj.win32 project configs
* modern cmake, cmake_cleanup_remove_unused_variables (#19146)
* Switch travis CI to xenial (#19207)
* Switch travis CI to xenial
* Remove language: android
* Set language: cpp
* Fix java problem
* Update sdkmanager
* Fix sdkmanger
* next sdkmanager fix
* Remove xenial from android
* revert to sdk-tools-{system}-3859397
* Remove linux cmake install
* Update before-install.sh
* Update .travis.yml
* Simplify install-deps-linux.sh, tested on Ubuntu 16.04 (#19212)
* Simplify install-deps-linux.sh
* Cleanup
* pick: install ninja
* update cocos2d-console submodule
* for metal-support alpha release, we only test cpp
* add HelloCpp into project(Cocos2d-x) for tmp test
* update extenal metal-support-4
* update uniform setting
* [Feature] update BindGroup
* [Feature] empty-test
* [Feature] cpp-test
* [Feature] fix GL compiler error
* [Feature] fix GL crash
* [Feature] empty-test
* [Feature] cpp-tests
* [feature] improve frameRate
* [feature] fix opengl compile error
* [feature] fix opengl compile error
* [BugFix] fix compute maxLocation error
* [Feature] update setting unifrom
* [Feature] fix namespace
* [Feature] remove unneeded code
* [Bugfix] fix project file
* [Feature] update review
* [texture2d] impl texture format support (#175)
* texture update
* update
* update texture
* commit
* compile on windows
* ddd
* rename
* rename methods
* no crash
* save gl
* save
* save
* rename
* move out pixel format convert functions
* metal crash
* update
* update android
* support gles compressed texture format
* support more compress format
* add more conversion methods
* ss
* save
* update conversion methods
* add PVRTC format support
* reformat
* add marco linux
* fix GL marcro
* pvrtc supported only by ios 8.0+
* remove unused cmake
* revert change
* refactor Texture2D::initWithData
* fix conversion log
* refactor Texture2D::initWithData
* remove some OpenGL constants for PVRTC
* add todo
* fix typo
* AutoTest works on mac/iOS by disable part cases, sync v3 bug fix (#174)
* review cpp-tests, and fix part issues on start auto test
* sync png format fix: Node:Particle3D abnormal texture effects #19204
* fix cpp-tests SpritePolygon crash, wrong png format (#19170)
* fix wrong png convert format from sRGB to Gray
* erase plist index if all frames was erased
* test_A8.png have I8 format, fix it
* [CCSpriteCache] allow re-add plist & add testcase (#19175)
* allow re-add plist & add testcase
* remove comments/rename method/update testcase
* fix isSpriteFramesWithFileLoaded & add testcase
* remove used variable
* remove unused variable
* fix double free issues when js/lua-tests exit on iOS (#19236)
* disable part cases, AutoTest works without crash on mac
* update cocos2dx files json, to test cocos new next
* fix spritecache plist parsing issue (#19269)
* [linux] Fix FileUtils::getContents with folder (#19157)
* fix FileUtils::getContents on linux/mac
* use stat.st_mode
* simplify
* [CCFileUtils] win32 getFileSize (#19176)
* win32 getFileSize
* fix stat
* [cpp test-Android]20:FileUtils/2 change title (#19197)
* sync #19200
* sync #19231
* [android lua] improve performance of lua loader (#19234)
* [lua] improve performance of lua loader
* remove cache fix
* Revert "fix spritecache plist parsing issue (#19269)"
This reverts commit f3a85ece4307a7b90816c34489d1ed2c8fd11baf.
* remove win32 project files ref in template.json
* add metal framework lnk ref into cpp template
* test on iOS, and disable part cases
* alBufferData instead of alBufferDataStatic for small audio file on Apple (#19227)
* changes AudioCache to use alBufferData instead of alBufferDataStatic
(also makes test 19 faster to trigger openal bugs faster)
The original problem: CrashIfClientProvidedBogusAudioBufferList
https://github.com/cocos2d/cocos2d-x/issues/18948
is not happening anymore, but there's still a not very frequent issue
that makes OpenAL crash with a call stack like this.
AudioCache::readDataTask > alBufferData > CleanUpDeadBufferList
It happes more frequently when the device is "cold", which means after
half an hour of not using the device (locked).
I could not find the actual source code for iOS OpenAL, so I used the
macOS versions:
https://opensource.apple.com/source/OpenAL/OpenAL-48.7/Source/OpenAL/oalImp.cpp.auto.html
They seem to use CAGuard.h to make sure the dead buffer list
has no threading issues. I'm worried because the CAGuard code I found
has macos and win32 define but no iOS, so I'm not sure. I guess the
iOS version is different and has the guard.
I could not find a place in the code that's unprotected by the locks
except the InitializeBufferMap() which should not be called more than
once from cocos, and there's a workaround in AudioEngine-impl for it.
I reduced the occurence of the CleanUpDeadBufferList crash by moving
the guard in ~AudioCache to cover the alDeleteBuffers call.
* remove hack method "setTimeout" on audio
* AutoTest works on iOS
* support set ios deployment target for root project
* enable all texture2d cases, since Jiang have fixed
* add CCTextureUtils to xcode project file (#176)
* add leak cases for SpriteFrameCache (#177)
* re-add SpriteFrameCache cases
* update template file json
* Update SpriteFrameCacheTest.cpp
* fix compiling error
2019-01-18 15:08:25 +08:00
|
|
|
auto map = TMXTiledMap::createWithXML(str ,resources.c_str());
|
2012-04-08 14:16:29 +08:00
|
|
|
addChild(map, 0, kTagTileMap);
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = map->getContentSize();
|
2013-07-24 06:20:22 +08:00
|
|
|
log("ContentSize: %f, %f", s.width,s.height);
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2013-12-17 17:45:29 +08:00
|
|
|
auto& children = map->getChildren();
|
2013-12-20 05:34:41 +08:00
|
|
|
for(const auto &node : children) {
|
2013-11-29 10:37:40 +08:00
|
|
|
auto child = static_cast<SpriteBatchNode*>(node);
|
2012-04-08 14:16:29 +08:00
|
|
|
child->getTexture()->setAntiAliasTexParameters();
|
2013-12-20 05:34:41 +08:00
|
|
|
}
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto action = ScaleBy::create(2, 0.5f);
|
2012-03-26 16:46:23 +08:00
|
|
|
map->runAction(action);
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXOrthoFromXMLTest::title() const
|
2012-03-26 16:46:23 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "TMX created from XML test";
|
2012-03-26 16:46:23 +08:00
|
|
|
}
|
2013-12-30 11:33:41 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
2013-12-30 12:01:22 +08:00
|
|
|
// TMXOrthoXMLFormatTest
|
2013-12-30 11:33:41 +08:00
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
|
2013-12-30 12:01:22 +08:00
|
|
|
TMXOrthoXMLFormatTest::TMXOrthoXMLFormatTest()
|
2013-12-30 11:33:41 +08:00
|
|
|
{
|
|
|
|
// this test tests for:
|
|
|
|
// 1. load xml format tilemap
|
|
|
|
// 2. gid lower than firstgid is ignored
|
|
|
|
// 3. firstgid in tsx is ignored, tile property in tsx loaded correctly.
|
|
|
|
auto map = TMXTiledMap::create("TileMaps/xml-test.tmx");
|
|
|
|
addChild(map, 0, kTagTileMap);
|
|
|
|
|
|
|
|
auto s = map->getContentSize();
|
|
|
|
log("ContentSize: %f, %f", s.width,s.height);
|
|
|
|
|
|
|
|
auto& children = map->getChildren();
|
|
|
|
for(const auto &node : children) {
|
|
|
|
auto child = static_cast<SpriteBatchNode*>(node);
|
|
|
|
child->getTexture()->setAntiAliasTexParameters();
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int i=24;i<=26;i++){
|
|
|
|
log("GID:%i, Properties:%s", i, map->getPropertiesForGID(i).asValueMap()["name"].asString().c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
auto action = ScaleBy::create(2, 0.5f);
|
|
|
|
map->runAction(action);
|
|
|
|
}
|
|
|
|
|
2013-12-30 12:01:22 +08:00
|
|
|
std::string TMXOrthoXMLFormatTest::title() const
|
2013-12-30 11:33:41 +08:00
|
|
|
{
|
2013-12-30 12:01:22 +08:00
|
|
|
return "you should see blue, green and yellow in console.";
|
2013-12-30 11:33:41 +08:00
|
|
|
}
|
2012-03-26 16:46:23 +08:00
|
|
|
|
2011-02-23 16:47:25 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TMXBug987
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2011-05-12 10:52:10 +08:00
|
|
|
TMXBug987::TMXBug987()
|
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto map = TMXTiledMap::create("TileMaps/orthogonal-test6.tmx");
|
2011-05-12 10:52:10 +08:00
|
|
|
addChild(map, 0, kTagTileMap);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size CC_UNUSED s1 = map->getContentSize();
|
2011-05-12 10:52:10 +08:00
|
|
|
CCLOG("ContentSize: %f, %f", s1.width,s1.height);
|
|
|
|
|
2013-12-17 17:45:29 +08:00
|
|
|
auto& children = map->getChildren();
|
2013-12-20 05:34:41 +08:00
|
|
|
for(const auto &child : children) {
|
2013-11-29 10:37:40 +08:00
|
|
|
auto node = static_cast<TMXLayer*>(child);
|
2013-07-23 08:25:44 +08:00
|
|
|
node->getTexture()->setAntiAliasTexParameters();
|
2013-12-20 05:34:41 +08:00
|
|
|
}
|
2011-05-12 10:52:10 +08:00
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
map->setAnchorPoint(Vec2(0, 0));
|
2013-08-16 16:05:27 +08:00
|
|
|
auto layer = map->getLayer("Tile Layer 1");
|
2014-05-15 01:07:09 +08:00
|
|
|
layer->setTileGID(3, Vec2(2,2));
|
2011-05-12 10:52:10 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXBug987::title() const
|
2011-05-12 10:52:10 +08:00
|
|
|
{
|
|
|
|
return "TMX Bug 987";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXBug987::subtitle() const
|
2011-05-12 10:52:10 +08:00
|
|
|
{
|
|
|
|
return "You should see an square";
|
|
|
|
}
|
|
|
|
|
2011-02-23 16:47:25 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TMXBug787
|
|
|
|
//
|
2011-05-12 10:52:10 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
TMXBug787::TMXBug787()
|
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto map = TMXTiledMap::create("TileMaps/iso-test-bug787.tmx");
|
2011-05-12 10:52:10 +08:00
|
|
|
addChild(map, 0, kTagTileMap);
|
|
|
|
|
|
|
|
map->setScale(0.25f);
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXBug787::title() const
|
2011-05-12 10:52:10 +08:00
|
|
|
{
|
|
|
|
return "TMX Bug 787";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXBug787::subtitle() const
|
2011-05-12 10:52:10 +08:00
|
|
|
{
|
|
|
|
return "You should see a map";
|
|
|
|
}
|
|
|
|
|
2010-09-01 17:30:51 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
2014-02-05 09:59:21 +08:00
|
|
|
// TMXGIDObjectsTest
|
2010-09-01 17:30:51 +08:00
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2011-07-12 14:21:29 +08:00
|
|
|
TMXGIDObjectsTest::TMXGIDObjectsTest()
|
2011-07-06 14:56:05 +08:00
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto map = TMXTiledMap::create("TileMaps/test-object-layer.tmx");
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(map, -1, kTagTileMap);
|
2011-07-06 14:56:05 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size CC_UNUSED s = map->getContentSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
CCLOG("Contentsize: %f, %f", s.width, s.height);
|
2011-07-06 14:56:05 +08:00
|
|
|
|
2017-02-10 10:35:52 +08:00
|
|
|
CCLOG("----> Iterating over all the group objects");
|
2013-12-26 11:19:09 +08:00
|
|
|
|
2014-09-11 15:39:56 +08:00
|
|
|
auto drawNode = DrawNode::create();
|
|
|
|
Color4F color(1.0, 1.0, 1.0, 1.0);
|
|
|
|
auto group = map->getObjectGroup("Object Layer 1");
|
2013-12-03 14:47:35 +08:00
|
|
|
auto& objects = group->getObjects();
|
|
|
|
for (auto& obj : objects)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-12-04 17:46:57 +08:00
|
|
|
ValueMap& dict = obj.asValueMap();
|
2013-12-03 14:47:35 +08:00
|
|
|
|
|
|
|
float x = dict["x"].asFloat();
|
|
|
|
float y = dict["y"].asFloat();
|
|
|
|
float width = dict["width"].asFloat();
|
|
|
|
float height = dict["height"].asFloat();
|
2013-12-26 11:19:09 +08:00
|
|
|
|
2014-09-11 15:39:56 +08:00
|
|
|
drawNode->drawLine(Vec2(x, y), Vec2(x + width, y), color);
|
|
|
|
drawNode->drawLine(Vec2(x + width, y), Vec2(x + width, y + height), color);
|
|
|
|
drawNode->drawLine(Vec2(x + width,y + height), Vec2(x,y + height), color);
|
|
|
|
drawNode->drawLine(Vec2(x,y + height), Vec2(x,y), color);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
2014-09-11 15:39:56 +08:00
|
|
|
map->addChild(drawNode);
|
2011-07-06 14:56:05 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXGIDObjectsTest::title() const
|
2011-07-06 14:56:05 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "TMX GID objects";
|
2011-07-06 14:56:05 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TMXGIDObjectsTest::subtitle() const
|
2011-07-06 14:56:05 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "Tiles are created from an object group";
|
2011-07-06 14:56:05 +08:00
|
|
|
}
|
2016-07-02 06:51:00 +08:00
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TMXHexOddXTest
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
TMXHexOddXTest::TMXHexOddXTest()
|
|
|
|
{
|
|
|
|
auto color = LayerColor::create( Color4B(64,64,64,255) );
|
|
|
|
addChild(color, -1);
|
|
|
|
|
|
|
|
auto map = TMXTiledMap::create("TileMaps/hexagonal-mini-odd-x.tmx");
|
|
|
|
addChild(map, 0, kTagTileMap);
|
|
|
|
|
|
|
|
Size CC_UNUSED s = map->getContentSize();
|
|
|
|
CCLOG("ContentSize: %f, %f", s.width,s.height);
|
2016-09-14 12:47:36 +08:00
|
|
|
|
|
|
|
// Testing issue 16512 as well. Should not crash
|
|
|
|
auto floor = map->getLayer("Ground");
|
|
|
|
for (auto x = 0; x < map->getMapSize().width; x++) {
|
|
|
|
for (auto y = 0; y < map->getMapSize().height; y++) {
|
|
|
|
Vec2 p(x, y);
|
|
|
|
floor->getTileAt(p);
|
|
|
|
}
|
|
|
|
}
|
2016-07-02 06:51:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string TMXHexOddXTest::title() const
|
|
|
|
{
|
|
|
|
return "TMX Hex Odd X";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TMXHexOddYTest
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
TMXHexOddYTest::TMXHexOddYTest()
|
|
|
|
{
|
|
|
|
auto color = LayerColor::create( Color4B(64,64,64,255) );
|
|
|
|
addChild(color, -1);
|
|
|
|
|
|
|
|
auto map = TMXTiledMap::create("TileMaps/hexagonal-mini-odd-y.tmx");
|
|
|
|
addChild(map, 0, kTagTileMap);
|
|
|
|
|
|
|
|
Size CC_UNUSED s = map->getContentSize();
|
|
|
|
CCLOG("ContentSize: %f, %f", s.width,s.height);
|
2016-09-14 12:47:36 +08:00
|
|
|
|
|
|
|
// Testing issue 16512 as well. Should not crash
|
|
|
|
auto floor = map->getLayer("Ground");
|
|
|
|
for (auto x = 0; x < map->getMapSize().width; x++) {
|
|
|
|
for (auto y = 0; y < map->getMapSize().height; y++) {
|
|
|
|
Vec2 p(x, y);
|
|
|
|
floor->getTileAt(p);
|
|
|
|
}
|
|
|
|
}
|
2016-07-02 06:51:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string TMXHexOddYTest::title() const
|
|
|
|
{
|
|
|
|
return "TMX Hex Odd Y";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TMXHexEvenXTest
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
TMXHexEvenXTest::TMXHexEvenXTest()
|
|
|
|
{
|
|
|
|
auto color = LayerColor::create( Color4B(64,64,64,255) );
|
|
|
|
addChild(color, -1);
|
|
|
|
|
|
|
|
auto map = TMXTiledMap::create("TileMaps/hexagonal-mini-even-x.tmx");
|
|
|
|
addChild(map, 0, kTagTileMap);
|
|
|
|
|
|
|
|
Size CC_UNUSED s = map->getContentSize();
|
|
|
|
CCLOG("ContentSize: %f, %f", s.width,s.height);
|
2016-09-14 12:47:36 +08:00
|
|
|
|
|
|
|
// Testing issue 16512 as well. Should not crash
|
|
|
|
auto floor = map->getLayer("Ground");
|
|
|
|
for (auto x = 0; x < map->getMapSize().width; x++) {
|
|
|
|
for (auto y = 0; y < map->getMapSize().height; y++) {
|
|
|
|
Vec2 p(x, y);
|
|
|
|
floor->getTileAt(p);
|
|
|
|
}
|
|
|
|
}
|
2016-07-02 06:51:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string TMXHexEvenXTest::title() const
|
|
|
|
{
|
|
|
|
return "TMX Hex Even X";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TMXHexEvenYTest
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
TMXHexEvenYTest::TMXHexEvenYTest()
|
|
|
|
{
|
|
|
|
auto color = LayerColor::create( Color4B(64,64,64,255) );
|
|
|
|
addChild(color, -1);
|
|
|
|
|
|
|
|
auto map = TMXTiledMap::create("TileMaps/hexagonal-mini-even-y.tmx");
|
|
|
|
addChild(map, 0, kTagTileMap);
|
|
|
|
|
|
|
|
Size CC_UNUSED s = map->getContentSize();
|
|
|
|
CCLOG("ContentSize: %f, %f", s.width,s.height);
|
2016-09-14 12:47:36 +08:00
|
|
|
|
|
|
|
// Testing issue 16512 as well. Should not crash
|
|
|
|
auto floor = map->getLayer("Ground");
|
|
|
|
for (auto x = 0; x < map->getMapSize().width; x++) {
|
|
|
|
for (auto y = 0; y < map->getMapSize().height; y++) {
|
|
|
|
Vec2 p(x, y);
|
|
|
|
floor->getTileAt(p);
|
|
|
|
}
|
|
|
|
}
|
2016-07-02 06:51:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string TMXHexEvenYTest::title() const
|
|
|
|
{
|
|
|
|
return "TMX Hex Even Y";
|
|
|
|
}
|
|
|
|
|
2016-07-15 02:21:24 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TMXHexAxisXTest
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
TMXHexAxisXTest::TMXHexAxisXTest()
|
|
|
|
{
|
|
|
|
auto color = LayerColor::create( Color4B(64,64,64,255) );
|
|
|
|
addChild(color, -1);
|
|
|
|
|
|
|
|
auto map = TMXTiledMap::create("TileMaps/hexa-axis-x.tmx");
|
|
|
|
addChild(map, 0, kTagTileMap);
|
|
|
|
|
|
|
|
Size CC_UNUSED s = map->getContentSize();
|
|
|
|
CCLOG("ContentSize: %f, %f", s.width,s.height);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string TMXHexAxisXTest::title() const
|
|
|
|
{
|
|
|
|
return "The map should be same with in Tiled Editor";
|
|
|
|
}
|
2016-07-20 13:55:05 +08:00
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Issue16105Test
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
Issue16105Test::Issue16105Test()
|
|
|
|
{
|
|
|
|
auto color = LayerColor::create( Color4B(64,64,64,255) );
|
|
|
|
addChild(color, -1);
|
|
|
|
|
|
|
|
auto map = TMXTiledMap::create("TileMaps/issue16105.tmx");
|
|
|
|
addChild(map, 0, kTagTileMap);
|
|
|
|
|
|
|
|
Size CC_UNUSED s = map->getContentSize();
|
|
|
|
CCLOG("ContentSize: %f, %f", s.width,s.height);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string Issue16105Test::title() const
|
|
|
|
{
|
|
|
|
return "Github Issue #16105";
|
|
|
|
}
|
2016-09-14 12:47:36 +08:00
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Issue16512Test
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
Issue16512Test::Issue16512Test()
|
|
|
|
{
|
|
|
|
auto color = LayerColor::create( Color4B(64,64,64,255) );
|
|
|
|
addChild(color, -1);
|
|
|
|
|
|
|
|
auto map = TMXTiledMap::create("TileMaps/issue_16512.tmx");
|
|
|
|
addChild(map, 0, kTagTileMap);
|
|
|
|
|
|
|
|
Size CC_UNUSED s = map->getContentSize();
|
|
|
|
CCLOG("ContentSize: %f, %f", s.width,s.height);
|
|
|
|
|
|
|
|
auto floor = map->getLayer("Floor");
|
|
|
|
for (auto x = 0; x < map->getMapSize().width; x++) {
|
|
|
|
for (auto y = 0; y < map->getMapSize().height; y++) {
|
|
|
|
Vec2 p(x, y);
|
|
|
|
floor->getTileAt(p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string Issue16512Test::title() const
|
|
|
|
{
|
|
|
|
return "Github Issue #16512. Should not crash";
|
|
|
|
}
|