Open felixtsu opened 2 years ago
Describe the bug Changing tilemap in spriteOverlapsTile callback leads to uncertain result
To Reproduce
Expected behavior should result in tilemap level 2
Screenshots
Additional context https://github.com/microsoft/pxt-common-packages/blob/f40bb636d27d44e58ace6e6da06b41af055fc8a7/libs/game/physics.ts#L597
protected tilemapOverlaps(sprite: Sprite, overlappedTiles: tiles.Location[]) { const alreadyHandled: tiles.Location[] = []; // save current tile map before loop let currentTileMap = game.currentScene().tileMap for (const tile of overlappedTiles) { if (alreadyHandled.some(l => l.column === tile.column && l.row === tile.row)) { continue; } alreadyHandled.push(tile); const tileOverlapHandlers = game.currentScene().tileOverlapHandlers; if (tileOverlapHandlers) { // use saved tile map tiles, preventing tile map changed in handlers tileOverlapHandlers .filter(h => h.spriteKind == sprite.kind() && h.tileKind.equals(currentTileMap.getTileImage(tile))) .forEach(h => h.handler(sprite, tile)); } } }
Repros.
Describe the bug Changing tilemap in spriteOverlapsTile callback leads to uncertain result
To Reproduce
Expected behavior should result in tilemap level 2
Screenshots
Additional context https://github.com/microsoft/pxt-common-packages/blob/f40bb636d27d44e58ace6e6da06b41af055fc8a7/libs/game/physics.ts#L597