removeTile causes "flashing" screen
Outridair opened this issue · comments
When I trigger the removeTile on the Tilemap object the screen flashes for a brief moment.
Line of code I am using is:
this.map.map.removeTile((Math.floor((this.sprite.x +directionHorizontal) / 32)), (Math.floor((this.sprite.y + directionVertical) / 32)), 3);
(The .map.map is an unfortunate naming coincidence that I'll refactor soon).
Can be seen here: chat.outriderstudio.com:3000 (Username: test2 // Password: test2)
Use Case:
The removeTile is bound to a keyboard command, face an object somewhere on the map, and hit the 1 key (non keypad) and you'll see the event fire, might have to press 1 a couple of times due to a seperate issue in a onAnimationComplete callback command.
I think this might have to do with how rerender is handled in the master branch, I think this may be solved in the thin-tiles
branch, but not 100% sure. Will keep this open for v2.
Confirmed with some testing. The issue is due to the line
this.layers[layer].dirty = true; in the removeTile function.
Seems like its just setting a property? Whats it doing when the layer dirty resolves to true?
When dirty is set on a layer it rerenders that layer (clears the sprites and rerenders). That is expensive in the master branch, but pretty cheap in the thin-tiles branch and I have ideas to make it even cheaper.
This should be solved in v2, let me know if it isn't.