MCPcopy Create free account
hub / github.com/axmolengine/axmol / setTile

Method setTile

core/2d/TileMapAtlas.cpp:124–148  ·  view source on GitHub ↗

TileMapAtlas - Atlas generation / updates

Source from the content-addressed store, hash-verified

122
123// TileMapAtlas - Atlas generation / updates
124void TileMapAtlas::setTile(const Color3B& tile, const Vec2& position)
125{
126 AXASSERT(_TGAInfo != nullptr, "tgaInfo must not be nil");
127 AXASSERT(position.x < _TGAInfo->width, "Invalid position.x");
128 AXASSERT(position.y < _TGAInfo->height, "Invalid position.x");
129 AXASSERT(tile.r != 0, "R component must be non 0");
130
131 Color3B* ptr = (Color3B*)_TGAInfo->imageData;
132 Color3B value = ptr[(unsigned int)(position.x + position.y * _TGAInfo->width)];
133 if (value.r == 0)
134 {
135 AXLOGD("Value.r must be non 0.");
136 }
137 else
138 {
139 ptr[(unsigned int)(position.x + position.y * _TGAInfo->width)] = tile;
140
141 // FIXME:: this method consumes a lot of memory
142 // FIXME:: a tree of something like that shall be implemented
143 std::string key = StringUtils::toString(position.x) + "," + StringUtils::toString(position.y);
144 int num = _posToAtlasIndex[key].asInt();
145
146 this->updateAtlasValueAt(position, tile, num);
147 }
148}
149
150Color3B TileMapAtlas::getTileAt(const Vec2& position) const
151{

Callers

nothing calls this directly

Calls 3

updateAtlasValueAtMethod · 0.95
asIntMethod · 0.80
toStringFunction · 0.50

Tested by

no test coverage detected