PuzzleSDK
SpriteNewTexture类 参考

#include <SpriteTest.h>

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

Public 成员函数

 CREATE_FUNC (SpriteNewTexture)
 
 SpriteNewTexture ()
 
virtual ~SpriteNewTexture ()
 
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 属性

bool _usingTexture1
 
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.h295 行定义.

构造及析构函数说明

◆ SpriteNewTexture()

SpriteNewTexture::SpriteNewTexture ( )

在文件 SpriteTest.cpp1545 行定义.

1546{
1547 auto listener = EventListenerTouchAllAtOnce::create();
1548 listener->onTouchesEnded = CC_CALLBACK_2(SpriteNewTexture::onTouchesEnded, this);
1549 _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
1550
1551 auto node = Node::create();
1552 addChild(node, 0, kTagSpriteBatchNode);
1553
1554 _texture1 = Director::getInstance()->getTextureCache()->addImage("Images/grossini_dance_atlas.png");
1555 _texture1->retain();
1556 _texture2 = Director::getInstance()->getTextureCache()->addImage("Images/grossini_dance_atlas-mono.png");
1557 _texture2->retain();
1558
1559 _usingTexture1 = true;
1560
1561 for(int i=0;i<30;i++)
1562 addNewSprite();
1563}
@ kTagSpriteBatchNode
Definition: SpriteTest.cpp:40
void onTouchesEnded(const std::vector< cocos2d::Touch * > &touches, cocos2d::Event *event)
cocos2d::Texture2D * _texture2
Definition: SpriteTest.h:309
cocos2d::Texture2D * _texture1
Definition: SpriteTest.h:308

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

+ 函数调用图:

◆ ~SpriteNewTexture()

SpriteNewTexture::~SpriteNewTexture ( )
virtual

在文件 SpriteTest.cpp1565 行定义.

1566{
1567 _texture1->release();
1568 _texture2->release();
1569}

引用了 _texture1 , 以及 _texture2.

成员函数说明

◆ addNewSprite()

void SpriteNewTexture::addNewSprite ( )

在文件 SpriteTest.cpp1571 行定义.

1572{
1573 auto s = Director::getInstance()->getWinSize();
1574
1575 auto p = Vec2( CCRANDOM_0_1() * s.width, CCRANDOM_0_1() * s.height);
1576
1577 int idx = CCRANDOM_0_1() * 1400 / 100;
1578 int x = (idx%5) * 85;
1579 int y = (idx/5) * 121;
1580
1581
1582 auto node = getChildByTag( kTagSpriteBatchNode );
1583 auto sprite = Sprite::createWithTexture(_texture1, Rect(x,y,85,121));
1584 node->addChild(sprite);
1585
1586 sprite->setPosition( Vec2( p.x, p.y) );
1587
1588 ActionInterval* action;
1589 float random = CCRANDOM_0_1();
1590
1591 if( random < 0.20 )
1592 action = ScaleBy::create(3, 2);
1593 else if(random < 0.40)
1594 action = RotateBy::create(3, 360);
1595 else if( random < 0.60)
1596 action = Blink::create(1, 3);
1597 else if( random < 0.8 )
1598 action = TintBy::create(2, 0, -255, -255);
1599 else
1600 action = FadeOut::create(2);
1601
1602 auto action_back = action->reverse();
1603 auto seq = Sequence::create(action, action_back, nullptr);
1604
1605 sprite->runAction( RepeatForever::create(seq) );
1606}

引用了 _texture1 , 以及 kTagSpriteBatchNode.

被这些函数引用 SpriteNewTexture().

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

◆ CREATE_FUNC()

SpriteNewTexture::CREATE_FUNC ( SpriteNewTexture  )

◆ onTouchesEnded()

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

在文件 SpriteTest.cpp1608 行定义.

1609{
1610
1611 auto node = getChildByTag( kTagSpriteBatchNode );
1612
1613 auto& children = node->getChildren();
1614 Sprite* sprite;
1615
1616 if( _usingTexture1 ) //--> win32 : Let's it make just simple sentence
1617 {
1618 for(const auto &obj : children) {
1619 sprite = static_cast<Sprite*>( obj );
1620 sprite->setTexture(_texture2);
1621 }
1622
1623 _usingTexture1 = false;
1624 }
1625 else
1626 {
1627 for(const auto &obj : children) {
1628 sprite = static_cast<Sprite*>( obj );
1629 sprite->setTexture(_texture1);
1630 }
1631
1632 _usingTexture1 = true;
1633 }
1634}

引用了 _texture1, _texture2, _usingTexture1 , 以及 kTagSpriteBatchNode.

被这些函数引用 SpriteNewTexture().

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

◆ subtitle()

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

重载 TestCase .

在文件 SpriteTest.cpp1641 行定义.

1642{
1643 return "setTexture() (tap / touch the screen)";
1644}

◆ title()

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

重载 TestCase .

在文件 SpriteTest.cpp1636 行定义.

1637{
1638 return "Testing Sprite";
1639}

类成员变量说明

◆ _texture1

cocos2d::Texture2D* SpriteNewTexture::_texture1
protected

在文件 SpriteTest.h308 行定义.

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

◆ _texture2

cocos2d::Texture2D* SpriteNewTexture::_texture2
protected

在文件 SpriteTest.h309 行定义.

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

◆ _usingTexture1

bool SpriteNewTexture::_usingTexture1
protected

在文件 SpriteTest.h307 行定义.

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


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