PuzzleSDK
SpriteBatchNode1类 参考

#include <SpriteTest.h>

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

Public 成员函数

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

额外继承的成员函数

- 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.h70 行定义.

构造及析构函数说明

◆ SpriteBatchNode1()

SpriteBatchNode1::SpriteBatchNode1 ( )

在文件 SpriteTest.cpp291 行定义.

292{
293 auto listener = EventListenerTouchAllAtOnce::create();
294 listener->onTouchesEnded = CC_CALLBACK_2(SpriteBatchNode1::onTouchesEnded, this);
295 _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
296
297 auto BatchNode = SpriteBatchNode::create("Images/grossini_dance_atlas.png", 50);
298 addChild(BatchNode, 0, kTagSpriteBatchNode);
299
300 auto s = Director::getInstance()->getWinSize();
301 addNewSpriteWithCoords( Vec2(s.width/2, s.height/2) );
302}
@ kTagSpriteBatchNode
Definition: SpriteTest.cpp:40
void onTouchesEnded(const std::vector< cocos2d::Touch * > &touches, cocos2d::Event *event)
Definition: SpriteTest.cpp:338
void addNewSpriteWithCoords(cocos2d::Vec2 p)
Definition: SpriteTest.cpp:304

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

+ 函数调用图:

成员函数说明

◆ addNewSpriteWithCoords()

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

在文件 SpriteTest.cpp304 行定义.

305{
306 auto BatchNode = static_cast<SpriteBatchNode*>( getChildByTag(kTagSpriteBatchNode) );
307
308 int idx = CCRANDOM_0_1() * 1400 / 100;
309 int x = (idx%5) * 85;
310 int y = (idx/5) * 121;
311
312
313 auto sprite = Sprite::createWithTexture(BatchNode->getTexture(), Rect(x,y,85,121));
314 BatchNode->addChild(sprite);
315
316 sprite->setPosition( Vec2( p.x, p.y) );
317
318 ActionInterval* action;
319 float random = CCRANDOM_0_1();
320
321 if( random < 0.20 )
322 action = ScaleBy::create(3, 2);
323 else if(random < 0.40)
324 action = RotateBy::create(3, 360);
325 else if( random < 0.60)
326 action = Blink::create(1, 3);
327 else if( random < 0.8 )
328 action = TintBy::create(2, 0, -255, -255);
329 else
330 action = FadeOut::create(2);
331
332 auto action_back = action->reverse();
333 auto seq = Sequence::create(action, action_back, nullptr);
334
335 sprite->runAction( RepeatForever::create(seq));
336}

引用了 kTagSpriteBatchNode.

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

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

◆ CREATE_FUNC()

SpriteBatchNode1::CREATE_FUNC ( SpriteBatchNode1  )

◆ onTouchesEnded()

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

在文件 SpriteTest.cpp338 行定义.

339{
340 for (auto &touch: touches)
341 {
342 auto location = touch->getLocation();
343
344 addNewSpriteWithCoords( location );
345 }
346
347}

引用了 addNewSpriteWithCoords().

被这些函数引用 SpriteBatchNode1().

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

◆ subtitle()

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

重载 TestCase .

在文件 SpriteTest.cpp354 行定义.

355{
356 return "SpriteBatchNode: Tap screen to add more sprites";
357}

◆ title()

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

重载 TestCase .

在文件 SpriteTest.cpp349 行定义.

350{
351 return "Testing SpriteBatchNode";
352}

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