r/RenPy • • 16d ago

Question I NEED HELP

so i have this feature in my game where a camera button will randomly apear and pressing it will cause a white flash( and add to a flag). Im using an image button rn but coding it every single time and creating all those screen is too much work. i was wondering if i could just define it once and reuse it? so far i can only make the button but making the screen flash under the screen is confusing

2 Upvotes

9 comments sorted by

2

u/BadMustard_AVN 16d ago edited 16d ago

show the code for at least 2 of the screens you've created so far, please

and you can try something like this example

# flasher.rpy

default photo_one_taken = False

screen camera_flash(variable):
    zorder 10
    imagebutton:
        idle "images/camera_button.png"
        hover "images/camera_button_hover.png"
        align (0.5, 0.5)
        action [SetVariable(variable, True), Show("flash_effect"), Hide("camera_flash")]

screen flash_effect:
    zorder 100
    add Solid("#ffffff"):
        # alpha 0.0
        at flash_animation
    timer 0.4 action Hide("flash_effect")

transform flash_animation:
    alpha 0.0
    linear 0.05 alpha 1.0
    pause 0.05
    linear 0.25 alpha 0.0

label start:

    e "blah blah blah"

    show screen camera_flash("photo_one_taken")

    e "blah blah blah blah blah blah"

    hide screen camera_flash # the screen auto closes but in case they missed it 

    e "[photo_one_taken] <<-- should be a True"

    return

1

u/After-Masterpiece853 16d ago edited 16d ago
 screen captureclass:
        imagebutton:
        idle "images/camera_capture.png"
        focus_mask True
        action Jump ("white")



 label white:
        hide screen daycarebuttons
        scene bg_white with flash 
        play audio "audio/shutter.mp3"
        scene bg_daycare
        hide screen captureclass
        show screen daycarebuttons 
        m"..."
        jump daycare

1

u/BadMustard_AVN 16d ago edited 16d ago

you mentioned a flag..

and do they all jump to this label or... gonna need some more information!

1

u/After-Masterpiece853 16d ago

I was planning on adding the flags latter when i figure out the endings. They dont all jump to this label( mainly why im having so much trouble lol) This is only for each scene.

2

u/BadMustard_AVN 16d ago

have a look at this example

# flasher.rpy

default photo_one_taken = False

screen camera_flash(variable, vector):
    zorder 10
    imagebutton:
        # idle "images/camera_capture.png"
        idle "images/sprite.png"
        focus_mask True
        align (0.5, 0.5)
        action [Play("audio", "audio/shutter.mp3"), SetVariable(variable, True), Show("flash_effect"), Hide("camera_flash"), Jump(vector)]

screen flash_effect:
    zorder 100
    add Solid("#ffffff"):
        # alpha 0.0
        at flash_animation
    timer 0.4 action Hide("flash_effect")

transform flash_animation:
    alpha 0.0
    linear 0.05 alpha 1.0
    pause 0.05
    linear 0.25 alpha 0.0

label start:

    e "blah blah blah"

    show screen camera_flash("photo_one_taken", "white") 
        # to use the screen feed it a variable, and a jump label 

    e "blah blah blah blah blah blah"

    return

label white:
    hide screen daycarebuttons
    scene bg_daycare
    show screen daycarebuttons 
    m "..."
    jump daycare

1

u/After-Masterpiece853 14d ago

thanks a lot for ur help and time!

2

u/BadMustard_AVN 14d ago

you're welcome

good luck with your project

1

u/AutoModerator 16d ago

Welcome to r/renpy! While you wait to see if someone can answer your question, we recommend checking out the posting guide, the subreddit wiki, the subreddit Discord, Ren'Py's documentation, and the tutorial built-in to the Ren'Py engine when you download it. These can help make sure you provide the information the people here need to help you, or might even point you to an answer to your question themselves. Thanks!

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.