PuzzleSDK
SpriteBatchNodeNewTexture类 参考

#include <SpriteTest.h>

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

Public 成员函数

 CREATE_FUNC (SpriteBatchNodeNewTexture)
 
 SpriteBatchNodeNewTexture ()
 
virtual ~SpriteBatchNodeNewTexture ()
 
void addNewSprite ()
 
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
 

Protected 属性

cocos2d::Texture2D * _texture1
 
cocos2d::Texture2D * _texture2
 
- 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.h312 行定义.

构造及析构函数说明

◆ SpriteBatchNodeNewTexture()

SpriteBatchNodeNewTexture::SpriteBatchNodeNewTexture ( )

在文件 SpriteTest.cpp1653 行定义.

1654{
1655 auto listener = EventListenerTouchAllAtOnce::create();
1656 listener->onTouchesEnded = CC_CALLBACK_2(SpriteBatchNodeNewTexture::onTouchesEnded, this);
1657 _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
1658
1659 auto batch = SpriteBatchNode::create("Images/grossini_dance_atlas.png", 50);
1660 addChild(batch, 0, kTagSpriteBatchNode);
1661
1662 _texture1 = batch->getTexture(); _texture1->retain();
1663 _texture2 = Director::getInstance()->getTextureCache()->addImage("Images/grossini_dance_atlas-mono.png");
1664 _texture2->retain();
1665
1666 for(int i=0;i<30;i++)
1667 addNewSprite();
1668}
@ kTagSpriteBatchNode
Definition: SpriteTest.cpp:40
cocos2d::Texture2D * _texture2
Definition: SpriteTest.h:325
void onTouchesEnded(const std::vector< cocos2d::Touch * > &touches, cocos2d::Event *event)
cocos2d::Texture2D * _texture1
Definition: SpriteTest.h:324

引用了 _texture1, _texture2, addNewSprite(), kTagSpriteBatchNode , 以及 onTouchesEnded().

+ 函数调用图:

◆ ~SpriteBatchNodeNewTexture()

SpriteBatchNodeNewTexture::~SpriteBatchNodeNewTexture ( )
virtual

在文件 SpriteTest.cpp1670 行定义.

1671{
1672 _texture1->release();
1673 _texture2->release();
1674}

引用了 _texture1 , 以及 _texture2.

成员函数说明

◆ addNewSprite()

void SpriteBatchNodeNewTexture::addNewSprite ( )

在文件 SpriteTest.cpp1676 行定义.

1677{
1678 auto s = Director::getInstance()->getWinSize();
1679
1680 auto p = Vec2( CCRANDOM_0_1() * s.width, CCRANDOM_0_1() * s.height);
1681
1682 auto batch = static_cast<SpriteBatchNode*>( getChildByTag( kTagSpriteBatchNode ) );
1683
1684 int idx = CCRANDOM_0_1() * 1400 / 100;
1685 int x = (idx%5) * 85;
1686 int y = (idx/5) * 121;
1687
1688
1689 auto sprite = Sprite::createWithTexture(batch->getTexture(), Rect(x,y,85,121));
1690 batch->addChild(sprite);
1691
1692 sprite->setPosition( Vec2( p.x, p.y) );
1693
1694 ActionInterval* action;
1695 float random = CCRANDOM_0_1();
1696
1697 if( random < 0.20 )
1698 action = ScaleBy::create(3, 2);
1699 else if(random < 0.40)
1700 action = RotateBy::create(3, 360);
1701 else if( random < 0.60)
1702 action = Blink::create(1, 3);
1703 else if( random < 0.8 )
1704 action = TintBy::create(2, 0, -255, -255);
1705 else
1706 action = FadeOut::create(2);
1707 auto action_back = action->reverse();
1708 auto seq = Sequence::create(action, action_back, nullptr);
1709
1710 sprite->runAction( RepeatForever::create(seq) );
1711}

引用了 kTagSpriteBatchNode.

被这些函数引用 SpriteBatchNodeNewTexture().

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

◆ CREATE_FUNC()

SpriteBatchNodeNewTexture::CREATE_FUNC ( SpriteBatchNodeNewTexture  )

◆ onTouchesEnded()

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

在文件 SpriteTest.cpp1713 行定义.

1714{
1715 auto batch = static_cast<SpriteBatchNode*>( getChildByTag( kTagSpriteBatchNode) );
1716
1717 if( batch->getTexture() == _texture1 )
1718 batch->setTexture(_texture2);
1719 else
1720 batch->setTexture(_texture1);
1721}

引用了 _texture1, _texture2 , 以及 kTagSpriteBatchNode.

被这些函数引用 SpriteBatchNodeNewTexture().

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

◆ subtitle()

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

重载 TestCase .

在文件 SpriteTest.cpp1728 行定义.

1729{
1730 return "setTexture() (tap / touch the screen)";
1731}

◆ title()

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

重载 TestCase .

在文件 SpriteTest.cpp1723 行定义.

1724{
1725 return "Testing SpriteBatchNode";
1726}

类成员变量说明

◆ _texture1

cocos2d::Texture2D* SpriteBatchNodeNewTexture::_texture1
protected

在文件 SpriteTest.h324 行定义.

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

◆ _texture2

cocos2d::Texture2D* SpriteBatchNodeNewTexture::_texture2
protected

在文件 SpriteTest.h325 行定义.

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


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