This is a script that I wrote and allows to set up sprites in 96x128 sheets as costumes for the Player to pick from and use.
I wrote it to suit my personal needs when playing RPG Maker VX Ace games, but I figured it'd be cool to share it with all of you.
You're all constantly sharing cool scripts for free and stuff so I might as well put my grain of sand.
Key Points
To open the selector you can use
SceneManager.call(Scene_SpriteSelector)
复制代码
.
The magic happens in the "@sprite_data" array
Which uses the following parameters:
-The filename of a 96x128 sprite sheet containing your sprite's walking frames
-A switch Id to toggle when you pick a sprite to use
-A text string meant to describe each sprite
-A switch Id that defines whether the sprite is unlocked and ready to use or not.
-An item Id through which you can unlock specific sprites by having a specific item in the inventory.
Setting the 2nd, 4th or 5th parameters (parameters 1, 3 and 4 in the code) to "-1" disables them.
The script is somewhat messy because I wrote it for personal usage.
Consider this something that you can plop into a project and will work as intended at best, and a script to use as a base to work with at worst.
By default, the selector is designed for games that use a base screen resolution of 640x480 pixels
But this can be easily adjusted with the variables that I laid at the top. Reducing the padding between or the amount of sprites per row and column should make it easy for this script to work in other screen resolutions besides the intended 640x480 for example.
Probably.
The script has a small safety measure of sorts
If you input an invalid or nonexistent filename the script will show "a code-based placeholder sprite" kinda thing, a black square with a question mark. I should expand that and make it detect sprite sheets that don't adjust to the 96x128px criteria, buuut I'm kinda lazy and I personally don't need to do that so.
The script uses a
SPRITE_ID_VARIABLE
复制代码
to track the Id of the current sprite in use
By default,
SPRITE_ID_VARIABLE
复制代码
is set to 6.
As a result, if you added 50 sprites to pick from and selected the 44th, the value of the Variable 6 would be set to 44.