Showing image in new context

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
Mild Curry
Regular
Posts: 107
Joined: Fri Jul 02, 2010 3:03 pm
Projects: That's The Way The Cookie Crumbles
Organization: TwinTurtle Games
Contact:

Showing image in new context

#1 Post by Mild Curry » Thu Apr 21, 2011 4:19 am

I'm attempting to make a mini-game in which the user has to press buttons in a certain sequence in order to advance. I want to make it so that, when the user presses a button, an image shows up and a sound plays. The sound plays fine, but no matter what I do, I can't get the program to show just an image.

It looks like this:

Code: Select all

label start:    
    $ input_answer = ""
    $ right_answer = "lrl"       

    "Enter the following sequence: <--, -->, <-- and press ENTER."
    $ ui.keymap(K_LEFT=ui.callsinnewcontext("left"))
    $ ui.keymap(K_RIGHT=ui.callsinnewcontext("right"))
    $ ui.keymap(K_UP=ui.callsinnewcontext("up"))
    $ ui.keymap(K_DOWN=ui.callsinnewcontext("down"))
    $ ui.keymap(K_RETURN=ui.jumps("check"))
    $ ui.interact()
     
label check:    
    if input_answer == right_answer:
        jump win
    else:
       "Fail."
       jump start
   
label left:
    show arrow_left #<----this just never shows up, even when using ui.image or renpy.show
    $ input_answer = input_answer + "l"
    play sound "piano-left.wav"
    return
    
label right:
    $ input_answer = input_answer + "r"
    play sound "piano-right.wav"
    return
    
label up:
    $ input_answer = input_answer + "u"
    play sound "piano-up.wav"
    return

label down:
    $ input_answer = input_answer + "d"
    play sound "piano-down.wav"
    return
    
label win:
    "TOTAL VICTORY"
Adding text directly underneath it makes it show up:

Code: Select all

label left:
    show arrow_left 
    "TEEEEEXXXT." #when this is here, both the text and the image come onscreen
    $ input_answer = input_answer + "l"
    play sound "piano-left.wav"
    return
...but there's no way to put text there without it interrupting the flow of the game.
Can someone tell me what's going on? And perhaps give suggestions about how to fix it?

Your help is kindly appreciated.

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: Showing image in new context

#2 Post by Aleema » Thu Apr 21, 2011 4:39 am

From what I see, you're not giving the image time to appear. There is no observable time between going to that label and then returning to the old one. You should do a dissolve or an actual pause. That's why it shows up when there's text -- because the text stops the game at that point. Right now, it's speeding right past it.

User avatar
Mild Curry
Regular
Posts: 107
Joined: Fri Jul 02, 2010 3:03 pm
Projects: That's The Way The Cookie Crumbles
Organization: TwinTurtle Games
Contact:

Re: Showing image in new context

#3 Post by Mild Curry » Thu Apr 21, 2011 2:13 pm

Ah! Thank-you!!! It works perfectly!

User avatar
roankun
Regular
Posts: 94
Joined: Fri Jun 11, 2010 4:01 am
Projects: RHS
Contact:

Re: Showing image in new context

#4 Post by roankun » Fri Apr 22, 2011 4:51 am

Aleema wrote:You should do a dissolve or an actual pause.
Excuse me, but what code do you use for the actual pause?
I don't have any kind words to spare to someone who already has all the reason in the world to feel good about himself.
http://roankun.wordpress.com/

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: Showing image in new context

#5 Post by Aleema » Fri Apr 22, 2011 5:05 am

Code: Select all

$ renpy.pause(1.0)
This will pause the game for 1 second.

Code: Select all

$ renpy.pause(3.0, hard=True)
This will pause the game for 3 seconds, and will not let the player click past it.

Code: Select all

$ renpy.pause()
This will stop the game until the player clicks.

User avatar
roankun
Regular
Posts: 94
Joined: Fri Jun 11, 2010 4:01 am
Projects: RHS
Contact:

Re: Showing image in new context

#6 Post by roankun » Fri Apr 22, 2011 5:20 am

Thank you very much :)
I don't have any kind words to spare to someone who already has all the reason in the world to feel good about himself.
http://roankun.wordpress.com/

Post Reply

Who is online

Users browsing this forum: Google [Bot]