I think I have found the line of code that cause the problem and it is the "xysize (300, 80)" code. The problem is rather complicated so please bear with me for a while. Okay, here I go:
First off, I want to mention that I 'm using the new GUI, and the three buttons I'm going to discuss here are "Start", "Load" and "Setting" which all belong to the Navigation screen:
For visualization, here is the image folder where I keep all the button image:
Here is the all of the navigation screen code I use: (you can just skip this to see the result below then come back and read it later)
Code: Select all
init -2:
image start_hover:
"start_h1", 0.1, "start_h2", 0.025
"start_h3", 0.025, "start_h4", 0.05
image load_hover:
"load_h1", 0.1, "load_h2", 0.025
"load_h3", 0.025, "load_h4", 0.05
image setting_hover:
"setting_h1", 0.1, "setting_h2", 0.025
"setting_h3", 0.025, "setting_h4", 0.05
image start_button:
on idle:
"start_idle"
on hover:
"start_hover"
on selected_idle:
"start_h4"
on selected_hover:
"start_h4"
image load_button:
on idle:
"load_idle"
on hover:
"load_hover"
on selected_idle:
"load_si"
on selected_hover:
"load_sh"
image setting_button:
on idle:
"setting_idle"
on hover:
"setting_hover"
on selected_idle:
"setting_si"
on selected_hover:
"setting_sh"
screen navigation():
vbox:
style_prefix "navigation"
xpos gui.navigation_xpos
yalign 0.5
spacing gui.navigation_spacing
if main_menu:
##START button
button:
add "start_button"
hover_sound "sfx/c5.MP3" activate_sound "sfx/c3 test.MP3"
xysize (122, 30)
action Start()
else:
##HISTORY button
imagebutton:
idle "history i" hover "history h"
xpos 0 ypos 0 focus_mask None
action ShowMenu("history")
hover_sound "sfx/c5.MP3"
##SAVE button
imagebutton:
idle "save i" hover "save h"
xpos 0 ypos 0 focus_mask None
action ShowMenu("save")
hover_sound "sfx/c5.MP3"
##LOAD Button
button:
add "load_button"
hover_sound "sfx/c5.MP3" activate_sound "sfx/c3 test.MP3"
xysize (122, 30) # to do: adjust the size width and height to match the size of the image
action ShowMenu("load")
#SETTING button
button:
add "setting_button"
hover_sound "sfx/c5.MP3"
xysize (122, 30) # to do: adjust the size width and height to match the size of the image
action ShowMenu("preferences")
if _in_replay:
textbutton _("End Replay") action EndReplay(confirm=True)
elif not main_menu:
textbutton _("Main Menu") action MainMenu()
textbutton _("Credit") activate_sound "sfx/g5 w.WAV" hover_sound "sfx/c5 w.WAV" action ShowMenu("about")
if renpy.variant("pc"):
## Help isn't necessary or relevant to mobile devices.
textbutton _("Help") action ShowMenu("help")
## The quit button is banned on iOS and unnecessary on Android.
textbutton _("Quit") action Quit(confirm=not main_menu)
Experiment 1With the code above:
1.Launching the game will result in:
As you can see, the cursor is hovering on the load button but nothing happen.
The animation did not play until the second time the button is hovered:
Let's call this problem no 1, and in the experiment it applies to all three buttons.
2.Going to the load menu, everything is as it should be:
But if I go to the Setting menu:
What is going on? Suddenly the "Start" and "Load" button spring to life and go into their hovered_idle state!
This is problem no 2
Experiment 2With the code above, but delete the line "xysize (122, 52)" in the Start button
1.This time, problem no 1 only happen with the Start button, the other two button play their animation right from the first hover:
(Notice the uneven spacing between the three buttons-that's because the "xysize (122, 52)" line for the Start button is not there anymore)
2.Going to the Load and Setting menu yields the same result as in Experiment 1
So how can I fix this ???
Sigh, I really want to make the GUI work, but it seems way harder for a non-coder than I thought (╯°□°)╯︵ ┻━┻