PuzzleSDK
Sprite1类 参考

#include <SpriteTest.h>

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

Public 成员函数

 CREATE_FUNC (Sprite1)
 
 Sprite1 ()
 
virtual std::string title () const override
 
virtual std::string subtitle () const override
 
void addNewSpriteWithCoords (cocos2d::Vec2 p)
 
void onTouchesEnded (const std::vector< cocos2d::Touch * > &touches, cocos2d::Event *event)
 
- 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
 

额外继承的成员函数

- Public 类型 继承自 TestCase
enum class  Type { ROBUSTNESS , UNIT , GRAPHICAL_STATIC , MANUAL }
 
- Public 属性 继承自 TestCase
CC_CONSTRUCTOR_ACCESS __pad0__: virtual bool init() override
 
- Protected 属性 继承自 SpriteTestDemo
std::string _title
 
- Protected 属性 继承自 TestCase
cocos2d::MenuItemImage * _priorTestItem
 
cocos2d::MenuItemImage * _restartTestItem
 
cocos2d::MenuItemImage * _nextTestItem
 
cocos2d::Label * _titleLabel
 
cocos2d::Label * _subtitleLabel
 

详细描述

在文件 SpriteTest.h43 行定义.

构造及析构函数说明

◆ Sprite1()

Sprite1::Sprite1 ( )

在文件 SpriteTest.cpp148 行定义.

149{
150 auto listener = EventListenerTouchAllAtOnce::create();
151 listener->onTouchesEnded = CC_CALLBACK_2(Sprite1::onTouchesEnded, this);
152 _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
153
154 auto s = Director::getInstance()->getWinSize();
155 addNewSpriteWithCoords( Vec2(s.width/2, s.height/2) );
156}
void onTouchesEnded(const std::vector< cocos2d::Touch * > &touches, cocos2d::Event *event)
Definition: SpriteTest.cpp:189
void addNewSpriteWithCoords(cocos2d::Vec2 p)
Definition: SpriteTest.cpp:158

引用了 addNewSpriteWithCoords() , 以及 onTouchesEnded().

+ 函数调用图:

成员函数说明

◆ addNewSpriteWithCoords()

void Sprite1::addNewSpriteWithCoords ( cocos2d::Vec2  p)

在文件 SpriteTest.cpp158 行定义.

159{
160 int idx = (int)(CCRANDOM_0_1() * 1400.0f / 100.0f);
161 int x = (idx%5) * 85;
162 int y = (idx/5) * 121;
163
164
165 auto sprite = Sprite::create("Images/grossini_dance_atlas.png", Rect(x,y,85,121) );
166 addChild( sprite );
167
168 sprite->setPosition( Vec2( p.x, p.y) );
169
170 ActionInterval* action;
171 float random = CCRANDOM_0_1();
172
173 if( random < 0.20 )
174 action = ScaleBy::create(3, 2);
175 else if(random < 0.40)
176 action = RotateBy::create(3, 360);
177 else if( random < 0.60)
178 action = Blink::create(1, 3);
179 else if( random < 0.8 )
180 action = TintBy::create(2, 0, -255, -255);
181 else
182 action = FadeOut::create(2);
183 auto action_back = action->reverse();
184 auto seq = Sequence::create( action, action_back, nullptr );
185
186 sprite->runAction( RepeatForever::create(seq) );
187}

被这些函数引用 onTouchesEnded() , 以及 Sprite1().

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

◆ CREATE_FUNC()

Sprite1::CREATE_FUNC ( Sprite1  )

◆ onTouchesEnded()

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

在文件 SpriteTest.cpp189 行定义.

190{
191 for (auto touch: touches)
192 {
193 auto location = touch->getLocation();
194
195 addNewSpriteWithCoords( location );
196 }
197}

引用了 addNewSpriteWithCoords().

被这些函数引用 Sprite1().

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

◆ subtitle()

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

重载 TestCase .

在文件 SpriteTest.cpp204 行定义.

205{
206 return "Tap screen to add more sprites";
207}

◆ title()

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

重载 TestCase .

在文件 SpriteTest.cpp199 行定义.

200{
201 return "Testing Sprite";
202}

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