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

Method startWithTarget

core/2d/ActionTiledGrid.cpp:274–310  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

272}
273
274void ShuffleTiles::startWithTarget(Node* target)
275{
276 TiledGrid3DAction::startWithTarget(target);
277
278 if (_seed != (unsigned int)-1)
279 {
280 std::srand(_seed);
281 }
282
283 _tilesCount = (unsigned int)(_gridSize.width * _gridSize.height);
284 _tilesOrder = new unsigned int[_tilesCount];
285
286 /**
287 * Use k to loop. Because _tilesCount is unsigned int,
288 * and i is used later for int.
289 */
290 for (unsigned int k = 0; k < _tilesCount; ++k)
291 {
292 _tilesOrder[k] = k;
293 }
294
295 shuffle(_tilesOrder, _tilesCount);
296
297 _tiles = (struct Tile*)new Tile[_tilesCount];
298 Tile* tileArray = (Tile*)_tiles;
299
300 for (int i = 0; i < _gridSize.width; ++i)
301 {
302 for (int j = 0; j < _gridSize.height; ++j)
303 {
304 tileArray->position.set((float)i, (float)j);
305 tileArray->startPosition.set((float)i, (float)j);
306 tileArray->delta = getDelta(Vec2((float)i, (float)j));
307 ++tileArray;
308 }
309 }
310}
311
312void ShuffleTiles::update(float time)
313{

Callers

nothing calls this directly

Calls 4

getInstanceFunction · 0.85
getWinSizeInPixelsMethod · 0.80
Vec2Class · 0.70
setMethod · 0.45

Tested by

no test coverage detected