Wait for a mouse click function

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
FlipTopBin
Newbie
Posts: 12
Joined: Thu Apr 12, 2018 5:55 am
Contact:

Wait for a mouse click function

#1 Post by FlipTopBin » Mon Nov 18, 2019 8:36 am

Hi All,

I am looking for a way to wait for a mouseclick and then see the coordinates of the click. I was hoping for something nice and easy like:

$ x, y = renpy.waitForMouseClick()

But no such luck it seems.

I found pause and get_mouse_pos() but pause will continue after a keypress as well and I need an actual click.

The use case is a background image with an invisible grid over the top of it. Think of an RPG Maker map. I need the user to click on the image and some areas will activate things and others won't. I am currently porting a game from RPGM so please don't ask me to use that instead.

User avatar
Per K Grok
Miko-Class Veteran
Posts: 556
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1
Projects: Defenders of Adacan Part 2
Deviantart: pekj
itch: per-k-grok
Location: Sverige
Contact:

Re: Wait for a mouse click function

#2 Post by Per K Grok » Mon Nov 18, 2019 1:15 pm

FlipTopBin wrote:
Mon Nov 18, 2019 8:36 am
Hi All,

I am looking for a way to wait for a mouseclick and then see the coordinates of the click. I was hoping for something nice and easy like:

$ x, y = renpy.waitForMouseClick()

But no such luck it seems.

I found pause and get_mouse_pos() but pause will continue after a keypress as well and I need an actual click.

The use case is a background image with an invisible grid over the top of it. Think of an RPG Maker map. I need the user to click on the image and some areas will activate things and others won't. I am currently porting a game from RPGM so please don't ask me to use that instead.
For clicking on areas and get different actions you can use screens, imagemaps with hotspots and maybe buttons.

That's worth getting familiar with before you test other solutions.

https://www.renpy.org/doc/html/screens. ... ht=screens


If you want to do something outside the normal renpy solutions these threads might be of some help.
If you are going to use clicks outside buttons or hotspots you need to be aware of the rollback side function.

viewtopic.php?f=51&t=57299
viewtopic.php?f=51&t=53333

But I would recommend to start with imagemap with hotspots.
Image Visual Story Telling, DeviantArt Group for animations, comics, games and illustrations https://www.deviantart.com/acgi

Post Reply

Who is online

Users browsing this forum: deltadidirac, Google [Bot]