New extension: Unique selection visual#2181
Open
github-actions[bot] wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Manages the visual, the audio and the boolean of a selection with the cursor.
it works with a behaviour and a module that you put in the event sheet. (they go hand in hand)
---CONTEXT--- and the problem it solves
this extension exist because the selection visual, sound, and variable (which are interconnected when dealing with cursor selection) are tricky for beginners to do. even though its a seemingly simple task. This is because when the cursor stops hovering on the first item, it might end up on another item without untrigerring the trigger once (due to the fact that selectables are next to each other). This issue is the main reason as to why the extension exist. Only one square should be selected at a time, hence the name: Unique Selection Visual
However... its sad to make an extension for just the visual (item get bigger when hovered). So I manage both the sound (selected and hovered) and the variable selected (stored in a behaviour property)
selection can be unique or capped
(note that this is my first published extension, be nice)
(note that i do not know JS so all the code is using events from GD)
(this extension uses another extension by silverstreak and krunkster named: play audio by file name. Because of this I want to credit them. do i have to do it manually or is the dependency automatically detected?)
proudly NO AI
How to use the extension
1: assign the behaviour "Unique sprite selection" to all your selectable sprites.
2: associate a sound for the hovering sound and/or the selection sound in the behaviour property. these can change dynamically and be different from instance to instance.
3: put the action "UniqueSelectionModule" in your event sheet. with the sprites having the behaviour. You can put a group, but every element of the group must be sprites and have the behaviour
4: if you want the selection to be unique (i.e. only one item will be selected at a time), put a 1 as the maxSelected. if you want many items to be selected at a time, you can increase that number to whatever you want (putting a float will not break the extension, it is just as if the number was truncated).
anytime you want to check the state of the selection boolean, use "sprite is selected" condition (and reverse it for checking unselected)
Checklist
AI usage
Example file
small tests.zip
Extension file
UniqueSelectionVisual.zip
Extension by @Aldebaran-Studio
You can update the extension on this "Pull Request" by commenting the update command: in the comment field, type
!update, then drag and drop a zip file with your extension file in the commenting field, like how you initially submitted the extension. It should look like this:It can take a few seconds for the file to fully upload and show as the above. Once it is like shown above, click "Comment" and let the bot do the rest!