Tilesheet perfomance + mouse events

Hello to OpenFL Masters! I have a few questions about performance… Lately I’ve started using Tilesheet rendering and stuck, when it comes to mouse events. Since I’m using OpenFl in a combination with Nape, I have no problem to determine which object were clicked with Nape pointInBody methods inside a game. But what should I do with a menu buttons? I have few ideas:

  1. Use sprites/bitmaps in the menu instead of tiles. And listen them for mouse events.
  2. Visual part of the button make as a tile, but listen for mouse event some sprite with alpha = 0.

And one more question please… What should I do with a big static bitmap background? Is it better to use a TileLayer with one DrawCall or left it on the the stage as a single bitmap image?

You can also listen to Mouse Event on the whole stage and check if the position of the mouse is inside the tile.
Personally, I use Sprites and not tiles for the UI. But I wonder if I should move to tiles to have better performance.

Thank you Loudo! I think this is a good idea when your button is a perfect square or circle, but what if it has more complex shape… Also there is still really interesting question about performance… Static (big) bitmap image VS. Tilesheet one DrawCall? Is there any differences to hardware performance? If no, then it will be no problem to use sprites for buttons as they all usually static (without animation)…

Oh you’re right about complex shape.
As for your performance question, I don’t know how display list works on openFL but I guess it’s also a single draw call since it’s only one image.
I would like somebody who knows better how it works answer you on this matter :slight_smile:

This. World is a world, lets separate interface from game view! You can create different container and add all your ui to it.

If you realy want to know what is better you need to code some performance tests, or build stress-demo for both cases and look where is the best FPS.

Thank you T1mL3arn for your response! The question that was bothered me, was using bitmapData for mobile builds, but indeed, I just need to make some tests and check it on my own. I just thought maybe there is some better solutions to check mouseEvents on Tilesheets.

I think this gets to the ideas of a Tilemap class, a bit, on brainstorming what better looks like :wink: