PuzzleSDK
Parallax1类 参考

#include <ParallaxTest.h>

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

Public 成员函数

 CREATE_FUNC (Parallax1)
 
 Parallax1 ()
 
virtual std::string title () const override
 
- Public 成员函数 继承自 TestCase
 TestCase ()
 
 ~TestCase ()
 
virtual std::string subtitle () const
 
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::Node * _root
 
cocos2d::Node * _target
 
cocos2d::MotionStreak * _streak
 
- Protected 属性 继承自 ParallaxDemo
cocos2d::TextureAtlas * _atlas
 
- 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
 

详细描述

在文件 ParallaxTest.h38 行定义.

构造及析构函数说明

◆ Parallax1()

Parallax1::Parallax1 ( )

在文件 ParallaxTest.cpp49 行定义.

50{
51 // Top Layer, a simple image
52 auto cocosImage = Sprite::create(s_Power);
53 // scale the image (optional)
54 cocosImage->setScale( 2.5f );
55 // change the transform anchor point to 0,0 (optional)
56 cocosImage->setAnchorPoint( Vec2(0,0) );
57
58
59 // Middle layer: a Tile map atlas
60 auto tilemap = TileMapAtlas::create(s_TilesPng, s_LevelMapTga, 16, 16);
61 tilemap->releaseMap();
62
63 // change the transform anchor to 0,0 (optional)
64 tilemap->setAnchorPoint( Vec2(0, 0) );
65
66 // Anti Aliased images
67 tilemap->getTexture()->setAntiAliasTexParameters();
68
69
70 // background layer: another image
71 auto background = Sprite::create(s_back);
72 // scale the image (optional)
73 background->setScale( 1.5f );
74 // change the transform anchor point (optional)
75 background->setAnchorPoint( Vec2(0,0) );
76
77
78 // create a void node, a parent node
79 auto voidNode = ParallaxNode::create();
80
81 // NOW add the 3 layers to the 'void' node
82
83 // background image is moved at a ratio of 0.4x, 0.5y
84 voidNode->addChild(background, -1, Vec2(0.4f,0.5f), Vec2::ZERO);
85
86 // tiles are moved at a ratio of 2.2x, 1.0y
87 voidNode->addChild(tilemap, 1, Vec2(2.2f,1.0f), Vec2(0,-200) );
88
89 // top image is moved at a ratio of 3.0x, 2.5y
90 voidNode->addChild(cocosImage, 2, Vec2(3.0f,2.5f), Vec2(200,800) );
91
92
93 // now create some actions that will move the 'void' node
94 // and the children of the 'void' node will move at different
95 // speed, thus, simulation the 3D environment
96 auto goUp = MoveBy::create(4, Vec2(0,-500) );
97 auto goDown = goUp->reverse();
98 auto go = MoveBy::create(8, Vec2(-1000,0) );
99 auto goBack = go->reverse();
100 auto seq = Sequence::create(goUp, go, goDown, goBack, nullptr);
101 voidNode->runAction( (RepeatForever::create(seq) ));
102
103 addChild( voidNode );
104}
static const char s_TilesPng[]
Definition: testResource.h:63
static const char s_LevelMapTga[]
Definition: testResource.h:64
static const char s_back[]
Definition: testResource.h:38
static const char s_Power[]
Definition: testResource.h:59

引用了 s_back, s_LevelMapTga, s_Power , 以及 s_TilesPng.

成员函数说明

◆ CREATE_FUNC()

Parallax1::CREATE_FUNC ( Parallax1  )

◆ title()

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

重载 TestCase .

在文件 ParallaxTest.cpp106 行定义.

107{
108 return "Parallax: parent and 3 children";
109}

类成员变量说明

◆ _root

cocos2d::Node* Parallax1::_root
protected

在文件 ParallaxTest.h41 行定义.

◆ _streak

cocos2d::MotionStreak* Parallax1::_streak
protected

在文件 ParallaxTest.h43 行定义.

◆ _target

cocos2d::Node* Parallax1::_target
protected

在文件 ParallaxTest.h42 行定义.


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