I've managed to get Spring 1 to show a list of dates or make the list of dates disappear. I've also managed to get the list of dates to scroll up and down.
However, when I press the Spring button, then press down on the keyboard to make the list of dates scroll down, then press the Spring button again,
Code: Select all
if show_buttons:
at date_buttons_appear
My guess is that I'm going to have to come up with an if statement for every possible combination of boolean variables if I'm going to create a menu screen using transforms.
Am I correct in my assumption? If not, how would you recommend coding a menu screen using if statements? Or could it be that if statements are the wrong way to go about triggering transforms for the menu screen? If that is possibly the case, then what other way would you do it?
If it helps, here's my code:
Code: Select all
## The script of the game goes in this file.
init python:
page_ID_min = 1
page_ID_max = 2
button_ID_min = 1
button_ID_max = 15
def next_page():
global page_ID
page_ID = max(page_ID_min, min(page_ID_max, page_ID + 1))
renpy.retain_after_load()
renpy.restart_interaction()
def previous_page():
global page_ID
page_ID = max(page_ID_min, min(page_ID_max, page_ID - 1))
renpy.retain_after_load()
renpy.restart_interaction()
## Declare characters used by this game. The color argument colorizes the name
## of the character.
define e = Character('Eileen')
# Declare a variable used in init python so that we can use it inside a screen.
define page_ID = page_ID_min
## The game starts here.
screen Page_Selector:
modal True
window:
background "#000"
area(0, 0, 1300, 750)
vbox:
text "Page [page_ID] of page [page_ID_max]"
text "show_buttons: [show_buttons] down_pressed: [down_pressed] up_pressed: [up_pressed]" xalign 0.5
key "K_RIGHT" action next_page
key "K_LEFT" action previous_page
key "K_x" action Show("Page_Content", Dissolve(1)), Hide("Page_Selector", Dissolve(1))
key "K_z" action Hide("Page_Selector", Dissolve(1))
textbutton "Next Page":
if page_ID < page_ID_max:
action next_page
textbutton "Previous Page":
if page_ID > page_ID_min:
action previous_page
vbox xalign 0.2 yalign 0.36:
spacing 25
textbutton "Spring" action ToggleVariable("show_buttons", True, False)
textbutton "Summer" action NullAction()
textbutton "Fall" action NullAction()
textbutton "Winter" action NullAction()
vbox spacing 25:
key "K_DOWN" action SetVariable("down_pressed", True), SetVariable("up_pressed", False)
key "K_UP" action SetVariable("up_pressed", True), SetVariable("down_pressed", False)
textbutton "Spring 1"
if show_buttons:
at date_buttons_appear
if up_pressed:
at date_buttons_scroll_up
if down_pressed:
at date_buttons_scroll_down
if show_buttons == False:
at date_buttons_disappear
screen Page_Content:
modal True
window:
background "#001"
area(0, 0, 1300, 750)
vbox:
text "You are at [page_ID]"
key "K_x" action Hide("Page_Content", Dissolve(1)), Show("Page_Selector", Dissolve(1))
key "K_z" action Hide("Page_Content", Dissolve(1)), Hide("Page_Selector", Dissolve(1))
textbutton "Back" action Hide("Page_Content", Dissolve(1)), Show("Page_Selector", Dissolve(1))
#Define any transformations here.
transform date_buttons_appear:
subpixel True
xalign 0.4 # this will center the main menu
alpha 0.0 yalign 0.6 xanchor 0.0 yanchor 0.32 # this will position the main menu at the bottom, outside of the screen
parallel:
easein 1.0 alpha 1.0
parallel:
easein 1.0 xanchor 1.0 #changing yanchor from 0 to 1 we make the menu appear
transform date_buttons_disappear:
subpixel True
xalign 0.4 # this will center the main menu
alpha 1.0 yalign 0.6 xanchor 1.0 yanchor 0.32 # this will position the main menu at the bottom, outside of the screen
parallel:
easein 1.0 alpha 0.0
parallel:
easein 1.0 xanchor 0.0 #changing yanchor from 0 to 1 we make the menu appear
transform date_buttons_disappear_while_up:
xalign 0.4 yalign 0.58
alpha 1.0
parallel:
easein 1.0 alpha 0.0
parallel:
easein 1.0 xalign 0.5
transform date_buttons_scroll_down:
subpixel True
xalign 0.4 yalign 0.6 xanchor 1.0 yanchor 0.32
parallel:
easein 1.0 xanchor 1.0 yanchor 0.76
transform date_buttons_scroll_up:
subpixel True
xalign 0.4 yalign 0.6 xanchor 1.0 yanchor 0.76
parallel:
easein 1.0 xanchor 1.0 yanchor 0.32
init python:
#Define other variables here.
show_buttons = None
up_pressed = None
down_pressed = None
label start:
show screen Page_Selector
## Show a background. This uses a placeholder by default, but you can add a
## file (named either "bg room.png" or "bg room.jpg") to the images
## directory to show it.
scene bg room
## This shows a character sprite. A placeholder is used, but you can replace
## it by adding a file named "eileen happy.png" to the images directory.
show eileen happy
## These display lines of dialogue.
"Hello, world."
e "You've created a new Ren'Py game."
e "Once you add a story, pictures, and music, you can release it to the world!"
## This ends the game.
return
Also ignore the fact that the button is showing in the corner in the beginning. I'll fix that once I've got the menu movements working.
Also ignore the unused transforms. I'm trying to implement them one by one.