PuzzleSDK
TileMapEditTest类 参考

#include <TileMapTest.h>

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

Public 成员函数

 CREATE_FUNC (TileMapEditTest)
 
 TileMapEditTest ()
 
virtual std::string title () const override
 
void updateMap (float dt)
 
- Public 成员函数 继承自 TileDemo
 TileDemo ()
 
virtual ~TileDemo ()
 
virtual std::string subtitle () const override
 
virtual void onExit () override
 
void onTouchesMoved (const std::vector< cocos2d::Touch * > &touches, cocos2d::Event *event)
 
- 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
 

额外继承的成员函数

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

详细描述

在文件 TileMapTest.h53 行定义.

构造及析构函数说明

◆ TileMapEditTest()

TileMapEditTest::TileMapEditTest ( )

在文件 TileMapTest.cpp170 行定义.

171{
172 auto map = TileMapAtlas::create(s_TilesPng, s_LevelMapTga, 16, 16);
173 // Create an Aliased Atlas
174 map->getTexture()->setAliasTexParameters();
175
176 Size CC_UNUSED s = map->getContentSize();
177 CCLOG("ContentSize: %f, %f", s.width,s.height);
178
179 // If you are not going to use the Map, you can free it now
180 // [tilemap releaseMap);
181 // And if you are going to use, it you can access the data with:
182 schedule(CC_SCHEDULE_SELECTOR(TileMapEditTest::updateMap), 0.2f);
183
184 addChild(map, 0, kTagTileMap);
185
186 map->setAnchorPoint( Vec2(0, 0) );
187 map->setPosition( Vec2(-20,-200) );
188}
@ kTagTileMap
Definition: TileMapTest.cpp:33
void updateMap(float dt)
static const char s_TilesPng[]
Definition: testResource.h:63
static const char s_LevelMapTga[]
Definition: testResource.h:64

引用了 kTagTileMap, s_LevelMapTga, s_TilesPng , 以及 updateMap().

+ 函数调用图:

成员函数说明

◆ CREATE_FUNC()

TileMapEditTest::CREATE_FUNC ( TileMapEditTest  )

◆ title()

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

重载 TileDemo .

在文件 TileMapTest.cpp222 行定义.

223{
224 return "Editable TileMapAtlas";
225}

◆ updateMap()

void TileMapEditTest::updateMap ( float  dt)

在文件 TileMapTest.cpp190 行定义.

191{
192 // IMPORTANT
193 // The only limitation is that you cannot change an empty, or assign an empty tile to a tile
194 // The value 0 not rendered so don't assign or change a tile with value 0
195
196 auto tilemap = (TileMapAtlas*) getChildByTag(kTagTileMap);
197
198 //
199 // For example you can iterate over all the tiles
200 // using this code, but try to avoid the iteration
201 // over all your tiles in every frame. It's very expensive
202 // for(int x=0; x < tilemap.tgaInfo->width; x++) {
203 // for(int y=0; y < tilemap.tgaInfo->height; y++) {
204 // Color3B c =[tilemap tileAt:Size(x,y));
205 // if( c.r != 0 ) {
206 // ////----CCLOG("%d,%d = %d", x,y,c.r);
207 // }
208 // }
209 // }
210
211 // NEW since v0.7
212 Color3B c = tilemap->getTileAt(Vec2(13,21));
213 c.r++;
214 c.r %= 50;
215 if( c.r==0)
216 c.r=1;
217
218 // NEW since v0.7
219 tilemap->setTile(c, Vec2(13,21) );
220}

引用了 kTagTileMap.

被这些函数引用 TileMapEditTest().

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

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