What I'd do to get a feel of how everything is set up is to do console.log() all over the place.
For example, if I'm not sure what _currentState is, then I'd either make an event that runs the script "console.log(Input._currentState)" or have something that logs currentState each time a button is pressed. For all I know, _currentState might be an integer (it's probably not).
But as for looping, do you mean you're not sure how to loop, or you're not sure what you'd be getting by looping through it? If it's the latter, try the console.log thing and see if anything occurs to you.
I have to double post to reply because it's so soon after and I don't want to necropost. Your code of Input._pressedTime > 0 is working it's just not working when I implement it into my code. Thank you, and I'm gonna search for what's wrong with my own script.
EDIT: So _pressedTime doesn't work, because it counts up the milliseconds, then never resets to 0 when no key is pressed. You would need it to reset to 0 if no key is pressed.
Input._currentState looks like this - > Object { right: true } (if right is pressed), so ...
What I need is like
if (Input._currentState is not empty)
And that's exactly what the loop above that I found on stackoverflow.com did. Here's the link:
http://stackoverflow.com/questions/135448/how-do-i-check-if-an-object-has-a-property-in-javascript
Okay, big update on this problem and for anyone that wants to solve this...
You can use Mjshi's suggestion of "
Input._pressedTime > 0", however you have to reset it back to 0 because it doesn't reset by itself. For example, if you press the up key and hold it and release it when the counter is at 100 (stands for milliseconds that the key was held), you will have to do "Input._pressedTime = 0" BEFORE you check for "Input._pressedTime > 0" in a conditional statement within an event, because it will just stay at 100 milliseconds.
Also, for anyone reading to solve this problem, you can use touchInput._pressedTime as well.
Thanks guys and happy coding. ; p
P.S, what I did in the end is like the following (warning, it is not aliased):
//Add _mousePressed to right click also.
TouchInput._onRightButtonDown = function(event) {
var x = Graphics.pageToCanvasX(event.pageX);
var y = Graphics.pageToCanvasY(event.pageY);
if (Graphics.isInsideCanvas(x, y)) {
this._mousePressed = true;
this._onCancel(x, y);
}
};
TouchInput._onMouseUp = function(event) {
if (event.button === 0) {
var x = Graphics.pageToCanvasX(event.pageX);
var y = Graphics.pageToCanvasY(event.pageY);
this._mousePressed = false;
this._onRelease(x, y);
}
if (event.button === 2) {
this._mousePressed = false;
this._onRelease(x, y);
}
};
this was thrown inside of a .js file in the plugin folder. This allows you to check for both left and right clicks using TouchInput.isTriggered() and TouchInput.isCancelled().
In my event I put this in the page before the conditional is checked:
Script : TouchInput._pressedTime = 0;
Script : Input._pressedTime = 0;
Then on the page where it checks for input it's:
If : Script : Input._pressedTime > 0 || TouchInput._pressedTime > 0
do specific key checks in here. Now in here you can go "If, then, else" where as before you would have to have tons of conditions.
End