I’m experimenting with making an RPG engine using the NPM version of OpenFL and have been having a lot of fun with it; the hot reloading has definitely sped up the development process. When testing it on a mobile browser however, I noticed the following behaviour:
Using a png bitmap asset of ~5kB with tileset sizes of 16px, the rendering causes vertical lines to appear when viewed on a mobile browser:
With the following code that looks something like:
...
var tilesize = 16;
var bitmapData = Assets.getBitmapData("zz-openfl.png");
var tileset = new Tileset(bitmapData);
var L = tileset.addRect(new Rectangle(11 * tilesize, 0, tilesize, tilesize));
var S = tileset.addRect(new Rectangle(10 * tilesize, 0, tilesize, tilesize));
var map = [
[L, L, L, L, L, L, L, L, L, L, L, L],
[L, L, S, S, S, L, L, S, S, S, L, L],
[L, S, S, S, S, S, S, S, S, S, S, L],
[L, S, S, S, S, S, S, S, S, S, S, L],
[L, S, S, S, S, S, S, S, S, S, S, L],
[L, L, S, S, S, S, S, S, S, S, L, L],
[L, L, L, S, S, S, S, S, S, L, L, L],
[L, L, L, L, S, S, S, S, L, L, L, L],
[L, L, L, L, L, S, S, L, L, L, L, L],
[L, L, L, L, L, L, L, L, L, L, L, L]
];
var numTiles = 15;
tilemap = new Tilemap(Math.round(myRoot.width), Math.round(myRoot.height), tileset, false);
tilemap.scaleX = myRoot.scaleFactor;
tilemap.scaleY = myRoot.scaleFactor;
for (row in 0...map.length) {
for (col in 0...map[row].length) {
tilemap.addTile(new Tile(map[row][col], tilesize * col, tilesize * row));
}
}
addChild(tilemap);
...
What’s weird is that if I use smaller x coordinates (containing the those same pixels for the tiles):
var L = tilesetLarge.addRect(new Rectangle(0 * tilesize, 12 * tilesize, tilesize, tilesize));
var S = tilesetLarge.addRect(new Rectangle(1 * tilesize, 12 * tilesize, tilesize, tilesize));
I get better rendering:
And this problem seems to be exacerbated whenever I make the Tilemap scroll across the screen (vertical lines flicker whenever it moves).
Any advice on going about how to debug/fix this issue would be greatly appreciated; I have an inkling it’s got to do with the size of the bitmap (e.g. this issue isn’t there when testing with an 32px * 16px png of 2 tiles), but I’m not sure why the coordinates of the Rectangle matter when using the same bitmap. I can post some sample code as well if that is helpful.
I’ve been using Chrome on Galaxy Note 4 and Safari on an iPhone 6 to test, with Haxe 4.1.0 and OpenFL 8.4.1 in package.json
.