Show Image User Cannot Interrupt

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
SuperbowserX
Veteran
Posts: 270
Joined: Sat Jan 07, 2017 3:09 pm
Contact:

Show Image User Cannot Interrupt

#1 Post by SuperbowserX »

Sorry if I'm asking too many questions lol, just a beginner here.

Wanted to ask: how can you handle a situation like this. Suppose I want to show an image (it's a pop-up that indicates a user's score is up). But I don't want this image to interrupt the user's actual progression of the game. I don't want the user's mouse clicking to affect the appearance of this image.

I want this immage to appear, be on-screen for a certain length of time, and then hide. But none of this process affects the progression of the game. The game still flows just as normal and the user's clicking on the mouse does not affect how long the image stays on screen.

Basically, I want to, in a way that is non-intrusive with regards to game progression, display an image for a certain amount of time and hide it.

Any ideas?

User avatar
warmsundae
Regular
Posts: 61
Joined: Tue Feb 24, 2015 9:51 pm
Skype: electriclan
Soundcloud: lanterny
Location: korea
Contact:

Re: Show Image User Cannot Interrupt

#2 Post by warmsundae »

What if you just handled it like a character sprite, but in a different location?

edit: adding to what Imperf3kt said: the above doesn't work in cases where you want a time limit on the image independent of the player's clicks.
Last edited by warmsundae on Tue Jan 10, 2017 10:20 am, edited 1 time in total.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3794
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Show Image User Cannot Interrupt

#3 Post by Imperf3kt »

warmsundae's suggestion should work in most situations unless you have a transition, or want a user to be able to call the score at will.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

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

Re: Show Image User Cannot Interrupt

#4 Post by Ocelot »

Check how notify screen works (in screens.rpy).

In short, there is a timer on screen, which hides it after several seconds after it was shown.
https://www.renpy.org/doc/html/screens.html#timer
< < insert Rick Cook quote here > >

User avatar
SuperbowserX
Veteran
Posts: 270
Joined: Sat Jan 07, 2017 3:09 pm
Contact:

Re: Show Image User Cannot Interrupt

#5 Post by SuperbowserX »

On mobile now and will be away for next while so I can't test this. Asking this for now so if anyone gets an idea I can see their reply when I get back

Code: Select all

screen timer_test():
    vbox:
         textbutton "Yes." action Jump("yes")
         textbutton "No." action Jump("no")

    timer 3.0 action Jump("too_slow")
So what would go where here?

User avatar
Enchant00
Regular
Posts: 136
Joined: Tue Jan 12, 2016 1:17 am
Contact:

Re: Show Image User Cannot Interrupt

#6 Post by Enchant00 »

SuperbowserX wrote:On mobile now and will be away for next while so I can't test this. Asking this for now so if anyone gets an idea I can see their reply when I get back

Code: Select all

screen timer_test():
    vbox:
         textbutton "Yes." action Jump("yes")
         textbutton "No." action Jump("no")

    timer 3.0 action Jump("too_slow")
So what would go where here?
- Ok so what I understand it you want a popup image to appear for a specific amount of time then disappear without it hindering the player actions in any way. So here's how I would do it.

First method
* You could put this anywhere, but I'd put this above in your script.rpy

Code: Select all

init:
    $ time = 0

screen popup:
    modal False
    add 'nameofimage.png' xalign 0.5 yalign 0.5
    timer 1.0 action If(time <= 0, Hide('popup'))
$ time - don't touch this :lol:
modal not really necessary but this is just to answer your question of not hindering player action
add - this part is responsible for adding the image. Change the name of image to the image you want to popup. xalign and yalign is the position of your image. From left to right is 0.0 => 1.0 and from top to bottom its 0.0 => 1.0; so example like the center position would be xalign .05 and yalign .05 and the top left of the screen would be xalign 0.0 yalign 0.0 Here's an image to help you out Image
timer - the 1.0 would be the time of the popup and its in seconds so if you want it 5 seconds then you'll change it to timer 5.0

* Now, to make the screen appear you need to go to the part of your code where the popup image is used. Then type show screen popup

Code: Select all

label start:

    "This is the part of my code where player does something and popup shows"
    $ affection =+ 1
    show screen popup


Second method
- You can create a screen that calls the popup and sets the variable. That way when example a player increase their affection ,then it will show popup as well as change the variable affection's number.

* You could put this anywhere, but I'd put this above in your script.rpy

Code: Select all

init:
    $ time = 0
    $ affection = 0

screen popup:
    python:
        global affection
        affection =+ 1
    modal False
    add 'try.png' xalign 0.5 yalign 0.5
    timer 1.0 action If(time <= 0, Hide('popup'))
affection example of a variable that will increase when the popup image shows; change the += 1 to whatever number for increase then change both affections to whatever name

* * Now, to make the screen appear you need to go to the part of your code where YOU increase the variable.

Code: Select all

label start:
    "I love you"
    show screen popup
* You can use ATL if you want animations when the popup shows and lastly you could apply music to it; just check the renpy docuentation :lol:

User avatar
SuperbowserX
Veteran
Posts: 270
Joined: Sat Jan 07, 2017 3:09 pm
Contact:

Re: Show Image User Cannot Interrupt

#7 Post by SuperbowserX »

Thanks. The first method is what I'm looking for as the variable increase is context-sensitive.

Anyway, let me ask: is there anyway I can portray the image with a dissolve or fade effect using the first method?

Code: Select all

init:
    $ time = 0

screen popup:
    modal False
    add 'sleuth.png' xalign 0.25 yalign 0.5
    timer 1.0 action If(time <= 0, Hide('popup'))
    
label correct:
    show screen popup
    play sound "SFX/right.wav"
    return
I tried adding "with fade" to the end of the first line of label correct but that doesn't compile.

Any idea how I can add a fade effect?

User avatar
Enchant00
Regular
Posts: 136
Joined: Tue Jan 12, 2016 1:17 am
Contact:

Re: Show Image User Cannot Interrupt

#8 Post by Enchant00 »

SuperbowserX wrote:Thanks. The first method is what I'm looking for as the variable increase is context-sensitive.

Anyway, let me ask: is there anyway I can portray the image with a dissolve or fade effect using the first method?

Code: Select all

init:
    $ time = 0

screen popup:
    modal False
    add 'sleuth.png' xalign 0.25 yalign 0.5
    timer 1.0 action If(time <= 0, Hide('popup'))
    
label correct:
    show screen popup
    play sound "SFX/right.wav"
    return
I tried adding "with fade" to the end of the first line of label correct but that doesn't compile.

Any idea how I can add a fade effect?
** For that you would use atl and transform, her is a basic fade for ya :lol: Just copy and paste the transform pop_fade above screen popup and in the screen popup, add a at pop_fade at the end of the add statment or just replace the entire thing with the code below.

Code: Select all

init:
    $ time = 0
    
transform pop_fade:
    on hide:
        linear 1.0 alpha 0

screen popup:
    modal False
    add 'nameofimage.png' xalign 0.5 yalign 0.5 at pop_fade
    timer 1.0 action If(time <= 0, Hide('popup')) 

linear this is the time and it's in seconds so change it to around 0.5 or whatever fade time you want
alpha it's like the degree of fade but just keep it at 0

User avatar
SuperbowserX
Veteran
Posts: 270
Joined: Sat Jan 07, 2017 3:09 pm
Contact:

Re: Show Image User Cannot Interrupt

#9 Post by SuperbowserX »

Thank you! This is exactly what I was looking for! :)

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: Show Image User Cannot Interrupt

#10 Post by xavimat »

The timer can be simpler. The variable "time" is not needed, neither the If() action:

Code: Select all

screen popup():
    modal False
    add 'nameofimage.png' xalign 0.5 yalign 0.5 at pop_fade
    timer 1.0 action Hide('popup')
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

Post Reply

Who is online

Users browsing this forum: Andredron