Description
Is it normal for drawTilemap() of FlxTilemap.as to be called all the time when FlxG.width and FlxG.height is over 1000? The reason why I am asking is because it is affecting the frame rate of my game.
In order for me to check, I placed a trace under drawTilemap function. Then I used the code: super(1000, 1000, PlayState, 1) to create a flxGame object. After running the program, the trace is called over and over again non-stop. But, if I reduce the width and height to 900 or lower, the trace is only called once.
To investigate further, I opened up one my other peojects, did the check, and the results were the same.
I temporarily fixed the problem by modifying FlxTilemap.as. I'm not really sure about this one but it did the trick.
What I did is that I've added a "buffer.dirty = false" on the first if statement.
if(_buffers[i] == null)
_buffers[i] = new FlxTilemapBuffer(_tileWidth,_tileHeight,widthInTiles,heightInTiles,camera);
buffer = _buffers[i++] as FlxTilemapBuffer;
if(!buffer.dirty)
{
_point.x = x - int(camera.scroll.x*scrollFactor.x) + buffer.x; //copied from getScreenXY()
_point.y = y - int(camera.scroll.y*scrollFactor.y) + buffer.y;
buffer.dirty = (_point.x > 0) || (_point.y > 0) || (_point.x + buffer.width < camera.width) || (_point.y + buffer.height < camera.height);
// This is a temporary fix for the performance problem for drawTilemap function
buffer.dirty = false;
}
if (buffer.dirty)
{
drawTilemap(buffer,camera);
buffer.dirty = false;
}