PuzzleSDK
Issue2572类 参考

#include <ParallaxTest.h>

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

Public 成员函数

 CREATE_FUNC (Issue2572)
 
 Issue2572 ()
 
virtual std::string title () const override
 
virtual std::string subtitle () const override
 
- Public 成员函数 继承自 TestCase
 TestCase ()
 
 ~TestCase ()
 
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 成员函数

virtual void update (float dt) override
 

Protected 属性

cocos2d::ParallaxNode * _paraNode
 
float _moveTimer
 
float _addTimer
 
cocos2d::Vector< cocos2d::Sprite * > _childList
 
ssize_t _preListSize
 
int _printCount
 
float _addChildStep
 
float _wholeMoveTime
 
cocos2d::Vec2 _wholeMoveSize
 
- 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.h67 行定义.

构造及析构函数说明

◆ Issue2572()

Issue2572::Issue2572 ( )

在文件 ParallaxTest.cpp185 行定义.

186: _moveTimer(0.0f)
187, _addTimer(0.0f)
188, _preListSize(0)
189, _printCount(0)
190{
191 _addChildStep = 1.0f;
192 _wholeMoveTime = 3.0f;
193 _wholeMoveSize = Vec2(-300, 0);
194
195 // create a parallax node, a parent node
196 _paraNode = ParallaxNode::create();
197 addChild(_paraNode, 0, kTagNode);
198
199 this->scheduleUpdate();
200}
@ kTagNode
cocos2d::Vec2 _wholeMoveSize
Definition: ParallaxTest.h:79
float _moveTimer
Definition: ParallaxTest.h:71
float _addChildStep
Definition: ParallaxTest.h:77
cocos2d::ParallaxNode * _paraNode
Definition: ParallaxTest.h:70
float _wholeMoveTime
Definition: ParallaxTest.h:78
ssize_t _preListSize
Definition: ParallaxTest.h:74
int _printCount
Definition: ParallaxTest.h:75
float _addTimer
Definition: ParallaxTest.h:72

引用了 _addChildStep, _paraNode, _wholeMoveSize, _wholeMoveTime , 以及 kTagNode.

成员函数说明

◆ CREATE_FUNC()

Issue2572::CREATE_FUNC ( Issue2572  )

◆ subtitle()

std::string Issue2572::subtitle ( ) const
overridevirtual

重载 TestCase .

在文件 ParallaxTest.cpp255 行定义.

256{
257 return "Look at the output in console";
258}

◆ title()

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

重载 TestCase .

在文件 ParallaxTest.cpp250 行定义.

251{
252 return "Issue 2572";
253}

◆ update()

void Issue2572::update ( float  dt)
overrideprotectedvirtual

在文件 ParallaxTest.cpp202 行定义.

203{
204 _addTimer += dt;
205 _moveTimer += dt;
206 if (_moveTimer >= _wholeMoveTime) {
207 this->unscheduleUpdate();
208 return;
209 }
210
211 _paraNode->setPosition(_paraNode->getPosition() + _wholeMoveSize * dt / _wholeMoveTime);
212
213 if (_addTimer >= _addChildStep) {
214 _addTimer = 0.0f;
215
216 auto child = Sprite::create("Images/Icon.png");
217 Size viewSize = Director::getInstance()->getVisibleSize();
218 Vec2 offset = Vec2(viewSize.width / 2, viewSize.height/2);
219 _paraNode->addChild(child, 1, Vec2( 1, 0 ), offset );
220
221 _childList.pushBack(child);
222 }
223
224 // After a child added, output the position of the children 3 times.
225 // Bug : The first output is much different with the second one & the third one.
226 if (_childList.size() != _preListSize) {
227 switch (_printCount) {
228 case 0:
229 case 1:
230 case 2:
231 log( "--child count-- %zd", _childList.size());
232 for (const auto& obj : _childList)
233 {
234 Sprite* obstacle = dynamic_cast<Sprite*>( obj );
235 log("child position : (%.2f, %.2f)", obstacle->getPositionX(), obstacle->getPositionY());
236 }
237 log("-------------------");
238 _printCount++;
239 break;
240 case 3:
241 _preListSize = _childList.size();
242 _printCount = 0;
243 break;
244 default:
245 break;
246 }
247 }
248}
cocos2d::Vector< cocos2d::Sprite * > _childList
Definition: ParallaxTest.h:73

引用了 _addChildStep, _addTimer, _childList, _moveTimer, _paraNode, _preListSize, _printCount, _wholeMoveSize , 以及 _wholeMoveTime.

类成员变量说明

◆ _addChildStep

float Issue2572::_addChildStep
protected

在文件 ParallaxTest.h77 行定义.

被这些函数引用 Issue2572() , 以及 update().

◆ _addTimer

float Issue2572::_addTimer
protected

在文件 ParallaxTest.h72 行定义.

被这些函数引用 update().

◆ _childList

cocos2d::Vector<cocos2d::Sprite*> Issue2572::_childList
protected

在文件 ParallaxTest.h73 行定义.

被这些函数引用 update().

◆ _moveTimer

float Issue2572::_moveTimer
protected

在文件 ParallaxTest.h71 行定义.

被这些函数引用 update().

◆ _paraNode

cocos2d::ParallaxNode* Issue2572::_paraNode
protected

在文件 ParallaxTest.h70 行定义.

被这些函数引用 Issue2572() , 以及 update().

◆ _preListSize

ssize_t Issue2572::_preListSize
protected

在文件 ParallaxTest.h74 行定义.

被这些函数引用 update().

◆ _printCount

int Issue2572::_printCount
protected

在文件 ParallaxTest.h75 行定义.

被这些函数引用 update().

◆ _wholeMoveSize

cocos2d::Vec2 Issue2572::_wholeMoveSize
protected

在文件 ParallaxTest.h79 行定义.

被这些函数引用 Issue2572() , 以及 update().

◆ _wholeMoveTime

float Issue2572::_wholeMoveTime
protected

在文件 ParallaxTest.h78 行定义.

被这些函数引用 Issue2572() , 以及 update().


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