PuzzleSDK
Parallax2类 参考

#include <ParallaxTest.h>

+ 类 Parallax2 继承关系图:
+ Parallax2 的协作图:

Public 成员函数

 CREATE_FUNC (Parallax2)
 
 Parallax2 ()
 
void onTouchesMoved (const std::vector< cocos2d::Touch * > &touches, cocos2d::Event *event)
 
virtual std::string title () const override
 
- Public 成员函数 继承自 TestCase
 TestCase ()
 
 ~TestCase ()
 
virtual std::string subtitle () const
 
virtual Type getTestType () const
 
virtual float getDuration () const
 
virtual std::string getExpectedOutput () const
 
virtual std::string getActualOutput () const
 
virtual void restartTestCallback (cocos2d::Ref *sender)
 
virtual void nextTestCallback (cocos2d::Ref *sender)
 
virtual void priorTestCallback (cocos2d::Ref *sender)
 
virtual void onBackCallback (cocos2d::Ref *sender)
 
void setTestSuite (TestSuite *testSuite)
 
TestSuitegetTestSuite () const
 
float getRunTime () const
 
void setTestCaseName (const std::string &name)
 
std::string getTestCaseName () const
 
const cocos2d::Label * getSubtitleLable () const
 
const cocos2d::MenuItemImage * getRestartTestItem () const
 
virtual void onEnter () override
 

Protected 属性

cocos2d::Node * _root
 
cocos2d::Node * _target
 
cocos2d::MotionStreak * _streak
 
- Protected 属性 继承自 ParallaxDemo
cocos2d::TextureAtlas * _atlas
 
- Protected 属性 继承自 TestCase
cocos2d::MenuItemImage * _priorTestItem
 
cocos2d::MenuItemImage * _restartTestItem
 
cocos2d::MenuItemImage * _nextTestItem
 
cocos2d::Label * _titleLabel
 
cocos2d::Label * _subtitleLabel
 

额外继承的成员函数

- Public 类型 继承自 TestCase
enum class  Type { ROBUSTNESS , UNIT , GRAPHICAL_STATIC , MANUAL }
 
- Public 属性 继承自 TestCase
CC_CONSTRUCTOR_ACCESS __pad0__: virtual bool init() override
 

详细描述

在文件 ParallaxTest.h51 行定义.

构造及析构函数说明

◆ Parallax2()

Parallax2::Parallax2 ( )

在文件 ParallaxTest.cpp117 行定义.

118{
119 auto listener = EventListenerTouchAllAtOnce::create();
120 listener->onTouchesMoved = CC_CALLBACK_2(Parallax2::onTouchesMoved, this);
121 _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
122
123 // Top Layer, a simple image
124 auto cocosImage = Sprite::create(s_Power);
125 // scale the image (optional)
126 cocosImage->setScale( 2.5f );
127 // change the transform anchor point to 0,0 (optional)
128 cocosImage->setAnchorPoint( Vec2(0,0) );
129
130
131 // Middle layer: a Tile map atlas
132 auto tilemap = TileMapAtlas::create(s_TilesPng, s_LevelMapTga, 16, 16);
133 tilemap->releaseMap();
134
135 // change the transform anchor to 0,0 (optional)
136 tilemap->setAnchorPoint( Vec2(0, 0) );
137
138 // Anti Aliased images
139 tilemap->getTexture()->setAntiAliasTexParameters();
140
141
142 // background layer: another image
143 auto background = Sprite::create(s_back);
144 // scale the image (optional)
145 background->setScale( 1.5f );
146 // change the transform anchor point (optional)
147 background->setAnchorPoint( Vec2(0,0) );
148
149
150 // create a void node, a parent node
151 auto voidNode = ParallaxNode::create();
152
153 // NOW add the 3 layers to the 'void' node
154
155 // background image is moved at a ratio of 0.4x, 0.5y
156 voidNode->addChild(background, -1, Vec2(0.4f,0.5f), Vec2::ZERO);
157
158 // tiles are moved at a ratio of 1.0, 1.0y
159 voidNode->addChild(tilemap, 1, Vec2(1.0f,1.0f), Vec2(0,-200) );
160
161 // top image is moved at a ratio of 3.0x, 2.5y
162 voidNode->addChild( cocosImage, 2, Vec2(3.0f,2.5f), Vec2(200,1000) );
163 addChild(voidNode, 0, kTagNode);
164}
@ kTagNode
void onTouchesMoved(const std::vector< cocos2d::Touch * > &touches, cocos2d::Event *event)
static const char s_TilesPng[]
Definition: testResource.h:63
static const char s_LevelMapTga[]
Definition: testResource.h:64
static const char s_back[]
Definition: testResource.h:38
static const char s_Power[]
Definition: testResource.h:59

引用了 kTagNode, onTouchesMoved(), s_back, s_LevelMapTga, s_Power , 以及 s_TilesPng.

+ 函数调用图:

成员函数说明

◆ CREATE_FUNC()

Parallax2::CREATE_FUNC ( Parallax2  )

◆ onTouchesMoved()

void Parallax2::onTouchesMoved ( const std::vector< cocos2d::Touch * > &  touches,
cocos2d::Event *  event 
)

在文件 ParallaxTest.cpp166 行定义.

167{
168 auto diff = touches[0]->getDelta();
169
170 auto node = getChildByTag(kTagNode);
171 auto currentPos = node->getPosition();
172 node->setPosition(currentPos + diff);
173}

引用了 kTagNode.

被这些函数引用 Parallax2().

+ 这是这个函数的调用关系图:

◆ title()

std::string Parallax2::title ( ) const
overridevirtual

重载 TestCase .

在文件 ParallaxTest.cpp175 行定义.

176{
177 return "Parallax: drag screen";
178}

类成员变量说明

◆ _root

cocos2d::Node* Parallax2::_root
protected

在文件 ParallaxTest.h54 行定义.

◆ _streak

cocos2d::MotionStreak* Parallax2::_streak
protected

在文件 ParallaxTest.h56 行定义.

◆ _target

cocos2d::Node* Parallax2::_target
protected

在文件 ParallaxTest.h55 行定义.


该类的文档由以下文件生成: