2013-12-21 03:52:52 +08:00
|
|
|
/****************************************************************************
|
2018-01-29 16:25:32 +08:00
|
|
|
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
2013-12-21 03:52:52 +08:00
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2013-12-10 10:50:31 +08:00
|
|
|
#ifndef __MISCNODE_CCGRID_NODE_H__
|
|
|
|
#define __MISCNODE_CCGRID_NODE_H__
|
|
|
|
|
2014-04-27 01:11:22 +08:00
|
|
|
#include "2d/CCNode.h"
|
2014-04-30 08:37:36 +08:00
|
|
|
#include "renderer/CCGroupCommand.h"
|
|
|
|
#include "renderer/CCCustomCommand.h"
|
2013-12-10 10:50:31 +08:00
|
|
|
|
|
|
|
NS_CC_BEGIN
|
|
|
|
|
|
|
|
class GridBase;
|
2015-03-21 17:06:26 +08:00
|
|
|
/**
|
|
|
|
* @addtogroup _2d
|
|
|
|
* @{
|
|
|
|
*/
|
2013-12-10 10:50:31 +08:00
|
|
|
|
2015-03-19 21:03:28 +08:00
|
|
|
/**
|
|
|
|
* @brief Base class for Grid Node.
|
|
|
|
*/
|
|
|
|
|
2014-07-15 12:00:31 +08:00
|
|
|
class CC_DLL NodeGrid : public Node
|
2013-12-10 10:50:31 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-03-19 21:03:28 +08:00
|
|
|
/** Create a Grid Node.
|
|
|
|
*
|
|
|
|
* @return An autorelease Grid Node.
|
|
|
|
*/
|
2013-12-16 14:21:05 +08:00
|
|
|
static NodeGrid* create();
|
2015-03-19 21:03:28 +08:00
|
|
|
|
2015-07-08 17:26:29 +08:00
|
|
|
static NodeGrid* create(const Rect& rect);
|
|
|
|
|
2015-03-19 21:03:28 +08:00
|
|
|
/** Get a Grid Node.
|
|
|
|
*
|
|
|
|
* @return Return a GridBase.
|
|
|
|
*/
|
2013-12-16 14:21:05 +08:00
|
|
|
GridBase* getGrid() { return _nodeGrid; }
|
2013-12-10 10:50:31 +08:00
|
|
|
/**
|
2015-03-19 21:03:28 +08:00
|
|
|
* @js NA
|
|
|
|
*/
|
2013-12-16 14:21:05 +08:00
|
|
|
const GridBase* getGrid() const { return _nodeGrid; }
|
2013-12-10 10:50:31 +08:00
|
|
|
|
|
|
|
/**
|
2015-03-19 21:03:28 +08:00
|
|
|
* Changes a grid object that is used when applying effects.
|
2013-12-10 10:50:31 +08:00
|
|
|
*
|
2015-03-19 21:03:28 +08:00
|
|
|
* @param grid A Grid object that is used when applying effects.
|
2013-12-10 10:50:31 +08:00
|
|
|
*/
|
2013-12-16 14:21:05 +08:00
|
|
|
void setGrid(GridBase *grid);
|
2015-03-19 21:03:28 +08:00
|
|
|
|
|
|
|
/** Set the Grid Target.
|
|
|
|
*
|
|
|
|
* @param target A Node is used to set the Grid Target.
|
|
|
|
*/
|
2013-12-16 14:21:05 +08:00
|
|
|
void setTarget(Node *target);
|
2015-07-08 17:26:29 +08:00
|
|
|
|
2015-07-08 22:34:33 +08:00
|
|
|
/**
|
|
|
|
* @brief Set the effect grid rect.
|
|
|
|
* @param gridRect The effect grid rect.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
void setGridRect(const Rect& gridRect) { _gridRect = gridRect; }
|
2015-07-08 22:34:33 +08:00
|
|
|
/**
|
|
|
|
* @brief Get the effect grid rect.
|
|
|
|
* @return Return the effect grid rect.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
const Rect& getGridRect() const { return _gridRect; }
|
2013-12-21 03:52:52 +08:00
|
|
|
|
|
|
|
// overrides
|
2014-05-31 07:42:05 +08:00
|
|
|
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override;
|
2013-12-21 03:52:52 +08:00
|
|
|
|
2014-08-21 15:11:33 +08:00
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2013-12-16 14:21:05 +08:00
|
|
|
NodeGrid();
|
|
|
|
virtual ~NodeGrid();
|
2013-12-10 10:50:31 +08:00
|
|
|
|
2014-08-21 15:11:33 +08:00
|
|
|
protected:
|
2013-12-18 17:19:50 +08:00
|
|
|
void onGridBeginDraw();
|
|
|
|
void onGridEndDraw();
|
|
|
|
|
2013-12-12 13:21:14 +08:00
|
|
|
Node* _gridTarget;
|
2013-12-10 10:50:31 +08:00
|
|
|
GridBase* _nodeGrid;
|
2013-12-26 18:11:23 +08:00
|
|
|
GroupCommand _groupCommand;
|
2013-12-26 21:19:12 +08:00
|
|
|
CustomCommand _gridBeginCommand;
|
|
|
|
CustomCommand _gridEndCommand;
|
2015-07-08 17:26:29 +08:00
|
|
|
|
|
|
|
Rect _gridRect;
|
2013-12-21 03:52:52 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(NodeGrid);
|
2013-12-10 10:50:31 +08:00
|
|
|
};
|
2015-03-21 17:06:26 +08:00
|
|
|
/** @} */
|
2013-12-10 10:50:31 +08:00
|
|
|
NS_CC_END
|
|
|
|
|
2014-06-19 19:45:49 +08:00
|
|
|
#endif
|