Bgofix.lua

Note: In SMBX2 Beta 4 or later, this library will no longer be required. BGOs will be able to have render priority and animation changed via .txt files, similarly to how NPCs can be changed. However, if you use LunaLua (Without SMBX2), this library is still required for use.

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 to your LuaScriptsLib directory.

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:
 * If you use a custom image for an animated BGO that is not the same size as the original or change that BGO's render priority, the BGO will not be displayed properly unless you use the setAnimation function.
 * 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.