Is there an easy way to force openfl-tilelayer to use stage3d for flash-target?

I want high performance for flash-target. Which is the best way to achive this when using openfl-tilelayer?

Tilelayer doesn’t support this option, sorry.

You can get better performance out of bitmaps if you don’t rotate or scale them; one option is to look into that. Flixel offers the option to pre-render any bitmap rotations, which it claims doesn’t hurt performance as long as there aren’t too many.

It’s tough to use Stage3D for this sort of thing because the display list is entirely separate. Everything you draw via Stage3D will show up behind the entire display list. If that’s fine with you, you can try implementing it yourself, but keep in mind that it won’t be consistent across platforms.

1 Like

I know that tilelayer doesn’t support Stage3d, but there are two libraries on gitHub that look like that I need (https://github.com/as3boyan/openfl-tilelayer and https://github.com/as3boyan/TilesheetStage3D) I can not get them to work yet. So I decide to ask, maybe somebody used it or know other ways to do that. In any case, thanks for the answer)

You can use https://github.com/as3boyan/TilesheetStage3D/ that one works fine. You need to follow the instructions and use an instance of TilesheetStage3D to draw. Use conditional compilation for flash

1 Like

Is there an example how make it work with tilelayer?

wuprui I dont understand exactly what you meant, but let me put you an example of how to use it

        #if !flash
	public var mTileSheet:Tilesheet;
	#else
	public var mTileSheet:TilesheetStage3D;
	#end

public function new()
{
super();
addEventListener(Event.ADDED_TO_STAGE, added);
}

function added(e) 
{
	removeEventListener(Event.ADDED_TO_STAGE, added);
	
	#if flash
	 TilesheetStage3D.init(stage, 0, 5, init); //we need to initialize Stage3D
	#else
	init();
	#end
	#end
}

and in your render you call

           #if (flash)
	 TilesheetStage3D.clearGraphic(mLayer.graphics);
	 mTileSheet.drawTiles(mLayer.graphics, toDraw, false, Tilesheet.TILE_TRANS_2x2);
	#else
	mLayer.graphics.clear();
	mTileSheet.drawTiles(mLayer.graphics, toDraw, false, Tilesheet.TILE_TRANS_2x2);
	#end

hope that helps

1 Like

Thanks juakob. But it’s not exactly what I need.

I am trying to attach TilesheetStage3d to tillayer (wrapper over drawTiles). In this regard, I have a question to those who know how it works.

I have uncommented such lines in TileLayer.hx:
flags |= Graphics.TILE_TRANS_2x2;
flags |= Graphics.TILE_RGB;
flags |= Graphics.TILE_ALPHA;
flags |= Graphics.TILE_BLEND_ADD;

Now an errors occur when compiling for flash: Class<flash.display.Graphics> has no field TILE_TRANS_2x2, <flash.display.Graphics> has no field TILE_RGB, etc. It is clear for me. But when compiling for android everything is ok. Can anybody tell me from where TILE_TRANS_2x2, TILE_RGB, etc. appear in the flash.display.Graphics when targeting android?

1 Like