Better Custom BGOs with bgofix.lua (Added wiki page)
Posted: Sat Nov 12, 2016 11:08 pm
When you make custom BGOs, your options are limited. They all have to be the same size as the originals, and you can't change the order in which they are rendered. I have created an API which allows for more customization with BGOs. It allows you to change their size and render order. It even allows you to give them custom animations! Using it is simple.
Wohlsoft.ru Wiki Page
Call the API with:
If you just wanted to change the size of some BGOs, this is all you need to do. It will correctly display BGOs of custom sizes automatically.
To change the render order, just call this function in onStart:
id is the ID of the BGO.
priority is the LunaLua render priority, NOT the SMBX sort priority. You can find more information here.
To change a BGO's animation, call:
id is, again, the ID of the BGO.
numFrames = the number of frames
frameSpeed = the frame speed in SMBX ticks per frame. If not defined, it is set to 8 by default.
To set an animation, you must create an image of all the frames, in the same style as all the other animated images in SMBX, with the naming convention, "bgo-anim-*.png," where '*' is the ID.
For the regular "background-*" custom image, just make an image of the first frame. This is so it won't look screwy in the PGE editor.
This API will also serve as a temporary fix for the bug with lunaTester that makes BGOs with smaller custom images than the originals to look screwy.
Download: https://www.dropbox.com/s/v3aaet4ij4wd3 ... x.zip?dl=1
To install, just drop the contents of the zip into your luaScriptsLib folder.
Notes. Please read before you complain about the API not working:
Wohlsoft.ru Wiki Page
Call the API with:
Code: Select all
local bgofix = API.load
To change the render order, just call this function in onStart:
Code: Select all
bgofix.setPriority(id, priority)
priority is the LunaLua render priority, NOT the SMBX sort priority. You can find more information here.
To change a BGO's animation, call:
Code: Select all
bgofix.setAnimation(id, numFrames, frameSpeed)
numFrames = the number of frames
frameSpeed = the frame speed in SMBX ticks per frame. If not defined, it is set to 8 by default.
To set an animation, you must create an image of all the frames, in the same style as all the other animated images in SMBX, with the naming convention, "bgo-anim-*.png," where '*' is the ID.
For the regular "background-*" custom image, just make an image of the first frame. This is so it won't look screwy in the PGE editor.
This API will also serve as a temporary fix for the bug with lunaTester that makes BGOs with smaller custom images than the originals to look screwy.
Download: https://www.dropbox.com/s/v3aaet4ij4wd3 ... x.zip?dl=1
To install, just drop the contents of the zip into your luaScriptsLib folder.
Notes. Please read before you complain about the API not working:
- The custom BGO images must be in .PNG format for this API to work, because LunaLua's drawImage function doesn't support drawing of masked GIFs.
- If you make an animated background of a custom size, it won't be displayed correctly unless you use the setAnimation function.
- This API uses LunaLua render priorities when drawing BGOs. The custom BGOs should render in about the same order as they do normally, but slight changes may occur. If this happens, just use setPriority to fix it.
- If you try to use this with the legacy SMBX editor, you're gonna have a bad time, because they will still be the original size. Use Wohl's editor.