axmol/core/2d/ActionTiledGrid.cpp

880 lines
22 KiB
C++
Raw Normal View History

/****************************************************************************
Copyright (c) 2009 On-Core
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2013-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
2021-12-25 10:04:45 +08:00
2022-10-01 16:24:52 +08:00
https://axmolengine.github.io/
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.
****************************************************************************/
#include "2d/ActionTiledGrid.h"
#include "2d/Grid.h"
#include "2d/NodeGrid.h"
#include "base/Director.h"
#include "base/Macros.h"
NS_AX_BEGIN
2012-04-18 18:43:45 +08:00
struct Tile
{
2021-12-25 10:04:45 +08:00
Vec2 position;
Vec2 startPosition;
Vec2 delta;
2012-04-18 18:43:45 +08:00
};
2012-04-18 18:43:45 +08:00
// implementation of ShakyTiles3D
2021-10-23 23:27:14 +08:00
ShakyTiles3D* ShakyTiles3D::create(float duration, const Vec2& gridSize, int range, bool shakeZ)
2012-04-18 18:43:45 +08:00
{
2021-12-25 10:04:45 +08:00
ShakyTiles3D* action = new ShakyTiles3D();
2021-12-08 00:11:53 +08:00
if (action->initWithDuration(duration, gridSize, range, shakeZ))
{
action->autorelease();
return action;
}
delete action;
return nullptr;
2012-04-18 18:43:45 +08:00
}
2021-10-23 23:27:14 +08:00
bool ShakyTiles3D::initWithDuration(float duration, const Vec2& gridSize, int range, bool shakeZ)
2012-04-18 18:43:45 +08:00
{
if (TiledGrid3DAction::initWithDuration(duration, gridSize))
{
_randrange = range;
2021-12-25 10:04:45 +08:00
_shakeZ = shakeZ;
2012-04-18 18:43:45 +08:00
return true;
}
2012-04-18 18:43:45 +08:00
return false;
2012-04-18 18:43:45 +08:00
}
ShakyTiles3D* ShakyTiles3D::clone() const
{
// no copy constructor
return ShakyTiles3D::create(_duration, _gridSize, _randrange, _shakeZ);
}
void ShakyTiles3D::update(float /*time*/)
2012-04-18 18:43:45 +08:00
{
int i, j;
for (i = 0; i < _gridSize.width; ++i)
{
for (j = 0; j < _gridSize.height; ++j)
{
Vec2 pos((float)i, (float)j);
Quad3 coords = getOriginalTile(pos);
// X
2021-12-25 10:04:45 +08:00
coords.bl.x += (rand() % (_randrange * 2)) - _randrange;
coords.br.x += (rand() % (_randrange * 2)) - _randrange;
coords.tl.x += (rand() % (_randrange * 2)) - _randrange;
coords.tr.x += (rand() % (_randrange * 2)) - _randrange;
// Y
2021-12-25 10:04:45 +08:00
coords.bl.y += (rand() % (_randrange * 2)) - _randrange;
coords.br.y += (rand() % (_randrange * 2)) - _randrange;
coords.tl.y += (rand() % (_randrange * 2)) - _randrange;
coords.tr.y += (rand() % (_randrange * 2)) - _randrange;
if (_shakeZ)
{
2021-12-25 10:04:45 +08:00
coords.bl.z += (rand() % (_randrange * 2)) - _randrange;
coords.br.z += (rand() % (_randrange * 2)) - _randrange;
coords.tl.z += (rand() % (_randrange * 2)) - _randrange;
coords.tr.z += (rand() % (_randrange * 2)) - _randrange;
}
2021-12-25 10:04:45 +08:00
setTile(pos, coords);
}
}
2012-04-18 18:43:45 +08:00
}
// implementation of ShatteredTiles3D
2012-04-18 18:43:45 +08:00
2021-10-23 23:27:14 +08:00
ShatteredTiles3D* ShatteredTiles3D::create(float duration, const Vec2& gridSize, int range, bool shatterZ)
2012-04-18 18:43:45 +08:00
{
2021-12-25 10:04:45 +08:00
ShatteredTiles3D* action = new ShatteredTiles3D();
2021-12-08 00:11:53 +08:00
if (action->initWithDuration(duration, gridSize, range, shatterZ))
{
action->autorelease();
return action;
}
delete action;
return nullptr;
2012-04-18 18:43:45 +08:00
}
2021-10-23 23:27:14 +08:00
bool ShatteredTiles3D::initWithDuration(float duration, const Vec2& gridSize, int range, bool shatterZ)
2012-04-18 18:43:45 +08:00
{
if (TiledGrid3DAction::initWithDuration(duration, gridSize))
{
2021-12-25 10:04:45 +08:00
_once = false;
_randrange = range;
2021-12-25 10:04:45 +08:00
_shatterZ = shatterZ;
2012-04-18 18:43:45 +08:00
return true;
}
return false;
2012-04-18 18:43:45 +08:00
}
ShatteredTiles3D* ShatteredTiles3D::clone() const
{
// no copy constructor
return ShatteredTiles3D::create(_duration, _gridSize, _randrange, _shatterZ);
}
void ShatteredTiles3D::update(float /*time*/)
2012-04-18 18:43:45 +08:00
{
int i, j;
if (_once == false)
{
for (i = 0; i < _gridSize.width; ++i)
{
for (j = 0; j < _gridSize.height; ++j)
{
Vec2 pos((float)i, (float)j);
Quad3 coords = getOriginalTile(pos);
2021-12-25 10:04:45 +08:00
// X
2021-12-25 10:04:45 +08:00
coords.bl.x += (rand() % (_randrange * 2)) - _randrange;
coords.br.x += (rand() % (_randrange * 2)) - _randrange;
coords.tl.x += (rand() % (_randrange * 2)) - _randrange;
coords.tr.x += (rand() % (_randrange * 2)) - _randrange;
// Y
2021-12-25 10:04:45 +08:00
coords.bl.y += (rand() % (_randrange * 2)) - _randrange;
coords.br.y += (rand() % (_randrange * 2)) - _randrange;
coords.tl.y += (rand() % (_randrange * 2)) - _randrange;
coords.tr.y += (rand() % (_randrange * 2)) - _randrange;
2021-12-25 10:04:45 +08:00
if (_shatterZ)
{
2021-12-25 10:04:45 +08:00
coords.bl.z += (rand() % (_randrange * 2)) - _randrange;
coords.br.z += (rand() % (_randrange * 2)) - _randrange;
coords.tl.z += (rand() % (_randrange * 2)) - _randrange;
coords.tr.z += (rand() % (_randrange * 2)) - _randrange;
}
2021-12-25 10:04:45 +08:00
setTile(pos, coords);
}
}
2021-12-25 10:04:45 +08:00
_once = true;
}
2012-04-18 18:43:45 +08:00
}
// implementation of ShuffleTiles
2021-10-23 23:27:14 +08:00
ShuffleTiles* ShuffleTiles::create(float duration, const Vec2& gridSize, unsigned int seed)
2012-04-18 18:43:45 +08:00
{
2021-12-25 10:04:45 +08:00
ShuffleTiles* action = new ShuffleTiles();
2021-12-08 00:11:53 +08:00
if (action->initWithDuration(duration, gridSize, seed))
{
action->autorelease();
return action;
}
delete action;
return nullptr;
2012-04-18 18:43:45 +08:00
}
2021-10-23 23:27:14 +08:00
bool ShuffleTiles::initWithDuration(float duration, const Vec2& gridSize, unsigned int seed)
2012-04-18 18:43:45 +08:00
{
if (TiledGrid3DAction::initWithDuration(duration, gridSize))
{
2021-12-25 10:04:45 +08:00
_seed = seed;
_tilesOrder = nullptr;
2021-12-25 10:04:45 +08:00
_tiles = nullptr;
2012-04-18 18:43:45 +08:00
return true;
}
return false;
2012-04-18 18:43:45 +08:00
}
ShuffleTiles* ShuffleTiles::clone() const
{
// no copy constructor
return ShuffleTiles::create(_duration, _gridSize, _seed);
}
2014-05-28 17:41:34 +08:00
ShuffleTiles::~ShuffleTiles()
2012-04-18 18:43:45 +08:00
{
2022-07-15 19:17:01 +08:00
AX_SAFE_DELETE_ARRAY(_tilesOrder);
AX_SAFE_DELETE_ARRAY(_tiles);
2012-04-18 18:43:45 +08:00
}
2021-12-25 10:04:45 +08:00
void ShuffleTiles::shuffle(unsigned int* array, unsigned int len)
2012-04-18 18:43:45 +08:00
{
2021-12-25 10:04:45 +08:00
for (int i = len - 1; i >= 0; i--)
{
2021-12-25 10:04:45 +08:00
unsigned int j = rand() % (i + 1);
unsigned int v = array[i];
2021-12-25 10:04:45 +08:00
array[i] = array[j];
array[j] = v;
}
2012-04-18 18:43:45 +08:00
}
2021-10-23 23:27:14 +08:00
Vec2 ShuffleTiles::getDelta(const Vec2& pos) const
2012-04-18 18:43:45 +08:00
{
unsigned int idx = static_cast<unsigned int>(pos.width * _gridSize.height + pos.height);
2021-12-25 10:04:45 +08:00
Vec2 pos2;
2019-11-06 16:25:30 +08:00
pos2.x = (float)(_tilesOrder[idx] / (int)_gridSize.height);
pos2.y = (float)(_tilesOrder[idx] % (int)_gridSize.height);
2021-12-26 23:26:34 +08:00
return Vec2(static_cast<float>((int)(pos2.x - pos.width)), static_cast<float>((int)(pos2.y - pos.height)));
2012-04-18 18:43:45 +08:00
}
2021-12-25 10:04:45 +08:00
void ShuffleTiles::placeTile(const Vec2& pos, Tile* t)
2012-04-18 18:43:45 +08:00
{
2013-07-08 23:12:11 +08:00
Quad3 coords = getOriginalTile(pos);
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
Vec2 step = _gridNodeTarget->getGrid()->getStep();
coords.bl.x += (int)(t->position.x * step.x);
coords.bl.y += (int)(t->position.y * step.y);
coords.br.x += (int)(t->position.x * step.x);
coords.br.y += (int)(t->position.y * step.y);
coords.tl.x += (int)(t->position.x * step.x);
coords.tl.y += (int)(t->position.y * step.y);
coords.tr.x += (int)(t->position.x * step.x);
coords.tr.y += (int)(t->position.y * step.y);
setTile(pos, coords);
2012-04-18 18:43:45 +08:00
}
2021-12-25 10:04:45 +08:00
void ShuffleTiles::startWithTarget(Node* target)
2012-04-18 18:43:45 +08:00
{
TiledGrid3DAction::startWithTarget(target);
if (_seed != (unsigned int)-1)
{
2016-07-11 11:17:28 +08:00
std::srand(_seed);
}
_tilesCount = (unsigned int)(_gridSize.width * _gridSize.height);
_tilesOrder = new unsigned int[_tilesCount];
/**
* Use k to loop. Because _tilesCount is unsigned int,
* and i is used later for int.
*/
2014-05-28 17:41:34 +08:00
for (unsigned int k = 0; k < _tilesCount; ++k)
{
_tilesOrder[k] = k;
}
shuffle(_tilesOrder, _tilesCount);
2021-12-25 10:04:45 +08:00
_tiles = (struct Tile*)new Tile[_tilesCount];
Tile* tileArray = (Tile*)_tiles;
2014-05-28 17:41:34 +08:00
for (int i = 0; i < _gridSize.width; ++i)
{
2021-12-25 10:04:45 +08:00
for (int j = 0; j < _gridSize.height; ++j)
{
tileArray->position.set((float)i, (float)j);
tileArray->startPosition.set((float)i, (float)j);
2021-10-23 23:27:14 +08:00
tileArray->delta = getDelta(Vec2((float)i, (float)j));
++tileArray;
}
}
2012-04-18 18:43:45 +08:00
}
void ShuffleTiles::update(float time)
2012-04-18 18:43:45 +08:00
{
2021-12-25 10:04:45 +08:00
Tile* tileArray = (Tile*)_tiles;
2014-05-28 17:41:34 +08:00
for (int i = 0; i < _gridSize.width; ++i)
{
2014-05-28 17:41:34 +08:00
for (int j = 0; j < _gridSize.height; ++j)
{
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
tileArray->position = Vec2((float)tileArray->delta.width, (float)tileArray->delta.height) * time;
placeTile(Vec2((float)i, (float)j), tileArray);
++tileArray;
}
}
2012-04-18 18:43:45 +08:00
}
// implementation of FadeOutTRTiles
2021-10-23 23:27:14 +08:00
FadeOutTRTiles* FadeOutTRTiles::create(float duration, const Vec2& gridSize)
2012-04-18 18:43:45 +08:00
{
2021-12-25 10:04:45 +08:00
FadeOutTRTiles* action = new FadeOutTRTiles();
2021-12-08 00:11:53 +08:00
if (action->initWithDuration(duration, gridSize))
{
action->autorelease();
return action;
}
delete action;
return nullptr;
2012-04-18 18:43:45 +08:00
}
FadeOutTRTiles* FadeOutTRTiles::clone() const
{
// no copy constructor
return FadeOutTRTiles::create(_duration, _gridSize);
}
2021-10-23 23:27:14 +08:00
float FadeOutTRTiles::testFunc(const Vec2& pos, float time)
2012-04-18 18:43:45 +08:00
{
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
Vec2 n = Vec2((float)_gridSize.width, (float)_gridSize.height) * time;
if ((n.x + n.y) == 0.0f)
{
return 1.0f;
}
return powf((pos.width + pos.height) / (n.x + n.y), 6);
2012-04-18 18:43:45 +08:00
}
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
void FadeOutTRTiles::turnOnTile(const Vec2& pos)
2012-04-18 18:43:45 +08:00
{
2013-07-08 23:12:11 +08:00
setTile(pos, getOriginalTile(pos));
2012-04-18 18:43:45 +08:00
}
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
void FadeOutTRTiles::turnOffTile(const Vec2& pos)
2012-04-18 18:43:45 +08:00
{
Quad3 coords;
memset(&coords, 0, sizeof(Quad3));
setTile(pos, coords);
2012-04-18 18:43:45 +08:00
}
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
void FadeOutTRTiles::transformTile(const Vec2& pos, float distance)
2012-04-18 18:43:45 +08:00
{
2013-07-08 23:12:11 +08:00
Quad3 coords = getOriginalTile(pos);
2021-12-25 10:04:45 +08:00
Vec2 step = _gridNodeTarget->getGrid()->getStep();
coords.bl.x += (step.x / 2) * (1.0f - distance);
coords.bl.y += (step.y / 2) * (1.0f - distance);
coords.br.x -= (step.x / 2) * (1.0f - distance);
coords.br.y += (step.y / 2) * (1.0f - distance);
coords.tl.x += (step.x / 2) * (1.0f - distance);
coords.tl.y -= (step.y / 2) * (1.0f - distance);
coords.tr.x -= (step.x / 2) * (1.0f - distance);
coords.tr.y -= (step.y / 2) * (1.0f - distance);
setTile(pos, coords);
2012-04-18 18:43:45 +08:00
}
void FadeOutTRTiles::update(float time)
2012-04-18 18:43:45 +08:00
{
2014-05-28 17:41:34 +08:00
for (int i = 0; i < _gridSize.width; ++i)
{
2014-05-28 17:41:34 +08:00
for (int j = 0; j < _gridSize.height; ++j)
{
Vec2 pos((float)i, (float)j);
2021-10-23 23:27:14 +08:00
float distance = testFunc(Vec2((float)i, (float)j), time);
2021-12-25 10:04:45 +08:00
if (distance == 0)
{
turnOffTile(pos);
2021-12-25 10:04:45 +08:00
}
else if (distance < 1)
{
transformTile(pos, distance);
}
else
{
turnOnTile(pos);
}
}
}
2012-04-18 18:43:45 +08:00
}
// implementation of FadeOutBLTiles
2021-10-23 23:27:14 +08:00
FadeOutBLTiles* FadeOutBLTiles::create(float duration, const Vec2& gridSize)
2012-04-18 18:43:45 +08:00
{
2021-12-25 10:04:45 +08:00
FadeOutBLTiles* action = new FadeOutBLTiles();
2021-12-08 00:11:53 +08:00
if (action->initWithDuration(duration, gridSize))
{
action->autorelease();
return action;
}
delete action;
return nullptr;
2012-04-18 18:43:45 +08:00
}
FadeOutBLTiles* FadeOutBLTiles::clone() const
{
// no copy constructor
return FadeOutBLTiles::create(_duration, _gridSize);
}
2021-10-23 23:27:14 +08:00
float FadeOutBLTiles::testFunc(const Vec2& pos, float time)
2012-04-18 18:43:45 +08:00
{
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
Vec2 n = Vec2((float)_gridSize.width, (float)_gridSize.height) * (1.0f - time);
if ((pos.width + pos.height) == 0)
{
return 1.0f;
}
return powf((n.x + n.y) / (pos.width + pos.height), 6);
2012-04-18 18:43:45 +08:00
}
// implementation of FadeOutUpTiles
2012-04-18 18:43:45 +08:00
2021-10-23 23:27:14 +08:00
FadeOutUpTiles* FadeOutUpTiles::create(float duration, const Vec2& gridSize)
2012-04-18 18:43:45 +08:00
{
2021-12-25 10:04:45 +08:00
FadeOutUpTiles* action = new FadeOutUpTiles();
2021-12-08 00:11:53 +08:00
if (action->initWithDuration(duration, gridSize))
{
action->autorelease();
return action;
}
delete action;
return nullptr;
2012-04-18 18:43:45 +08:00
}
FadeOutUpTiles* FadeOutUpTiles::clone() const
{
// no copy constructor
return FadeOutUpTiles::create(_duration, _gridSize);
}
2021-10-23 23:27:14 +08:00
float FadeOutUpTiles::testFunc(const Vec2& pos, float time)
2012-04-18 18:43:45 +08:00
{
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
Vec2 n = Vec2((float)_gridSize.width, (float)_gridSize.height) * time;
if (n.y == 0.0f)
{
return 1.0f;
}
return powf(pos.height / n.y, 6);
2012-04-18 18:43:45 +08:00
}
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
void FadeOutUpTiles::transformTile(const Vec2& pos, float distance)
2012-04-18 18:43:45 +08:00
{
2013-07-08 23:12:11 +08:00
Quad3 coords = getOriginalTile(pos);
2021-12-25 10:04:45 +08:00
Vec2 step = _gridNodeTarget->getGrid()->getStep();
coords.bl.y += (step.y / 2) * (1.0f - distance);
coords.br.y += (step.y / 2) * (1.0f - distance);
coords.tl.y -= (step.y / 2) * (1.0f - distance);
coords.tr.y -= (step.y / 2) * (1.0f - distance);
setTile(pos, coords);
2012-04-18 18:43:45 +08:00
}
// implementation of FadeOutDownTiles
2021-10-23 23:27:14 +08:00
FadeOutDownTiles* FadeOutDownTiles::create(float duration, const Vec2& gridSize)
2012-04-18 18:43:45 +08:00
{
2021-12-25 10:04:45 +08:00
FadeOutDownTiles* action = new FadeOutDownTiles();
2021-12-08 00:11:53 +08:00
if (action->initWithDuration(duration, gridSize))
{
action->autorelease();
return action;
}
delete action;
return nullptr;
2012-04-18 18:43:45 +08:00
}
FadeOutDownTiles* FadeOutDownTiles::clone() const
{
// no copy constructor
return FadeOutDownTiles::create(_duration, _gridSize);
}
2021-10-23 23:27:14 +08:00
float FadeOutDownTiles::testFunc(const Vec2& pos, float time)
2012-04-18 18:43:45 +08:00
{
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
Vec2 n = Vec2((float)_gridSize.width, (float)_gridSize.height) * (1.0f - time);
return powf(n.y / (pos.height > 0.0f ? pos.height : 0.1f), 6);
2012-04-18 18:43:45 +08:00
}
2012-04-18 18:43:45 +08:00
// implementation of TurnOffTiles
2021-10-23 23:27:14 +08:00
TurnOffTiles* TurnOffTiles::create(float duration, const Vec2& gridSize)
2012-04-18 18:43:45 +08:00
{
2021-12-08 00:11:53 +08:00
TurnOffTiles* action = new TurnOffTiles();
if (action->initWithDuration(duration, gridSize, 0))
{
action->autorelease();
return action;
}
2021-12-25 10:04:45 +08:00
delete action;
return nullptr;
2012-04-18 18:43:45 +08:00
}
2021-10-23 23:27:14 +08:00
TurnOffTiles* TurnOffTiles::create(float duration, const Vec2& gridSize, unsigned int seed)
2012-04-18 18:43:45 +08:00
{
2021-12-25 10:04:45 +08:00
TurnOffTiles* action = new TurnOffTiles();
2021-12-08 00:11:53 +08:00
if (action->initWithDuration(duration, gridSize, seed))
{
action->autorelease();
return action;
}
delete action;
return nullptr;
2012-04-18 18:43:45 +08:00
}
2021-10-23 23:27:14 +08:00
bool TurnOffTiles::initWithDuration(float duration, const Vec2& gridSize, unsigned int seed)
2012-04-18 18:43:45 +08:00
{
if (TiledGrid3DAction::initWithDuration(duration, gridSize))
{
2021-12-25 10:04:45 +08:00
_seed = seed;
_tilesOrder = nullptr;
return true;
}
return false;
2012-04-18 18:43:45 +08:00
}
TurnOffTiles* TurnOffTiles::clone() const
{
// no copy constructor
return TurnOffTiles::create(_duration, _gridSize, _seed);
}
TurnOffTiles::~TurnOffTiles()
2012-04-18 18:43:45 +08:00
{
2022-07-15 19:17:01 +08:00
AX_SAFE_DELETE_ARRAY(_tilesOrder);
2012-04-18 18:43:45 +08:00
}
2021-12-25 10:04:45 +08:00
void TurnOffTiles::shuffle(unsigned int* array, unsigned int len)
2012-04-18 18:43:45 +08:00
{
2014-05-28 17:41:34 +08:00
for (int i = len - 1; i >= 0; i--)
{
2021-12-25 10:04:45 +08:00
unsigned int j = rand() % (i + 1);
unsigned int v = array[i];
2021-12-25 10:04:45 +08:00
array[i] = array[j];
array[j] = v;
}
2012-04-18 18:43:45 +08:00
}
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
void TurnOffTiles::turnOnTile(const Vec2& pos)
2012-04-18 18:43:45 +08:00
{
2013-07-08 23:12:11 +08:00
setTile(pos, getOriginalTile(pos));
2012-04-18 18:43:45 +08:00
}
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
void TurnOffTiles::turnOffTile(const Vec2& pos)
2012-04-18 18:43:45 +08:00
{
Quad3 coords;
memset(&coords, 0, sizeof(Quad3));
setTile(pos, coords);
2012-04-18 18:43:45 +08:00
}
2021-12-25 10:04:45 +08:00
void TurnOffTiles::startWithTarget(Node* target)
2012-04-18 18:43:45 +08:00
{
TiledGrid3DAction::startWithTarget(target);
if (_seed != (unsigned int)-1)
{
2016-07-11 11:17:28 +08:00
std::srand(_seed);
}
_tilesCount = (unsigned int)(_gridSize.width * _gridSize.height);
_tilesOrder = new unsigned int[_tilesCount];
2014-05-28 17:41:34 +08:00
for (unsigned int i = 0; i < _tilesCount; ++i)
{
_tilesOrder[i] = i;
}
shuffle(_tilesOrder, _tilesCount);
2012-04-18 18:43:45 +08:00
}
void TurnOffTiles::update(float time)
2012-04-18 18:43:45 +08:00
{
2014-05-28 17:41:34 +08:00
unsigned int l = (unsigned int)(time * (float)_tilesCount);
2014-05-28 17:41:34 +08:00
unsigned int t = 0;
2021-12-25 10:04:45 +08:00
for (unsigned int i = 0; i < _tilesCount; i++)
{
t = _tilesOrder[i];
2021-12-25 10:04:45 +08:00
// needs integer value
unsigned int x = (unsigned int)(t / _gridSize.height);
Vec2 tilePos((float)x, (float)(t % (unsigned int)_gridSize.height));
2021-12-25 10:04:45 +08:00
if (i < l)
{
turnOffTile(tilePos);
}
else
{
turnOnTile(tilePos);
}
}
2012-04-18 18:43:45 +08:00
}
// implementation of WavesTiles3D
2012-04-18 18:43:45 +08:00
2021-10-23 23:27:14 +08:00
WavesTiles3D* WavesTiles3D::create(float duration, const Vec2& gridSize, unsigned int waves, float amplitude)
2012-04-18 18:43:45 +08:00
{
2021-12-25 10:04:45 +08:00
WavesTiles3D* action = new WavesTiles3D();
2021-12-08 00:11:53 +08:00
if (action->initWithDuration(duration, gridSize, waves, amplitude))
{
action->autorelease();
return action;
}
delete action;
return nullptr;
2012-04-18 18:43:45 +08:00
}
2021-10-23 23:27:14 +08:00
bool WavesTiles3D::initWithDuration(float duration, const Vec2& gridSize, unsigned int waves, float amplitude)
2012-04-18 18:43:45 +08:00
{
if (TiledGrid3DAction::initWithDuration(duration, gridSize))
{
2021-12-25 10:04:45 +08:00
_waves = waves;
_amplitude = amplitude;
_amplitudeRate = 1.0f;
return true;
}
return false;
2012-04-18 18:43:45 +08:00
}
WavesTiles3D* WavesTiles3D::clone() const
{
// no copy constructor
return WavesTiles3D::create(_duration, _gridSize, _waves, _amplitude);
}
void WavesTiles3D::update(float time)
2012-04-18 18:43:45 +08:00
{
2021-12-25 10:04:45 +08:00
for (int i = 0; i < _gridSize.width; i++)
{
2021-12-25 10:04:45 +08:00
for (int j = 0; j < _gridSize.height; j++)
{
Vec2 pos((float)i, (float)j);
Quad3 coords = getOriginalTile(pos);
2021-12-25 10:04:45 +08:00
coords.bl.z = (sinf(time * (float)M_PI * _waves * 2 + (coords.bl.y + coords.bl.x) * .01f) * _amplitude *
_amplitudeRate);
coords.br.z = coords.bl.z;
coords.tl.z = coords.bl.z;
coords.tr.z = coords.bl.z;
setTile(pos, coords);
}
}
2012-04-18 18:43:45 +08:00
}
// implementation of JumpTiles3D
2012-04-18 18:43:45 +08:00
2021-10-23 23:27:14 +08:00
JumpTiles3D* JumpTiles3D::create(float duration, const Vec2& gridSize, unsigned int numberOfJumps, float amplitude)
2012-04-18 18:43:45 +08:00
{
2021-12-25 10:04:45 +08:00
JumpTiles3D* action = new JumpTiles3D();
2021-12-08 00:11:53 +08:00
if (action->initWithDuration(duration, gridSize, numberOfJumps, amplitude))
{
action->autorelease();
return action;
}
delete action;
return nullptr;
2012-04-18 18:43:45 +08:00
}
2021-10-23 23:27:14 +08:00
bool JumpTiles3D::initWithDuration(float duration, const Vec2& gridSize, unsigned int numberOfJumps, float amplitude)
2012-04-18 18:43:45 +08:00
{
if (TiledGrid3DAction::initWithDuration(duration, gridSize))
{
2021-12-25 10:04:45 +08:00
_jumps = numberOfJumps;
_amplitude = amplitude;
_amplitudeRate = 1.0f;
return true;
}
return false;
2012-04-18 18:43:45 +08:00
}
JumpTiles3D* JumpTiles3D::clone() const
{
// no copy constructor
return JumpTiles3D::create(_duration, _gridSize, _jumps, _amplitude);
}
void JumpTiles3D::update(float time)
2012-04-18 18:43:45 +08:00
{
2021-12-25 10:04:45 +08:00
float sinz = (sinf((float)M_PI * time * _jumps * 2) * _amplitude * _amplitudeRate);
float sinz2 = (sinf((float)M_PI * (time * _jumps * 2 + 1)) * _amplitude * _amplitudeRate);
2021-12-25 10:04:45 +08:00
for (int i = 0; i < _gridSize.width; i++)
{
2021-12-25 10:04:45 +08:00
for (int j = 0; j < _gridSize.height; j++)
{
Vec2 pos((float)i, (float)j);
Quad3 coords = getOriginalTile(pos);
2021-12-25 10:04:45 +08:00
if (((i + j) % 2) == 0)
{
coords.bl.z += sinz;
coords.br.z += sinz;
coords.tl.z += sinz;
coords.tr.z += sinz;
}
else
{
coords.bl.z += sinz2;
coords.br.z += sinz2;
coords.tl.z += sinz2;
coords.tr.z += sinz2;
}
setTile(pos, coords);
}
}
2012-04-18 18:43:45 +08:00
}
// implementation of SplitRows
SplitRows* SplitRows::create(float duration, unsigned int nRows)
2012-04-18 18:43:45 +08:00
{
2021-12-25 10:04:45 +08:00
SplitRows* action = new SplitRows();
2021-12-08 00:11:53 +08:00
if (action->initWithDuration(duration, nRows))
{
action->autorelease();
return action;
}
delete action;
return nullptr;
2012-04-18 18:43:45 +08:00
}
bool SplitRows::initWithDuration(float duration, unsigned int rows)
2012-04-18 18:43:45 +08:00
{
_rows = rows;
2021-10-23 23:27:14 +08:00
return TiledGrid3DAction::initWithDuration(duration, Vec2(1.0f, (float)rows));
2012-04-18 18:43:45 +08:00
}
SplitRows* SplitRows::clone() const
{
// no copy constructor
return SplitRows::create(_duration, _rows);
}
2021-12-25 10:04:45 +08:00
void SplitRows::startWithTarget(Node* target)
2012-04-18 18:43:45 +08:00
{
TiledGrid3DAction::startWithTarget(target);
_winSize = Director::getInstance()->getWinSizeInPixels();
2012-04-18 18:43:45 +08:00
}
void SplitRows::update(float time)
2012-04-18 18:43:45 +08:00
{
for (int j = 0; j < _gridSize.height; ++j)
{
Vec2 pos(0, (float)j);
2021-12-25 10:04:45 +08:00
Quad3 coords = getOriginalTile(pos);
float direction = 1;
2021-12-25 10:04:45 +08:00
if ((j % 2) == 0)
{
direction = -1;
}
coords.bl.x += direction * _winSize.width * time;
coords.br.x += direction * _winSize.width * time;
coords.tl.x += direction * _winSize.width * time;
coords.tr.x += direction * _winSize.width * time;
setTile(pos, coords);
}
2012-04-18 18:43:45 +08:00
}
// implementation of SplitCols
2012-04-18 18:43:45 +08:00
SplitCols* SplitCols::create(float duration, unsigned int cols)
2012-04-18 18:43:45 +08:00
{
2021-12-25 10:04:45 +08:00
SplitCols* action = new SplitCols();
2021-12-08 00:11:53 +08:00
if (action->initWithDuration(duration, cols))
{
action->autorelease();
return action;
}
delete action;
return nullptr;
2012-04-18 18:43:45 +08:00
}
bool SplitCols::initWithDuration(float duration, unsigned int cols)
2012-04-18 18:43:45 +08:00
{
_cols = cols;
2021-10-23 23:27:14 +08:00
return TiledGrid3DAction::initWithDuration(duration, Vec2((float)cols, 1.0f));
2012-04-18 18:43:45 +08:00
}
SplitCols* SplitCols::clone() const
{
// no copy constructor
return SplitCols::create(_duration, _cols);
}
2021-12-25 10:04:45 +08:00
void SplitCols::startWithTarget(Node* target)
2012-04-18 18:43:45 +08:00
{
TiledGrid3DAction::startWithTarget(target);
_winSize = Director::getInstance()->getWinSizeInPixels();
2012-04-18 18:43:45 +08:00
}
void SplitCols::update(float time)
2012-04-18 18:43:45 +08:00
{
2014-05-28 17:41:34 +08:00
for (unsigned int i = 0; i < _gridSize.width; ++i)
{
Vec2 pos((float)i, 0);
2021-12-25 10:04:45 +08:00
Quad3 coords = getOriginalTile(pos);
float direction = 1;
2012-04-18 18:43:45 +08:00
2021-12-25 10:04:45 +08:00
if ((i % 2) == 0)
{
direction = -1;
}
coords.bl.y += direction * _winSize.height * time;
coords.br.y += direction * _winSize.height * time;
coords.tl.y += direction * _winSize.height * time;
coords.tr.y += direction * _winSize.height * time;
2012-04-18 18:43:45 +08:00
setTile(pos, coords);
}
2012-04-18 18:43:45 +08:00
}
NS_AX_END