PuzzleSDK
ActionCatmullRomStacked类 参考

#include <ActionsTest.h>

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

Public 成员函数

 CREATE_FUNC (ActionCatmullRomStacked)
 
virtual ~ActionCatmullRomStacked ()
 
virtual void onEnter () override
 
virtual std::string title () const override
 
virtual std::string subtitle () const override
 
- Public 成员函数 继承自 ActionsDemo
virtual void onExit () override
 
void centerSprites (unsigned int numberOfSprites)
 
void alignSpritesLeft (unsigned int numberOfSprites)
 
- 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
 

额外继承的成员函数

- Public 类型 继承自 TestCase
enum class  Type { ROBUSTNESS , UNIT , GRAPHICAL_STATIC , MANUAL }
 
- Public 属性 继承自 TestCase
CC_CONSTRUCTOR_ACCESS __pad0__: virtual bool init() override
 
- Protected 属性 继承自 ActionsDemo
cocos2d::Sprite * _grossini
 
cocos2d::Sprite * _tamara
 
cocos2d::Sprite * _kathia
 
- Protected 属性 继承自 TestCase
cocos2d::MenuItemImage * _priorTestItem
 
cocos2d::MenuItemImage * _restartTestItem
 
cocos2d::MenuItemImage * _nextTestItem
 
cocos2d::Label * _titleLabel
 
cocos2d::Label * _subtitleLabel
 

详细描述

在文件 ActionsTest.h437 行定义.

构造及析构函数说明

◆ ~ActionCatmullRomStacked()

ActionCatmullRomStacked::~ActionCatmullRomStacked ( )
virtual

在文件 ActionsTest.cpp1631 行定义.

1632{
1633}

成员函数说明

◆ CREATE_FUNC()

ActionCatmullRomStacked::CREATE_FUNC ( ActionCatmullRomStacked  )

◆ onEnter()

void ActionCatmullRomStacked::onEnter ( )
overridevirtual

重载 ActionsDemo .

在文件 ActionsTest.cpp1551 行定义.

1552{
1554
1555 this->centerSprites(2);
1556
1557 auto s = Director::getInstance()->getWinSize();
1558
1559 //
1560 // sprite 1 (By)
1561 //
1562 // startPosition can be any coordinate, but since the movement
1563 // is relative to the Catmull Rom curve, it is better to start with (0,0).
1564 //
1565
1566 _tamara->setPosition(50,50);
1567
1568 auto array = PointArray::create(20);
1569
1570 array->addControlPoint(Vec2(0.0f,0.0f));
1571 array->addControlPoint(Vec2(80.0f,80.0f));
1572 array->addControlPoint(Vec2(s.width-80,80.0f));
1573 array->addControlPoint(Vec2(s.width-80,s.height-80.0f));
1574 array->addControlPoint(Vec2(80.0f,s.height-80.0f));
1575 array->addControlPoint(Vec2(80.0f,80.0f));
1576 array->addControlPoint(Vec2(s.width/2, s.height/2));
1577
1578 auto action = CatmullRomBy::create(3, array);
1579 auto reverse = action->reverse();
1580
1581 auto seq = Sequence::create(action, reverse, nullptr);
1582
1583 _tamara->runAction(seq);
1584
1585 _tamara->runAction(
1586 RepeatForever::create(
1587 Sequence::create(
1588 MoveBy::create(0.05f, Vec2(10.0f,0.0f)),
1589 MoveBy::create(0.05f, Vec2(-10.0f,0.0f)),
1590 nullptr)));
1591
1592 auto drawNode1 = DrawNode::create();
1593 drawNode1->setPosition(Vec2(50.0f,50.0f));
1594 drawNode1->drawCatmullRom(array, 50, Color4F(1.0f, 1.0f, 0.0f, 0.5f));
1595 this->addChild(drawNode1);
1596
1597 //
1598 // sprite 2 (To)
1599 //
1600 // The startPosition is not important here, because it uses a "To" action.
1601 // The initial position will be the 1st point of the Catmull Rom path
1602 //
1603
1604 auto array2 = PointArray::create(20);
1605
1606 array2->addControlPoint(Vec2(s.width/2, 30.0f));
1607 array2->addControlPoint(Vec2(s.width-80,30.0f));
1608 array2->addControlPoint(Vec2(s.width-80.0f,s.height-80.0f));
1609 array2->addControlPoint(Vec2(s.width/2,s.height-80.0f));
1610 array2->addControlPoint(Vec2(s.width/2, 30.0f));
1611
1612 auto action2 = CatmullRomTo::create(3, array2);
1613 auto reverse2 = action2->reverse();
1614
1615 auto seq2 = Sequence::create(action2, reverse2, nullptr);
1616
1617 _kathia->runAction(seq2);
1618
1619 _kathia->runAction(
1620 RepeatForever::create(
1621 Sequence::create(
1622 MoveBy::create(0.05f, Vec2(10.0f,0.0f)),
1623 MoveBy::create(0.05f, Vec2(-10.0f,0.0f)),
1624 nullptr)));
1625
1626 auto drawNode2 = DrawNode::create();
1627 drawNode2->drawCatmullRom(array2, 50, Color4F(1.0, 0.0, 0.0, 0.5));
1628 this->addChild(drawNode2);
1629}
void centerSprites(unsigned int numberOfSprites)
virtual void onEnter() override
cocos2d::Sprite * _tamara
Definition: ActionsTest.h:38
cocos2d::Sprite * _kathia
Definition: ActionsTest.h:39

引用了 ActionsDemo::_kathia, ActionsDemo::_tamara, ActionsDemo::centerSprites() , 以及 ActionsDemo::onEnter().

+ 函数调用图:

◆ subtitle()

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

重载 TestCase .

在文件 ActionsTest.cpp1640 行定义.

1641{
1642 return "MoveBy + CatmullRom at the same time in the same sprite";
1643}

◆ title()

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

重载 ActionsDemo .

在文件 ActionsTest.cpp1635 行定义.

1636{
1637 return "Stacked MoveBy + CatmullRom actions";
1638}

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