Showing a screen with a 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
User avatar
cbx33
Newbie
Posts: 22
Joined: Fri Nov 02, 2012 5:57 pm
Projects: Convenience Wars
Organization: Rakit Studios
Contact:

Showing a screen with a transition

#1 Post by cbx33 » Fri Nov 02, 2012 8:26 pm

Ok, so off the back of the last post, I have been advised to use a screen instead of calling my UI elements with python code, which is fine, however I can only get the Dissolve transition to work when showing the scree and can someone tell me why I have to use such rediculous x/ypos values when using 1280x720 res screen.....

Code: Select all

screen show_phone:
    if show_p:
        window:
            background 'extras/phone.png'
            top_padding 80
            left_padding 65
            xpos 1530
            ypos 500
            #,xpos=1530, ypos=547, top_padding=80, left_padding=65)
            vbox:
                text(phone_message)
                hbox:
                    textbutton _("Close") action Hide('show_phone', transition=dissolve)
And if I try to invoke with a

Code: Select all

show screen
like so....

Code: Select all

    $ phone_message = "You got mail"
    $ show_p = True
    show screen show_phone
    with dissolve
it works, but any other transition doesn't seem to. In particular I wanted to moveinbottom.

Any takers?

User avatar
Arowana
Miko-Class Veteran
Posts: 531
Joined: Thu May 31, 2012 11:17 pm
Completed: a2 ~a due~
Projects: AXIOM.01, The Pirate Mermaid
Organization: Variable X, Navigame
Tumblr: navigame-media
itch: navigame
Contact:

Re: Showing a screen with a transition

#2 Post by Arowana » Sat Nov 03, 2012 12:41 am

Hmm, I usually show screens with "transforms" rather than "transitions." Not sure why transitions don't work, quite honestly, but if you want a "moveinbottom" type effect, you can define an ATL transform like:

Code: Select all

init:
    transform moveup:
       ypos 1.0 # start low
       ease 0.5 ypos 0.5 # move up in 0.5 seconds
You can also specify specific animations for showing vs. hiding the screen using "on show" and "on hide" - example.

Then for your phone screen, add "at moveup" to your screen window.

Code: Select all

screen show_phone:
    if show_p:
        window:
            at moveup #<---------------------------------------specifies transform to use
            background 'extras/phone.png'
            top_padding 80
            left_padding 65
            xpos 1530
            ypos 500
            #,xpos=1530, ypos=547, top_padding=80, left_padding=65)
            vbox:
                text(phone_message)
                hbox:
                    textbutton _("Close") action Hide('show_phone', transition=dissolve)
Lol, not sure why your positions are so large - is your image weirdly sized/has a lot of empty space around it?
Complete: a2 ~a due~ (music, language, love)
In progress: The Pirate Mermaid (fairytale otome)
On hold: AXIOM.01 (girl detective game)

Image

User avatar
cbx33
Newbie
Posts: 22
Joined: Fri Nov 02, 2012 5:57 pm
Projects: Convenience Wars
Organization: Rakit Studios
Contact:

Re: Showing a screen with a transition

#3 Post by cbx33 » Sat Nov 03, 2012 9:27 am

That worked awesomely Arowana
I guess I was getting confused between transitions and transforms and didn't really know which was the right one to use. It "should" have worked with the transition, but works awesomely with the transform.

The image is small. 334x444px
Is it possibly because I didn't specify a width for the window? I dunno, but it's working well now. Thank you

[Update] I found out how to fix the odd dimensions. I had not set an xanchor/yanchor. After setting those to 0, it performed a lot more predictably.
Last edited by cbx33 on Sat Nov 03, 2012 10:48 am, edited 1 time in total.

User avatar
cbx33
Newbie
Posts: 22
Joined: Fri Nov 02, 2012 5:57 pm
Projects: Convenience Wars
Organization: Rakit Studios
Contact:

Re: Showing a screen with a transition

#4 Post by cbx33 » Sat Nov 03, 2012 10:43 am

OK, another small problem. I wanted to make some buttons to scroll through a text message on the phone

Code: Select all

    $ phone_message = "You got mail\nand it's cool\nthat we can\nscroll through\na message\nYou got mail\nand it's cool\nthat we can\nscroll through\na message"
    $ show_p = True
    $ phone_offset = 0
    show screen show_phone
And the screen code is here, note I have some debug messages

Code: Select all

screen show_phone:
    if show_p:
        window:
            $ print " " + str(phone_offset)
            $ m_len = phone_message.split("\n")
            if phone_offset < 0: 
                $ print "I'm low"
                $ phone_offset = 0
            elif phone_offset > len(m_len)-5:
                $ print "I'm high"
                $ phone_offset = len(m_len)-5

            $ m_dict = phone_message.split("\n")[phone_offset:phone_offset+5]

            at phone_trans
            background 'extras/phone.png'
            top_padding 80
            left_padding 65

            vbox:
                text("\n".join(m_dict))
                text(str(phone_offset))
                hbox:
                    textbutton _("Down") action SetVariable('phone_offset', phone_offset + 1)
                    textbutton _("Close") action Hide('show_phone')
                    textbutton _("Up") action SetVariable('phone_offset', phone_offset - 1)
Now the buttons work fine, until I hit one of the limits defined in the IF statement. Can anyone give me a hint as to how to fix this?

Levrex
Veteran
Posts: 280
Joined: Mon Jun 18, 2012 12:16 pm
Contact:

Re: Showing a screen with a transition

#5 Post by Levrex » Sat Nov 03, 2012 12:23 pm

Try adding "else" too?
If your question is solved, please add [Solved] to theme's name by editing its first post, so that the helpful guys out there wouldn't mistakenly think the problem is still unanswered and waste their time.

User avatar
cbx33
Newbie
Posts: 22
Joined: Fri Nov 02, 2012 5:57 pm
Projects: Convenience Wars
Organization: Rakit Studios
Contact:

Re: Showing a screen with a transition

#6 Post by cbx33 » Sat Nov 03, 2012 2:01 pm

I'll give that a go

User avatar
cbx33
Newbie
Posts: 22
Joined: Fri Nov 02, 2012 5:57 pm
Projects: Convenience Wars
Organization: Rakit Studios
Contact:

Re: Showing a screen with a transition

#7 Post by cbx33 » Sat Nov 03, 2012 2:05 pm

Tried that, still doesn't work. Interestingly I'm using a default style for the UI elements and the buttons seemed to glow, ie the text colour gets brighter and stays that way....like it's hitting some kind of loop condition. Interestingly also, when I added an else that did

Code: Select all

$ phone_offset = phone_offset
The buttons didn't work at all. It is almost like those conditions are being evaluated constantly and the inc/dec of the buttons never gets used. Without the else, the buttons do work up until their limits are reached.
------------------------Tear off here--------------------------

Check out Convenience Wars, Rakit Studios' first VN title!

User avatar
Arowana
Miko-Class Veteran
Posts: 531
Joined: Thu May 31, 2012 11:17 pm
Completed: a2 ~a due~
Projects: AXIOM.01, The Pirate Mermaid
Organization: Variable X, Navigame
Tumblr: navigame-media
itch: navigame
Contact:

Re: Showing a screen with a transition

#8 Post by Arowana » Sat Nov 03, 2012 10:20 pm

Oh, that's an cool way to scroll text! I've usually just seen people use viewports, so your method is pretty interesting. :)

Not entirely sure, but my hunch for why this is not working is that "if" statements checking for out-of-bounds values of "phone_offset" are only run once, when the screen is initially called. Since "phone_offset" is 0 initially, it just passes through without doing anything. Then when the "phone_offset" values get out-of-bounds, you get problems.

One way around this is to make the button actions conditional, so they won't go out-of-bounds in the first place. So maybe something like:

Code: Select all

textbutton _("Down") action If( (phone_offset+1 > len(m_len)-5), SetVariable('phone_offset', len(m_len)-5), SetVariable('phone_offset', phone_offset + 1))

textbutton _("Up") action If( (phone_offset-1 < 0), SetVariable('phone_offset', 0), SetVariable('phone_offset', phone_offset - 1))     
An alternative way could be to hide and reshow the screen whenever you click a button, so the "if" statements will be rechecked each time. Since your screen has an entrance animation, however, you might have to define an alternate version without the animation (else the screen will "pop up" each time it is reshown).
Complete: a2 ~a due~ (music, language, love)
In progress: The Pirate Mermaid (fairytale otome)
On hold: AXIOM.01 (girl detective game)

Image

User avatar
cbx33
Newbie
Posts: 22
Joined: Fri Nov 02, 2012 5:57 pm
Projects: Convenience Wars
Organization: Rakit Studios
Contact:

Re: Showing a screen with a transition

#9 Post by cbx33 » Wed Nov 07, 2012 6:22 pm

That worked beautifully
Thanks :)
------------------------Tear off here--------------------------

Check out Convenience Wars, Rakit Studios' first VN title!

Post Reply

Who is online

Users browsing this forum: Google [Bot], TioNick