PuzzleSDK
TileMapEditTestNew类 参考

#include <TileMapTest2.h>

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

Public 成员函数

 CREATE_FUNC (TileMapEditTestNew)
 
 TileMapEditTestNew ()
 
virtual std::string title () const override
 
void updateMap (float dt)
 
- Public 成员函数 继承自 TileDemoNew
 TileDemoNew ()
 
virtual ~TileDemoNew ()
 
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
 

详细描述

在文件 TileMapTest2.h53 行定义.

构造及析构函数说明

◆ TileMapEditTestNew()

TileMapEditTestNew::TileMapEditTestNew ( )

在文件 TileMapTest2.cpp155 行定义.

156{
157 auto map = TileMapAtlas::create(s_TilesPng, s_LevelMapTga, 16, 16);
158 // Create an Aliased Atlas
159 map->getTexture()->setAliasTexParameters();
160
161 Size CC_UNUSED s = map->getContentSize();
162 CCLOG("ContentSize: %f, %f", s.width,s.height);
163
164 // If you are not going to use the Map, you can free it now
165 // [tilemap releaseMap);
166 // And if you are going to use, it you can access the data with:
167 schedule(CC_SCHEDULE_SELECTOR(TileMapEditTestNew::updateMap), 0.2f);
168
169 addChild(map, 0, kTagTileMap);
170
171 map->setAnchorPoint( Vec2(0, 0) );
172 map->setPosition( Vec2(-20,-200) );
173}
@ kTagTileMap
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()

TileMapEditTestNew::CREATE_FUNC ( TileMapEditTestNew  )

◆ title()

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

重载 TileDemoNew .

在文件 TileMapTest2.cpp207 行定义.

208{
209 return "Editable TileMapAtlas";
210}

◆ updateMap()

void TileMapEditTestNew::updateMap ( float  dt)

在文件 TileMapTest2.cpp175 行定义.

176{
177 // IMPORTANT
178 // The only limitation is that you cannot change an empty, or assign an empty tile to a tile
179 // The value 0 not rendered so don't assign or change a tile with value 0
180
181 auto tilemap = (TileMapAtlas*) getChildByTag(kTagTileMap);
182
183 //
184 // For example you can iterate over all the tiles
185 // using this code, but try to avoid the iteration
186 // over all your tiles in every frame. It's very expensive
187 // for(int x=0; x < tilemap.tgaInfo->width; x++) {
188 // for(int y=0; y < tilemap.tgaInfo->height; y++) {
189 // Color3B c =[tilemap tileAt:Size(x,y));
190 // if( c.r != 0 ) {
191 // ////----CCLOG("%d,%d = %d", x,y,c.r);
192 // }
193 // }
194 // }
195
196 // NEW since v0.7
197 Color3B c = tilemap->getTileAt(Vec2(13,21));
198 c.r++;
199 c.r %= 50;
200 if( c.r==0)
201 c.r=1;
202
203 // NEW since v0.7
204 tilemap->setTile(c, Vec2(13,21) );
205}

引用了 kTagTileMap.

被这些函数引用 TileMapEditTestNew().

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

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