PuzzleSDK
SpriteBatchNodeZOrder类 参考

#include <SpriteTest.h>

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

Public 成员函数

 CREATE_FUNC (SpriteBatchNodeZOrder)
 
 SpriteBatchNodeZOrder ()
 
void reorderSprite (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
 

Protected 属性

int _dir
 
- Protected 属性 继承自 SpriteTestDemo
std::string _title
 
- 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
 

详细描述

在文件 SpriteTest.h117 行定义.

构造及析构函数说明

◆ SpriteBatchNodeZOrder()

SpriteBatchNodeZOrder::SpriteBatchNodeZOrder ( )

在文件 SpriteTest.cpp610 行定义.

611{
612 _dir = 1;
613
614 // small capacity. Testing resizing.
615 // Don't use capacity=1 in your real game. It is expensive to resize the capacity
616 auto batch = SpriteBatchNode::create("Images/grossini_dance_atlas.png", 1);
617 addChild(batch, 0, kTagSpriteBatchNode);
618
619 auto s = Director::getInstance()->getWinSize();
620
621 float step = s.width/11;
622 for(int i=0;i<5;i++)
623 {
624 auto sprite = Sprite::createWithTexture(batch->getTexture(), Rect(85*0, 121*1, 85, 121));
625 sprite->setPosition( Vec2( (i+1)*step, s.height/2) );
626 batch->addChild(sprite, i);
627 }
628
629 for(int i=5;i<10;i++)
630 {
631 auto sprite = Sprite::createWithTexture(batch->getTexture(), Rect(85*1, 121*0, 85, 121));
632 sprite->setPosition( Vec2( (i+1)*step, s.height/2) );
633 batch->addChild(sprite, 14-i);
634 }
635
636 auto sprite = Sprite::createWithTexture(batch->getTexture(), Rect(85*3, 121*0, 85, 121));
637 batch->addChild(sprite, -1, kTagSprite1);
638 sprite->setPosition( Vec2(s.width/2, s.height/2 - 20) );
639 sprite->setScaleX( 6 );
640 sprite->setColor(Color3B::RED);
641
642 schedule( CC_CALLBACK_1(SpriteBatchNodeZOrder::reorderSprite, this), 1, "reorder_key");
643}
@ kTagSprite1
Definition: SpriteTest.cpp:49
@ kTagSpriteBatchNode
Definition: SpriteTest.cpp:40
void reorderSprite(float dt)
Definition: SpriteTest.cpp:645

引用了 _dir, kTagSprite1, kTagSpriteBatchNode , 以及 reorderSprite().

+ 函数调用图:

成员函数说明

◆ CREATE_FUNC()

SpriteBatchNodeZOrder::CREATE_FUNC ( SpriteBatchNodeZOrder  )

◆ reorderSprite()

void SpriteBatchNodeZOrder::reorderSprite ( float  dt)

在文件 SpriteTest.cpp645 行定义.

646{
647 auto batch= static_cast<SpriteBatchNode*>( getChildByTag( kTagSpriteBatchNode ));
648 auto sprite = static_cast<Sprite*>(batch->getChildByTag(kTagSprite1));
649
650 int z = sprite->getLocalZOrder();
651
652 if( z < -1 )
653 _dir = 1;
654 if( z > 10 )
655 _dir = -1;
656
657 z += _dir * 3;
658
659 batch->reorderChild(sprite, z);
660}

引用了 _dir, kTagSprite1 , 以及 kTagSpriteBatchNode.

被这些函数引用 SpriteBatchNodeZOrder().

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

◆ subtitle()

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

重载 TestCase .

在文件 SpriteTest.cpp667 行定义.

668{
669 return "Z order";
670}

◆ title()

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

重载 TestCase .

在文件 SpriteTest.cpp662 行定义.

663{
664 return "Testing SpriteBatchNode";
665}

类成员变量说明

◆ _dir

int SpriteBatchNodeZOrder::_dir
protected

在文件 SpriteTest.h128 行定义.

被这些函数引用 reorderSprite() , 以及 SpriteBatchNodeZOrder().


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