mirror of https://github.com/axmolengine/axmol.git
Merge branch 'v3' of https://github.com/cocos2d/cocos2d-x into v3.8-label-gb2312
This commit is contained in:
commit
c4112e1ce5
|
@ -102,7 +102,7 @@ GridBase* GridAction::getGrid()
|
|||
|
||||
GridBase* Grid3DAction::getGrid()
|
||||
{
|
||||
return Grid3D::create(_gridSize);
|
||||
return Grid3D::create(_gridSize, _gridNodeTarget->getGridRect());
|
||||
}
|
||||
|
||||
Vec3 Grid3DAction::getVertex(const Vec2& position) const
|
||||
|
@ -123,11 +123,17 @@ void Grid3DAction::setVertex(const Vec2& position, const Vec3& vertex)
|
|||
g->setVertex(position, vertex);
|
||||
}
|
||||
|
||||
Rect Grid3DAction::getGridRect() const
|
||||
{
|
||||
Grid3D *g = (Grid3D*)_gridNodeTarget->getGrid();
|
||||
return g->getGridRect();
|
||||
}
|
||||
|
||||
// implementation of TiledGrid3DAction
|
||||
|
||||
GridBase* TiledGrid3DAction::getGrid(void)
|
||||
{
|
||||
return TiledGrid3D::create(_gridSize);
|
||||
return TiledGrid3D::create(_gridSize, _gridNodeTarget->getGridRect());
|
||||
}
|
||||
|
||||
Quad3 TiledGrid3DAction::getTile(const Vec2& pos) const
|
||||
|
|
|
@ -140,6 +140,12 @@ public:
|
|||
CC_ASSERT(0);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the effect grid rect.
|
||||
* @return Return the effect grid rect.
|
||||
*/
|
||||
Rect getGridRect() const;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -25,6 +25,7 @@ THE SOFTWARE.
|
|||
****************************************************************************/
|
||||
#include "2d/CCActionPageTurn3D.h"
|
||||
#include "2d/CCGrid.h"
|
||||
#include "2d/CCNodeGrid.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
|
@ -58,7 +59,7 @@ PageTurn3D *PageTurn3D::clone() const
|
|||
|
||||
GridBase* PageTurn3D::getGrid()
|
||||
{
|
||||
auto result = Grid3D::create(_gridSize);
|
||||
auto result = Grid3D::create(_gridSize, _gridNodeTarget->getGridRect());
|
||||
result->setNeedDepthTestForBlit(true);
|
||||
return result;
|
||||
}
|
||||
|
@ -73,8 +74,10 @@ void PageTurn3D::update(float time)
|
|||
float deltaAy = (tt * tt * 500);
|
||||
float ay = -100 - deltaAy;
|
||||
|
||||
float deltaTheta = - (float) M_PI_2 * sqrtf( time) ;
|
||||
float theta = /*0.01f */ + (float) M_PI_2 +deltaTheta;
|
||||
float deltaTheta = sqrtf(time);
|
||||
float theta = deltaTheta>0.5?(float)M_PI_2*deltaTheta:(float)M_PI_2*(1-deltaTheta);
|
||||
|
||||
float rotateByYAxis = (2-time)* M_PI;
|
||||
|
||||
float sinTheta = sinf(theta);
|
||||
float cosTheta = cosf(theta);
|
||||
|
@ -86,6 +89,7 @@ void PageTurn3D::update(float time)
|
|||
// Get original vertex
|
||||
Vec3 p = getOriginalVertex(Vec2(i ,j));
|
||||
|
||||
p.x -= getGridRect().origin.x;
|
||||
float R = sqrtf((p.x * p.x) + ((p.y - ay) * (p.y - ay)));
|
||||
float r = R * sinTheta;
|
||||
float alpha = asinf( p.x / R );
|
||||
|
@ -109,8 +113,11 @@ void PageTurn3D::update(float time)
|
|||
|
||||
// We scale z here to avoid the animation being
|
||||
// too much bigger than the screen due to perspective transform
|
||||
p.z = (r * ( 1 - cosBeta ) * cosTheta) / 7;// "100" didn't work for
|
||||
|
||||
p.z = (r * ( 1 - cosBeta ) * cosTheta);// "100" didn't work for
|
||||
p.x = p.z * sinf(rotateByYAxis) + p.x * cosf(rotateByYAxis);
|
||||
p.z = p.z * cosf(rotateByYAxis) - p.x * sinf(rotateByYAxis);
|
||||
p.z/=7;
|
||||
// Stop z coord from dropping beneath underlying page in a transition
|
||||
// issue #751
|
||||
if( p.z < 0.5f )
|
||||
|
@ -119,6 +126,7 @@ void PageTurn3D::update(float time)
|
|||
}
|
||||
|
||||
// Set new coords
|
||||
p.x += getGridRect().origin.x;
|
||||
setVertex(Vec2(i, j), p);
|
||||
|
||||
}
|
||||
|
|
|
@ -79,22 +79,76 @@ GridBase* GridBase::create(const Size& gridSize, Texture2D *texture, bool flippe
|
|||
return pGridBase;
|
||||
}
|
||||
|
||||
bool GridBase::initWithSize(const Size& gridSize)
|
||||
{
|
||||
return initWithSize(gridSize, Rect::ZERO);
|
||||
}
|
||||
|
||||
bool GridBase::initWithSize(const cocos2d::Size &gridSize, const cocos2d::Rect &rect)
|
||||
{
|
||||
Director *director = Director::getInstance();
|
||||
Size s = director->getWinSizeInPixels();
|
||||
|
||||
auto POTWide = ccNextPOT((unsigned int)s.width);
|
||||
auto POTHigh = ccNextPOT((unsigned int)s.height);
|
||||
|
||||
// we only use rgba8888
|
||||
Texture2D::PixelFormat format = Texture2D::PixelFormat::RGBA8888;
|
||||
|
||||
auto dataLen = POTWide * POTHigh * 4;
|
||||
void *data = calloc(dataLen, 1);
|
||||
if (! data)
|
||||
{
|
||||
CCLOG("cocos2d: Grid: not enough memory.");
|
||||
this->release();
|
||||
return false;
|
||||
}
|
||||
|
||||
Texture2D *texture = new (std::nothrow) Texture2D();
|
||||
texture->initWithData(data, dataLen, format, POTWide, POTHigh, s);
|
||||
|
||||
free(data);
|
||||
|
||||
if (! texture)
|
||||
{
|
||||
CCLOG("cocos2d: Grid: error creating texture");
|
||||
return false;
|
||||
}
|
||||
|
||||
initWithSize(gridSize, texture, false, rect);
|
||||
|
||||
texture->release();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GridBase::initWithSize(const Size& gridSize, Texture2D *texture, bool flipped)
|
||||
{
|
||||
bool ret = true;
|
||||
return initWithSize(gridSize, texture, flipped, Rect::ZERO);
|
||||
}
|
||||
|
||||
bool GridBase::initWithSize(const Size& gridSize, Texture2D *texture, bool flipped, const Rect& rect)
|
||||
{
|
||||
bool ret = true;
|
||||
|
||||
_active = false;
|
||||
_reuseGrid = 0;
|
||||
_gridSize = gridSize;
|
||||
|
||||
|
||||
_texture = texture;
|
||||
CC_SAFE_RETAIN(_texture);
|
||||
_isTextureFlipped = flipped;
|
||||
|
||||
Size texSize = _texture->getContentSize();
|
||||
_step.x = texSize.width / _gridSize.width;
|
||||
_step.y = texSize.height / _gridSize.height;
|
||||
|
||||
|
||||
if (rect.equals(Rect::ZERO)) {
|
||||
auto size = _texture->getContentSize();
|
||||
_gridRect.setRect(0, 0, size.width, size.height);
|
||||
}
|
||||
else{
|
||||
_gridRect = rect;
|
||||
}
|
||||
_step.x = _gridRect.size.width/_gridSize.width;
|
||||
_step.y = _gridRect.size.height/_gridSize.height;
|
||||
|
||||
_grabber = new (std::nothrow) Grabber();
|
||||
if (_grabber)
|
||||
{
|
||||
|
@ -107,46 +161,8 @@ bool GridBase::initWithSize(const Size& gridSize, Texture2D *texture, bool flipp
|
|||
|
||||
_shaderProgram = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE);
|
||||
calculateVertexPoints();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool GridBase::initWithSize(const Size& gridSize)
|
||||
{
|
||||
Director *director = Director::getInstance();
|
||||
Size s = director->getWinSizeInPixels();
|
||||
|
||||
auto POTWide = ccNextPOT((unsigned int)s.width);
|
||||
auto POTHigh = ccNextPOT((unsigned int)s.height);
|
||||
|
||||
// we only use rgba8888
|
||||
Texture2D::PixelFormat format = Texture2D::PixelFormat::RGBA8888;
|
||||
|
||||
auto dataLen = POTWide * POTHigh * 4;
|
||||
void *data = calloc(dataLen, 1);
|
||||
if (! data)
|
||||
{
|
||||
CCLOG("cocos2d: Grid: not enough memory.");
|
||||
this->release();
|
||||
return false;
|
||||
}
|
||||
|
||||
Texture2D *texture = new (std::nothrow) Texture2D();
|
||||
texture->initWithData(data, dataLen, format, POTWide, POTHigh, s);
|
||||
|
||||
free(data);
|
||||
|
||||
if (! texture)
|
||||
{
|
||||
CCLOG("cocos2d: Grid: error creating texture");
|
||||
return false;
|
||||
}
|
||||
|
||||
initWithSize(gridSize, texture, false);
|
||||
|
||||
texture->release();
|
||||
|
||||
return true;
|
||||
return ret;
|
||||
}
|
||||
|
||||
GridBase::~GridBase(void)
|
||||
|
@ -195,6 +211,11 @@ void GridBase::set2DProjection()
|
|||
GL::setProjectionMatrixDirty();
|
||||
}
|
||||
|
||||
void GridBase::setGridRect(const cocos2d::Rect &rect)
|
||||
{
|
||||
_gridRect = rect;
|
||||
}
|
||||
|
||||
void GridBase::beforeDraw(void)
|
||||
{
|
||||
// save projection
|
||||
|
@ -260,26 +281,6 @@ void GridBase::calculateVertexPoints(void)
|
|||
|
||||
// implementation of Grid3D
|
||||
|
||||
Grid3D* Grid3D::create(const Size& gridSize, Texture2D *texture, bool flipped)
|
||||
{
|
||||
Grid3D *ret= new (std::nothrow) Grid3D();
|
||||
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithSize(gridSize, texture, flipped))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
delete ret;
|
||||
ret = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Grid3D* Grid3D::create(const Size& gridSize)
|
||||
{
|
||||
Grid3D *ret= new (std::nothrow) Grid3D();
|
||||
|
@ -300,6 +301,66 @@ Grid3D* Grid3D::create(const Size& gridSize)
|
|||
return ret;
|
||||
}
|
||||
|
||||
Grid3D* Grid3D::create(const Size& gridSize, const Rect& rect)
|
||||
{
|
||||
Grid3D *ret= new (std::nothrow) Grid3D();
|
||||
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithSize(gridSize, rect))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
delete ret;
|
||||
ret = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Grid3D* Grid3D::create(const Size& gridSize, Texture2D *texture, bool flipped)
|
||||
{
|
||||
Grid3D *ret= new (std::nothrow) Grid3D();
|
||||
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithSize(gridSize, texture, flipped))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
delete ret;
|
||||
ret = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Grid3D* Grid3D::create(const Size& gridSize, Texture2D *texture, bool flipped, const Rect& rect)
|
||||
{
|
||||
Grid3D *ret= new (std::nothrow) Grid3D();
|
||||
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithSize(gridSize, texture, flipped, rect))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
delete ret;
|
||||
ret = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Grid3D::Grid3D()
|
||||
: _texCoordinates(nullptr)
|
||||
|
@ -402,9 +463,9 @@ void Grid3D::calculateVertexPoints(void)
|
|||
{
|
||||
int idx = (y * _gridSize.width) + x;
|
||||
|
||||
GLfloat x1 = x * _step.x;
|
||||
GLfloat x1 = x * _step.x + _gridRect.origin.x;
|
||||
GLfloat x2 = x1 + _step.x;
|
||||
GLfloat y1 = y * _step.y;
|
||||
GLfloat y1 = y * _step.y + _gridRect.origin.y;
|
||||
GLfloat y2= y1 + _step.y;
|
||||
|
||||
GLushort a = (GLushort)(x * (_gridSize.height + 1) + y);
|
||||
|
@ -511,26 +572,6 @@ TiledGrid3D::~TiledGrid3D(void)
|
|||
CC_SAFE_FREE(_indices);
|
||||
}
|
||||
|
||||
TiledGrid3D* TiledGrid3D::create(const Size& gridSize, Texture2D *texture, bool flipped)
|
||||
{
|
||||
TiledGrid3D *ret= new (std::nothrow) TiledGrid3D();
|
||||
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithSize(gridSize, texture, flipped))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
delete ret;
|
||||
ret = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
TiledGrid3D* TiledGrid3D::create(const Size& gridSize)
|
||||
{
|
||||
TiledGrid3D *ret= new (std::nothrow) TiledGrid3D();
|
||||
|
@ -551,6 +592,66 @@ TiledGrid3D* TiledGrid3D::create(const Size& gridSize)
|
|||
return ret;
|
||||
}
|
||||
|
||||
TiledGrid3D* TiledGrid3D::create(const Size& gridSize, const Rect& rect)
|
||||
{
|
||||
TiledGrid3D *ret= new (std::nothrow) TiledGrid3D();
|
||||
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithSize(gridSize, rect))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
delete ret;
|
||||
ret = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
TiledGrid3D* TiledGrid3D::create(const Size& gridSize, Texture2D *texture, bool flipped, const Rect& rect)
|
||||
{
|
||||
TiledGrid3D *ret= new (std::nothrow) TiledGrid3D();
|
||||
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithSize(gridSize, texture, flipped, rect))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
delete ret;
|
||||
ret = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
TiledGrid3D* TiledGrid3D::create(const Size& gridSize, Texture2D *texture, bool flipped)
|
||||
{
|
||||
TiledGrid3D *ret= new (std::nothrow) TiledGrid3D();
|
||||
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithSize(gridSize, texture, flipped))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
delete ret;
|
||||
ret = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void TiledGrid3D::blit(void)
|
||||
{
|
||||
int n = _gridSize.width * _gridSize.height;
|
||||
|
@ -602,9 +703,9 @@ void TiledGrid3D::calculateVertexPoints(void)
|
|||
{
|
||||
for( y = 0; y < _gridSize.height; y++ )
|
||||
{
|
||||
float x1 = x * _step.x;
|
||||
float x1 = x * _step.x + _gridRect.origin.x;
|
||||
float x2 = x1 + _step.x;
|
||||
float y1 = y * _step.y;
|
||||
float y1 = y * _step.y + _gridRect.origin.y;
|
||||
float y2 = y1 + _step.y;
|
||||
|
||||
*vertArray++ = x1;
|
||||
|
|
|
@ -63,9 +63,13 @@ public:
|
|||
@param gridSize the size of the grid.
|
||||
@param texture The texture used for grab.
|
||||
@param flipped whether or not the grab texture should be flip by Y or not.
|
||||
@param rect The effct grid rect.
|
||||
*/
|
||||
bool initWithSize(const Size& gridSize, Texture2D *texture, bool flipped);
|
||||
bool initWithSize(const Size& gridSize);
|
||||
bool initWithSize(const Size& gridSize, const Rect& rect);
|
||||
bool initWithSize(const Size& gridSize, Texture2D *texture, bool flipped);
|
||||
bool initWithSize(const Size& gridSize, Texture2D *texture, bool flipped, const Rect& rect);
|
||||
|
||||
/**@}*/
|
||||
/** @{
|
||||
Getter and setter of the active state of the grid.
|
||||
|
@ -118,6 +122,17 @@ public:
|
|||
|
||||
/**Change projection to 2D for grabbing.*/
|
||||
void set2DProjection(void);
|
||||
|
||||
/**
|
||||
* @brief Set the effect grid rect.
|
||||
* @param rect The effect grid rect.
|
||||
*/
|
||||
void setGridRect(const Rect& rect);
|
||||
/**
|
||||
* @brief Get the effect grid rect.
|
||||
* @return Return the effect grid rect.
|
||||
*/
|
||||
inline const Rect& getGridRect() const {return _gridRect;}
|
||||
|
||||
protected:
|
||||
bool _active;
|
||||
|
@ -129,6 +144,7 @@ protected:
|
|||
bool _isTextureFlipped;
|
||||
GLProgram* _shaderProgram;
|
||||
Director::Projection _directorProjection;
|
||||
Rect _gridRect;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -137,10 +153,14 @@ protected:
|
|||
class CC_DLL Grid3D : public GridBase
|
||||
{
|
||||
public:
|
||||
/** create one Grid. */
|
||||
static Grid3D* create(const Size& gridSize);
|
||||
/** craete one Grid. */
|
||||
static Grid3D* create(const Size& gridSize, const Rect& rect);
|
||||
/** create one Grid. */
|
||||
static Grid3D* create(const Size& gridSize, Texture2D *texture, bool flipped);
|
||||
/** create one Grid. */
|
||||
static Grid3D* create(const Size& gridSize);
|
||||
static Grid3D* create(const Size& gridSize, Texture2D *texture, bool flipped, const Rect& rect);
|
||||
/**
|
||||
Constructor.
|
||||
* @js ctor
|
||||
|
@ -210,10 +230,14 @@ protected:
|
|||
class CC_DLL TiledGrid3D : public GridBase
|
||||
{
|
||||
public:
|
||||
/** Create one Grid. */
|
||||
static TiledGrid3D* create(const Size& gridSize);
|
||||
/** Create one Grid. */
|
||||
static TiledGrid3D* create(const Size& gridSize, const Rect& rect);
|
||||
/** Create one Grid. */
|
||||
static TiledGrid3D* create(const Size& gridSize, Texture2D *texture, bool flipped);
|
||||
/** Create one Grid. */
|
||||
static TiledGrid3D* create(const Size& gridSize);
|
||||
static TiledGrid3D* create(const Size& gridSize, Texture2D *texture, bool flipped, const Rect& rect);
|
||||
/**
|
||||
Constructor.
|
||||
* @js ctor
|
||||
|
|
|
@ -42,9 +42,19 @@ NodeGrid* NodeGrid::create()
|
|||
return ret;
|
||||
}
|
||||
|
||||
NodeGrid* NodeGrid::create(const cocos2d::Rect &rect)
|
||||
{
|
||||
NodeGrid* ret = NodeGrid::create();
|
||||
if (ret) {
|
||||
ret->setGridRect(rect);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
NodeGrid::NodeGrid()
|
||||
: _gridTarget(nullptr)
|
||||
, _nodeGrid(nullptr)
|
||||
, _gridRect(Rect::ZERO)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -50,6 +50,8 @@ public:
|
|||
*/
|
||||
static NodeGrid* create();
|
||||
|
||||
static NodeGrid* create(const Rect& rect);
|
||||
|
||||
/** Get a Grid Node.
|
||||
*
|
||||
* @return Return a GridBase.
|
||||
|
@ -72,6 +74,17 @@ public:
|
|||
* @param target A Node is used to set the Grid Target.
|
||||
*/
|
||||
void setTarget(Node *target);
|
||||
|
||||
/**
|
||||
* @brief Set the effect grid rect.
|
||||
* @param gridRect The effect grid rect.
|
||||
*/
|
||||
inline void setGridRect(const Rect& gridRect){_gridRect = gridRect;}
|
||||
/**
|
||||
* @brief Get the effect grid rect.
|
||||
* @return Return the effect grid rect.
|
||||
*/
|
||||
inline const Rect& getGridRect() const { return _gridRect;}
|
||||
|
||||
// overrides
|
||||
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override;
|
||||
|
@ -89,6 +102,8 @@ protected:
|
|||
GroupCommand _groupCommand;
|
||||
CustomCommand _gridBeginCommand;
|
||||
CustomCommand _gridEndCommand;
|
||||
|
||||
Rect _gridRect;
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(NodeGrid);
|
||||
|
|
|
@ -283,6 +283,8 @@ void RichText::handleTextRenderer(const std::string& text, const std::string& fo
|
|||
std::string curText = text;
|
||||
size_t stringLength = StringUtils::getCharacterCountInUTF8String(text);
|
||||
int leftLength = stringLength * (1.0f - overstepPercent);
|
||||
//The minimum cut length is 1, otherwise will cause the infinite loop.
|
||||
if (0 == leftLength) leftLength = 1;
|
||||
std::string leftWords = Helper::getSubStringOfUTF8String(curText,0,leftLength);
|
||||
std::string cutWords = Helper::getSubStringOfUTF8String(curText, leftLength, stringLength - leftLength);
|
||||
if (leftLength > 0)
|
||||
|
|
|
@ -3,374 +3,377 @@
|
|||
|
||||
USING_NS_CC;
|
||||
|
||||
enum {
|
||||
kTagTextLayer = 1,
|
||||
|
||||
kTagBackground = 1,
|
||||
kTagLabel = 2,
|
||||
};
|
||||
|
||||
static std::string effectsList[] =
|
||||
{
|
||||
"Shaky3D",
|
||||
"Waves3D",
|
||||
"FlipX3D",
|
||||
"FlipY3D",
|
||||
"Lens3D",
|
||||
"Ripple3D",
|
||||
"Liquid",
|
||||
"Waves",
|
||||
"Twirl",
|
||||
"ShakyTiles3D",
|
||||
"ShatteredTiles3D",
|
||||
"ShuffleTiles",
|
||||
"FadeOutTRTiles",
|
||||
"FadeOutBLTiles",
|
||||
"FadeOutUpTiles",
|
||||
"FadeOutDownTiles",
|
||||
"TurnOffTiles",
|
||||
"WavesTiles3D",
|
||||
"JumpTiles3D",
|
||||
"SplitRows",
|
||||
"SplitCols",
|
||||
"PageTurn3D",
|
||||
};
|
||||
|
||||
EffectTests::EffectTests()
|
||||
{
|
||||
int index = 0;
|
||||
for (auto& effectName : effectsList)
|
||||
{
|
||||
addTestCase(effectName, [index](){return EffectBaseTest::create(index); });
|
||||
index++;
|
||||
}
|
||||
ADD_TEST_CASE(Shaky3DDemo);
|
||||
ADD_TEST_CASE(Waves3DDemo);
|
||||
ADD_TEST_CASE(FlipX3DDemo);
|
||||
ADD_TEST_CASE(FlipY3DDemo);
|
||||
ADD_TEST_CASE(Lens3DDemo);
|
||||
ADD_TEST_CASE(Ripple3DDemo);
|
||||
ADD_TEST_CASE(LiquidDemo);
|
||||
ADD_TEST_CASE(WavesDemo);
|
||||
ADD_TEST_CASE(TwirlDemo);
|
||||
ADD_TEST_CASE(ShakyTiles3DDemo);
|
||||
ADD_TEST_CASE(ShatteredTiles3DDemo);
|
||||
ADD_TEST_CASE(ShuffleTilesDemo);
|
||||
ADD_TEST_CASE(FadeOutTRTilesDemo);
|
||||
ADD_TEST_CASE(FadeOutBLTilesDemo);
|
||||
ADD_TEST_CASE(FadeOutUpTilesDemo);
|
||||
ADD_TEST_CASE(FadeOutDownTilesDemo);
|
||||
ADD_TEST_CASE(TurnOffTilesDemo);
|
||||
ADD_TEST_CASE(WavesTiles3DDemo);
|
||||
ADD_TEST_CASE(JumpTiles3DDemo);
|
||||
ADD_TEST_CASE(SplitRowsDemo);
|
||||
ADD_TEST_CASE(SplitColsDemo);
|
||||
ADD_TEST_CASE(PageTurn3DDemo);
|
||||
ADD_TEST_CASE(PageTurn3DRectDemo);
|
||||
}
|
||||
|
||||
class Shaky3DDemo : public Shaky3D
|
||||
Shaky3DDemo::Shaky3DDemo()
|
||||
{
|
||||
public:
|
||||
static ActionInterval* create(float t)
|
||||
{
|
||||
return Shaky3D::create(t, Size(15,10), 5, false);
|
||||
}
|
||||
};
|
||||
_title = "Shaky3D";
|
||||
_subtitle = "";
|
||||
}
|
||||
|
||||
class Waves3DDemo : public Waves3D
|
||||
cocos2d::ActionInterval* Shaky3DDemo::createEffect(float t)
|
||||
{
|
||||
public:
|
||||
static ActionInterval* create(float t)
|
||||
{
|
||||
return Waves3D::create(t, Size(15,10), 5, 40);
|
||||
}
|
||||
};
|
||||
return Shaky3D::create(t, Size(15,10), 5, false);
|
||||
}
|
||||
|
||||
class FlipX3DDemo : public FlipX3D
|
||||
Waves3DDemo::Waves3DDemo()
|
||||
{
|
||||
public:
|
||||
static ActionInterval* create(float t)
|
||||
{
|
||||
auto flipx = FlipX3D::create(t);
|
||||
auto flipx_back = flipx->reverse();
|
||||
auto delay = DelayTime::create(2);
|
||||
|
||||
return Sequence::create(flipx, delay, flipx_back, nullptr);
|
||||
}
|
||||
};
|
||||
_title = "Waves3D";
|
||||
_subtitle = "";
|
||||
}
|
||||
|
||||
class FlipY3DDemo : public FlipY3D
|
||||
cocos2d::ActionInterval* Waves3DDemo::createEffect(float t)
|
||||
{
|
||||
public:
|
||||
static ActionInterval* create(float t)
|
||||
{
|
||||
auto flipy = FlipY3D::create(t);
|
||||
auto flipy_back = flipy->reverse();
|
||||
auto delay = DelayTime::create(2);
|
||||
|
||||
return Sequence::create(flipy, delay, flipy_back, nullptr);
|
||||
}
|
||||
};
|
||||
return Waves3D::create(t, Size(15,10), 5, 40);
|
||||
}
|
||||
|
||||
class Lens3DDemo : public Lens3D
|
||||
cocos2d::ActionInterval* FlipX3DDemo::createEffect(float t)
|
||||
{
|
||||
public:
|
||||
static ActionInterval* create(float t)
|
||||
{
|
||||
auto size = Director::getInstance()->getWinSize();
|
||||
return Lens3D::create(t, Size(15,10), Vec2(size.width/2,size.height/2), 240);
|
||||
}
|
||||
};
|
||||
auto flipx = FlipX3D::create(t);
|
||||
auto flipx_back = flipx->reverse();
|
||||
auto delay = DelayTime::create(2);
|
||||
return Sequence::create(flipx, delay, flipx_back, nullptr);
|
||||
}
|
||||
|
||||
|
||||
class Ripple3DDemo : public Ripple3D
|
||||
FlipX3DDemo::FlipX3DDemo()
|
||||
{
|
||||
public:
|
||||
static ActionInterval* create(float t)
|
||||
{
|
||||
auto size = Director::getInstance()->getWinSize();
|
||||
return Ripple3D::create(t, Size(32,24), Vec2(size.width/2,size.height/2), 240, 4, 160);
|
||||
}
|
||||
};
|
||||
_title = "FlipX3D";
|
||||
_subtitle = "";
|
||||
}
|
||||
|
||||
|
||||
class LiquidDemo : public Liquid
|
||||
cocos2d::ActionInterval* FlipY3DDemo::createEffect(float t)
|
||||
{
|
||||
public:
|
||||
static ActionInterval* create(float t)
|
||||
{
|
||||
return Liquid::create(t, Size(16,12), 4, 20);
|
||||
}
|
||||
};
|
||||
auto flipy = FlipY3D::create(t);
|
||||
auto flipy_back = flipy->reverse();
|
||||
auto delay = DelayTime::create(2);
|
||||
|
||||
return Sequence::create(flipy, delay, flipy_back, nullptr);
|
||||
}
|
||||
|
||||
|
||||
class WavesDemo : public Waves
|
||||
FlipY3DDemo::FlipY3DDemo()
|
||||
{
|
||||
public:
|
||||
static ActionInterval* create(float t)
|
||||
{
|
||||
return Waves::create(t, Size(16,12), 4, 20, true, true);
|
||||
}
|
||||
};
|
||||
_title = "FlipY3D";
|
||||
_subtitle = "";
|
||||
}
|
||||
|
||||
|
||||
class TwirlDemo : public Twirl
|
||||
cocos2d::ActionInterval* Lens3DDemo::createEffect(float t)
|
||||
{
|
||||
public:
|
||||
static ActionInterval* create(float t)
|
||||
{
|
||||
auto size = Director::getInstance()->getWinSize();
|
||||
return Twirl::create(t, Size(12,8), Vec2(size.width/2, size.height/2), 1, 2.5f);
|
||||
}
|
||||
};
|
||||
auto size = Director::getInstance()->getWinSize();
|
||||
return Lens3D::create(t, Size(15,10), Vec2(size.width/2,size.height/2), 240);
|
||||
}
|
||||
|
||||
|
||||
class ShakyTiles3DDemo : public ShakyTiles3D
|
||||
Lens3DDemo::Lens3DDemo()
|
||||
{
|
||||
public:
|
||||
static ActionInterval* create(float t)
|
||||
{
|
||||
return ShakyTiles3D::create(t, Size(16,12), 5, false) ;
|
||||
}
|
||||
};
|
||||
_title = "Lens3D";
|
||||
_subtitle = "";
|
||||
}
|
||||
|
||||
|
||||
class ShatteredTiles3DDemo : public ShatteredTiles3D
|
||||
cocos2d::ActionInterval* Ripple3DDemo::createEffect(float t)
|
||||
{
|
||||
public:
|
||||
static ActionInterval* create(float t)
|
||||
{
|
||||
return ShatteredTiles3D::create(t, Size(16,12), 5, false);
|
||||
}
|
||||
};
|
||||
auto size = Director::getInstance()->getWinSize();
|
||||
return Ripple3D::create(t, Size(32,24), Vec2(size.width/2,size.height/2), 240, 4, 160);
|
||||
}
|
||||
|
||||
|
||||
class ShuffleTilesDemo : public ShuffleTiles
|
||||
Ripple3DDemo::Ripple3DDemo()
|
||||
{
|
||||
public:
|
||||
static ActionInterval* create(float t)
|
||||
{
|
||||
auto shuffle = ShuffleTiles::create(t, Size(16,12), 25);
|
||||
auto shuffle_back = shuffle->reverse();
|
||||
auto delay = DelayTime::create(2);
|
||||
_title = "Ripple3D";
|
||||
_subtitle = "";
|
||||
}
|
||||
|
||||
return Sequence::create(shuffle, delay, shuffle_back, nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class FadeOutTRTilesDemo : public FadeOutTRTiles
|
||||
cocos2d::ActionInterval* LiquidDemo::createEffect(float t)
|
||||
{
|
||||
public:
|
||||
static ActionInterval* create(float t)
|
||||
{
|
||||
auto fadeout = FadeOutTRTiles::create(t, Size(16,12));
|
||||
auto back = fadeout->reverse();
|
||||
auto delay = DelayTime::create(0.5f);
|
||||
return Liquid::create(t, Size(16,12), 4, 20);
|
||||
}
|
||||
|
||||
return Sequence::create(fadeout, delay, back, nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class FadeOutBLTilesDemo : public FadeOutBLTiles
|
||||
LiquidDemo::LiquidDemo()
|
||||
{
|
||||
public:
|
||||
static ActionInterval* create(float t)
|
||||
{
|
||||
auto fadeout = FadeOutBLTiles::create(t, Size(16,12));
|
||||
auto back = fadeout->reverse();
|
||||
auto delay = DelayTime::create(0.5f);
|
||||
_title = "Liquid";
|
||||
_subtitle = "";
|
||||
}
|
||||
|
||||
return Sequence::create(fadeout, delay, back, nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class FadeOutUpTilesDemo : public FadeOutUpTiles
|
||||
cocos2d::ActionInterval* WavesDemo::createEffect(float t)
|
||||
{
|
||||
public:
|
||||
static ActionInterval* create(float t)
|
||||
{
|
||||
auto fadeout = FadeOutUpTiles::create(t, Size(16,12));
|
||||
auto back = fadeout->reverse();
|
||||
auto delay = DelayTime::create(0.5f);
|
||||
return Waves::create(t, Size(16,12), 4, 20, true, true);
|
||||
}
|
||||
|
||||
return Sequence::create(fadeout, delay, back, nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
class FadeOutDownTilesDemo : public FadeOutDownTiles
|
||||
WavesDemo::WavesDemo()
|
||||
{
|
||||
public:
|
||||
static ActionInterval* create(float t)
|
||||
{
|
||||
auto fadeout = FadeOutDownTiles::create(t, Size(16,12));
|
||||
auto back = fadeout->reverse();
|
||||
auto delay = DelayTime::create(0.5f);
|
||||
_title = "Waves";
|
||||
_subtitle = "";
|
||||
}
|
||||
|
||||
return Sequence::create(fadeout, delay, back, nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
class TurnOffTilesDemo : public TurnOffTiles
|
||||
cocos2d::ActionInterval* TwirlDemo::createEffect(float t)
|
||||
{
|
||||
public:
|
||||
static ActionInterval* create(float t)
|
||||
{
|
||||
auto fadeout = TurnOffTiles::create(t, Size(48,32), 25);
|
||||
auto back = fadeout->reverse();
|
||||
auto delay = DelayTime::create(0.5f);
|
||||
auto size = Director::getInstance()->getWinSize();
|
||||
return Twirl::create(t, Size(12,8), Vec2(size.width/2, size.height/2), 1, 2.5f);
|
||||
}
|
||||
|
||||
return Sequence::create(fadeout, delay, back, nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
class WavesTiles3DDemo : public WavesTiles3D
|
||||
TwirlDemo::TwirlDemo()
|
||||
{
|
||||
public:
|
||||
static ActionInterval* create(float t)
|
||||
{
|
||||
return WavesTiles3D::create(t, Size(15,10), 4, 120);
|
||||
}
|
||||
};
|
||||
_title = "Twirl";
|
||||
_subtitle = "";
|
||||
}
|
||||
|
||||
class JumpTiles3DDemo : public JumpTiles3D
|
||||
cocos2d::ActionInterval* ShakyTiles3DDemo::createEffect(float t)
|
||||
{
|
||||
public:
|
||||
static ActionInterval* create(float t)
|
||||
{
|
||||
return JumpTiles3D::create(t, Size(15,10), 2, 30);
|
||||
}
|
||||
};
|
||||
return ShakyTiles3D::create(t, Size(16,12), 5, false) ;
|
||||
}
|
||||
|
||||
class SplitRowsDemo : public SplitRows
|
||||
ShakyTiles3DDemo::ShakyTiles3DDemo()
|
||||
{
|
||||
public:
|
||||
static ActionInterval* create(float t)
|
||||
{
|
||||
return SplitRows::create(t, 9);
|
||||
}
|
||||
};
|
||||
_title = "ShakyTiles3D";
|
||||
_subtitle = "";
|
||||
}
|
||||
|
||||
class SplitColsDemo : public SplitCols
|
||||
cocos2d::ActionInterval* ShatteredTiles3DDemo::createEffect(float t)
|
||||
{
|
||||
public:
|
||||
static ActionInterval* create(float t)
|
||||
{
|
||||
return SplitCols::create(t, 9);
|
||||
}
|
||||
};
|
||||
return ShatteredTiles3D::create(t, Size(16,12), 5, false);
|
||||
}
|
||||
|
||||
class PageTurn3DDemo : public PageTurn3D
|
||||
ShatteredTiles3DDemo::ShatteredTiles3DDemo()
|
||||
{
|
||||
public:
|
||||
static ActionInterval* create(float t)
|
||||
{
|
||||
return PageTurn3D::create(t, Size(15,10));
|
||||
}
|
||||
};
|
||||
_title = "ShatteredTiles3D";
|
||||
_subtitle = "";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// EffectBaseTest
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
|
||||
ActionInterval* createEffect(int nIndex, float t)
|
||||
cocos2d::ActionInterval* ShuffleTilesDemo::createEffect(float t)
|
||||
{
|
||||
auto shuffle = ShuffleTiles::create(t, Size(16,12), 25);
|
||||
auto shuffle_back = shuffle->reverse();
|
||||
auto delay = DelayTime::create(2);
|
||||
|
||||
return Sequence::create(shuffle, delay, shuffle_back, nullptr);
|
||||
}
|
||||
|
||||
Director::getInstance()->setDepthTest(false);
|
||||
ShuffleTilesDemo::ShuffleTilesDemo()
|
||||
{
|
||||
_title = "ShuffleTiles";
|
||||
_subtitle = "";
|
||||
}
|
||||
|
||||
switch(nIndex)
|
||||
{
|
||||
case 0: return Shaky3DDemo::create(t);
|
||||
case 1: return Waves3DDemo::create(t);
|
||||
case 2: return FlipX3DDemo::create(t);
|
||||
case 3: return FlipY3DDemo::create(t);
|
||||
case 4: return Lens3DDemo::create(t);
|
||||
case 5: return Ripple3DDemo::create(t);
|
||||
case 6: return LiquidDemo::create(t);
|
||||
case 7: return WavesDemo::create(t);
|
||||
case 8: return TwirlDemo::create(t);
|
||||
case 9: return ShakyTiles3DDemo::create(t);
|
||||
case 10: return ShatteredTiles3DDemo::create(t);
|
||||
case 11: return ShuffleTilesDemo::create(t);
|
||||
case 12: return FadeOutTRTilesDemo::create(t);
|
||||
case 13: return FadeOutBLTilesDemo::create(t);
|
||||
case 14: return FadeOutUpTilesDemo::create(t);
|
||||
case 15: return FadeOutDownTilesDemo::create(t);
|
||||
case 16: return TurnOffTilesDemo::create(t);
|
||||
case 17: return WavesTiles3DDemo::create(t);
|
||||
case 18: return JumpTiles3DDemo::create(t);
|
||||
case 19: return SplitRowsDemo::create(t);
|
||||
case 20: return SplitColsDemo::create(t);
|
||||
case 21: return PageTurn3DDemo::create(t);
|
||||
}
|
||||
cocos2d::ActionInterval* FadeOutTRTilesDemo::createEffect(float t)
|
||||
{
|
||||
auto fadeout = FadeOutTRTiles::create(t, Size(16,12));
|
||||
auto back = fadeout->reverse();
|
||||
auto delay = DelayTime::create(0.5f);
|
||||
|
||||
return Sequence::create(fadeout, delay, back, nullptr);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
FadeOutTRTilesDemo::FadeOutTRTilesDemo()
|
||||
{
|
||||
_title = "FadeOutTRTiles";
|
||||
_subtitle = "";
|
||||
}
|
||||
|
||||
cocos2d::ActionInterval* FadeOutBLTilesDemo::createEffect(float t)
|
||||
{
|
||||
auto fadeout = FadeOutBLTiles::create(t, Size(16,12));
|
||||
auto back = fadeout->reverse();
|
||||
auto delay = DelayTime::create(0.5f);
|
||||
|
||||
return Sequence::create(fadeout, delay, back, nullptr);
|
||||
}
|
||||
|
||||
FadeOutBLTilesDemo::FadeOutBLTilesDemo()
|
||||
{
|
||||
_title = "FadeOutBLTiles";
|
||||
_subtitle = "";
|
||||
}
|
||||
|
||||
cocos2d::ActionInterval* FadeOutUpTilesDemo::createEffect(float t)
|
||||
{
|
||||
auto fadeout = FadeOutUpTiles::create(t, Size(16,12));
|
||||
auto back = fadeout->reverse();
|
||||
auto delay = DelayTime::create(0.5f);
|
||||
|
||||
return Sequence::create(fadeout, delay, back, nullptr);
|
||||
}
|
||||
|
||||
FadeOutUpTilesDemo::FadeOutUpTilesDemo()
|
||||
{
|
||||
_title = "FadeOutUpTiles";
|
||||
_subtitle = "";
|
||||
}
|
||||
|
||||
cocos2d::ActionInterval* FadeOutDownTilesDemo::createEffect(float t)
|
||||
{
|
||||
auto fadeout = FadeOutDownTiles::create(t, Size(16,12));
|
||||
auto back = fadeout->reverse();
|
||||
auto delay = DelayTime::create(0.5f);
|
||||
|
||||
return Sequence::create(fadeout, delay, back, nullptr);
|
||||
}
|
||||
|
||||
FadeOutDownTilesDemo::FadeOutDownTilesDemo()
|
||||
{
|
||||
_title = "Waves3D";
|
||||
_subtitle = "";
|
||||
}
|
||||
|
||||
cocos2d::ActionInterval* TurnOffTilesDemo::createEffect(float t)
|
||||
{
|
||||
auto fadeout = TurnOffTiles::create(t, Size(48,32), 25);
|
||||
auto back = fadeout->reverse();
|
||||
auto delay = DelayTime::create(0.5f);
|
||||
|
||||
return Sequence::create(fadeout, delay, back, nullptr);
|
||||
}
|
||||
|
||||
TurnOffTilesDemo::TurnOffTilesDemo()
|
||||
{
|
||||
_title = "TurnOffTiles";
|
||||
_subtitle = "";
|
||||
}
|
||||
|
||||
cocos2d::ActionInterval* WavesTiles3DDemo::createEffect(float t)
|
||||
{
|
||||
return WavesTiles3D::create(t, Size(15,10), 4, 120);
|
||||
}
|
||||
|
||||
WavesTiles3DDemo::WavesTiles3DDemo()
|
||||
{
|
||||
_title = "WavesTiles3D";
|
||||
_subtitle = "";
|
||||
}
|
||||
|
||||
cocos2d::ActionInterval* JumpTiles3DDemo::createEffect(float t)
|
||||
{
|
||||
return JumpTiles3D::create(t, Size(15,10), 2, 30);
|
||||
}
|
||||
|
||||
JumpTiles3DDemo::JumpTiles3DDemo()
|
||||
{
|
||||
_title = "JumpTiles3D";
|
||||
_subtitle = "";
|
||||
}
|
||||
|
||||
cocos2d::ActionInterval* SplitRowsDemo::createEffect(float t)
|
||||
{
|
||||
return SplitRows::create(t, 9);
|
||||
}
|
||||
|
||||
SplitRowsDemo::SplitRowsDemo()
|
||||
{
|
||||
_title = "SplitRows";
|
||||
_subtitle = "";
|
||||
}
|
||||
|
||||
cocos2d::ActionInterval* SplitColsDemo::createEffect(float t)
|
||||
{
|
||||
return SplitCols::create(t, 9);
|
||||
}
|
||||
|
||||
SplitColsDemo::SplitColsDemo()
|
||||
{
|
||||
_title = "SplitCols";
|
||||
_subtitle = "";
|
||||
}
|
||||
|
||||
cocos2d::ActionInterval* PageTurn3DDemo::createEffect(float t)
|
||||
{
|
||||
return PageTurn3D::create(t, Size(15,10));
|
||||
}
|
||||
|
||||
PageTurn3DDemo::PageTurn3DDemo()
|
||||
{
|
||||
_title = "PageTurn3D";
|
||||
_subtitle = "";
|
||||
}
|
||||
|
||||
cocos2d::ActionInterval* PageTurn3DRectDemo::createEffect(float t)
|
||||
{
|
||||
return PageTurn3D::create(t, Size(15,10));
|
||||
}
|
||||
|
||||
PageTurn3DRectDemo::PageTurn3DRectDemo()
|
||||
{
|
||||
_title = "PageTurn3D-Rect";
|
||||
_subtitle = "";
|
||||
}
|
||||
|
||||
#define SID_RESTART 1
|
||||
|
||||
EffectBaseTest::EffectBaseTest(int actionIdx)
|
||||
EffectBaseTest::EffectBaseTest()
|
||||
: _gridNodeTarget(nullptr)
|
||||
{
|
||||
LayerColor *background = LayerColor::create( Color4B(32,128,32,255) );
|
||||
this->addChild(background,-20);
|
||||
|
||||
_gridNodeTarget = NodeGrid::create();
|
||||
auto effect = createEffect(actionIdx, 3);
|
||||
_gridNodeTarget->runAction(effect);
|
||||
addChild(_gridNodeTarget, 0, kTagBackground);
|
||||
|
||||
auto bg = Sprite::create(s_back3);
|
||||
_gridNodeTarget->addChild(bg, 0);
|
||||
bg->setPosition(VisibleRect::center());
|
||||
}
|
||||
|
||||
auto grossini = Sprite::create(s_pathSister2);
|
||||
_gridNodeTarget->addChild(grossini, 1);
|
||||
grossini->setPosition(VisibleRect::left().x+VisibleRect::getVisibleRect().size.width/3,VisibleRect::center().y);
|
||||
auto sc = ScaleBy::create(2, 5);
|
||||
auto sc_back = sc->reverse();
|
||||
grossini->runAction( RepeatForever::create(Sequence::create(sc, sc_back, nullptr) ) );
|
||||
|
||||
auto tamara = Sprite::create(s_pathSister1);
|
||||
_gridNodeTarget->addChild(tamara, 1);
|
||||
tamara->setPosition(VisibleRect::left().x+2*VisibleRect::getVisibleRect().size.width/3,VisibleRect::center().y);
|
||||
auto sc2 = ScaleBy::create(2, 5);
|
||||
auto sc2_back = sc2->reverse();
|
||||
tamara->runAction( RepeatForever::create(Sequence::create(sc2, sc2_back, nullptr)) );
|
||||
|
||||
auto label = Label::createWithTTF((effectsList[actionIdx]).c_str(), "fonts/Marker Felt.ttf", 32);
|
||||
|
||||
label->setPosition(VisibleRect::center().x,VisibleRect::top().y-80);
|
||||
addChild(label);
|
||||
label->setTag( kTagLabel );
|
||||
|
||||
schedule( CC_SCHEDULE_SELECTOR(EffectBaseTest::checkAnim) );
|
||||
bool EffectBaseTest::init()
|
||||
{
|
||||
if(TestCase::init())
|
||||
{
|
||||
LayerColor *background = LayerColor::create( Color4B(32,128,32,255) );
|
||||
this->addChild(background,-20);
|
||||
if(isRectEffect())
|
||||
{
|
||||
Size visibleSize = Director::getInstance()->getVisibleSize();
|
||||
Rect gridRect = Rect(visibleSize.width * 0.2,
|
||||
visibleSize.height * 0.2,
|
||||
visibleSize.width * 0.6,
|
||||
visibleSize.height * 0.6);
|
||||
_gridNodeTarget = NodeGrid::create(gridRect);
|
||||
}
|
||||
else
|
||||
{
|
||||
_gridNodeTarget = NodeGrid::create();
|
||||
}
|
||||
addChild(_gridNodeTarget, 0);
|
||||
_gridNodeTarget->runAction(createEffect(3));
|
||||
|
||||
auto bg = Sprite::create(s_back3);
|
||||
_gridNodeTarget->addChild(bg, 0);
|
||||
bg->setPosition(VisibleRect::center());
|
||||
|
||||
auto grossini = Sprite::create(s_pathSister2);
|
||||
_gridNodeTarget->addChild(grossini, 1);
|
||||
grossini->setPosition(VisibleRect::left().x+VisibleRect::getVisibleRect().size.width/3,VisibleRect::center().y);
|
||||
auto sc = ScaleBy::create(2, 5);
|
||||
auto sc_back = sc->reverse();
|
||||
grossini->runAction( RepeatForever::create(Sequence::create(sc, sc_back, nullptr) ) );
|
||||
|
||||
auto tamara = Sprite::create(s_pathSister1);
|
||||
_gridNodeTarget->addChild(tamara, 1);
|
||||
tamara->setPosition(VisibleRect::left().x+2*VisibleRect::getVisibleRect().size.width/3,VisibleRect::center().y);
|
||||
auto sc2 = ScaleBy::create(2, 5);
|
||||
auto sc2_back = sc2->reverse();
|
||||
tamara->runAction( RepeatForever::create(Sequence::create(sc2, sc2_back, nullptr)) );
|
||||
|
||||
schedule( CC_SCHEDULE_SELECTOR(EffectBaseTest::checkAnim) );
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void EffectBaseTest::checkAnim(float dt)
|
||||
{
|
||||
//auto s2 = getChildByTag(kTagBackground);
|
||||
if ( _gridNodeTarget->getNumberOfRunningActions() == 0 && _gridNodeTarget->getGrid() != nullptr)
|
||||
_gridNodeTarget->setGrid(nullptr);;
|
||||
}
|
||||
|
|
|
@ -7,30 +7,227 @@ DEFINE_TEST_SUITE(EffectTests);
|
|||
|
||||
class EffectBaseTest : public TestCase
|
||||
{
|
||||
protected:
|
||||
//UxString _title;
|
||||
cocos2d::NodeGrid* _gridNodeTarget;
|
||||
public:
|
||||
static EffectBaseTest* create(int index)
|
||||
{
|
||||
auto ret = new (std::nothrow) EffectBaseTest(index);
|
||||
if (ret && ret->init())
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
delete ret;
|
||||
ret = nullptr;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
EffectBaseTest(int index);
|
||||
~EffectBaseTest();
|
||||
|
||||
EffectBaseTest();
|
||||
virtual ~EffectBaseTest();
|
||||
protected:
|
||||
virtual bool init() override;
|
||||
virtual cocos2d::ActionInterval* createEffect(float t) {return nullptr;}
|
||||
void checkAnim(float dt);
|
||||
virtual bool isRectEffect(){return false;}
|
||||
virtual std::string title() const override {return _title;};
|
||||
virtual std::string subtitle() const override {return _subtitle;};
|
||||
std::string _title;
|
||||
std::string _subtitle;
|
||||
cocos2d::NodeGrid* _gridNodeTarget;
|
||||
};
|
||||
|
||||
class Shaky3DDemo : public EffectBaseTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(Shaky3DDemo);
|
||||
Shaky3DDemo();
|
||||
protected:
|
||||
virtual cocos2d::ActionInterval* createEffect(float t) override;
|
||||
};
|
||||
|
||||
class Waves3DDemo : public EffectBaseTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(Waves3DDemo);
|
||||
Waves3DDemo();
|
||||
protected:
|
||||
virtual cocos2d::ActionInterval* createEffect(float t) override;
|
||||
};
|
||||
|
||||
class FlipX3DDemo : public EffectBaseTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(FlipX3DDemo);
|
||||
FlipX3DDemo();
|
||||
protected:
|
||||
virtual cocos2d::ActionInterval* createEffect(float t) override;
|
||||
};
|
||||
|
||||
class FlipY3DDemo : public EffectBaseTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(FlipY3DDemo);
|
||||
FlipY3DDemo();
|
||||
protected:
|
||||
virtual cocos2d::ActionInterval* createEffect(float t) override;
|
||||
};
|
||||
|
||||
class Lens3DDemo : public EffectBaseTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(Lens3DDemo);
|
||||
Lens3DDemo();
|
||||
protected:
|
||||
virtual cocos2d::ActionInterval* createEffect(float t) override;
|
||||
};
|
||||
|
||||
class Ripple3DDemo : public EffectBaseTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(Ripple3DDemo);
|
||||
Ripple3DDemo();
|
||||
protected:
|
||||
virtual cocos2d::ActionInterval* createEffect(float t) override;
|
||||
};
|
||||
|
||||
class LiquidDemo : public EffectBaseTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(LiquidDemo);
|
||||
LiquidDemo();
|
||||
protected:
|
||||
virtual cocos2d::ActionInterval* createEffect(float t) override;
|
||||
};
|
||||
|
||||
class WavesDemo : public EffectBaseTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(WavesDemo);
|
||||
WavesDemo();
|
||||
protected:
|
||||
virtual cocos2d::ActionInterval* createEffect(float t) override;
|
||||
};
|
||||
|
||||
class TwirlDemo : public EffectBaseTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(TwirlDemo);
|
||||
TwirlDemo();
|
||||
protected:
|
||||
virtual cocos2d::ActionInterval* createEffect(float t) override;
|
||||
};
|
||||
|
||||
class ShakyTiles3DDemo : public EffectBaseTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(ShakyTiles3DDemo);
|
||||
ShakyTiles3DDemo();
|
||||
protected:
|
||||
virtual cocos2d::ActionInterval* createEffect(float t) override;
|
||||
};
|
||||
|
||||
class ShatteredTiles3DDemo : public EffectBaseTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(ShatteredTiles3DDemo);
|
||||
ShatteredTiles3DDemo();
|
||||
protected:
|
||||
virtual cocos2d::ActionInterval* createEffect(float t) override;
|
||||
};
|
||||
|
||||
class ShuffleTilesDemo : public EffectBaseTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(ShuffleTilesDemo);
|
||||
ShuffleTilesDemo();
|
||||
protected:
|
||||
virtual cocos2d::ActionInterval* createEffect(float t) override;
|
||||
};
|
||||
|
||||
class FadeOutTRTilesDemo : public EffectBaseTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(FadeOutTRTilesDemo);
|
||||
FadeOutTRTilesDemo();
|
||||
protected:
|
||||
virtual cocos2d::ActionInterval* createEffect(float t) override;
|
||||
};
|
||||
|
||||
class FadeOutBLTilesDemo : public EffectBaseTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(FadeOutBLTilesDemo);
|
||||
FadeOutBLTilesDemo();
|
||||
protected:
|
||||
virtual cocos2d::ActionInterval* createEffect(float t) override;
|
||||
};
|
||||
|
||||
class FadeOutUpTilesDemo : public EffectBaseTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(FadeOutUpTilesDemo);
|
||||
FadeOutUpTilesDemo();
|
||||
protected:
|
||||
virtual cocos2d::ActionInterval* createEffect(float t) override;
|
||||
};
|
||||
|
||||
class FadeOutDownTilesDemo : public EffectBaseTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(FadeOutDownTilesDemo);
|
||||
FadeOutDownTilesDemo();
|
||||
protected:
|
||||
virtual cocos2d::ActionInterval* createEffect(float t) override;
|
||||
};
|
||||
|
||||
class TurnOffTilesDemo : public EffectBaseTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(TurnOffTilesDemo);
|
||||
TurnOffTilesDemo();
|
||||
protected:
|
||||
virtual cocos2d::ActionInterval* createEffect(float t) override;
|
||||
};
|
||||
|
||||
class WavesTiles3DDemo : public EffectBaseTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(WavesTiles3DDemo);
|
||||
WavesTiles3DDemo();
|
||||
protected:
|
||||
virtual cocos2d::ActionInterval* createEffect(float t) override;
|
||||
};
|
||||
|
||||
class JumpTiles3DDemo : public EffectBaseTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(JumpTiles3DDemo);
|
||||
JumpTiles3DDemo();
|
||||
protected:
|
||||
virtual cocos2d::ActionInterval* createEffect(float t) override;
|
||||
};
|
||||
|
||||
class SplitRowsDemo : public EffectBaseTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(SplitRowsDemo);
|
||||
SplitRowsDemo();
|
||||
protected:
|
||||
virtual cocos2d::ActionInterval* createEffect(float t) override;
|
||||
};
|
||||
|
||||
class SplitColsDemo : public EffectBaseTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(SplitColsDemo);
|
||||
SplitColsDemo();
|
||||
protected:
|
||||
virtual cocos2d::ActionInterval* createEffect(float t) override;
|
||||
};
|
||||
|
||||
class PageTurn3DDemo : public EffectBaseTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(PageTurn3DDemo);
|
||||
PageTurn3DDemo();
|
||||
protected:
|
||||
virtual cocos2d::ActionInterval* createEffect(float t) override;
|
||||
};
|
||||
|
||||
class PageTurn3DRectDemo : public EffectBaseTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(PageTurn3DRectDemo);
|
||||
PageTurn3DRectDemo();
|
||||
protected:
|
||||
virtual bool isRectEffect() override {return true;}
|
||||
virtual cocos2d::ActionInterval* createEffect(float t) override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -595,7 +595,12 @@ var ShaderNode = cc.GLNode.extend({
|
|||
// Uniforms
|
||||
//
|
||||
var frameSize = cc.view.getFrameSize();
|
||||
this.shader.setUniformLocationF32( this.uniformCenter, frameSize.width/2, frameSize.height/2);
|
||||
var visibleSize = cc.view.getVisibleSize();
|
||||
var retinaFactor = cc.view.getDevicePixelRatio();
|
||||
var positionx = frameSize.width/2,
|
||||
positiony = frameSize.height/2;
|
||||
|
||||
this.shader.setUniformLocationF32( this.uniformCenter, positionx*frameSize.width/visibleSize.width * retinaFactor, positiony*frameSize.height/visibleSize.height * retinaFactor);
|
||||
this.shader.setUniformLocationF32( this.uniformResolution, 256, 256);
|
||||
|
||||
cc.glEnableVertexAttribs( cc.VERTEX_ATTRIB_FLAG_POSITION );
|
||||
|
@ -1358,4 +1363,4 @@ var previousOpenGLTest = function () {
|
|||
};
|
||||
var restartOpenGLTest = function () {
|
||||
return new arrayOfOpenGLTest[OpenGLTestIdx]();
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue