PuzzleSDK
IntervalTest类 参考

#include <IntervalTest.h>

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

Public 成员函数

 CREATE_FUNC (IntervalTest)
 
 IntervalTest ()
 
virtual ~IntervalTest ()
 
virtual void update (float dt) override
 
- Public 成员函数 继承自 TestCase
 TestCase ()
 
 ~TestCase ()
 
virtual std::string title () const
 
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::Label * _label0
 
cocos2d::Label * _label1
 
cocos2d::Label * _label2
 
cocos2d::Label * _label3
 
cocos2d::Label * _label4
 
float _time0
 
float _time1
 
float _time2
 
float _time3
 
float _time4
 
- 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
 

详细描述

在文件 IntervalTest.h32 行定义.

构造及析构函数说明

◆ IntervalTest()

IntervalTest::IntervalTest ( )

在文件 IntervalTest.cpp41 行定义.

42{
43 _time0 = _time1 = _time2 = _time3 = _time4 = 0.0f;
44
45 auto s = Director::getInstance()->getWinSize();
46 // sun
47 auto sun = ParticleSun::create();
48 sun->setTexture(Director::getInstance()->getTextureCache()->addImage("Images/fire.png"));
49 sun->setPosition(VisibleRect::rightTop().x-32,VisibleRect::rightTop().y-32);
50
51 sun->setTotalParticles(130);
52 sun->setLife(0.6f);
53 this->addChild(sun);
54
55 // timers
56 _label0 = Label::createWithBMFont("fonts/bitmapFontTest4.fnt", "0");
57 _label1 = Label::createWithBMFont("fonts/bitmapFontTest4.fnt", "0");
58 _label2 = Label::createWithBMFont("fonts/bitmapFontTest4.fnt", "0");
59 _label3 = Label::createWithBMFont("fonts/bitmapFontTest4.fnt", "0");
60 _label4 = Label::createWithBMFont("fonts/bitmapFontTest4.fnt", "0");
61
62 scheduleUpdate();
63 schedule([&](float dt){
64 _time1 +=dt;
65
66 char str[10] = {0};
67 sprintf(str, "%2.1f", _time1);
68 _label1->setString( str );
69 }, "step_1");
70
71 schedule([&](float dt){
72 _time2 +=dt;
73
74 char str[10] = {0};
75 sprintf(str, "%2.1f", _time2);
76 _label2->setString( str );
77 }, 0.5, "step_2");
78
79 schedule([&](float dt){
80 _time3 +=dt;
81
82 char str[10] = {0};
83 sprintf(str, "%2.1f", _time3);
84 _label3->setString( str );
85 }, 1, "step_3");
86
87 schedule([&](float dt){
88 _time4 +=dt;
89
90 char str[10] = {0};
91 sprintf(str, "%2.1f", _time4);
92 _label4->setString( str );
93 }, 2, "step_4");
94
95 _label0->setPosition(s.width*1/6, s.height/2);
96 _label1->setPosition(s.width*2/6, s.height/2);
97 _label2->setPosition(s.width*3/6, s.height/2);
98 _label3->setPosition(s.width*4/6, s.height/2);
99 _label4->setPosition(s.width*5/6, s.height/2);
100
101 addChild(_label0);
102 addChild(_label1);
103 addChild(_label2);
104 addChild(_label3);
105 addChild(_label4);
106
107 // Sprite
108 auto sprite = Sprite::create(s_pathGrossini);
109 sprite->setPosition(VisibleRect::left().x + 40, VisibleRect::bottom().y + 50);
110
111 auto jump = JumpBy::create(3, Vec2(s.width-80,0.0f), 50, 4);
112
113 addChild(sprite);
114 sprite->runAction( RepeatForever::create(Sequence::create(jump, jump->reverse(), nullptr) ));
115 // pause button
116 auto item1 = MenuItemFont::create("Pause", [&](Ref* sender) {
117 if(Director::getInstance()->isPaused())
118 Director::getInstance()->resume();
119 else
120 Director::getInstance()->pause();
121 });
122 auto menu = Menu::create(item1, nullptr);
123 menu->setPosition(s.width/2, s.height-50);
124
125 addChild( menu );
126}
cocos2d::Label * _label4
Definition: IntervalTest.h:48
cocos2d::Label * _label0
Definition: IntervalTest.h:44
cocos2d::Label * _label1
Definition: IntervalTest.h:45
cocos2d::Label * _label2
Definition: IntervalTest.h:46
cocos2d::Label * _label3
Definition: IntervalTest.h:47
static cocos2d::Vec2 bottom()
Definition: VisibleRect.cpp:63
static cocos2d::Vec2 rightTop()
Definition: VisibleRect.cpp:81
static cocos2d::Vec2 left()
Definition: VisibleRect.cpp:45
static const char s_pathGrossini[]
Definition: testResource.h:28

引用了 _label0, _label1, _label2, _label3, _label4, _time0, _time1, _time2, _time3, _time4, VisibleRect::bottom(), VisibleRect::left(), VisibleRect::rightTop() , 以及 s_pathGrossini.

+ 函数调用图:

◆ ~IntervalTest()

IntervalTest::~IntervalTest ( )
virtual

在文件 IntervalTest.cpp128 行定义.

129{
130 if(Director::getInstance()->isPaused())
131 {
132 Director::getInstance()->resume();
133 }
134}

成员函数说明

◆ CREATE_FUNC()

IntervalTest::CREATE_FUNC ( IntervalTest  )

◆ update()

void IntervalTest::update ( float  dt)
overridevirtual

在文件 IntervalTest.cpp136 行定义.

137{
138 _time0 +=dt;
139 char time[10] = {0};
140 sprintf(time, "%2.1f", _time0);
141 _label0->setString(time);
142}

引用了 _label0 , 以及 _time0.

类成员变量说明

◆ _label0

cocos2d::Label* IntervalTest::_label0
protected

在文件 IntervalTest.h44 行定义.

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

◆ _label1

cocos2d::Label* IntervalTest::_label1
protected

在文件 IntervalTest.h45 行定义.

被这些函数引用 IntervalTest().

◆ _label2

cocos2d::Label* IntervalTest::_label2
protected

在文件 IntervalTest.h46 行定义.

被这些函数引用 IntervalTest().

◆ _label3

cocos2d::Label* IntervalTest::_label3
protected

在文件 IntervalTest.h47 行定义.

被这些函数引用 IntervalTest().

◆ _label4

cocos2d::Label* IntervalTest::_label4
protected

在文件 IntervalTest.h48 行定义.

被这些函数引用 IntervalTest().

◆ _time0

float IntervalTest::_time0
protected

在文件 IntervalTest.h50 行定义.

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

◆ _time1

float IntervalTest::_time1
protected

在文件 IntervalTest.h50 行定义.

被这些函数引用 IntervalTest().

◆ _time2

float IntervalTest::_time2
protected

在文件 IntervalTest.h50 行定义.

被这些函数引用 IntervalTest().

◆ _time3

float IntervalTest::_time3
protected

在文件 IntervalTest.h50 行定义.

被这些函数引用 IntervalTest().

◆ _time4

float IntervalTest::_time4
protected

在文件 IntervalTest.h50 行定义.

被这些函数引用 IntervalTest().


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