HaxeFlixel is a great engine used for making 2D cross-platform games. Each engine has its own way of doing things. So, how is the UI position handled in Flixel? Have you ever run into an issue where your game UI moves out of place in Flixel?
There is a simple fix for that and it is based on the scroll factor; this is something that can be easily overlooked. Let’s get into it.
Scroll Factor & Camera
In Flixel, the game screen is shown to you through the camera. This camera can be zoomed in/out, scaled, and have it’s sized adjusted. However, as a result, things in the world are dependent on the position of the camera. This affects your UI as well. The only way to fix this is to adjust the scroll factor. You can do so using the below.
As you can see, very simple. This allows you to set the scroll factor. By setting it to zero, the UI will not scroll with the rest of the world when the camera moves. Instead, the position of the UI will be fixed to what you see in the camera viewport.
I hope this helps you with your own Flixel game. For more helpful information you can find it below.
Happy game making!