Store mouse coordinate XY in variables [Solved]

Status
Not open for further replies.

Lakaroth

Veteran
Veteran
Joined
Dec 9, 2014
Messages
274
Reaction score
132
First Language
English
Primarily Uses
Hello there i'm trying to store in 2 varabiles the XY mouse coordinate, something like that, but i receive result as Zero, they are the wrong variable?

Also, how can i identify the "Mouse Press" button?
I need that in order to define some clickable areas, like a menù in pictures.
Best.

EDIT: Ok it Works!
It's case sensitive, so the X and Y must be x y no Uppercase.
How can i define IF CLICK?
 
Last edited by a moderator:

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,696
Reaction score
935
First Language
English
Primarily Uses
N/A
I see you found out it's case sensitive, nicely done :)

For checking if the player has clicked, you'll probably want to try TouchInput.isTriggered(), which will return true if the mouse was just pressed down, or a touch screen was just pressed. This only is true once per time, so click and holding the mouse button will only return true once.

To see if the player is holding the mouse down, or their finger on a touch screen, use TouchInput.isPressed().

Please note that in both cases, you will need to check the mouse position to see specifically where it was pressed, as this only returns true or false, not the position it was pressed.
 

Lakaroth

Veteran
Veteran
Joined
Dec 9, 2014
Messages
274
Reaction score
132
First Language
English
Primarily Uses
I see you found out it's case sensitive, nicely done :)

For checking if the player has clicked, you'll probably want to try TouchInput.isTriggered(), which will return true if the mouse was just pressed down, or a touch screen was just pressed. This only is true once per time, so click and holding the mouse button will only return true once.

To see if the player is holding the mouse down, or their finger on a touch screen, use TouchInput.isPressed().

Please note that in both cases, you will need to check the mouse position to see specifically where it was pressed, as this only returns true or false, not the position it was pressed.
Perfect it works!!!

If anyonw need is like this

Best

Lakaroth
 
Last edited by a moderator:

JareX

Veteran
Veteran
Joined
Dec 30, 2013
Messages
33
Reaction score
8
First Language
Spanish
Primarily Uses
Thanks Lakaroth for asking this because I had a similar issue.

I'm trying to build a custom menu, and I want to make some portions of the screen trigger an event while the mouse is there.

For that I'm now using the mouse coordinates thanks to you.

But I have one problem.

If I click on the desired area the event is triggered, but I want it to activate while hovering the mouse on that area

The problem is that the coordinates of the variable are only updated when the mouse is clicked

So, the question is: How do I make the variables update without the need of the mouse click, or else how do I create a conditional branch that triggers when the mouse hovers over an area of the screen?

PD: Sorry to ask this here, but I think you have this answer.
 

Lakaroth

Veteran
Veteran
Joined
Dec 9, 2014
Messages
274
Reaction score
132
First Language
English
Primarily Uses
Thanks Lakaroth for asking this because I had a similar issue.

I'm trying to build a custom menu, and I want to make some portions of the screen trigger an event while the mouse is there.

For that I'm now using the mouse coordinates thanks to you.

But I have one problem.

If I click on the desired area the event is triggered, but I want it to activate while hovering the mouse on that area

The problem is that the coordinates of the variable are only updated when the mouse is clicked

So, the question is: How do I make the variables update without the need of the mouse click, or else how do I create a conditional branch that triggers when the mouse hovers over an area of the screen?

PD: Sorry to ask this here, but I think you have this answer.
 Humm... i see, this is really out of my range i'm not a Javascript programmer, but i want let you think about this:

Are you planning for a mobile version too?

Because even if you find a way to updates mouse position coordinates, this work on PC or Web etc etc

BUT think a mobile game, you don't have the cursor so how can you do that?

I don't know if u'r planning for a commercial game, in that case you need to realize how many "clients" you can lost without a mobile porting.

Anyway, i think there ust be a way to update mouse cordinates maybe with mouse system ex i tryi some variable but dont work, ask to the guy who made the plugin!

Best!
 

CynicSyndrome

Veteran
Veteran
Joined
May 4, 2017
Messages
57
Reaction score
39
First Language
English
Primarily Uses
RMMV
this method stores pixel coordinates, how do you store grid coordinates??
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,713
First Language
English
Primarily Uses
RMVXA
[necro]Member[/necro]
In addition this is a different query. Please post a new thread.
 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

I should realize that error was produced by a outdated version of MZ so that's why it pop up like that
Ami
i can't wait to drink some ice after struggling with my illness in 9 days. 9 days is really bad for me,i can't focus with my shop and even can't do something with my project
How many hours have you got in mz so far?

A bit of a "sparkle" update to the lower portion of the world map. :LZSexcite:
attack on titan final season is airing tomorrow, I'm excited and scared at the same time!

Forum statistics

Threads
105,882
Messages
1,017,231
Members
137,607
Latest member
Maddo
Top