[SOLVED] Simple status message text (drop in, rise out)

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
LofnBard
Newbie
Posts: 14
Joined: Sun Jan 26, 2014 6:37 am
Projects: Herb Witch
Location: Quebec, Canada
Contact:

[SOLVED] Simple status message text (drop in, rise out)

#1 Post by LofnBard »

Hello, amazing people!

I'm trying to have a status message drop in from offscreen, wait a few seconds, then float up offscreen.

The problem: If I use "call screen stat_drop" it displays properly, dropping in, waiting, then floating off, but the default text area at the bottom disappears, and control is never returned to the main program. It displays "1", the status message, then becomes unresponsive and never shows "2".
If I use "show screen stat_drop", then it never shows the stat screen, just goes through 1,2,3,4

I've spent weeks coding data structures as classes in Python, creating game sprites, imagebuttons (with the help of the excellent Renpy Imagebuttons GUI Sample), and opening screens to show character stats. Those work well, and I'm pretty good at programming in procedural languages, but the logic of screens language often still confounds me. I've isolated the problem section into its own project (shown below) but still can't figure it out. I'd really appreciate some help. Thanks!

Code: Select all

init python:
    actiontext = "Stats increase by 50" # Sample status message to display

screen stat_change:                     # Screen for showing stat change message
    text (actiontext) size 30:          # Display string with size 30, use transform to drop in and drop out
        at drop_status

init:
    image bg blueDream = "gui/BackgroundBlueDream.jpg"
    
label start: # ■██▓▒░ START LABEL ░▒▓████████████████████████████████████■
    show bg blueDream                   # Show background
    "1"
    call screen stat_change             # Drop status message text
    "2"
    hide screen stat_change             # Hide status message text
    "3"
    "4"

init -2:
    transform drop_status:
        xpos 350  ypos -300     # Start above the visible screen
        easeout 1.0 ypos 50     # Drop down to 50 pixels from the tops to show status message
        2.5                     # 2.5 second Pause
        linear 3.0 ypos -300    # Go back above the visible screen in 3 seconds to hide status message
        
    transform drop_status2:  # Second attempt at making stat_drop return control 
        on show:
            xpos 350  ypos -300 
            easeout 1.0 ypos 50
            2.5                 # 2.5 second Pause
        on hide: 
            linear 3.0 ypos -300    
Note: I'm doing this as part of the Pixelles Game Incubator (which is for helping women make their first video game). Whatever I've got working is going to be showcased Saturday Feb 22 and Wednesday Feb 26 at game fairs. We had playtesters come try our games last Wednesday, and mine really needed more feedback to the players.
Last edited by LofnBard on Mon Feb 17, 2014 8:58 pm, edited 1 time in total.

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Simple status message text (drop in, rise out) question

#2 Post by xela »

You have nothing that actually hides the screen, try setting the on screen timer to hide it:

Code: Select all

screen stat_change:                     # Screen for showing stat change message
    text (actiontext) size 30:          # Display string with size 30, use transform to drop in and drop out
        at drop_status
    timer 2.5 action Hide("stat_change")
There is no need for a timer in your tranforms.
Like what we're doing? Support us at:
Image

SundownKid
Lemma-Class Veteran
Posts: 2299
Joined: Mon Feb 06, 2012 9:50 pm
Completed: Icebound, Selenon Rising Ep. 1-2
Projects: Selenon Rising Ep. 3-4
Organization: Fastermind Games
Deviantart: sundownkid
Location: NYC
Contact:

Re: Simple status message text (drop in, rise out) question

#3 Post by SundownKid »

I've actually been thinking of something like this, so thanks for the info too. A timer seems like it should work.

User avatar
LofnBard
Newbie
Posts: 14
Joined: Sun Jan 26, 2014 6:37 am
Projects: Herb Witch
Location: Quebec, Canada
Contact:

Re: Simple status message text (drop in, rise out) question

#4 Post by LofnBard »

Thanks so much Xela! This makes it usable in my game. :)

But this brings up some new problems. A minor one is that I wanted the status message to drop in, wait, and then float up, because people notice movement above all things, and that really draws attention to to the stat change. The timer's so short, it just drops, then disappears. Easily fixed by extending the timer to 7 seconds, the full length of my transform.

However, if the player is rapidly clicking through the story they will *never* see the status message. I didn't even think it was working the first time I tested the solution. Once "2" is displayed, I have to wait to let the animation play out. If I click anywhere, stat_change immediately disappears and "3" is displayed. The whole point of using a screen is to let it play out its animated display independently of whatever else is going on. This stat message is going to be displayed while the player is doing battle, rapidly clicking on the firing imagebuttons, to give them feedback on the effect of their attack. I can't let it disappear just because they clicked on a new button. Isn't there a way to let the animation play out no matter what? I don't even mind if the main text display is paused while this happens, as long as it eventually comes back.

Thank! :)

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Simple status message text (drop in, rise out) question

#5 Post by xela »

?

Remove the hide screen from your script between "2" and "3" and show the screen instead of calling it and it will go away with the timer while user can do whatever he/she likes best.
Like what we're doing? Support us at:
Image

User avatar
LofnBard
Newbie
Posts: 14
Joined: Sun Jan 26, 2014 6:37 am
Projects: Herb Witch
Location: Quebec, Canada
Contact:

Re: Simple status message text (drop in, rise out) question

#6 Post by LofnBard »

Solved! Thank you Xela!
Since I couldn't find anything like this in the forums, here's the corrected version for our home viewers, with a fancier status message version that takes parameters and displays multiple lines.

In wanting to show another example of how parameters are passed, I also realized that calling stat_change again will have no effect if the user clicks rapidly. Until the end of its transform animation, it's the *same* screen, and you can't show two instances of the same screen at once. Thus I made a duplicate of stat_change2 and called it stat_change3. That way those two screens can be shown at the same time. I also duplicated the transform, but with different ypos so they wouldn't overlap. Otherwise they're identical. It's a little clunky, but sufficient for a code example. I hope this helps others out in their games, and really appreciate Xela's insight. :)

Code: Select all

### Drop down and float up status message  -- code example
### Multiple screens are used, since you can't show a status message screen with new values until it's finished displaying.  
### This example will run "as is" in a new project if you change the background image to one you have, or delete both statements 

init python:
    actiontext = "Stats increase by 50"         # Sample status message to display

screen stat_change:                             # Screen for showing status change message
    text (actiontext) size 30:                  # Display string with size 30, use transform to drop in and float up the message
        at drop_status                  
    timer 7.0 action Hide("stat_change")        # The transform animation lasts 6.5 second, so dismiss the screen after 7 seconds. 
                                                # Do not use "hide screen" in main program, that would dismiss it too soon. 

screen stat_change2 (msg1,msg2="", change = 0, size1=30, size2=20):  # Fancier screem takes variable parameters, has default values)
    frame background None:                      # This makes the frame background transparent
        vbox:
           text msg1 size size1                 # Display first string in size1 (default is 30)
           text (msg2+str(change)) size size2   # Display second string in size2 (default is 20) with change value (converted to a string)
        at drop_status2                         # Use transform to drop in and float up the frame
        timer 7.0 action Hide("stat_change")    # The transform animation lasts 7 second, so dismiss the screen after 7 seconds.
                                                # Do not use "hide screen" in main program, that would dismiss it too soon. 

                                                # Use version below to display message before previous one ends:
screen stat_change3 (msg1,msg2="", change = 0, size1=30, size2=20):  #IDENTICAL TO THE ONE ABOVE! 
    frame background None:                      # This makes the frame background transparent
        vbox:
           text msg1 size size1                 # Display first string in size1 (default is 30)
           text (msg2+str(change)) size size2   # Display second string in size2 (default is 20) with change value (converted to a string)
        at drop_status3                         # Use transform to drop in and float up the frame
        timer 7.0 action Hide("stat_change")    # The transform animation lasts 7 second, so dismiss the screen after 7 seconds.
                                                # Do not use "hide screen" in main program, that would dismiss it too soon. 


init:
    image bg blueDream = "gui/BackgroundBlueDream.jpg" # CHANGE TO YOUR OWN BACKGROUND FILE
    
label start: # ■██▓▒░ START LABEL ░▒▓████████████████████████████████████■
    show bg blueDream                   # Show background
    
    "1"                                 # Numbers simulate story progression in the main text window. 
    show screen stat_change             # Drop status message text
    "2: Displaying stat change above"
                                        # Do not use "hide screen stat_change", that would hide the screen before the end of the animation
    "3"                                 # stat_change continues to display until the end of its animation, no matter how fast user clicks
    "4"
    $damage = -50                       # Sample game variable for attack damage. This would be a calculated value during game. 
    show screen stat_change2("Villager under attack!", "Villager health: ", damage) #Uses whatever messages you want
    "5: Displaying a custom drop message"
    "6"
    "7"
    show screen stat_change3("Important!", "Morale: ", 100, 50,10)      # This time we specify the size of the texts
    "8: Displaying another custom drop message"                         # we can't use stat_change2 again until it finishes displaying
    "9"
    show screen stat_change                                             # First stat_change screen should be done, and available again for display. 
    "10"                                                                # However, if player clicks too fast, this one will NOT display. 
    "11"
    "12"

init -2:                        # These transforms are identical, except for different y postions (so messages don't overlap)
    transform drop_status:
        xpos 350  ypos -300     # Start above the visible screen
        easeout 1.0 ypos 75     # Drop down to 50 pixels from the tops to show status message
        3                       # 2.5 second Pause
        linear 3.0 ypos -300    # Go back above the visible screen in 3 seconds to hide status message
        
    transform drop_status2:     # IDENTICAL to above, except for position "ypos 0"
        xpos 350  ypos -300     # Start above the visible screen
        easeout 1.0 ypos 0      # Drop down to 50 pixels from the tops to show status message
        3                       # 2.5 second Pause
        linear 3.0 ypos -300    # Go back above the visible screen in 3 seconds to hide status message
        
    transform drop_status3:     # IDENTICAL to above, except for position "ypos 100"
        xpos 350  ypos -300     # Start above the visible screen
        easeout 1.0 ypos 100    # Drop down to 50 pixels from the tops to show status message
        3                       # 2.5 second Pause
        linear 3.0 ypos -300    # Go back above the visible screen in 3 seconds to hide status message

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot]