本文来自http://blog.csdn.net/runaying ,引用必须注明出处!
cocos2d-x节点(CCParallaxNode.h)API
温馨提醒:为了大家能更好学习,强烈推荐大家看看本人的这篇博客 Cocos2d-X权威指南笔记
Parallax(视差) 类似滚动条
//cocos2d-x-3.0alpha0/cocos2dx/tilemap_parallax_nodes/
//Parallax(视差) 类似滚动条
#ifndef __CCPARALLAX_NODE_H__
#define __CCPARALLAX_NODE_H__
#include "base_nodes/CCNode.h"
/*#include "support/data_support/ccArray.h"*/
NS_CC_BEGIN
struct _ccArray;
/**
* @addtogroup tilemap_parallax_nodes
* @{
*/
/** @brief ParallaxNode: A node that simulates a parallax scroller //模拟视差滚动的节点
children 移动的 faster / slower 是根据 parent 视差比确定的
*/
class CC_DLL ParallaxNode : public Node
{
public:
// Create a Parallax(视差) node
static ParallaxNode * create();
/** 使用 z-顺序,视差比和位置偏移 在内容里面添加一个 child
It returns self, 你可以连接几个 addChilds.
@since v0.8
* @js ctor
*/
ParallaxNode();
/**
* @js NA
* @lua NA
*/
virtual ~ParallaxNode();
// 防止编译器警告:“包括函数隐藏重载虚函数”
using Node::addChild;
void addChild(Node * child, int z, const Point& parallaxRatio, const Point& positionOffset);
/** 为 Parallax(视差) 节点设置一个 layer 数组 */
void setParallaxArray( struct _ccArray *parallaxArray) { _parallaxArray = parallaxArray; }
/** Returns Parallax(视差) 节点的 layer 数组 */
struct _ccArray* getParallaxArray() { return _parallaxArray; }
const struct _ccArray* getParallaxArray() const { return _parallaxArray; }
//
// Overrides
//
virtual void addChild(Node * child, int zOrder, int tag) override;
virtual void removeChild(Node* child, bool cleanup) override;
virtual void removeAllChildrenWithCleanup(bool cleanup) override;
virtual void visit(void) override;
protected:
Point absolutePosition();
Point _lastPosition;
struct _ccArray* _parallaxArray;
};
// end of tilemap_parallax_nodes group
/// @}
NS_CC_END
#endif //__CCPARALLAX_NODE_H__