mirror of https://github.com/axmolengine/axmol.git
Merge pull request #4482 from dabingnn/develop_gridNode
Develop grid node
This commit is contained in:
commit
756f8f7a11
|
@ -1 +1 @@
|
||||||
4cd02813dfcd14b7de3ccb157cd0f25b0bce9f37
|
54e971301f0ad11306c27cf6eba8eca695fb4f37
|
|
@ -60,6 +60,7 @@ CCGLProgram.cpp \
|
||||||
ccGLStateCache.cpp \
|
ccGLStateCache.cpp \
|
||||||
CCGrabber.cpp \
|
CCGrabber.cpp \
|
||||||
CCGrid.cpp \
|
CCGrid.cpp \
|
||||||
|
CCNodeGrid.cpp \
|
||||||
CCIMEDispatcher.cpp \
|
CCIMEDispatcher.cpp \
|
||||||
CCLabel.cpp \
|
CCLabel.cpp \
|
||||||
CCLabelAtlas.cpp \
|
CCLabelAtlas.cpp \
|
||||||
|
|
|
@ -25,6 +25,7 @@ THE SOFTWARE.
|
||||||
#include "CCActionGrid.h"
|
#include "CCActionGrid.h"
|
||||||
#include "CCDirector.h"
|
#include "CCDirector.h"
|
||||||
#include "CCGrid.h"
|
#include "CCGrid.h"
|
||||||
|
#include "CCNodeGrid.h"
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
// implementation of GridAction
|
// implementation of GridAction
|
||||||
|
@ -44,11 +45,11 @@ bool GridAction::initWithDuration(float duration, const Size& gridSize)
|
||||||
void GridAction::startWithTarget(Node *target)
|
void GridAction::startWithTarget(Node *target)
|
||||||
{
|
{
|
||||||
ActionInterval::startWithTarget(target);
|
ActionInterval::startWithTarget(target);
|
||||||
|
cacheTargetAsGridNode();
|
||||||
|
|
||||||
GridBase *newgrid = this->getGrid();
|
GridBase *newgrid = this->getGrid();
|
||||||
|
|
||||||
Node *t = _target;
|
GridBase *targetGrid = _gridNodeTarget->getGrid();
|
||||||
GridBase *targetGrid = t->getGrid();
|
|
||||||
|
|
||||||
if (targetGrid && targetGrid->getReuseGrid() > 0)
|
if (targetGrid && targetGrid->getReuseGrid() > 0)
|
||||||
{
|
{
|
||||||
|
@ -69,11 +70,17 @@ void GridAction::startWithTarget(Node *target)
|
||||||
targetGrid->setActive(false);
|
targetGrid->setActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
t->setGrid(newgrid);
|
_gridNodeTarget->setGrid(newgrid);
|
||||||
t->getGrid()->setActive(true);
|
_gridNodeTarget->getGrid()->setActive(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GridAction::cacheTargetAsGridNode()
|
||||||
|
{
|
||||||
|
_gridNodeTarget = dynamic_cast<NodeGrid*> (_target);
|
||||||
|
CCASSERT(_gridNodeTarget, "GridActions can only used on NodeGrid");
|
||||||
|
}
|
||||||
|
|
||||||
GridAction* GridAction::reverse() const
|
GridAction* GridAction::reverse() const
|
||||||
{
|
{
|
||||||
// FIXME: This conversion isn't safe.
|
// FIXME: This conversion isn't safe.
|
||||||
|
@ -97,19 +104,19 @@ GridBase* Grid3DAction::getGrid()
|
||||||
|
|
||||||
Vertex3F Grid3DAction::getVertex(const Point& position) const
|
Vertex3F Grid3DAction::getVertex(const Point& position) const
|
||||||
{
|
{
|
||||||
Grid3D *g = (Grid3D*)_target->getGrid();
|
Grid3D *g = (Grid3D*)_gridNodeTarget->getGrid();
|
||||||
return g->getVertex(position);
|
return g->getVertex(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vertex3F Grid3DAction::getOriginalVertex(const Point& position) const
|
Vertex3F Grid3DAction::getOriginalVertex(const Point& position) const
|
||||||
{
|
{
|
||||||
Grid3D *g = (Grid3D*)_target->getGrid();
|
Grid3D *g = (Grid3D*)_gridNodeTarget->getGrid();
|
||||||
return g->getOriginalVertex(position);
|
return g->getOriginalVertex(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Grid3DAction::setVertex(const Point& position, const Vertex3F& vertex)
|
void Grid3DAction::setVertex(const Point& position, const Vertex3F& vertex)
|
||||||
{
|
{
|
||||||
Grid3D *g = (Grid3D*)_target->getGrid();
|
Grid3D *g = (Grid3D*)_gridNodeTarget->getGrid();
|
||||||
g->setVertex(position, vertex);
|
g->setVertex(position, vertex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,19 +129,19 @@ GridBase* TiledGrid3DAction::getGrid(void)
|
||||||
|
|
||||||
Quad3 TiledGrid3DAction::getTile(const Point& pos) const
|
Quad3 TiledGrid3DAction::getTile(const Point& pos) const
|
||||||
{
|
{
|
||||||
TiledGrid3D *g = (TiledGrid3D*)_target->getGrid();
|
TiledGrid3D *g = (TiledGrid3D*)_gridNodeTarget->getGrid();
|
||||||
return g->getTile(pos);
|
return g->getTile(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
Quad3 TiledGrid3DAction::getOriginalTile(const Point& pos) const
|
Quad3 TiledGrid3DAction::getOriginalTile(const Point& pos) const
|
||||||
{
|
{
|
||||||
TiledGrid3D *g = (TiledGrid3D*)_target->getGrid();
|
TiledGrid3D *g = (TiledGrid3D*)_gridNodeTarget->getGrid();
|
||||||
return g->getOriginalTile(pos);
|
return g->getOriginalTile(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TiledGrid3DAction::setTile(const Point& pos, const Quad3& coords)
|
void TiledGrid3DAction::setTile(const Point& pos, const Quad3& coords)
|
||||||
{
|
{
|
||||||
TiledGrid3D *g = (TiledGrid3D*)_target->getGrid();
|
TiledGrid3D *g = (TiledGrid3D*)_gridNodeTarget->getGrid();
|
||||||
return g->setTile(pos, coords);
|
return g->setTile(pos, coords);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,14 +352,20 @@ DeccelAmplitude* DeccelAmplitude::reverse() const
|
||||||
void StopGrid::startWithTarget(Node *target)
|
void StopGrid::startWithTarget(Node *target)
|
||||||
{
|
{
|
||||||
ActionInstant::startWithTarget(target);
|
ActionInstant::startWithTarget(target);
|
||||||
|
cacheTargetAsGridNode();
|
||||||
GridBase *grid = _target->getGrid();
|
GridBase *grid = _gridNodeTarget->getGrid();
|
||||||
if (grid && grid->isActive())
|
if (grid && grid->isActive())
|
||||||
{
|
{
|
||||||
grid->setActive(false);
|
grid->setActive(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StopGrid::cacheTargetAsGridNode()
|
||||||
|
{
|
||||||
|
_gridNodeTarget = dynamic_cast<NodeGrid*> (_target);
|
||||||
|
CCASSERT(_gridNodeTarget, "GridActions can only used on NodeGrid");
|
||||||
|
}
|
||||||
|
|
||||||
StopGrid* StopGrid::create()
|
StopGrid* StopGrid::create()
|
||||||
{
|
{
|
||||||
StopGrid* pAction = new StopGrid();
|
StopGrid* pAction = new StopGrid();
|
||||||
|
@ -402,13 +415,20 @@ bool ReuseGrid::initWithTimes(int times)
|
||||||
void ReuseGrid::startWithTarget(Node *target)
|
void ReuseGrid::startWithTarget(Node *target)
|
||||||
{
|
{
|
||||||
ActionInstant::startWithTarget(target);
|
ActionInstant::startWithTarget(target);
|
||||||
|
cacheTargetAsGridNode();
|
||||||
|
|
||||||
if (_target->getGrid() && _target->getGrid()->isActive())
|
if (_gridNodeTarget->getGrid() && _gridNodeTarget->getGrid()->isActive())
|
||||||
{
|
{
|
||||||
_target->getGrid()->setReuseGrid(_target->getGrid()->getReuseGrid() + _times);
|
_gridNodeTarget->getGrid()->setReuseGrid(_gridNodeTarget->getGrid()->getReuseGrid() + _times);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ReuseGrid::cacheTargetAsGridNode()
|
||||||
|
{
|
||||||
|
_gridNodeTarget = dynamic_cast<NodeGrid*> (_target);
|
||||||
|
CCASSERT(_gridNodeTarget, "GridActions can only used on NodeGrid");
|
||||||
|
}
|
||||||
|
|
||||||
ReuseGrid* ReuseGrid::clone() const
|
ReuseGrid* ReuseGrid::clone() const
|
||||||
{
|
{
|
||||||
return ReuseGrid::create(_times);
|
return ReuseGrid::create(_times);
|
||||||
|
|
|
@ -31,6 +31,7 @@ THE SOFTWARE.
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
class GridBase;
|
class GridBase;
|
||||||
|
class NodeGrid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @addtogroup actions
|
* @addtogroup actions
|
||||||
|
@ -57,6 +58,10 @@ protected:
|
||||||
bool initWithDuration(float duration, const Size& gridSize);
|
bool initWithDuration(float duration, const Size& gridSize);
|
||||||
|
|
||||||
Size _gridSize;
|
Size _gridSize;
|
||||||
|
|
||||||
|
NodeGrid* _gridNodeTarget;
|
||||||
|
|
||||||
|
void cacheTargetAsGridNode();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CC_DISALLOW_COPY_AND_ASSIGN(GridAction);
|
CC_DISALLOW_COPY_AND_ASSIGN(GridAction);
|
||||||
|
@ -264,6 +269,10 @@ public:
|
||||||
protected:
|
protected:
|
||||||
StopGrid() {}
|
StopGrid() {}
|
||||||
virtual ~StopGrid() {}
|
virtual ~StopGrid() {}
|
||||||
|
|
||||||
|
NodeGrid* _gridNodeTarget;
|
||||||
|
|
||||||
|
void cacheTargetAsGridNode();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CC_DISALLOW_COPY_AND_ASSIGN(StopGrid);
|
CC_DISALLOW_COPY_AND_ASSIGN(StopGrid);
|
||||||
|
@ -286,7 +295,11 @@ protected:
|
||||||
virtual ~ReuseGrid() {}
|
virtual ~ReuseGrid() {}
|
||||||
/** initializes an action with the number of times that the current grid will be reused */
|
/** initializes an action with the number of times that the current grid will be reused */
|
||||||
bool initWithTimes(int times);
|
bool initWithTimes(int times);
|
||||||
|
|
||||||
|
NodeGrid* _gridNodeTarget;
|
||||||
|
|
||||||
|
void cacheTargetAsGridNode();
|
||||||
|
|
||||||
int _times;
|
int _times;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -26,6 +26,7 @@ THE SOFTWARE.
|
||||||
#include "CCDirector.h"
|
#include "CCDirector.h"
|
||||||
#include "ccMacros.h"
|
#include "ccMacros.h"
|
||||||
#include "CCGrid.h"
|
#include "CCGrid.h"
|
||||||
|
#include "CCNodeGrid.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
@ -279,7 +280,7 @@ void ShuffleTiles::placeTile(const Point& pos, Tile *t)
|
||||||
{
|
{
|
||||||
Quad3 coords = getOriginalTile(pos);
|
Quad3 coords = getOriginalTile(pos);
|
||||||
|
|
||||||
Point step = _target->getGrid()->getStep();
|
Point step = _gridNodeTarget->getGrid()->getStep();
|
||||||
coords.bl.x += (int)(t->position.x * step.x);
|
coords.bl.x += (int)(t->position.x * step.x);
|
||||||
coords.bl.y += (int)(t->position.y * step.y);
|
coords.bl.y += (int)(t->position.y * step.y);
|
||||||
|
|
||||||
|
@ -408,7 +409,7 @@ void FadeOutTRTiles::turnOffTile(const Point& pos)
|
||||||
void FadeOutTRTiles::transformTile(const Point& pos, float distance)
|
void FadeOutTRTiles::transformTile(const Point& pos, float distance)
|
||||||
{
|
{
|
||||||
Quad3 coords = getOriginalTile(pos);
|
Quad3 coords = getOriginalTile(pos);
|
||||||
Point step = _target->getGrid()->getStep();
|
Point step = _gridNodeTarget->getGrid()->getStep();
|
||||||
|
|
||||||
coords.bl.x += (step.x / 2) * (1.0f - distance);
|
coords.bl.x += (step.x / 2) * (1.0f - distance);
|
||||||
coords.bl.y += (step.y / 2) * (1.0f - distance);
|
coords.bl.y += (step.y / 2) * (1.0f - distance);
|
||||||
|
@ -535,7 +536,7 @@ float FadeOutUpTiles::testFunc(const Size& pos, float time)
|
||||||
void FadeOutUpTiles::transformTile(const Point& pos, float distance)
|
void FadeOutUpTiles::transformTile(const Point& pos, float distance)
|
||||||
{
|
{
|
||||||
Quad3 coords = getOriginalTile(pos);
|
Quad3 coords = getOriginalTile(pos);
|
||||||
Point step = _target->getGrid()->getStep();
|
Point step = _gridNodeTarget->getGrid()->getStep();
|
||||||
|
|
||||||
coords.bl.y += (step.y / 2) * (1.0f - distance);
|
coords.bl.y += (step.y / 2) * (1.0f - distance);
|
||||||
coords.br.y += (step.y / 2) * (1.0f - distance);
|
coords.br.y += (step.y / 2) * (1.0f - distance);
|
||||||
|
|
|
@ -109,7 +109,6 @@ Node::Node(void)
|
||||||
, _camera(nullptr)
|
, _camera(nullptr)
|
||||||
// children (lazy allocs)
|
// children (lazy allocs)
|
||||||
// lazy alloc
|
// lazy alloc
|
||||||
, _grid(nullptr)
|
|
||||||
, _ZOrder(0)
|
, _ZOrder(0)
|
||||||
, _parent(nullptr)
|
, _parent(nullptr)
|
||||||
// "whole screen" objects. like Scenes and Layers, should set _ignoreAnchorPointForPosition to true
|
// "whole screen" objects. like Scenes and Layers, should set _ignoreAnchorPointForPosition to true
|
||||||
|
@ -171,7 +170,6 @@ Node::~Node()
|
||||||
// attributes
|
// attributes
|
||||||
CC_SAFE_RELEASE(_camera);
|
CC_SAFE_RELEASE(_camera);
|
||||||
|
|
||||||
CC_SAFE_RELEASE(_grid);
|
|
||||||
CC_SAFE_RELEASE(_shaderProgram);
|
CC_SAFE_RELEASE(_shaderProgram);
|
||||||
CC_SAFE_RELEASE(_userObject);
|
CC_SAFE_RELEASE(_userObject);
|
||||||
|
|
||||||
|
@ -415,15 +413,6 @@ Camera* Node::getCamera()
|
||||||
return _camera;
|
return _camera;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// grid setter
|
|
||||||
void Node::setGrid(GridBase* grid)
|
|
||||||
{
|
|
||||||
CC_SAFE_RETAIN(grid);
|
|
||||||
CC_SAFE_RELEASE(_grid);
|
|
||||||
_grid = grid;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// isVisible getter
|
/// isVisible getter
|
||||||
bool Node::isVisible() const
|
bool Node::isVisible() const
|
||||||
{
|
{
|
||||||
|
@ -823,11 +812,6 @@ void Node::visit()
|
||||||
|
|
||||||
kmGLPushMatrix();
|
kmGLPushMatrix();
|
||||||
|
|
||||||
if (_grid && _grid->isActive())
|
|
||||||
{
|
|
||||||
_grid->beforeDraw();
|
|
||||||
}
|
|
||||||
|
|
||||||
this->transform();
|
this->transform();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
|
@ -857,11 +841,6 @@ void Node::visit()
|
||||||
|
|
||||||
// reset for next frame
|
// reset for next frame
|
||||||
_orderOfArrival = 0;
|
_orderOfArrival = 0;
|
||||||
|
|
||||||
if (_grid && _grid->isActive())
|
|
||||||
{
|
|
||||||
_grid->afterDraw(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
kmGLPopMatrix();
|
kmGLPopMatrix();
|
||||||
}
|
}
|
||||||
|
@ -888,24 +867,9 @@ void Node::transform()
|
||||||
|
|
||||||
|
|
||||||
kmGLMultMatrix( &transfrom4x4 );
|
kmGLMultMatrix( &transfrom4x4 );
|
||||||
|
|
||||||
// saves the MV matrix
|
// saves the MV matrix
|
||||||
kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewTransform);
|
kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewTransform);
|
||||||
|
|
||||||
|
|
||||||
// XXX: Expensive calls. Camera should be integrated into the cached affine matrix
|
|
||||||
if ( _camera != nullptr && !(_grid != nullptr && _grid->isActive()) )
|
|
||||||
{
|
|
||||||
bool translate = (_anchorPointInPoints.x != 0.0f || _anchorPointInPoints.y != 0.0f);
|
|
||||||
|
|
||||||
if( translate )
|
|
||||||
kmGLTranslatef(RENDER_IN_SUBPIXEL(_anchorPointInPoints.x), RENDER_IN_SUBPIXEL(_anchorPointInPoints.y), 0 );
|
|
||||||
|
|
||||||
_camera->locate();
|
|
||||||
|
|
||||||
if( translate )
|
|
||||||
kmGLTranslatef(RENDER_IN_SUBPIXEL(-_anchorPointInPoints.x), RENDER_IN_SUBPIXEL(-_anchorPointInPoints.y), 0 );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -702,34 +702,7 @@ public:
|
||||||
virtual void sortAllChildren();
|
virtual void sortAllChildren();
|
||||||
|
|
||||||
/// @} end of Children and Parent
|
/// @} end of Children and Parent
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// @{
|
|
||||||
/// @name Grid object for effects
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a grid object that is used when applying effects
|
|
||||||
*
|
|
||||||
* @return A Grid object that is used when applying effects
|
|
||||||
* @js NA
|
|
||||||
*/
|
|
||||||
virtual GridBase* getGrid() { return _grid; }
|
|
||||||
/**
|
|
||||||
* @js NA
|
|
||||||
*/
|
|
||||||
virtual const GridBase* getGrid() const { return _grid; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Changes a grid object that is used when applying effects
|
|
||||||
*
|
|
||||||
* @param grid A Grid object that is used when applying effects
|
|
||||||
*/
|
|
||||||
virtual void setGrid(GridBase *grid);
|
|
||||||
|
|
||||||
/// @} end of Grid
|
|
||||||
|
|
||||||
|
|
||||||
/// @{
|
/// @{
|
||||||
/// @name Tag & User data
|
/// @name Tag & User data
|
||||||
|
|
||||||
|
@ -1466,8 +1439,6 @@ protected:
|
||||||
|
|
||||||
Camera *_camera; ///< a camera
|
Camera *_camera; ///< a camera
|
||||||
|
|
||||||
GridBase *_grid; ///< a grid
|
|
||||||
|
|
||||||
int _ZOrder; ///< z-order value that affects the draw order
|
int _ZOrder; ///< z-order value that affects the draw order
|
||||||
|
|
||||||
Vector<Node*> _children; ///< array of children nodes
|
Vector<Node*> _children; ///< array of children nodes
|
||||||
|
|
|
@ -0,0 +1,160 @@
|
||||||
|
|
||||||
|
#include "CCNodeGrid.h"
|
||||||
|
#include "CCGrid.h"
|
||||||
|
|
||||||
|
#include "CCGroupCommand.h"
|
||||||
|
#include "CCRenderer.h"
|
||||||
|
#include "CCCustomCommand.h"
|
||||||
|
|
||||||
|
|
||||||
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
NodeGrid* NodeGrid::create()
|
||||||
|
{
|
||||||
|
NodeGrid * ret = new NodeGrid();
|
||||||
|
if (ret && ret->init())
|
||||||
|
{
|
||||||
|
ret->autorelease();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CC_SAFE_DELETE(ret);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
NodeGrid::NodeGrid()
|
||||||
|
: _nodeGrid(nullptr)
|
||||||
|
, _gridTarget(nullptr)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void NodeGrid::setTarget(Node* target)
|
||||||
|
{
|
||||||
|
CC_SAFE_RELEASE(_gridTarget);
|
||||||
|
CC_SAFE_RETAIN(target);
|
||||||
|
_gridTarget = target;
|
||||||
|
}
|
||||||
|
|
||||||
|
NodeGrid::~NodeGrid()
|
||||||
|
{
|
||||||
|
CC_SAFE_RELEASE(_nodeGrid);
|
||||||
|
CC_SAFE_RELEASE(_gridTarget);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NodeGrid::init()
|
||||||
|
{
|
||||||
|
return Node::init();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NodeGrid::onGridBeginDraw()
|
||||||
|
{
|
||||||
|
if (_nodeGrid && _nodeGrid->isActive())
|
||||||
|
{
|
||||||
|
_nodeGrid->beforeDraw();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void NodeGrid::onGridEndDraw()
|
||||||
|
{
|
||||||
|
if(_nodeGrid && _nodeGrid->isActive())
|
||||||
|
{
|
||||||
|
_nodeGrid->afterDraw(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void NodeGrid::visit()
|
||||||
|
{
|
||||||
|
// quick return if not visible. children won't be drawn.
|
||||||
|
if (!_visible)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Renderer* renderer = Director::getInstance()->getRenderer();
|
||||||
|
|
||||||
|
GroupCommand* groupCommand = GroupCommand::getCommandPool().generateCommand();
|
||||||
|
groupCommand->init(0,_vertexZ);
|
||||||
|
renderer->addCommand(groupCommand);
|
||||||
|
|
||||||
|
renderer->pushGroup(groupCommand->getRenderQueueID());
|
||||||
|
|
||||||
|
kmGLPushMatrix();
|
||||||
|
Director::Projection beforeProjectionType;
|
||||||
|
if(_nodeGrid && _nodeGrid->isActive())
|
||||||
|
{
|
||||||
|
beforeProjectionType = Director::getInstance()->getProjection();
|
||||||
|
_nodeGrid->set2DProjection();
|
||||||
|
}
|
||||||
|
|
||||||
|
kmGLGetMatrix(KM_GL_MODELVIEW, &_cachedMVmat);
|
||||||
|
|
||||||
|
CustomCommand* gridBeginCmd = CustomCommand::getCommandPool().generateCommand();
|
||||||
|
gridBeginCmd->init(0,_vertexZ);
|
||||||
|
gridBeginCmd->func = CC_CALLBACK_0(NodeGrid::onGridBeginDraw, this);
|
||||||
|
renderer->addCommand(gridBeginCmd);
|
||||||
|
|
||||||
|
this->transform();
|
||||||
|
|
||||||
|
if(_gridTarget)
|
||||||
|
{
|
||||||
|
_gridTarget->visit();
|
||||||
|
}
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
if(!_children.empty())
|
||||||
|
{
|
||||||
|
sortAllChildren();
|
||||||
|
// draw children zOrder < 0
|
||||||
|
for( ; i < _children.size(); i++ )
|
||||||
|
{
|
||||||
|
auto node = _children.at(i);
|
||||||
|
|
||||||
|
if ( node && node->getZOrder() < 0 )
|
||||||
|
node->visit();
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// self draw,currently we have nothing to draw on NodeGrid, so there is no need to add render command
|
||||||
|
this->draw();
|
||||||
|
|
||||||
|
// Uses std::for_each to improve performance.
|
||||||
|
std::for_each(_children.cbegin()+i, _children.cend(), [](Node* node){
|
||||||
|
node->visit();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
// reset for next frame
|
||||||
|
_orderOfArrival = 0;
|
||||||
|
|
||||||
|
if(_nodeGrid && _nodeGrid->isActive())
|
||||||
|
{
|
||||||
|
// restore projection
|
||||||
|
Director *director = Director::getInstance();
|
||||||
|
director->setProjection(beforeProjectionType);
|
||||||
|
}
|
||||||
|
|
||||||
|
CustomCommand* gridEndCmd = CustomCommand::getCommandPool().generateCommand();
|
||||||
|
gridEndCmd->init(0,_vertexZ);
|
||||||
|
gridEndCmd->func = CC_CALLBACK_0(NodeGrid::onGridEndDraw, this);
|
||||||
|
renderer->addCommand(gridEndCmd);
|
||||||
|
|
||||||
|
renderer->popGroup();
|
||||||
|
|
||||||
|
kmGLPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NodeGrid::setGrid(GridBase *grid)
|
||||||
|
{
|
||||||
|
CC_SAFE_RELEASE(_nodeGrid);
|
||||||
|
CC_SAFE_RETAIN(grid);
|
||||||
|
_nodeGrid = grid;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_CC_END
|
|
@ -0,0 +1,47 @@
|
||||||
|
#ifndef __MISCNODE_CCGRID_NODE_H__
|
||||||
|
#define __MISCNODE_CCGRID_NODE_H__
|
||||||
|
|
||||||
|
#include "CCNode.h"
|
||||||
|
#include "kazmath/GL/matrix.h"
|
||||||
|
|
||||||
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
class GridBase;
|
||||||
|
|
||||||
|
class NodeGrid : public Node
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static NodeGrid* create();
|
||||||
|
|
||||||
|
GridBase* getGrid() { return _nodeGrid; }
|
||||||
|
/**
|
||||||
|
* @js NA
|
||||||
|
*/
|
||||||
|
const GridBase* getGrid() const { return _nodeGrid; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes a grid object that is used when applying effects
|
||||||
|
*
|
||||||
|
* @param grid A Grid object that is used when applying effects
|
||||||
|
*/
|
||||||
|
void setGrid(GridBase *grid);
|
||||||
|
|
||||||
|
virtual bool init();
|
||||||
|
virtual void visit();
|
||||||
|
|
||||||
|
void setTarget(Node *target);
|
||||||
|
protected:
|
||||||
|
NodeGrid();
|
||||||
|
virtual ~NodeGrid();
|
||||||
|
|
||||||
|
void onGridBeginDraw();
|
||||||
|
void onGridEndDraw();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
kmMat4 _cachedMVmat;
|
||||||
|
Node* _gridTarget;
|
||||||
|
GridBase* _nodeGrid;
|
||||||
|
};
|
||||||
|
NS_CC_END
|
||||||
|
|
||||||
|
#endif
|
|
@ -135,21 +135,10 @@ void ParticleBatchNode::visit()
|
||||||
|
|
||||||
kmGLPushMatrix();
|
kmGLPushMatrix();
|
||||||
|
|
||||||
if ( _grid && _grid->isActive())
|
|
||||||
{
|
|
||||||
_grid->beforeDraw();
|
|
||||||
transformAncestors();
|
|
||||||
}
|
|
||||||
|
|
||||||
transform();
|
transform();
|
||||||
|
|
||||||
draw();
|
draw();
|
||||||
|
|
||||||
if ( _grid && _grid->isActive())
|
|
||||||
{
|
|
||||||
_grid->afterDraw(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
kmGLPopMatrix();
|
kmGLPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -456,22 +456,11 @@ void RenderTexture::visit()
|
||||||
}
|
}
|
||||||
|
|
||||||
kmGLPushMatrix();
|
kmGLPushMatrix();
|
||||||
|
|
||||||
if (_grid && _grid->isActive())
|
|
||||||
{
|
|
||||||
_grid->beforeDraw();
|
|
||||||
transformAncestors();
|
|
||||||
}
|
|
||||||
|
|
||||||
transform();
|
transform();
|
||||||
_sprite->visit();
|
_sprite->visit();
|
||||||
draw();
|
draw();
|
||||||
|
|
||||||
if (_grid && _grid->isActive())
|
|
||||||
{
|
|
||||||
_grid->afterDraw(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
kmGLPopMatrix();
|
kmGLPopMatrix();
|
||||||
|
|
||||||
_orderOfArrival = 0;
|
_orderOfArrival = 0;
|
||||||
|
|
|
@ -146,21 +146,10 @@ void SpriteBatchNode::visit(void)
|
||||||
|
|
||||||
kmGLPushMatrix();
|
kmGLPushMatrix();
|
||||||
|
|
||||||
if (_grid && _grid->isActive())
|
|
||||||
{
|
|
||||||
_grid->beforeDraw();
|
|
||||||
transformAncestors();
|
|
||||||
}
|
|
||||||
|
|
||||||
sortAllChildren();
|
sortAllChildren();
|
||||||
transform();
|
transform();
|
||||||
|
|
||||||
draw();
|
draw();
|
||||||
|
|
||||||
if (_grid && _grid->isActive())
|
|
||||||
{
|
|
||||||
_grid->afterDraw(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
kmGLPopMatrix();
|
kmGLPopMatrix();
|
||||||
setOrderOfArrival(0);
|
setOrderOfArrival(0);
|
||||||
|
|
|
@ -35,6 +35,7 @@ THE SOFTWARE.
|
||||||
#include "CCActionGrid.h"
|
#include "CCActionGrid.h"
|
||||||
#include "CCLayer.h"
|
#include "CCLayer.h"
|
||||||
#include "CCRenderTexture.h"
|
#include "CCRenderTexture.h"
|
||||||
|
#include "CCNodeGrid.h"
|
||||||
|
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
@ -1346,10 +1347,13 @@ void TransitionCrossFade::onExit()
|
||||||
//
|
//
|
||||||
TransitionTurnOffTiles::TransitionTurnOffTiles()
|
TransitionTurnOffTiles::TransitionTurnOffTiles()
|
||||||
{
|
{
|
||||||
|
_outSceneProxy = NodeGrid::create();
|
||||||
|
_outSceneProxy->retain();
|
||||||
}
|
}
|
||||||
|
|
||||||
TransitionTurnOffTiles::~TransitionTurnOffTiles()
|
TransitionTurnOffTiles::~TransitionTurnOffTiles()
|
||||||
{
|
{
|
||||||
|
CC_SAFE_RELEASE(_outSceneProxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
TransitionTurnOffTiles* TransitionTurnOffTiles::create(float t, Scene* scene)
|
TransitionTurnOffTiles* TransitionTurnOffTiles::create(float t, Scene* scene)
|
||||||
|
@ -1373,6 +1377,9 @@ void TransitionTurnOffTiles::sceneOrder()
|
||||||
void TransitionTurnOffTiles::onEnter()
|
void TransitionTurnOffTiles::onEnter()
|
||||||
{
|
{
|
||||||
TransitionScene::onEnter();
|
TransitionScene::onEnter();
|
||||||
|
_outSceneProxy->setTarget(_outScene);
|
||||||
|
_outSceneProxy->onEnter();
|
||||||
|
|
||||||
Size s = Director::getInstance()->getWinSize();
|
Size s = Director::getInstance()->getWinSize();
|
||||||
float aspect = s.width / s.height;
|
float aspect = s.width / s.height;
|
||||||
int x = (int)(12 * aspect);
|
int x = (int)(12 * aspect);
|
||||||
|
@ -1380,7 +1387,7 @@ void TransitionTurnOffTiles::onEnter()
|
||||||
|
|
||||||
TurnOffTiles* toff = TurnOffTiles::create(_duration, Size(x,y));
|
TurnOffTiles* toff = TurnOffTiles::create(_duration, Size(x,y));
|
||||||
ActionInterval* action = easeActionWithAction(toff);
|
ActionInterval* action = easeActionWithAction(toff);
|
||||||
_outScene->runAction
|
_outSceneProxy->runAction
|
||||||
(
|
(
|
||||||
Sequence::create
|
Sequence::create
|
||||||
(
|
(
|
||||||
|
@ -1392,6 +1399,29 @@ void TransitionTurnOffTiles::onEnter()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TransitionTurnOffTiles::onExit()
|
||||||
|
{
|
||||||
|
_outSceneProxy->setTarget(nullptr);
|
||||||
|
_outSceneProxy->onExit();
|
||||||
|
TransitionScene::onExit();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransitionTurnOffTiles::draw()
|
||||||
|
{
|
||||||
|
Scene::draw();
|
||||||
|
|
||||||
|
if( _isInSceneOnTop )
|
||||||
|
{
|
||||||
|
_outSceneProxy->visit();
|
||||||
|
_inScene->visit();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_inScene->visit();
|
||||||
|
_outSceneProxy->visit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ActionInterval* TransitionTurnOffTiles:: easeActionWithAction(ActionInterval* action)
|
ActionInterval* TransitionTurnOffTiles:: easeActionWithAction(ActionInterval* action)
|
||||||
{
|
{
|
||||||
|
@ -1403,9 +1433,12 @@ ActionInterval* TransitionTurnOffTiles:: easeActionWithAction(ActionInterval* ac
|
||||||
//
|
//
|
||||||
TransitionSplitCols::TransitionSplitCols()
|
TransitionSplitCols::TransitionSplitCols()
|
||||||
{
|
{
|
||||||
|
_gridProxy = NodeGrid::create();
|
||||||
|
_gridProxy->retain();
|
||||||
}
|
}
|
||||||
TransitionSplitCols::~TransitionSplitCols()
|
TransitionSplitCols::~TransitionSplitCols()
|
||||||
{
|
{
|
||||||
|
CC_SAFE_RELEASE(_gridProxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
TransitionSplitCols* TransitionSplitCols::create(float t, Scene* scene)
|
TransitionSplitCols* TransitionSplitCols::create(float t, Scene* scene)
|
||||||
|
@ -1423,18 +1456,20 @@ TransitionSplitCols* TransitionSplitCols::create(float t, Scene* scene)
|
||||||
void TransitionSplitCols::onEnter()
|
void TransitionSplitCols::onEnter()
|
||||||
{
|
{
|
||||||
TransitionScene::onEnter();
|
TransitionScene::onEnter();
|
||||||
_inScene->setVisible(false);
|
|
||||||
|
_gridProxy->setTarget(_outScene);
|
||||||
|
_gridProxy->onEnter();
|
||||||
|
|
||||||
ActionInterval* split = action();
|
ActionInterval* split = action();
|
||||||
ActionInterval* seq = (ActionInterval*)Sequence::create
|
ActionInterval* seq = (ActionInterval*)Sequence::create
|
||||||
(
|
(
|
||||||
split,
|
split,
|
||||||
CallFunc::create(CC_CALLBACK_0(TransitionScene::hideOutShowIn,this)),
|
CallFunc::create(CC_CALLBACK_0(TransitionSplitCols::switchTargetToInscene,this)),
|
||||||
split->reverse(),
|
split->reverse(),
|
||||||
nullptr
|
nullptr
|
||||||
);
|
);
|
||||||
|
|
||||||
this->runAction
|
_gridProxy->runAction
|
||||||
(
|
(
|
||||||
Sequence::create
|
Sequence::create
|
||||||
(
|
(
|
||||||
|
@ -1446,6 +1481,24 @@ void TransitionSplitCols::onEnter()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TransitionSplitCols::switchTargetToInscene()
|
||||||
|
{
|
||||||
|
_gridProxy->setTarget(_inScene);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransitionSplitCols::draw()
|
||||||
|
{
|
||||||
|
Scene::draw();
|
||||||
|
_gridProxy->visit();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransitionSplitCols::onExit()
|
||||||
|
{
|
||||||
|
_gridProxy->setTarget(nullptr);
|
||||||
|
_gridProxy->onExit();
|
||||||
|
TransitionScene::onExit();
|
||||||
|
}
|
||||||
|
|
||||||
ActionInterval* TransitionSplitCols:: action()
|
ActionInterval* TransitionSplitCols:: action()
|
||||||
{
|
{
|
||||||
return SplitCols::create(_duration/2.0f, 3);
|
return SplitCols::create(_duration/2.0f, 3);
|
||||||
|
@ -1491,9 +1544,12 @@ TransitionSplitRows* TransitionSplitRows::create(float t, Scene* scene)
|
||||||
//
|
//
|
||||||
TransitionFadeTR::TransitionFadeTR()
|
TransitionFadeTR::TransitionFadeTR()
|
||||||
{
|
{
|
||||||
|
_outSceneProxy = NodeGrid::create();
|
||||||
|
_outSceneProxy->retain();
|
||||||
}
|
}
|
||||||
TransitionFadeTR::~TransitionFadeTR()
|
TransitionFadeTR::~TransitionFadeTR()
|
||||||
{
|
{
|
||||||
|
CC_SAFE_RELEASE(_outSceneProxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
TransitionFadeTR* TransitionFadeTR::create(float t, Scene* scene)
|
TransitionFadeTR* TransitionFadeTR::create(float t, Scene* scene)
|
||||||
|
@ -1517,6 +1573,9 @@ void TransitionFadeTR::onEnter()
|
||||||
{
|
{
|
||||||
TransitionScene::onEnter();
|
TransitionScene::onEnter();
|
||||||
|
|
||||||
|
_outSceneProxy->setTarget(_outScene);
|
||||||
|
_outSceneProxy->onEnter();
|
||||||
|
|
||||||
Size s = Director::getInstance()->getWinSize();
|
Size s = Director::getInstance()->getWinSize();
|
||||||
float aspect = s.width / s.height;
|
float aspect = s.width / s.height;
|
||||||
int x = (int)(12 * aspect);
|
int x = (int)(12 * aspect);
|
||||||
|
@ -1524,7 +1583,7 @@ void TransitionFadeTR::onEnter()
|
||||||
|
|
||||||
ActionInterval* action = actionWithSize(Size(x,y));
|
ActionInterval* action = actionWithSize(Size(x,y));
|
||||||
|
|
||||||
_outScene->runAction
|
_outSceneProxy->runAction
|
||||||
(
|
(
|
||||||
Sequence::create
|
Sequence::create
|
||||||
(
|
(
|
||||||
|
@ -1536,6 +1595,28 @@ void TransitionFadeTR::onEnter()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TransitionFadeTR::onExit()
|
||||||
|
{
|
||||||
|
_outSceneProxy->setTarget(nullptr);
|
||||||
|
_outSceneProxy->onExit();
|
||||||
|
TransitionScene::onExit();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransitionFadeTR::draw()
|
||||||
|
{
|
||||||
|
Scene::draw();
|
||||||
|
|
||||||
|
if( _isInSceneOnTop )
|
||||||
|
{
|
||||||
|
_outSceneProxy->visit();
|
||||||
|
_inScene->visit();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_inScene->visit();
|
||||||
|
_outSceneProxy->visit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ActionInterval* TransitionFadeTR::actionWithSize(const Size& size)
|
ActionInterval* TransitionFadeTR::actionWithSize(const Size& size)
|
||||||
{
|
{
|
||||||
|
|
|
@ -43,6 +43,7 @@ NS_CC_BEGIN
|
||||||
|
|
||||||
class ActionInterval;
|
class ActionInterval;
|
||||||
class Node;
|
class Node;
|
||||||
|
class NodeGrid;
|
||||||
|
|
||||||
/** @brief TransitionEaseScene can ease the actions of the scene protocol.
|
/** @brief TransitionEaseScene can ease the actions of the scene protocol.
|
||||||
@since v0.8.2
|
@since v0.8.2
|
||||||
|
@ -643,13 +644,16 @@ public :
|
||||||
* @lua NA
|
* @lua NA
|
||||||
*/
|
*/
|
||||||
virtual void onEnter() override;
|
virtual void onEnter() override;
|
||||||
|
virtual void onExit() override;
|
||||||
virtual ActionInterval * easeActionWithAction(ActionInterval * action) override;
|
virtual ActionInterval * easeActionWithAction(ActionInterval * action) override;
|
||||||
|
virtual void draw() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
TransitionTurnOffTiles();
|
TransitionTurnOffTiles();
|
||||||
virtual ~TransitionTurnOffTiles();
|
virtual ~TransitionTurnOffTiles();
|
||||||
|
|
||||||
virtual void sceneOrder() override;
|
virtual void sceneOrder() override;
|
||||||
|
NodeGrid* _outSceneProxy;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CC_DISALLOW_COPY_AND_ASSIGN(TransitionTurnOffTiles);
|
CC_DISALLOW_COPY_AND_ASSIGN(TransitionTurnOffTiles);
|
||||||
|
@ -674,11 +678,13 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void onEnter() override;
|
virtual void onEnter() override;
|
||||||
virtual ActionInterval * easeActionWithAction(ActionInterval * action) override;
|
virtual ActionInterval * easeActionWithAction(ActionInterval * action) override;
|
||||||
|
virtual void onExit() override;
|
||||||
|
virtual void draw() override;
|
||||||
protected:
|
protected:
|
||||||
TransitionSplitCols();
|
TransitionSplitCols();
|
||||||
virtual ~TransitionSplitCols();
|
virtual ~TransitionSplitCols();
|
||||||
|
void switchTargetToInscene();
|
||||||
|
NodeGrid* _gridProxy;
|
||||||
private:
|
private:
|
||||||
CC_DISALLOW_COPY_AND_ASSIGN(TransitionSplitCols);
|
CC_DISALLOW_COPY_AND_ASSIGN(TransitionSplitCols);
|
||||||
};
|
};
|
||||||
|
@ -723,13 +729,16 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void onEnter() override;
|
virtual void onEnter() override;
|
||||||
virtual ActionInterval* easeActionWithAction(ActionInterval * action) override;
|
virtual ActionInterval* easeActionWithAction(ActionInterval * action) override;
|
||||||
|
virtual void onExit() override;
|
||||||
|
virtual void draw() override;
|
||||||
protected:
|
protected:
|
||||||
TransitionFadeTR();
|
TransitionFadeTR();
|
||||||
virtual ~TransitionFadeTR();
|
virtual ~TransitionFadeTR();
|
||||||
|
|
||||||
virtual void sceneOrder();
|
virtual void sceneOrder();
|
||||||
|
|
||||||
|
NodeGrid* _outSceneProxy;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CC_DISALLOW_COPY_AND_ASSIGN(TransitionFadeTR);
|
CC_DISALLOW_COPY_AND_ASSIGN(TransitionFadeTR);
|
||||||
};
|
};
|
||||||
|
|
|
@ -29,6 +29,7 @@ THE SOFTWARE.
|
||||||
#include "CCActionInstant.h"
|
#include "CCActionInstant.h"
|
||||||
#include "CCActionGrid.h"
|
#include "CCActionGrid.h"
|
||||||
#include "CCActionPageTurn3D.h"
|
#include "CCActionPageTurn3D.h"
|
||||||
|
#include "CCNodeGrid.h"
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
@ -37,10 +38,17 @@ float TransitionPageTurn::POLYGON_OFFSET_UNITS = -20.f;
|
||||||
|
|
||||||
TransitionPageTurn::TransitionPageTurn()
|
TransitionPageTurn::TransitionPageTurn()
|
||||||
{
|
{
|
||||||
|
_inSceneProxy = NodeGrid::create();
|
||||||
|
_outSceneProxy = NodeGrid::create();
|
||||||
|
|
||||||
|
_inSceneProxy->retain();
|
||||||
|
_outSceneProxy->retain();
|
||||||
}
|
}
|
||||||
|
|
||||||
TransitionPageTurn::~TransitionPageTurn()
|
TransitionPageTurn::~TransitionPageTurn()
|
||||||
{
|
{
|
||||||
|
CC_SAFE_RELEASE(_inSceneProxy);
|
||||||
|
CC_SAFE_RELEASE(_outSceneProxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** creates a base transition with duration and incoming scene */
|
/** creates a base transition with duration and incoming scene */
|
||||||
|
@ -75,17 +83,17 @@ void TransitionPageTurn::draw()
|
||||||
Scene::draw();
|
Scene::draw();
|
||||||
|
|
||||||
if( _isInSceneOnTop ) {
|
if( _isInSceneOnTop ) {
|
||||||
_outScene->visit();
|
_outSceneProxy->visit();
|
||||||
glEnable(GL_POLYGON_OFFSET_FILL);
|
glEnable(GL_POLYGON_OFFSET_FILL);
|
||||||
glPolygonOffset(POLYGON_OFFSET_FACTOR, POLYGON_OFFSET_UNITS);
|
glPolygonOffset(POLYGON_OFFSET_FACTOR, POLYGON_OFFSET_UNITS);
|
||||||
_inScene->visit();
|
_inSceneProxy->visit();
|
||||||
glDisable(GL_POLYGON_OFFSET_FILL);
|
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||||
glPolygonOffset(0, 0);
|
glPolygonOffset(0, 0);
|
||||||
} else {
|
} else {
|
||||||
_inScene->visit();
|
_inSceneProxy->visit();
|
||||||
glEnable(GL_POLYGON_OFFSET_FILL);
|
glEnable(GL_POLYGON_OFFSET_FILL);
|
||||||
glPolygonOffset(POLYGON_OFFSET_FACTOR, POLYGON_OFFSET_UNITS);
|
glPolygonOffset(POLYGON_OFFSET_FACTOR, POLYGON_OFFSET_UNITS);
|
||||||
_outScene->visit();
|
_outSceneProxy->visit();
|
||||||
glDisable(GL_POLYGON_OFFSET_FILL);
|
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||||
glPolygonOffset(0, 0);
|
glPolygonOffset(0, 0);
|
||||||
}
|
}
|
||||||
|
@ -94,6 +102,13 @@ void TransitionPageTurn::draw()
|
||||||
void TransitionPageTurn::onEnter()
|
void TransitionPageTurn::onEnter()
|
||||||
{
|
{
|
||||||
TransitionScene::onEnter();
|
TransitionScene::onEnter();
|
||||||
|
|
||||||
|
_inSceneProxy->setTarget(_inScene);
|
||||||
|
_outSceneProxy->setTarget(_outScene);
|
||||||
|
|
||||||
|
_inSceneProxy->onEnter();
|
||||||
|
_outSceneProxy->onEnter();
|
||||||
|
|
||||||
Size s = Director::getInstance()->getWinSize();
|
Size s = Director::getInstance()->getWinSize();
|
||||||
int x,y;
|
int x,y;
|
||||||
if (s.width > s.height)
|
if (s.width > s.height)
|
||||||
|
@ -111,7 +126,7 @@ void TransitionPageTurn::onEnter()
|
||||||
|
|
||||||
if (! _back )
|
if (! _back )
|
||||||
{
|
{
|
||||||
_outScene->runAction
|
_outSceneProxy->runAction
|
||||||
(
|
(
|
||||||
Sequence::create
|
Sequence::create
|
||||||
(
|
(
|
||||||
|
@ -125,8 +140,8 @@ void TransitionPageTurn::onEnter()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// to prevent initial flicker
|
// to prevent initial flicker
|
||||||
_inScene->setVisible(false);
|
_inSceneProxy->setVisible(false);
|
||||||
_inScene->runAction
|
_inSceneProxy->runAction
|
||||||
(
|
(
|
||||||
Sequence::create
|
Sequence::create
|
||||||
(
|
(
|
||||||
|
@ -139,7 +154,15 @@ void TransitionPageTurn::onEnter()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void TransitionPageTurn::onExit()
|
||||||
|
{
|
||||||
|
_outSceneProxy->setTarget(nullptr);
|
||||||
|
_outSceneProxy->setTarget(nullptr);
|
||||||
|
_outSceneProxy->onExit();
|
||||||
|
_inSceneProxy->onExit();
|
||||||
|
|
||||||
|
TransitionScene::onExit();
|
||||||
|
}
|
||||||
|
|
||||||
ActionInterval* TransitionPageTurn:: actionWithSize(const Size& vector)
|
ActionInterval* TransitionPageTurn:: actionWithSize(const Size& vector)
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,6 +30,8 @@ THE SOFTWARE.
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
class NodeGrid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @addtogroup transition
|
* @addtogroup transition
|
||||||
* @{
|
* @{
|
||||||
|
@ -83,11 +85,14 @@ public:
|
||||||
// Overrides
|
// Overrides
|
||||||
//
|
//
|
||||||
virtual void onEnter() override;
|
virtual void onEnter() override;
|
||||||
|
virtual void onExit() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void sceneOrder() override;
|
virtual void sceneOrder() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
NodeGrid* _inSceneProxy;
|
||||||
|
NodeGrid* _outSceneProxy;
|
||||||
bool _back;
|
bool _back;
|
||||||
static float POLYGON_OFFSET_FACTOR;
|
static float POLYGON_OFFSET_FACTOR;
|
||||||
static float POLYGON_OFFSET_UNITS;
|
static float POLYGON_OFFSET_UNITS;
|
||||||
|
|
|
@ -63,6 +63,7 @@ set(COCOS2D_SRC
|
||||||
CCDrawNode.cpp
|
CCDrawNode.cpp
|
||||||
CCGrabber.cpp
|
CCGrabber.cpp
|
||||||
CCGrid.cpp
|
CCGrid.cpp
|
||||||
|
CCNodeGrid.cpp
|
||||||
CCFont.cpp
|
CCFont.cpp
|
||||||
CCFontAtlas.cpp
|
CCFontAtlas.cpp
|
||||||
CCFontAtlasCache.cpp
|
CCFontAtlasCache.cpp
|
||||||
|
|
|
@ -257,6 +257,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou
|
||||||
<ClCompile Include="ccGLStateCache.cpp" />
|
<ClCompile Include="ccGLStateCache.cpp" />
|
||||||
<ClCompile Include="CCGrabber.cpp" />
|
<ClCompile Include="CCGrabber.cpp" />
|
||||||
<ClCompile Include="CCGrid.cpp" />
|
<ClCompile Include="CCGrid.cpp" />
|
||||||
|
<ClCompile Include="CCNodeGrid.cpp" />
|
||||||
<ClCompile Include="CCIMEDispatcher.cpp" />
|
<ClCompile Include="CCIMEDispatcher.cpp" />
|
||||||
<ClCompile Include="CCLabel.cpp" />
|
<ClCompile Include="CCLabel.cpp" />
|
||||||
<ClCompile Include="CCLabelAtlas.cpp" />
|
<ClCompile Include="CCLabelAtlas.cpp" />
|
||||||
|
@ -442,6 +443,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou
|
||||||
<ClInclude Include="ccGLStateCache.h" />
|
<ClInclude Include="ccGLStateCache.h" />
|
||||||
<ClInclude Include="CCGrabber.h" />
|
<ClInclude Include="CCGrabber.h" />
|
||||||
<ClInclude Include="CCGrid.h" />
|
<ClInclude Include="CCGrid.h" />
|
||||||
|
<ClInclude Include="CCNodeGrid.h" />
|
||||||
<ClInclude Include="CCIMEDelegate.h" />
|
<ClInclude Include="CCIMEDelegate.h" />
|
||||||
<ClInclude Include="CCIMEDispatcher.h" />
|
<ClInclude Include="CCIMEDispatcher.h" />
|
||||||
<ClInclude Include="CCLabel.h" />
|
<ClInclude Include="CCLabel.h" />
|
||||||
|
|
|
@ -569,6 +569,9 @@
|
||||||
<ClCompile Include="..\base\CCValue.cpp">
|
<ClCompile Include="..\base\CCValue.cpp">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="CCNodeGrid.cpp">
|
||||||
|
<Filter>misc_nodes</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\external\edtaa3func\edtaa3func.cpp">
|
<ClCompile Include="..\..\external\edtaa3func\edtaa3func.cpp">
|
||||||
<Filter>label_nodes</Filter>
|
<Filter>label_nodes</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -1188,6 +1191,9 @@
|
||||||
<ClInclude Include="..\base\CCVector.h">
|
<ClInclude Include="..\base\CCVector.h">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="CCNodeGrid.h">
|
||||||
|
<Filter>misc_nodes</Filter>
|
||||||
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\external\edtaa3func\edtaa3func.h">
|
<ClInclude Include="..\..\external\edtaa3func\edtaa3func.h">
|
||||||
<Filter>label_nodes</Filter>
|
<Filter>label_nodes</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
|
|
@ -68,6 +68,7 @@ int GroupCommandManager::getGroupID()
|
||||||
{
|
{
|
||||||
if(!it->second)
|
if(!it->second)
|
||||||
{
|
{
|
||||||
|
_groupMapping[it->first] = true;
|
||||||
return it->first;
|
return it->first;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -444,11 +444,6 @@ void Armature::visit()
|
||||||
}
|
}
|
||||||
kmGLPushMatrix();
|
kmGLPushMatrix();
|
||||||
|
|
||||||
if (_grid && _grid->isActive())
|
|
||||||
{
|
|
||||||
_grid->beforeDraw();
|
|
||||||
}
|
|
||||||
|
|
||||||
transform();
|
transform();
|
||||||
sortAllChildren();
|
sortAllChildren();
|
||||||
draw();
|
draw();
|
||||||
|
@ -456,11 +451,6 @@ void Armature::visit()
|
||||||
// reset for next frame
|
// reset for next frame
|
||||||
_orderOfArrival = 0;
|
_orderOfArrival = 0;
|
||||||
|
|
||||||
if (_grid && _grid->isActive())
|
|
||||||
{
|
|
||||||
_grid->afterDraw(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
kmGLPopMatrix();
|
kmGLPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,11 +101,6 @@ void BatchNode::visit()
|
||||||
}
|
}
|
||||||
kmGLPushMatrix();
|
kmGLPushMatrix();
|
||||||
|
|
||||||
if (_grid && _grid->isActive())
|
|
||||||
{
|
|
||||||
_grid->beforeDraw();
|
|
||||||
}
|
|
||||||
|
|
||||||
transform();
|
transform();
|
||||||
sortAllChildren();
|
sortAllChildren();
|
||||||
draw();
|
draw();
|
||||||
|
@ -113,11 +108,6 @@ void BatchNode::visit()
|
||||||
// reset for next frame
|
// reset for next frame
|
||||||
_orderOfArrival = 0;
|
_orderOfArrival = 0;
|
||||||
|
|
||||||
if (_grid && _grid->isActive())
|
|
||||||
{
|
|
||||||
_grid->afterDraw(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
kmGLPopMatrix();
|
kmGLPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
6ea6ffc183c8a15eae0641c73c9886b90172266f
|
cb193c00a0514b8292266fba55b5f97cbebb73bd
|
|
@ -549,12 +549,6 @@ void ScrollView::visit()
|
||||||
}
|
}
|
||||||
|
|
||||||
kmGLPushMatrix();
|
kmGLPushMatrix();
|
||||||
|
|
||||||
if (_grid && _grid->isActive())
|
|
||||||
{
|
|
||||||
_grid->beforeDraw();
|
|
||||||
this->transformAncestors();
|
|
||||||
}
|
|
||||||
|
|
||||||
this->transform();
|
this->transform();
|
||||||
this->beforeDraw();
|
this->beforeDraw();
|
||||||
|
@ -594,10 +588,6 @@ void ScrollView::visit()
|
||||||
}
|
}
|
||||||
|
|
||||||
this->afterDraw();
|
this->afterDraw();
|
||||||
if ( _grid && _grid->isActive())
|
|
||||||
{
|
|
||||||
_grid->afterDraw(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
kmGLPopMatrix();
|
kmGLPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "EffectsAdvancedTest.h"
|
#include "EffectsAdvancedTest.h"
|
||||||
|
#include "CCNodeGrid.h"
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -20,7 +21,7 @@ void Effect1::onEnter()
|
||||||
{
|
{
|
||||||
EffectAdvanceTextLayer::onEnter();
|
EffectAdvanceTextLayer::onEnter();
|
||||||
|
|
||||||
auto target = getChildByTag(kTagBackground);
|
//auto target = getChildByTag(kTagBackground);
|
||||||
|
|
||||||
// To reuse a grid the grid size and the grid type must be the same.
|
// To reuse a grid the grid size and the grid type must be the same.
|
||||||
// in this case:
|
// in this case:
|
||||||
|
@ -37,8 +38,8 @@ void Effect1::onEnter()
|
||||||
auto orbit = OrbitCamera::create(5, 1, 2, 0, 180, 0, -90);
|
auto orbit = OrbitCamera::create(5, 1, 2, 0, 180, 0, -90);
|
||||||
auto orbit_back = orbit->reverse();
|
auto orbit_back = orbit->reverse();
|
||||||
|
|
||||||
target->runAction( RepeatForever::create( Sequence::create( orbit, orbit_back, NULL) ) );
|
//_bgNode->runAction( RepeatForever::create( Sequence::create( orbit, orbit_back, NULL) ) );
|
||||||
target->runAction( Sequence::create(lens, delay, reuse, waves, NULL) );
|
_bgNode->runAction( Sequence::create(lens, delay, reuse, waves, NULL) );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Effect1::title() const
|
std::string Effect1::title() const
|
||||||
|
@ -55,7 +56,7 @@ void Effect2::onEnter()
|
||||||
{
|
{
|
||||||
EffectAdvanceTextLayer::onEnter();
|
EffectAdvanceTextLayer::onEnter();
|
||||||
|
|
||||||
auto target = getChildByTag(kTagBackground);
|
//auto target = getChildByTag(kTagBackground);
|
||||||
|
|
||||||
// To reuse a grid the grid size and the grid type must be the same.
|
// To reuse a grid the grid size and the grid type must be the same.
|
||||||
// in this case:
|
// in this case:
|
||||||
|
@ -78,8 +79,8 @@ void Effect2::onEnter()
|
||||||
// id orbit = [OrbitCamera::create:5 radius:1 deltaRadius:2 angleZ:0 deltaAngleZ:180 angleX:0 deltaAngleX:-90];
|
// id orbit = [OrbitCamera::create:5 radius:1 deltaRadius:2 angleZ:0 deltaAngleZ:180 angleX:0 deltaAngleX:-90];
|
||||||
// id orbit_back = [orbit reverse];
|
// id orbit_back = [orbit reverse];
|
||||||
//
|
//
|
||||||
// [target runAction: [RepeatForever::create: [Sequence actions: orbit, orbit_back, nil]]];
|
// [target runAction: [RepeatForever::create: [Sequence actions: orbit, orbit_back, nil]]];
|
||||||
target->runAction(Sequence::create( shaky, delay, reuse, shuffle, delay->clone(), turnoff, turnon, NULL) );
|
_bgNode->runAction(Sequence::create( shaky, delay, reuse, shuffle, delay->clone(), turnoff, turnon, NULL) );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Effect2::title() const
|
std::string Effect2::title() const
|
||||||
|
@ -96,20 +97,18 @@ std::string Effect2::title() const
|
||||||
void Effect3::onEnter()
|
void Effect3::onEnter()
|
||||||
{
|
{
|
||||||
EffectAdvanceTextLayer::onEnter();
|
EffectAdvanceTextLayer::onEnter();
|
||||||
|
//auto bg = getChildByTag(kTagBackground);
|
||||||
auto bg = getChildByTag(kTagBackground);
|
//auto target1 = bg->getChildByTag(kTagSprite1);
|
||||||
auto target1 = bg->getChildByTag(kTagSprite1);
|
//auto target2 = bg->getChildByTag(kTagSprite2);
|
||||||
auto target2 = bg->getChildByTag(kTagSprite2);
|
|
||||||
|
|
||||||
auto waves = Waves::create(5, Size(15,10), 5, 20, true, false);
|
auto waves = Waves::create(5, Size(15,10), 5, 20, true, false);
|
||||||
auto shaky = Shaky3D::create(5, Size(15,10), 4, false);
|
auto shaky = Shaky3D::create(5, Size(15,10), 4, false);
|
||||||
|
|
||||||
target1->runAction( RepeatForever::create( waves ) );
|
_target1->runAction( RepeatForever::create( waves ) );
|
||||||
target2->runAction( RepeatForever::create( shaky ) );
|
_target2->runAction( RepeatForever::create( shaky ) );
|
||||||
|
|
||||||
// moving background. Testing issue #244
|
// moving background. Testing issue #244
|
||||||
auto move = MoveBy::create(3, Point(200,0) );
|
auto move = MoveBy::create(3, Point(200,0) );
|
||||||
bg->runAction(RepeatForever::create( Sequence::create(move, move->reverse(), NULL) ));
|
_bgNode->runAction(RepeatForever::create( Sequence::create(move, move->reverse(), NULL) ));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Effect3::title() const
|
std::string Effect3::title() const
|
||||||
|
@ -156,7 +155,8 @@ private:
|
||||||
void Effect4::onEnter()
|
void Effect4::onEnter()
|
||||||
{
|
{
|
||||||
EffectAdvanceTextLayer::onEnter();
|
EffectAdvanceTextLayer::onEnter();
|
||||||
|
//Node* gridNode = NodeGrid::create();
|
||||||
|
|
||||||
auto lens = Lens3D::create(10, Size(32,24), Point(100,180), 150);
|
auto lens = Lens3D::create(10, Size(32,24), Point(100,180), 150);
|
||||||
auto move = JumpBy::create(5, Point(380,0), 100, 4);
|
auto move = JumpBy::create(5, Point(380,0), 100, 4);
|
||||||
auto move_back = move->reverse();
|
auto move_back = move->reverse();
|
||||||
|
@ -171,9 +171,11 @@ void Effect4::onEnter()
|
||||||
auto pTarget = Lens3DTarget::create(lens);
|
auto pTarget = Lens3DTarget::create(lens);
|
||||||
// Please make sure the target been added to its parent.
|
// Please make sure the target been added to its parent.
|
||||||
this->addChild(pTarget);
|
this->addChild(pTarget);
|
||||||
|
//gridNode->addChild(pTarget);
|
||||||
|
|
||||||
director->getActionManager()->addAction(seq, pTarget, false);
|
director->getActionManager()->addAction(seq, pTarget, false);
|
||||||
this->runAction( lens );
|
|
||||||
|
_bgNode->runAction( lens );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Effect4::title() const
|
std::string Effect4::title() const
|
||||||
|
@ -202,8 +204,8 @@ void Effect5::onEnter()
|
||||||
// [[effect copy] autorelease],
|
// [[effect copy] autorelease],
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
auto bg = getChildByTag(kTagBackground);
|
//auto bg = getChildByTag(kTagBackground);
|
||||||
bg->runAction(stopEffect);
|
_bgNode->runAction(stopEffect);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Effect5::title() const
|
std::string Effect5::title() const
|
||||||
|
@ -230,8 +232,8 @@ void Issue631::onEnter()
|
||||||
auto effect = Sequence::create( DelayTime::create(2.0f), Shaky3D::create(5.0f, Size(5, 5), 16, false), NULL);
|
auto effect = Sequence::create( DelayTime::create(2.0f), Shaky3D::create(5.0f, Size(5, 5), 16, false), NULL);
|
||||||
|
|
||||||
// cleanup
|
// cleanup
|
||||||
auto bg = getChildByTag(kTagBackground);
|
//auto bg = getChildByTag(kTagBackground);
|
||||||
removeChild(bg, true);
|
removeChild(_bgNode, true);
|
||||||
|
|
||||||
// background
|
// background
|
||||||
auto layer = LayerColor::create( Color4B(255,0,0,255) );
|
auto layer = LayerColor::create( Color4B(255,0,0,255) );
|
||||||
|
@ -241,15 +243,17 @@ void Issue631::onEnter()
|
||||||
layer->addChild(sprite, 10);
|
layer->addChild(sprite, 10);
|
||||||
|
|
||||||
// foreground
|
// foreground
|
||||||
|
auto layer2BaseGrid = NodeGrid::create();
|
||||||
auto layer2 = LayerColor::create(Color4B( 0, 255,0,255 ) );
|
auto layer2 = LayerColor::create(Color4B( 0, 255,0,255 ) );
|
||||||
auto fog = Sprite::create("Images/Fog.png");
|
auto fog = Sprite::create("Images/Fog.png");
|
||||||
|
|
||||||
BlendFunc bf = {GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA};
|
BlendFunc bf = {GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA};
|
||||||
fog->setBlendFunc(bf);
|
fog->setBlendFunc(bf);
|
||||||
layer2->addChild(fog, 1);
|
layer2->addChild(fog, 1);
|
||||||
addChild(layer2, 1);
|
addChild(layer2BaseGrid, 1);
|
||||||
|
layer2BaseGrid->addChild(layer2);
|
||||||
|
|
||||||
layer2->runAction( RepeatForever::create(effect) );
|
layer2BaseGrid->runAction( RepeatForever::create(effect) );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Issue631::title() const
|
std::string Issue631::title() const
|
||||||
|
@ -335,23 +339,37 @@ void EffectAdvanceTextLayer::onEnter(void)
|
||||||
{
|
{
|
||||||
BaseTest::onEnter();
|
BaseTest::onEnter();
|
||||||
|
|
||||||
|
_bgNode = NodeGrid::create();
|
||||||
|
_bgNode->setAnchorPoint(Point(0.5,0.5));
|
||||||
|
addChild(_bgNode);
|
||||||
|
//_bgNode->setPosition( VisibleRect::center() );
|
||||||
auto bg = Sprite::create("Images/background3.png");
|
auto bg = Sprite::create("Images/background3.png");
|
||||||
addChild(bg, 0, kTagBackground);
|
|
||||||
bg->setPosition( VisibleRect::center() );
|
bg->setPosition( VisibleRect::center() );
|
||||||
|
//addChild(bg, 0, kTagBackground);
|
||||||
|
//bg->setPosition( VisibleRect::center() );
|
||||||
|
_bgNode->addChild(bg);
|
||||||
|
|
||||||
|
_target1 = NodeGrid::create();
|
||||||
|
_target1->setAnchorPoint(Point(0.5,0.5));
|
||||||
auto grossini = Sprite::create("Images/grossinis_sister2.png");
|
auto grossini = Sprite::create("Images/grossinis_sister2.png");
|
||||||
bg->addChild(grossini, 1, kTagSprite1);
|
_target1->addChild(grossini);
|
||||||
grossini->setPosition( Point(VisibleRect::left().x+VisibleRect::getVisibleRect().size.width/3.0f, VisibleRect::bottom().y+ 200) );
|
_bgNode->addChild(_target1);
|
||||||
|
_target1->setPosition( Point(VisibleRect::left().x+VisibleRect::getVisibleRect().size.width/3.0f, VisibleRect::bottom().y+ 200) );
|
||||||
auto sc = ScaleBy::create(2, 5);
|
auto sc = ScaleBy::create(2, 5);
|
||||||
auto sc_back = sc->reverse();
|
auto sc_back = sc->reverse();
|
||||||
grossini->runAction( RepeatForever::create(Sequence::create(sc, sc_back, NULL) ) );
|
_target1->runAction( RepeatForever::create(Sequence::create(sc, sc_back, NULL) ) );
|
||||||
|
|
||||||
|
|
||||||
|
_target2 = NodeGrid::create();
|
||||||
|
_target2->setAnchorPoint(Point(0.5,0.5));
|
||||||
auto tamara = Sprite::create("Images/grossinis_sister1.png");
|
auto tamara = Sprite::create("Images/grossinis_sister1.png");
|
||||||
bg->addChild(tamara, 1, kTagSprite2);
|
_target2->addChild(tamara);
|
||||||
tamara->setPosition( Point(VisibleRect::left().x+2*VisibleRect::getVisibleRect().size.width/3.0f,VisibleRect::bottom().y+200) );
|
_bgNode->addChild(_target2);
|
||||||
|
_target2->setPosition( Point(VisibleRect::left().x+2*VisibleRect::getVisibleRect().size.width/3.0f,VisibleRect::bottom().y+200) );
|
||||||
auto sc2 = ScaleBy::create(2, 5);
|
auto sc2 = ScaleBy::create(2, 5);
|
||||||
auto sc2_back = sc2->reverse();
|
auto sc2_back = sc2->reverse();
|
||||||
tamara->runAction( RepeatForever::create(Sequence::create(sc2, sc2_back, NULL) ) );
|
_target2->runAction( RepeatForever::create(Sequence::create(sc2, sc2_back, NULL) ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EffectAdvanceTextLayer::~EffectAdvanceTextLayer(void)
|
EffectAdvanceTextLayer::~EffectAdvanceTextLayer(void)
|
||||||
|
|
|
@ -12,6 +12,10 @@ protected:
|
||||||
|
|
||||||
std::string _title;
|
std::string _title;
|
||||||
|
|
||||||
|
Node* _bgNode;
|
||||||
|
Node* _target1;
|
||||||
|
Node* _target2;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void onEnter();
|
virtual void onEnter();
|
||||||
~EffectAdvanceTextLayer(void);
|
~EffectAdvanceTextLayer(void);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "EffectsTest.h"
|
#include "EffectsTest.h"
|
||||||
#include "../testResource.h"
|
#include "../testResource.h"
|
||||||
|
#include "CCNodeGrid.h"
|
||||||
enum {
|
enum {
|
||||||
kTagTextLayer = 1,
|
kTagTextLayer = 1,
|
||||||
|
|
||||||
|
@ -342,25 +342,25 @@ TextLayer::TextLayer(void)
|
||||||
LayerColor *background = LayerColor::create( Color4B(32,128,32,255) );
|
LayerColor *background = LayerColor::create( Color4B(32,128,32,255) );
|
||||||
this->addChild(background,-20);
|
this->addChild(background,-20);
|
||||||
|
|
||||||
auto node = Node::create();
|
_gridNodeTarget = NodeGrid::create();
|
||||||
auto effect = getAction();
|
auto effect = getAction();
|
||||||
node->runAction(effect);
|
_gridNodeTarget->runAction(effect);
|
||||||
addChild(node, 0, kTagBackground);
|
addChild(_gridNodeTarget, 0, kTagBackground);
|
||||||
|
|
||||||
auto bg = Sprite::create(s_back3);
|
auto bg = Sprite::create(s_back3);
|
||||||
node->addChild(bg, 0);
|
_gridNodeTarget->addChild(bg, 0);
|
||||||
// bg->setAnchorPoint( Point::ZERO );
|
// bg->setAnchorPoint( Point::ZERO );
|
||||||
bg->setPosition(VisibleRect::center());
|
bg->setPosition(VisibleRect::center());
|
||||||
|
|
||||||
auto grossini = Sprite::create(s_pathSister2);
|
auto grossini = Sprite::create(s_pathSister2);
|
||||||
node->addChild(grossini, 1);
|
_gridNodeTarget->addChild(grossini, 1);
|
||||||
grossini->setPosition( Point(VisibleRect::left().x+VisibleRect::getVisibleRect().size.width/3,VisibleRect::center().y) );
|
grossini->setPosition( Point(VisibleRect::left().x+VisibleRect::getVisibleRect().size.width/3,VisibleRect::center().y) );
|
||||||
auto sc = ScaleBy::create(2, 5);
|
auto sc = ScaleBy::create(2, 5);
|
||||||
auto sc_back = sc->reverse();
|
auto sc_back = sc->reverse();
|
||||||
grossini->runAction( RepeatForever::create(Sequence::create(sc, sc_back, NULL) ) );
|
grossini->runAction( RepeatForever::create(Sequence::create(sc, sc_back, NULL) ) );
|
||||||
|
|
||||||
auto tamara = Sprite::create(s_pathSister1);
|
auto tamara = Sprite::create(s_pathSister1);
|
||||||
node->addChild(tamara, 1);
|
_gridNodeTarget->addChild(tamara, 1);
|
||||||
tamara->setPosition( Point(VisibleRect::left().x+2*VisibleRect::getVisibleRect().size.width/3,VisibleRect::center().y) );
|
tamara->setPosition( Point(VisibleRect::left().x+2*VisibleRect::getVisibleRect().size.width/3,VisibleRect::center().y) );
|
||||||
auto sc2 = ScaleBy::create(2, 5);
|
auto sc2 = ScaleBy::create(2, 5);
|
||||||
auto sc2_back = sc2->reverse();
|
auto sc2_back = sc2->reverse();
|
||||||
|
@ -377,9 +377,9 @@ TextLayer::TextLayer(void)
|
||||||
|
|
||||||
void TextLayer::checkAnim(float dt)
|
void TextLayer::checkAnim(float dt)
|
||||||
{
|
{
|
||||||
auto s2 = getChildByTag(kTagBackground);
|
//auto s2 = getChildByTag(kTagBackground);
|
||||||
if ( s2->getNumberOfRunningActions() == 0 && s2->getGrid() != NULL)
|
if ( _gridNodeTarget->getNumberOfRunningActions() == 0 && _gridNodeTarget->getGrid() != NULL)
|
||||||
s2->setGrid(NULL);;
|
_gridNodeTarget->setGrid(NULL);;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ class TextLayer : public BaseTest
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
//UxString _title;
|
//UxString _title;
|
||||||
|
NodeGrid* _gridNodeTarget;
|
||||||
public:
|
public:
|
||||||
TextLayer(void);
|
TextLayer(void);
|
||||||
~TextLayer(void);
|
~TextLayer(void);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "ArmatureScene.h"
|
#include "ArmatureScene.h"
|
||||||
#include "../../testResource.h"
|
#include "../../testResource.h"
|
||||||
#include "cocostudio/CocoStudio.h"
|
#include "cocostudio/CocoStudio.h"
|
||||||
|
#include "CCNodeGrid.h"
|
||||||
|
|
||||||
|
|
||||||
using namespace cocos2d;
|
using namespace cocos2d;
|
||||||
|
@ -574,6 +575,7 @@ void TestAnimationEvent::callback2()
|
||||||
void TestFrameEvent::onEnter()
|
void TestFrameEvent::onEnter()
|
||||||
{
|
{
|
||||||
ArmatureTestLayer::onEnter();
|
ArmatureTestLayer::onEnter();
|
||||||
|
_gridNode = NodeGrid::create();
|
||||||
Armature *armature = Armature::create("HeroAnimation");
|
Armature *armature = Armature::create("HeroAnimation");
|
||||||
armature->getAnimation()->play("attack");
|
armature->getAnimation()->play("attack");
|
||||||
armature->getAnimation()->setSpeedScale(0.5);
|
armature->getAnimation()->setSpeedScale(0.5);
|
||||||
|
@ -584,7 +586,9 @@ void TestFrameEvent::onEnter()
|
||||||
* To disconnect this event, just setFrameEventCallFunc(nullptr);
|
* To disconnect this event, just setFrameEventCallFunc(nullptr);
|
||||||
*/
|
*/
|
||||||
armature->getAnimation()->setFrameEventCallFunc(CC_CALLBACK_0(TestFrameEvent::onFrameEvent, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4));
|
armature->getAnimation()->setFrameEventCallFunc(CC_CALLBACK_0(TestFrameEvent::onFrameEvent, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4));
|
||||||
addChild(armature);
|
|
||||||
|
_gridNode->addChild(armature);
|
||||||
|
addChild(_gridNode);
|
||||||
|
|
||||||
schedule( schedule_selector(TestFrameEvent::checkAction) );
|
schedule( schedule_selector(TestFrameEvent::checkAction) );
|
||||||
}
|
}
|
||||||
|
@ -596,20 +600,19 @@ void TestFrameEvent::onFrameEvent(Bone *bone, const char *evt, int originFrameIn
|
||||||
{
|
{
|
||||||
CCLOG("(%s) emit a frame event (%s) at frame index (%d).", bone->getName().c_str(), evt, currentFrameIndex);
|
CCLOG("(%s) emit a frame event (%s) at frame index (%d).", bone->getName().c_str(), evt, currentFrameIndex);
|
||||||
|
|
||||||
|
if (!_gridNode->getActionByTag(FRAME_EVENT_ACTION_TAG) || _gridNode->getActionByTag(FRAME_EVENT_ACTION_TAG)->isDone())
|
||||||
|
{
|
||||||
|
_gridNode->stopAllActions();
|
||||||
|
|
||||||
// if (!this->getActionByTag(FRAME_EVENT_ACTION_TAG) || this->getActionByTag(FRAME_EVENT_ACTION_TAG)->isDone())
|
ActionInterval *action = ShatteredTiles3D::create(0.2f, Size(16,12), 5, false);
|
||||||
// {
|
action->setTag(FRAME_EVENT_ACTION_TAG);
|
||||||
// this->stopAllActions();
|
_gridNode->runAction(action);
|
||||||
//
|
}
|
||||||
// ActionInterval *action = ShatteredTiles3D::create(0.2f, Size(16,12), 5, false);
|
|
||||||
// action->setTag(FRAME_EVENT_ACTION_TAG);
|
|
||||||
// this->runAction(action);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
void TestFrameEvent::checkAction(float dt)
|
void TestFrameEvent::checkAction(float dt)
|
||||||
{
|
{
|
||||||
if ( this->getNumberOfRunningActions() == 0 && this->getGrid() != nullptr)
|
if ( _gridNode->getNumberOfRunningActions() == 0 && _gridNode->getGrid() != nullptr)
|
||||||
this->setGrid(nullptr);
|
_gridNode->setGrid(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -168,6 +168,8 @@ public:
|
||||||
virtual std::string title() const override;
|
virtual std::string title() const override;
|
||||||
void onFrameEvent(cocostudio::Bone *bone, const char *evt, int originFrameIndex, int currentFrameIndex);
|
void onFrameEvent(cocostudio::Bone *bone, const char *evt, int originFrameIndex, int currentFrameIndex);
|
||||||
void checkAction(float dt);
|
void checkAction(float dt);
|
||||||
|
protected:
|
||||||
|
NodeGrid* _gridNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue