- Home /
Need help with enum and stuff (right, left click) in JavaScript
Hey,
im kind of new and was testing around but don't know how to bring my test to a success :/
actually i want it to be like there are no lower or upper limits for the values when clicking the mouse buttons, but when the last value is reached, the first value should be used again when clicking with the left mouse button. When the first value is reached, the last one should be used when clicking with the right mouse button. i hope everyone understands it because my english isn't that well.
For the Germans (also to understand me better): Ich möchte, dass es beim ausführen der Maustasten keine untere oder obere Grenzen für die Werte gibt, aber wenn der letzte Wert erreicht ist soll beim klicken mit der linken Maustaste wieder der erste Wert verwendet werden. Wenn der erste Wert erreicht wird, soll beim Klicken mit der rechten Maustaste wieder der letzte benutzt werden.
Here is the code i got so far:
enum speed {off, slow, normal, fast};
var objectSpeed : Speed = Speed.slow;
private var numberOfSpeed : int = System.Enum.GetValues(Speed).length - 1;
function Start () { }
function Update () { var mySpeed : int = parseInt(objectSpeed) * 100;
transform.Rotate(mySpeed * Time.deltaTime, 0, 0);
if (Input.GetMouseButtonDown(MouseButtons.left))
{
if (objectSpeed < numberOfSpeed)
objectSpeed = objectSpeed + 1;
}
else {
if (Input.GetMouseButtonDown(MouseButtons.right))
{
if (objectSpeed > 0)
objectSpeed = objectSpeed -1;
}
}
//Debug
Debug.Log(mySpeed + " " + objectSpeed); }
I hope you will be able to help me out :) <3