PuzzleSDK
SpriteBatchNodeColorOpacity类 参考

#include <SpriteTest.h>

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

Public 成员函数

 CREATE_FUNC (SpriteBatchNodeColorOpacity)
 
 SpriteBatchNodeColorOpacity ()
 
void removeAndAddSprite (float dt)
 
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.h92 行定义.

构造及析构函数说明

◆ SpriteBatchNodeColorOpacity()

SpriteBatchNodeColorOpacity::SpriteBatchNodeColorOpacity ( )

在文件 SpriteTest.cpp451 行定义.

452{
453 // small capacity. Testing resizing.
454 // Don't use capacity=1 in your real game. It is expensive to resize the capacity
455 auto batch = SpriteBatchNode::create("Images/grossini_dance_atlas.png", 1);
456 addChild(batch, 0, kTagSpriteBatchNode);
457
458 auto sprite1 = Sprite::createWithTexture(batch->getTexture(), Rect(85*0, 121*1, 85, 121));
459 auto sprite2 = Sprite::createWithTexture(batch->getTexture(), Rect(85*1, 121*1, 85, 121));
460 auto sprite3 = Sprite::createWithTexture(batch->getTexture(), Rect(85*2, 121*1, 85, 121));
461 auto sprite4 = Sprite::createWithTexture(batch->getTexture(), Rect(85*3, 121*1, 85, 121));
462
463 auto sprite5 = Sprite::createWithTexture(batch->getTexture(), Rect(85*0, 121*1, 85, 121));
464 auto sprite6 = Sprite::createWithTexture(batch->getTexture(), Rect(85*1, 121*1, 85, 121));
465 auto sprite7 = Sprite::createWithTexture(batch->getTexture(), Rect(85*2, 121*1, 85, 121));
466 auto sprite8 = Sprite::createWithTexture(batch->getTexture(), Rect(85*3, 121*1, 85, 121));
467
468
469 auto s = Director::getInstance()->getWinSize();
470 sprite1->setPosition( Vec2( (s.width/5)*1, (s.height/3)*1) );
471 sprite2->setPosition( Vec2( (s.width/5)*2, (s.height/3)*1) );
472 sprite3->setPosition( Vec2( (s.width/5)*3, (s.height/3)*1) );
473 sprite4->setPosition( Vec2( (s.width/5)*4, (s.height/3)*1) );
474 sprite5->setPosition( Vec2( (s.width/5)*1, (s.height/3)*2) );
475 sprite6->setPosition( Vec2( (s.width/5)*2, (s.height/3)*2) );
476 sprite7->setPosition( Vec2( (s.width/5)*3, (s.height/3)*2) );
477 sprite8->setPosition( Vec2( (s.width/5)*4, (s.height/3)*2) );
478
479 auto action = FadeIn::create(2);
480 auto action_back = action->reverse();
481 auto fade = RepeatForever::create( Sequence::create( action, action_back,nullptr) );
482
483 auto tintred = TintBy::create(2, 0, -255, -255);
484 auto tintred_back = tintred->reverse();
485 auto red = RepeatForever::create( Sequence::create( tintred, tintred_back,nullptr) );
486
487 auto tintgreen = TintBy::create(2, -255, 0, -255);
488 auto tintgreen_back = tintgreen->reverse();
489 auto green = RepeatForever::create( Sequence::create( tintgreen, tintgreen_back,nullptr) );
490
491 auto tintblue = TintBy::create(2, -255, -255, 0);
492 auto tintblue_back = tintblue->reverse();
493 auto blue = RepeatForever::create( Sequence::create( tintblue, tintblue_back,nullptr) );
494
495
496 sprite5->runAction(red);
497 sprite6->runAction(green);
498 sprite7->runAction(blue);
499 sprite8->runAction(fade);
500
501 // late add: test dirtyColor and dirtyPosition
502 batch->addChild(sprite1, 0, kTagSprite1);
503 batch->addChild(sprite2, 0, kTagSprite2);
504 batch->addChild(sprite3, 0, kTagSprite3);
505 batch->addChild(sprite4, 0, kTagSprite4);
506 batch->addChild(sprite5, 0, kTagSprite5);
507 batch->addChild(sprite6, 0, kTagSprite6);
508 batch->addChild(sprite7, 0, kTagSprite7);
509 batch->addChild(sprite8, 0, kTagSprite8);
510
511
512 schedule( CC_CALLBACK_1(SpriteBatchNodeColorOpacity::removeAndAddSprite, this), 2, "remove_add_key");
513}
@ kTagSprite5
Definition: SpriteTest.cpp:53
@ kTagSprite2
Definition: SpriteTest.cpp:50
@ kTagSprite8
Definition: SpriteTest.cpp:56
@ kTagSprite6
Definition: SpriteTest.cpp:54
@ kTagSprite7
Definition: SpriteTest.cpp:55
@ kTagSprite4
Definition: SpriteTest.cpp:52
@ kTagSprite1
Definition: SpriteTest.cpp:49
@ kTagSprite3
Definition: SpriteTest.cpp:51
@ kTagSpriteBatchNode
Definition: SpriteTest.cpp:40
void removeAndAddSprite(float dt)
Definition: SpriteTest.cpp:517

引用了 kTagSprite1, kTagSprite2, kTagSprite3, kTagSprite4, kTagSprite5, kTagSprite6, kTagSprite7, kTagSprite8, kTagSpriteBatchNode , 以及 removeAndAddSprite().

+ 函数调用图:

成员函数说明

◆ CREATE_FUNC()

SpriteBatchNodeColorOpacity::CREATE_FUNC ( SpriteBatchNodeColorOpacity  )

◆ removeAndAddSprite()

void SpriteBatchNodeColorOpacity::removeAndAddSprite ( float  dt)

在文件 SpriteTest.cpp517 行定义.

518{
519 auto batch= static_cast<SpriteBatchNode*>( getChildByTag(kTagSpriteBatchNode) );
520 auto sprite = static_cast<Sprite*>( batch->getChildByTag(kTagSprite5) );
521
522 sprite->retain();
523
524 batch->removeChild(sprite, false);
525 batch->addChild(sprite, 0, kTagSprite5);
526
527 sprite->release();
528}

引用了 kTagSprite5 , 以及 kTagSpriteBatchNode.

被这些函数引用 SpriteBatchNodeColorOpacity().

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

◆ subtitle()

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

重载 TestCase .

在文件 SpriteTest.cpp535 行定义.

536{
537 return "Color & Opacity";
538}

◆ title()

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

重载 TestCase .

在文件 SpriteTest.cpp530 行定义.

531{
532 return "Testing SpriteBatchNode";
533}

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