axmol/cocos/2d/CCNodeGrid.h

115 lines
3.1 KiB
C
Raw Normal View History

/****************************************************************************
Copyright (c) 2013-2017 Chukong Technologies Inc.
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__
#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.
*/
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.
*/
GridBase* getGrid() { return _nodeGrid; }
2013-12-10 10:50:31 +08:00
/**
2015-03-19 21:03:28 +08:00
* @js NA
*/
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
*/
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.
*/
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.
*/
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.
*/
const Rect& getGridRect() const { return _gridRect; }
// overrides
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override;
CC_CONSTRUCTOR_ACCESS:
NodeGrid();
virtual ~NodeGrid();
2013-12-10 10:50:31 +08:00
protected:
2013-12-18 17:19:50 +08:00
void onGridBeginDraw();
void onGridEndDraw();
Node* _gridTarget;
2013-12-10 10:50:31 +08:00
GridBase* _nodeGrid;
GroupCommand _groupCommand;
CustomCommand _gridBeginCommand;
CustomCommand _gridEndCommand;
2015-07-08 17:26:29 +08:00
Rect _gridRect;
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
#endif