How to set up a layered image map

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
Ryder
Newbie
Posts: 2
Joined: Thu Jun 27, 2019 5:32 pm
Contact:

How to set up a layered image map

#1 Post by Ryder » Thu Jun 27, 2019 5:42 pm

I am trying to set up an imagemap in Renpy, where I have a number of buttons, each which will trigger different action. That part I can do.

However, I also want to be able to delete buttons, depending on earlier choices. For example, in the initial imagemap, there will be six buttons, each of which triggers certain results. On of the results will be that the button, and the triggered event, will be deleted and no longer available, unless some other choice is later made which brings it back.

What's the best way to do this? I can layer buttons in separate png images over the base image, but I can't figure out how to manipulate the imagemap to remove the triggers if the button is deleted. I could probably manage this by calling different screens, depending on which buttons have been deleted, but that seems clumsy.

Any help would be much appreciated.

philat
Eileen-Class Veteran
Posts: 1692
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: How to set up a layered image map

#2 Post by philat » Thu Jun 27, 2019 9:11 pm

You can just use an if clause in the screen. You can also use imagebuttons instead if you'd prefer.

Code: Select all

screen blah():
    imagemap:
        # set images
        if var:
            hotspot # add various shit
        else:
            hotspot # add various other shit
    if var:
        imagebutton # stuff

User avatar
xavimat
Eileen-Class Veteran
Posts: 1436
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love, unknown
Organization: Pilgrim Creations
Github: xavi-mat
itch: xavimat
Location: Italy
Contact:

Re: How to set up a layered image map

#3 Post by xavimat » Fri Jun 28, 2019 6:37 am

You can use the action SensitiveIf() to control which hotspots are active and which ones are disabled:
https://www.renpy.org/doc/html/screen_a ... ensitiveIf

Code: Select all

default var = 1
screen test5():
    imagemap:
        ground Solid("#880", xysize=(310,110))
        idle Solid("#ff0", xysize=(310,110))
        hover Solid("#800", xysize=(310,110))
        hotspot (10,10,90,90) action [SensitiveIf(var==1), SetVariable("var", 2)]
        hotspot (110,10,90,90) action [SensitiveIf(var==2), SetVariable("var", 1)]
        hotspot (210,10,90,90) action [SensitiveIf(var==1), SetVariable("var", 2)]
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Cops&Robbers A two-player experiment
Fear&Love Why can’t we simply express our feelings? Why am I afraid to say ‘I love you’?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

Ryder
Newbie
Posts: 2
Joined: Thu Jun 27, 2019 5:32 pm
Contact:

Re: How to set up a layered image map

#4 Post by Ryder » Fri Jun 28, 2019 9:03 am

Thank you. Those solutions both look great. Much appreciated.

Post Reply

Who is online

Users browsing this forum: Google [Bot]