Confused about TouchInput's actual update

Milena

The woman of many questions
Veteran
Joined
Jan 26, 2014
Messages
1,281
Reaction score
106
First Language
Irish
Primarily Uses
N/A
So I am trying to do a small TouchInput check.


What I did is something like this:


Scene_Title.prototype.updateTouchX = function() {
if (TouchInput.x >= Graphics.boxWidth - 20 || TouchInput.y >= Graphics.height - 20) {
// function here
} else {
// function here
}
}


Thing is, it does check what I want correctly and properly, however, my only gripe is that it ONLY checks it when I click the mouse. Is there a way to check the mouse's x and y without clicking? I mean a way to check the current, real time x and y of the mouse as is without clicking it?
 

Hudell

Dog Lord
Veteran
Joined
Oct 2, 2014
Messages
3,545
Reaction score
3,715
First Language
Java's Crypt
Primarily Uses
RMMZ
That's because TouchInput only stores the mouse position when you click, but it's easy to change that:


TouchInput._onMouseMove = function(event) {
var x = Graphics.pageToCanvasX(event.pageX);
var y = Graphics.pageToCanvasY(event.pageY);
if (this._mousePressed) {
this._onMove(x, y);
}
};


This is the original _onMouseMove method. You can store those x and y variables somewhere else, like this:


this.mouseX = x;
this.mouseY = y;


And then check those properties when you need the position without clicking.
 

Milena

The woman of many questions
Veteran
Joined
Jan 26, 2014
Messages
1,281
Reaction score
106
First Language
Irish
Primarily Uses
N/A
Thank you! This works wonders! Now I can do almost anything I want when I use the mouse.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,049
Members
137,569
Latest member
Shtelsky
Top