Intro
In this short tutorial, we will add some sound effects to gooey and will add some animation to demonstrate how this can be done.
In reality, nothing in this tutorial is gooey-specific - we will use standard techniques and combine them with gooey methods to make them work together.
Adding sound effects
We can add hover and click sound to our interactable widgets. We already imported the hover and click sounds in the previous tutorial, so we're ready to use them. Let's define two methods that we can use on every interaction:
| Game / Create | |
|---|---|
Once these are ready, we can use them in all of our widgets. We'll use MOUSE_ENTER for hovering sounds and LEFT_CLICK for clicking sounds. For example, for our Pause menu:
| Game / Draw GUI | |
|---|---|
As another example, we can add the same sounds to the tabs in our Options panel, with a little help from getTabControl, which gets the group that contains the tab buttons, and then calling getChildren in a loop to get all buttons:
| Game / Draw GUI | |
|---|---|
Adding a custom cursor
gooey includes macro variables in the configuration file to setup a custom cursor sprite. The library has the ability to process a default cursor, as well as interact and drag cursors, along with resize cursors for panels. Only certain widgets are processed for interaction: sprites, surfaces, canvases, grids, groups and texts are excluded.
Cursor handling
Since 2025.11, gooey includes improved cursor sprite handling, as well as the possibility to set any widget (e.g. sprites, surfaces and text) as "interactable" via .setInteractable, meaning that gooey will assign the interaction cursor sprite when it's over them, and the drag cursor sprite when the left mouse button is clicked.
We can then use some of the sprites our asset pack already contains:
| __Configuration__ Script | |
|---|---|
We can also set the cells of the inventory as interactable, so even when they're not normally processed for cursor interaction, they can:
| Game / Draw GUI | |
|---|---|
With this change, we can see that gooey processes our custom cursors automatically!
Adding animation
We can use any tweening library or technique to animate any gooey widget. The general way of doing this is by tweening a desired variable and then using gooey methods to set this variable where appropriate inside gooey (for example, setDimensions to set position or size).
For tweening, in this case I have already imported my Animatron library, which allows you to create a tween of any instance or struct variable. Let's for example, animate the Pause menu when we press ESC, so that it flies from the top of the screen. To do this, we'll:
- Create a variable (for example,
Game.pause_menu_y) in theGame'sCreateevent - Set the initial
yoffset value of thePanel_Pausepanel to the variable ofGame.pause_menu_yinstead of 0; - Use
setPreRenderCallbackto dynamically set itsyto the value ofGame.pause_menu_y.
| Game / Create | |
|---|---|
If we run it now, we can see the panel will be hidden when we pause the game. To run an animation using Animatron, we can add the tween line to our self.pause method as follows:
| Game / Create | |
|---|---|
Here, we're telling Animatron to animate the Game.pause_menu_y variable from its current value to 0 in the span of 30 frames, using the curve_ElasticInv animation curve (these curves are also included in the Animatron library). The next two arguments specify that the animation does not loop and that the specified target value of 0 is not a "relative" value but an "absolute" value. Finally, we set the time_source_global animation curve parent, so even if we pause the game and all instances of time_source_game, the animation still runs.
This will correctly animate the menu when paused. To animate it the other way around when we resume, we can make a very similar call in our self.resume. The only difference is that, since we do not want to resume the game until the animation finishes, we wrap it up in a callback that fires when the animation is at 100%:
| Game / Create | |
|---|---|
This way, we can see that we can easily use Animatron (or any other tweening library) to animate widgets in gooey!
The final result