Hiding image with off-screen transition

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
Valhalla Ent
Newbie
Posts: 13
Joined: Mon Mar 11, 2019 5:35 pm
Contact:

Hiding image with off-screen transition

#1 Post by Valhalla Ent »

I have a little image notification appear at the top right corner of my screen using this command:

Code: Select all

image notification:
    "gallery_notification.png"
    xalign 1.1 yalign 0
    linear 0.1 xalign 1.0 yalign 0
As you can see, it slides inside the screen. I like this because it does it in a very fluid movement.

I was wondering if there's a way to make that same image slide off-screen after a certain period of time. I was experimenting with "timer" but couldn't figure it out.

I can make it disappear with:

Code: Select all

hide image "notification" with Dissolve(0.2)
but it doesn't have that fluid movement I'm looking for.

User avatar
hell_oh_world
Miko-Class Veteran
Posts: 777
Joined: Fri Jul 12, 2019 5:21 am
Contact:

Re: Hiding image with off-screen transition

#2 Post by hell_oh_world »

use atl events... and probably a screen.

Code: Select all

transform fader:
    on show:
        alpha 0.0
        easein 0.15 alpha 1.0
    on hide:
        easein 0.15 alpha 0.0

screen notif(image, delay=2):
    default hide = False
    showif not hide:
        add image at fader

    timer delay action SetScreenVariable("hide", True) # hides the notif after 2 seconds.
    if hide:
        timer 0.15 action Hide("notif") # makes the transform happen before hiding the screen.
    
label start:
    show screen notif("gallery_image.png")
    "some dialogue"

Valhalla Ent
Newbie
Posts: 13
Joined: Mon Mar 11, 2019 5:35 pm
Contact:

Re: Hiding image with off-screen transition

#3 Post by Valhalla Ent »

I get this error:

Code: Select all

[code]
I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.


File "game/notification.rpy", line 14: expected 'name' not found.
    screen notif(image, delay=2):
                 ^

File "game/notification.rpy", line 19: expected statement.
    timer delay action SetScreenVariable("hide", True) 
                                        ^


User avatar
hell_oh_world
Miko-Class Veteran
Posts: 777
Joined: Fri Jul 12, 2019 5:21 am
Contact:

Re: Hiding image with off-screen transition

#4 Post by hell_oh_world »

my bad... i used a reserved keyword.

Code: Select all

transform fader:
    on show:
        alpha 0.0
        easein 0.15 alpha 1.0
    on hide:
        easein 0.15 alpha 0.0

screen notif(the_image, delay=2):
    default hide = False
    showif not hide:
        add the_image at fader

    timer delay action SetScreenVariable("hide", True) # hides the notif after 2 seconds.
    if hide:
        timer 0.15 action Hide("notif") # makes the transform happen before hiding the screen.
    
label start:
    show screen notif("gallery_image.png")
    "some dialogue"

Valhalla Ent
Newbie
Posts: 13
Joined: Mon Mar 11, 2019 5:35 pm
Contact:

Re: Hiding image with off-screen transition

#5 Post by Valhalla Ent »

You are a legend! Thanks.

Post Reply

Who is online

Users browsing this forum: Google [Bot], Yone28