Get mouse position

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
MisterHarold
Regular
Posts: 51
Joined: Tue Jul 17, 2018 10:32 am
Location: Philippines
Contact:

Get mouse position

#1 Post by MisterHarold »

Is there an easier way to get the x and y pos of the mouse pointer?

Thanks.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3794
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Get mouse position

#2 Post by Imperf3kt »

Easier than what? What are you currently doing?
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
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-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: Get mouse position

#3 Post by Per K Grok »

MisterHarold wrote: Wed Mar 06, 2019 2:35 am Is there an easier way to get the x and y pos of the mouse pointer?

Thanks.
If you are looking for a way to check the x/y position in a scene, this could be a way.
You just click at the place you want the values for, and they will be written out at the top left corner

Code: Select all

default mX=0
default mY=0

screen checkMPos():
    text str(mX)+":"+str(mY)
    key "mousedown_1" action [SetVariable("mX",renpy.get_mouse_pos()[0]), SetVariable("mY", renpy.get_mouse_pos()[1])]

-----
-----
    show screen checkMPos

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]