Showing a screen inside a viewport. SOLVED (Thankyou)

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
Evildumdum
Regular
Posts: 191
Joined: Sun Jan 18, 2015 8:49 am
Projects: ApoclypseZ
Contact:

Showing a screen inside a viewport. SOLVED (Thankyou)

#1 Post by Evildumdum »

So i need to make the campaign map for my game bigger than the screen. I can use viewports to an extent, but i've hit a snag. With a normal screen i can position everything with xaligns or xpos etc. With a viewport, I can position the pictures where i need them, or a can make it scrollable. But if i try to do both i am unable to.

Example:

Code: Select all

screen campaign_map:
    viewport:
        area 0.00,0.00,600,600
        draggable True
        has vbox
        hbox:
            add "map/map.png" xalign 0.00 yalign 0.00
            add "map/overlay.png" xalign 0.00 yalign 0.00
This results in a window that is scrollable, but makes it so that every picture is next to each other, rather than overlayed like they need to be.

Example:

Code: Select all

screen campaign_map:
    viewport:
        area 0.00,0.00,600,600
        draggable True
        has vbox
        hbox:
            show screen map
        
        
screen map:
    add "map/map.png" xalign 0.00 yalign 0.00
    add "map/overlay.png" xalign 0.00 yalign 0.00
This is an example of the sort of thing i am trying. Obviously its not working. Is there any way to have a screen bigger than the game screen, position things wherever you like and still be able to scroll across it with a viewport?
Last edited by Evildumdum on Tue Nov 24, 2015 3:19 pm, edited 1 time in total.
"If at first you don't succeed, try hitting it with a shoe."

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

Re: Showing a screen inside a viewport.

#2 Post by xela »

Why is there an hbox within a vbox there? Normally, your first approach was smarter.
Like what we're doing? Support us at:
Image

User avatar
Evildumdum
Regular
Posts: 191
Joined: Sun Jan 18, 2015 8:49 am
Projects: ApoclypseZ
Contact:

Re: Showing a screen inside a viewport.

#3 Post by Evildumdum »

That's the thing. I've tried it without the vbox and hbox and it doesn't drag at all. With only a vbox the pictures all show in a line downwards and with only a hbox the pictures all show in a line horizontally. What i really need to do is create a screen. then show it through a draggable viewport.
"If at first you don't succeed, try hitting it with a shoe."

User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: Showing a screen inside a viewport.

#4 Post by Kia »

I've tried this and looks like the drag wont works as long as you have two or more objects on each other inside your map screen. if you don't want anything but maps you can put the vbox inside the map screen instead.

Code: Select all

screen map:
    vbox:
        add "map/map.png" xalign 0.00 yalign 0.00
        add "map/overlay.png" xalign 0.00 yalign 0.00
feel free to use hbox or grid instead if you have different pieces to put together but remember you can't put two things on top of each other for some reason

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Showing a screen inside a viewport.

#5 Post by Alex »

Sometimes (when Ren'Py is unable to guess the viewport's child size) the viewport doesn't scroll, so you need to set this size manually. Try

Code: Select all

screen vs():
    viewport:
        area 0,0,600,600
        draggable True
        child_size 1600, 1200
        
        add "images/bg washington.jpg" xalign 0.00 yalign 0.00 zoom 2.0
        add "images/bg washington.jpg" xalign 0.20 yalign 0.25 zoom 1.5
    
# The game starts here.
label start:
    "..."
    show screen vs
    "?"
http://www.renpy.org/doc/html/screens.html#viewport

User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: Showing a screen inside a viewport.

#6 Post by Kia »

Alex wrote:Sometimes (when Ren'Py is unable to guess the viewport's child size) the viewport doesn't scroll, so you need to set this size manually.
funny thing is: child size was the only part I've read to see what it's about and still made a mistake :roll:

User avatar
Evildumdum
Regular
Posts: 191
Joined: Sun Jan 18, 2015 8:49 am
Projects: ApoclypseZ
Contact:

Re: Showing a screen inside a viewport.

#7 Post by Evildumdum »

Set the child size, worked like an absolute dream :) this is why i love you guys.
"If at first you don't succeed, try hitting it with a shoe."

Post Reply

Who is online

Users browsing this forum: Imperf3kt, Majestic-12 [Bot], Yone28