Label as main menu background

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
neometalero
Regular
Posts: 198
Joined: Sun Oct 23, 2016 3:51 am
Completed: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Projects: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Deviantart: neometalero
Contact:

Label as main menu background

#1 Post by neometalero »

I have this label on my script file, basically it works as a gallery of pictures with some transitions added to it. I want to put this as the main menu background. Any idea on how I could do this?

Code: Select all

label menuCarruselTest:
    $numPoster=renpy.random.randint(1,cantImgMainMenu)
    #Si es el que acaba de salir sortea denuevo
    if numPoster==numAnterior:
        jump menuCarruselTest

    $numAnterior=numPoster #guardo cual fue el que salio
    $numPosterstr="[numPoster]" #lo convierto a string
    $imagenAMostrarMM="MainMenuPresent/Poster-"+numPosterstr+".png" #arma la imagen a mostrar

    show image (imagenAMostrarMM) at MMTransicion
    $ renpy.pause(5.0, hard=True) #para hacer una pausa, y el hard es para que no se la salteen
    scene black
    with dissolve
    $contadorAlPedo=contadorAlPedo+1
    if contadorAlPedo==1000:
        return #sale del programa, es para evitar un loop infinito
    else:
        jump menuCarruselTest
Working on many weird narrative games at Curse Box Studios
Image
https://www.curseboxstudios.com/

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2405
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Label as main menu background

#2 Post by Ocelot »

If main_menu label exist, it will be executed, instead of showing the main menu screen. Note that you will be responsible for shwing and handling all menu screens in this case.
An alternative approach is to convert you code into a screen and use that instead.
< < insert Rick Cook quote here > >

User avatar
neometalero
Regular
Posts: 198
Joined: Sun Oct 23, 2016 3:51 am
Completed: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Projects: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Deviantart: neometalero
Contact:

Re: Label as main menu background

#3 Post by neometalero »

Ocelot wrote: Wed Mar 20, 2024 4:49 am If main_menu label exist, it will be executed, instead of showing the main menu screen. Note that you will be responsible for shwing and handling all menu screens in this case.
An alternative approach is to convert you code into a screen and use that instead.
How can I write this in screen language? I can't use jumps or repeat. Hoy could I accomplish the same loop?
Working on many weird narrative games at Curse Box Studios
Image
https://www.curseboxstudios.com/

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2405
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Label as main menu background

#4 Post by Ocelot »

a) Use timers that change varable controlling current image.
b) CDD which change rendered image based on elapsed time
c) Potentially ATL animation which has a funtcion statement changing child of transform.
< < insert Rick Cook quote here > >

User avatar
neometalero
Regular
Posts: 198
Joined: Sun Oct 23, 2016 3:51 am
Completed: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Projects: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Deviantart: neometalero
Contact:

Re: Label as main menu background

#5 Post by neometalero »

Ocelot wrote: Wed Mar 20, 2024 3:52 pm a) Use timers that change varable controlling current image.
b) CDD which change rendered image based on elapsed time
c) Potentially ATL animation which has a funtcion statement changing child of transform.
Right now Im triying to do it this way, as an animated image

Code: Select all

image MMCarrusAsImgSimple:
    ("MainMenuPresent/Poster-"+(renpy.random.randint(1,cantImgMainMenu))+".png") at MMTransicion
    pause 5
    repeat
but Im getting the following error.
Image
Working on many weird narrative games at Curse Box Studios
Image
https://www.curseboxstudios.com/

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2405
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Label as main menu background

#6 Post by Ocelot »

You cannot simply add random code and expect it to work. ATL has different syntax from both RenPy script and SL, so you'll need more complex approach. This, for example will change bachground from red to green and back every 3 seconds:

Code: Select all

init python:
    def change_image(trans, st, at):
        if (at // 3) % 2 == 0:
            trans.set_child(Solid("#0F0"))
        else:
            trans.set_child(Solid("#F00"))
        return None


image green_to_red:
    function change_image
    pause 1.0
    repeat

label start:
    show green_to_red
    "..."
    return
[code]
If you have any transitions you want to use, you will have to bake them into [c]funtion[/c] code as well. In this case I heavily suggest go with "screen with timers" approach instead.
< < insert Rick Cook quote here > >

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot], Milkymalk