How to interact with screens

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
thelonelyjoker
Newbie
Posts: 4
Joined: Fri Jan 19, 2018 12:39 pm
Contact:

How to interact with screens

#1 Post by thelonelyjoker »

I'm completely new to Renpy and have not experienced Python. I'm trying to make a game, still messing around in my room. Because this is my first game so i want to make it simple. I want to create a text box with words "go out" then when I click on it I will move to world map. Could you give me an example of this kind of code?. I tried to watch some tutorial and know about Imagine Location Picker but still confused so I choose background point the mouse to pick a spot then use that number on my screen? because I do not see my background in Imagine Location Picker.

Ana
Regular
Posts: 61
Joined: Sun Oct 12, 2014 5:56 pm
Contact:

Re: How to interact with screens

#2 Post by Ana »

If you want to create a textbox saying to 'go out' once, you can probably get away with just a menu. You can use menus for just one choice as well.

Code: Select all

    menu:
        "Go out.":
            jump go_out
Then you can probably pull out a screen with the world map by using the 'call screen' function:

Code: Select all

label go_out:
    call screen world_map
Once you do that, you can add an imagemap in the same type of area that you define your characters (i.e. before your game)

Code: Select all

screen world_map(): #this is how you prepare the imagemap
    imagemap:
        ground "image.jpg" 
This image is the world map image of whatever your world map looks like, and you can change the image.jpg to match whatever image you are using.

Then, you can add a hotspot directly below that:

Code: Select all

# this is the code for adding hotspots to your imagemap:
        hotspot (xcoordinate, ycoordinate, xsize, ysize) clicked Jump("gotoschool") hovered ShowTransient("schoolhover", school="school.jpg") unhovered Hide("schoolhover")
  • xcoodinate is the x coordinate of where that hotspot starts (i.e. "960").
  • ycoodinate is the y coordinate of where that hotspot starts.
  • xsize is how large your hotspot is horizontally, in pixels.
  • ysize is how large your hotspot is vertically, in pixels.
  • clicked Jump("gotoschool") allows you to jump to a label. You can replace 'gotoschool' with your label name.
  • If you press 'Shift+D', you can press 'Image Location Picker' and choose the image you are using for the worldmap image. You should have a list of images if you have put the images into the nameofyourvisualnovel/game/images folder. On the bottom left corner, you will get the coordinates on the screen.
I have also added how to add hovering and unhovering to show an image in the code. I just added in case you wanted to show an image when you hover.
  • hovered ShowTransient("schoolhover", school="school.jpg") allows you to show an image when hovering on the hotspot.
  • unhovered Hide("schoolhover") allows you to hide that image when not hovering on the hotspot.
  • These can all be removed if unneeded.
To add this image when hovering you would add another screen:

Code: Select all

#This is how you add images onto the imagemap when hovering.
screen schoolhover(school):
    add school pos (xcoordinate, ycoordinate)
Hopefully this helps!

Post Reply

Who is online

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