Attention: This page contains dead links!
Note: This library is no longer required due to Lunalua 0.7.3 and up can replaces PNG files at runtime by using Graphics.sprites.(playername)[powerup].img function.
playerGfx is a library for swapping or overlaying sets of player graphics at runtime.
Drop the playerGfx.lua file in the LuaScriptsLib folder.
How to use
Overlay/replacement images should be formatted like regular SMBX player graphics, except they must be PNG files with transparent backgrounds and they should ideally use the naming convention "[prefix]_[number]" as opposed to SMBX's default "[prefix]-number". They should be placed in the episode or level folder.
Once you have your images in place, load in the API and use 'playerGfx.arrayFromPrefix()' to generate a table of your images' filenames. Use that table in PlayerGfxSet.createEx() to generate a PlayerGraphicsSet instance, and call playerGfx.assignSet() to assign a PlayerGraphicsSet to a given character.
Player graphic sets are only used when playerGfx.isOn == true; use playerGfx.enable(), playerGfx.disable() and playerGfx.toggle() to activate and deactivate the system.
|Type||Function/Field||Return values/Value type||Description|
|function||playerGfx.enable ()||nil||Enables the graphic replacement system.|
|function||playerGfx.disable ()||nil||Disables the graphic replacement system.|
|function||playerGfx.toggle ()||nil||Toggles the graphic replacement system.|
|function||myFilenameTable = playerGfx.arrayFromPrefix (String prefix)||Table of String||Generates a table of filenames corresponding to powerup states from a given prefix using the format "[prefix]_[number].png".|
|function||PlayerGfxSet||Creates a new graphics set from the given filename array. When assigned to a player character, the images will be offset from the player's position by offsetX and offsetY, and if overwrite is true the player's normal graphics will be hidden.|
|function||myPlayerGfx = PlayerGfxSet.createEx (Table of String filenameArray, Table of named arguments properties)||PlayerGfxSet||Creates a new graphics set from the given filename array and table of named arguments. The arguments of PlayerGfxSet.create() have equivalents of the same name ("offsetX", "offsetY" and "overwrite"), and additional arguments will be listed here in the future.|
|function||playerGfx.assignSet (Character constant playerChar, PlayerGfxSet gfxSet)||nil||Changes the given player character's graphics to use the given PlayerGfxSet; if gfxSet is nil, the character is reset to their default graphics.|