iOS 10.x.x and Tilemap


#1

Hi everyone! I’m having an issue running my project in an iPad 4th gen with iOS 10.3.3. Everything but the Tiles is showing, the tiles appear only a black square instead. I’ve tested on an iphone 7 with iOS 12 and works fine. Also tried on android and HTML5 and everything seems ok.

The texture is a PNG (4690 x 2560) with alpha channel, I’ve tried a JPG without sucess. Maybe the texture size? The BunnyMark sample works fine with “use_tilemap” flag…

There is only one Tilemap with the same dimensions of Stage.
Here is the code used to load the BitmapData:

    var bmpData:BitmapData = Assets.getBitmapData("assets/images/tile_sheet.png");
	var scaledW:Float = Scaler.scaleX(4690);
	var scaledH:Float = Scaler.scaleY(2560);
	var scaledBmpData = new BitmapData(Std.int(scaledW), Std.int(scaledH), true, 0x00000000);
	var matrix:Matrix = new Matrix();
	matrix.scale(scaledW / 4690, scaledH / 2560);
	scaledBmpData.draw(bmpData, matrix);
	tileset = new Tileset(scaledBmpData);

	MAIN_MENU = tileset.addRect(new Rectangle(0, 0, Scaler.scaleX(1440), Scaler.scaleY(2560)));
	
	CARDS = [];
	var offsetX:Float = Scaler.scaleX(1440);
	var cardW:Float = Scaler.scaleX(250);
	var cardH:Float = Scaler.scaleY(357);
	for (i in 0...57) 
	{
		var x:Float = offsetX + cardW * Std.int(i % 13);
		var y:Float = cardH * Std.int(i / 13);
		CARDS.push(tileset.addRect(new Rectangle(x, y, cardW, cardH)));
	}
	
	INDICATOR = tileset.addRect(new Rectangle(Scaler.scaleX(2690), Scaler.scaleY(1429), Scaler.scaleX(122), Scaler.scaleY(140)));
	BTN_GREEN_DOWN = tileset.addRect(new Rectangle(Scaler.scaleX(1440), Scaler.scaleY(1785), Scaler.scaleX(839), Scaler.scaleY(209)));

Thank you in advance.


#2

Does it work if you use bmpData, and don’t use scaledBmpData?

Does it work if you use scaledBmpData, but reduce the size dramatically?


#3

nope.

Yes, if I reduce the texture by a fourth (was my first test, I really don’t know the maximum size that works), it does work. Seems to be a texture size limitation. Any suggestion on how to solve this? This only happens on iOS 10…


#4

I think the texture size limit is 4096x4096 on the majority of recent mobile devices.
You might even want to stay below 2048x2048 since some Android devices don’t support higher sizes.


#5

Thank you for the responses. I think break the texture in smaller ones is one viable solution. I posted only because I’m curious why it runs flawless in many devices/targets but in iOS 10.


#6

It shouldn’t be related to the operating system version, but the native resolution of the device.
Some iOS devices have “retina support” enabled by default, which doubles the final resolution.


#7

Exactly! Also related to the OpenGL version and its implementation. In my case I realized that the resolution of the iPad 4 is even bigger than that I setted as my target (1440 x 2560), so the scaler performed an upscale. I will break the texture in chunks and case solved! (y)