Clickable areas for all

A place for Ren'Py tutorials and reusable Ren'Py code.
Forum rules
Do not post questions here!

This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Post Reply
Posts: 8
Joined: Sun Apr 14, 2019 4:12 am
Github: 0Shie0
itch: shie

Clickable areas for all

#1 Post by Shie » Thu Jun 20, 2019 1:26 pm

I recently get known, that people need clickable areas, so i hope this will be usefull for someone. Forgive me for my poor english
I make all in 4 sections:
2)My explanation
3)Similiar from Renpy Cookbock
4)What i used from Renpy documentation

Here is code

Code: Select all

screen crime_scene:
    add "bg_crime.png"
        auto "left_%s.png"
        focus_mask "left_mask.png"
        mouse 'closer'
        action [Hide("crime_scene"),Show("left")]
        xpos 280
        ypos 330
        auto "pers1_%s.png"
        mouse "talk"
        focus_mask "pers1_mask.png"
        action [Hide("crime_scene"),Call("pers1")]

screen left:
        idle "black.png"
        action [Show("crime_scene"), Hide("left")]
    text "Here like in previos room, but i didnt maked it" xalign 0.5 yalign 0.5

label pers1:
    scene bg_crime
    show pers1
    "What do you want? I am busy."
    hide pers1
    call screen crime_scene
And here is cod for mouse

Code: Select all

define config.mouse = {"default":[ ("gui/cursor.png", 1, 1) ],
                       "closer":[ ("gui/cursor_closer.png", 20, 20) ],
                       "seek":[ ("gui/cursor_seek.png", 20, 20) ],
                       "talk":[ ("gui/cursor_talk.png", 20, 15) ]}
I use imagemaps as clickable areas - after you click it it move you to next point of game - screen(with Show) or label(with Call)
auto is used for automatic select images, it replaced %s with "idle" or "hover" or other
focus_mask is used for defining clickable area - for more accurate, than just with imagebutton. String after docus_mask is name of image, in which non-transparent places are sensitive. It is really usefull, if you get 2 objects, that cross each other.
mouse is used for changing mouse pointer. String after mouse define which you use, and pointer you can use you define with config.mouse.

Here is other similiar methods or code i found in cookboock
viewtopic.php?f=51&t=20541#p265137 - here is used imagebuttons as object you can take, but it is old
viewtopic.php?f=51&t=22565#p284753 - here imagebuttons explained way more better, then i can do
viewtopic.php?f=51&t=17933#p234782 - here is mouse, but not like i used it
viewtopic.php?f=8&t=37403#p404987 - same situation

And here are Renpy Documentation, that i used for my screen: ... magebutton - about imagebutton and auto ... l?#actions - about Show, Hide and other screen actions ... nfig.mouse - about config.mouse ... properties - about mouse and more focus_mask

Post Reply

Who is online

Users browsing this forum: No registered users