New extension: Alternative Buttons #1529
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This extension was initially created as an alternative for the "panel sprite button" object.
This extension contains:
-A behavior for sprites to change animations when hovered/pressed
-A behavior for texts to enable the outline and/or the shadow when hovered/pressed
-A behavior for sprites to enable an effect and/or change one of its properties when hovered/pressed
-An object (advanced) with a sprite which changes animation when hovered/pressed and a BBtext over it
How to use the extension
For each behavior: you can decide wether to apply changes when the button is hovered, pressed or both. So, you'll always found a property, a condition and an action for these. Also, there is condition for when the button is hovered, and another one when it's pressed
Sprite Button behavior: for this behavior to work, you'll need an animation named "Idle"; and if you check their respective, an animation named "Hovered" and another one named "Pressed"
Text Button behavior: on this behavior you will find 2 other properties, conditions and actions: one to activate the outline and the other one to activate the shadow, when the text is hovered or pressed (as decided before)
Effect Button behavior: this behavior works only with sprites and you'll have to have set at least one effect.
You'll find a property where you have to put the name of the effect, and you'll also find an expression and an action for this.
Then there is a property to choose wether to enable the effect when the changes are applied, there is also a condition and an action.
If you want to change an effect's property's value, you'll have to put its name in the behavior's property; if you don't want this, just leave it blank; then you have to declare if the given property is a number using a checkbox (if it isn't, then it assumes it's a color), there is also a condition for this and there is an expression which gives you the property's name, and an action where you have to specify if the property is a number or a color type.
Then, always if you want the effect's property to be changed, you have to give two numbers or colors: one for the original value and one with the modified one; for each type, there is also an expression and an action.
Button object (advanced): the object works as the Sprite Button behavior but it has also a BBtext object over it, for this reason there are two more expressions and actions: one for the text and one for the font size.
Because object are probably not intended to be used like this, there are some defects: first of all, in the editor the sprite's mask (which is used in the editor to select or move the instance) is always 64x64, even if the sprite is bigger or smaller; second thing, because of the previous issue and to make everything work, the BBtext can't be seen in the editor, but it's created with the object or at the start of the scene. In practice everything works, but you should have in mind these defects before working with the object, and if you don't need to have a text over the button, I suggest to use the Sprite Button behavior.
Checklist
What tier of review do you aim for your extension?
Community (Unreviewed)
Example file
Alternative Buttons example.zip
Extension file
AlternativeButtons.zip