Bgofix.lua

*In SMBX2 B4+, the file "background- * .txt" is the successor of this library.

bgofix is an API that makes BGOs more customizable.

Features
With this API, you can:


 * Make custom BGOs of any size,
 * Change the render priority of BGOs, and
 * Give BGOs custom animations

Installation
Download the API here and extract its contents in either your level's custom graphics folder for use in a level, along with a lunadll.lua file, or in the same directory as your .wld file along with a lunaworld.lua file for use throughout an entire episode.

Setup
To enable the bgofix library in a level, add this line to your 'lunadll.lua' file:

Use PGE's GIFs2PNG utility to change the contents of your level's folder to PNGs. LunaLua does not support GIF images in its drawImage function.

BGOs of custom sizes will now automatically be rendered correctly at runtime.

Notes:
 * It is not recommended to use this library to modify the width, height, render priorities, or number of frames that animated BGOs have. This has been known to cause bugs. Instead, make your own animated BGO over one that is not animated by default.
 * Using this library may result in slight changes in the render order of BGOs from normal. If this messes up the render priority, adjust the render priorities with setPriority.
 * The BGOs are only rendered correctly during SMBX runtime. In editing mode, they will still be shown in default size. For the most convenience, use the PGE editor as it can draw BGOs of any size natively.

setPriority
setPriority uses LunaLua render priorities. These are not equivalent to SMBX sort order priorities! See here for more information.

setAnimation
setAnimation may not work in the way you expect. Don't replace a BGO's image with an animated version as you would normally do in SMBX. Instead, do the following:


 * 1) Create a copy of the desired animated BGO image, then remove all but the first frame from that copy.
 * 2) Save the image with only the first frame as the "background-*.png" image. (Replace '*' with the ID)
 * 3) Save the image with all of the frames as "bgo-anim-*.png" (Replace '*' with the ID)

This may seem like a bit of a hassle, but it is less of a hassle than trying to edit a level with your custom animated BGOs showing all their frames at once, and since the way BGOs are drawn in PGE can't currently be changed, this was the only way to get around this problem.