PuzzleSDK
BatchingExample类 参考

#include <SpineTest.h>

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

Public 成员函数

 CREATE_FUNC (BatchingExample)
 
 ~BatchingExample ()
 
virtual bool init ()
 
- Public 成员函数 继承自 SpineTestLayer
 SpineTestLayer ()
 
virtual std::string title () const
 
- 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 属性

spAtlas * _atlas
 
spAttachmentLoader * _attachmentLoader
 
spSkeletonData * _skeletonData
 
spAnimationStateData * _stateData
 
- Protected 属性 继承自 SpineTestLayer
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
 

详细描述

在文件 SpineTest.h45 行定义.

构造及析构函数说明

◆ ~BatchingExample()

BatchingExample::~BatchingExample ( )

在文件 SpineTest.cpp109 行定义.

109 {
110 // SkeletonAnimation instances are cocos2d-x nodes and are disposed of automatically as normal, but the data created
111 // manually to be shared across multiple SkeletonAnimations needs to be disposed of manually.
112 spSkeletonData_dispose(_skeletonData);
113 spAnimationStateData_dispose(_stateData);
114 spAttachmentLoader_dispose(_attachmentLoader);
115 spAtlas_dispose(_atlas);
116}
spAttachmentLoader * _attachmentLoader
Definition: SpineTest.h:54
spSkeletonData * _skeletonData
Definition: SpineTest.h:55
spAtlas * _atlas
Definition: SpineTest.h:53
spAnimationStateData * _stateData
Definition: SpineTest.h:56

引用了 _atlas, _attachmentLoader, _skeletonData , 以及 _stateData.

成员函数说明

◆ CREATE_FUNC()

BatchingExample::CREATE_FUNC ( BatchingExample  )

◆ init()

bool BatchingExample::init ( )
virtual

在文件 SpineTest.cpp62 行定义.

62 {
63 if (!SpineTestLayer::init()) return false;
64
65 _title = "BatchingExample";
66
67 // Load the texture atlas.
68 _atlas = spAtlas_createFromFile("spine/spineboy.atlas", 0);
69 CCASSERT(_atlas, "Error reading atlas file.");
70
71 // This attachment loader configures attachments with data needed for cocos2d-x rendering.
72 // Do not dispose the attachment loader until the skeleton data is disposed!
73 _attachmentLoader = (spAttachmentLoader*)Cocos2dAttachmentLoader_create(_atlas);
74
75 // Load the skeleton data.
76 spSkeletonJson* json = spSkeletonJson_createWithLoader(_attachmentLoader);
77 json->scale = 0.6f; // Resizes skeleton data to 60% of the size it was in Spine.
78 _skeletonData = spSkeletonJson_readSkeletonDataFile(json, "spine/spineboy-ess.json");
79 CCASSERT(_skeletonData, json->error ? json->error : "Error reading skeleton data file.");
80 spSkeletonJson_dispose(json);
81
82 // Setup mix times.
83 _stateData = spAnimationStateData_create(_skeletonData);
84 spAnimationStateData_setMixByName(_stateData, "walk", "jump", 0.2f);
85 spAnimationStateData_setMixByName(_stateData, "jump", "run", 0.2f);
86
87 int xMin = _contentSize.width * 0.10f, xMax = _contentSize.width * 0.90f;
88 int yMin = 0, yMax = _contentSize.height * 0.7f;
89 for (int i = 0; i < 50; i++) {
90 // Each skeleton node shares the same atlas, skeleton data, and mix times.
91 SkeletonAnimation* skeletonNode = SkeletonAnimation::createWithData(_skeletonData, false);
92 skeletonNode->setAnimationStateData(_stateData);
93
94 skeletonNode->setAnimation(0, "walk", true);
95 skeletonNode->addAnimation(0, "jump", false, 3);
96 skeletonNode->addAnimation(0, "run", true);
97
98 skeletonNode->setPosition(Vec2(
99 RandomHelper::random_int(xMin, xMax),
100 RandomHelper::random_int(yMin, yMax)
101 ));
102 skeletonNode->setScale(0.8);
103 addChild(skeletonNode);
104 }
105
106 return true;
107}
std::string _title
Definition: SpineTest.h:42

引用了 _atlas, _attachmentLoader, _skeletonData, _stateData , 以及 SpineTestLayer::_title.

类成员变量说明

◆ _atlas

spAtlas* BatchingExample::_atlas
protected

在文件 SpineTest.h53 行定义.

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

◆ _attachmentLoader

spAttachmentLoader* BatchingExample::_attachmentLoader
protected

在文件 SpineTest.h54 行定义.

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

◆ _skeletonData

spSkeletonData* BatchingExample::_skeletonData
protected

在文件 SpineTest.h55 行定义.

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

◆ _stateData

spAnimationStateData* BatchingExample::_stateData
protected

在文件 SpineTest.h56 行定义.

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


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