PuzzleSDK
Sprite3DUVAnimationTest类 参考

#include <Sprite3DTest.h>

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

Public 成员函数

 CREATE_FUNC (Sprite3DUVAnimationTest)
 
 Sprite3DUVAnimationTest ()
 
virtual ~Sprite3DUVAnimationTest ()
 
virtual std::string title () const override
 
virtual std::string subtitle () const override
 
- Public 成员函数 继承自 Sprite3DTestDemo
virtual ~Sprite3DTestDemo ()
 
- 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 成员函数

void cylinderUpdate (float dt)
 

Protected 属性

float _cylinder_texture_offset
 
float _shining_duration
 
cocos2d::backend::ProgramState * _state = nullptr
 
cocos2d::EventListenerCustom * _backToForegroundListener
 
- 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
 

详细描述

在文件 Sprite3DTest.h82 行定义.

构造及析构函数说明

◆ Sprite3DUVAnimationTest()

Sprite3DUVAnimationTest::Sprite3DUVAnimationTest ( )

在文件 Sprite3DTest.cpp235 行定义.

236{
237 //the offset use to translating texture
240 Size visibleSize = Director::getInstance()->getVisibleSize();
241
242 //use custom camera
243 auto camera = Camera::createPerspective(60, visibleSize.width / visibleSize.height, 0.1f, 200);
244 camera->setCameraFlag(CameraFlag::USER1);
245
246 //create cylinder
247 auto cylinder = Sprite3D::create("Sprite3DTest/cylinder.c3b");
248 auto mat = Sprite3DMaterial::createWithFilename("Sprite3DTest/UVAnimation.material");
249 _state = mat->getTechniqueByIndex(0)->getPassByIndex(0)->getProgramState();
250 cylinder->setMaterial(mat);
251
252 this->addChild(cylinder);
253 this->setCameraMask(2);
254 this->addChild(camera);
255
256 //adjust cylinder's position & rotation
257 cylinder->setPosition3D(Vec3(0.0f, -15.0f, -50.0f));
258 cylinder->setRotation3D(Vec3(-90.0f, 0.0f, 0.0f));
259
260 //the callback function update cylinder's texcoord
261 schedule(CC_SCHEDULE_SELECTOR(Sprite3DUVAnimationTest::cylinderUpdate));
262
263#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
264 _backToForegroundListener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND,
265 [=](EventCustom*)
266 {
267 auto mat = Sprite3DMaterial::createWithFilename("Sprite3DTest/UVAnimation.material");
268
269 cylinder->setMaterial(mat);
270 _state = mat->getTechniqueByIndex(0)->getPassByIndex(0)->getProgramState();
271 }
272 );
273 Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_backToForegroundListener, -1);
274#endif
275}
cocos2d::backend::ProgramState * _state
Definition: Sprite3DTest.h:96
cocos2d::EventListenerCustom * _backToForegroundListener
Definition: Sprite3DTest.h:99
void cylinderUpdate(float dt)

引用了 _backToForegroundListener, _cylinder_texture_offset, _shining_duration, _state , 以及 cylinderUpdate().

+ 函数调用图:

◆ ~Sprite3DUVAnimationTest()

Sprite3DUVAnimationTest::~Sprite3DUVAnimationTest ( )
virtual

在文件 Sprite3DTest.cpp277 行定义.

278{
279#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
280 Director::getInstance()->getEventDispatcher()->removeEventListener(_backToForegroundListener);
281#endif
282}

引用了 _backToForegroundListener.

成员函数说明

◆ CREATE_FUNC()

Sprite3DUVAnimationTest::CREATE_FUNC ( Sprite3DUVAnimationTest  )

◆ cylinderUpdate()

void Sprite3DUVAnimationTest::cylinderUpdate ( float  dt)
protected

在文件 Sprite3DTest.cpp294 行定义.

295{
296 //callback function to update cylinder's texcoord
297 static bool fade_in = true;
298 _cylinder_texture_offset += 0.3*dt;
300 if (fade_in)
301 {
302 _shining_duration += 0.5 * dt;
303 if (_shining_duration > 1) fade_in = false;
304 }
305 else
306 {
307 _shining_duration -= 0.5 * dt;
308 if (_shining_duration < 0) fade_in = true;
309 }
310
311 //pass the result to shader
312 auto offsetLoc = _state->getUniformLocation("offset");
313 auto durationLoc = _state->getUniformLocation("duration");
314 _state->setUniform(offsetLoc, &_cylinder_texture_offset, sizeof(_cylinder_texture_offset));
315 _state->setUniform(durationLoc, &_shining_duration, sizeof(_shining_duration));
316}

引用了 _cylinder_texture_offset, _shining_duration , 以及 _state.

被这些函数引用 Sprite3DUVAnimationTest().

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

◆ subtitle()

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

重载 TestCase .

在文件 Sprite3DTest.cpp289 行定义.

290{
291 return "";
292}

◆ title()

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

重载 Sprite3DTestDemo .

在文件 Sprite3DTest.cpp284 行定义.

285{
286 return "Testing UV Animation";
287}

类成员变量说明

◆ _backToForegroundListener

cocos2d::EventListenerCustom* Sprite3DUVAnimationTest::_backToForegroundListener
protected

在文件 Sprite3DTest.h99 行定义.

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

◆ _cylinder_texture_offset

float Sprite3DUVAnimationTest::_cylinder_texture_offset
protected

在文件 Sprite3DTest.h94 行定义.

被这些函数引用 cylinderUpdate() , 以及 Sprite3DUVAnimationTest().

◆ _shining_duration

float Sprite3DUVAnimationTest::_shining_duration
protected

在文件 Sprite3DTest.h95 行定义.

被这些函数引用 cylinderUpdate() , 以及 Sprite3DUVAnimationTest().

◆ _state

cocos2d::backend::ProgramState* Sprite3DUVAnimationTest::_state = nullptr
protected

在文件 Sprite3DTest.h96 行定义.

被这些函数引用 cylinderUpdate() , 以及 Sprite3DUVAnimationTest().


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