Author Topic: Repeat button on javascript  (Read 2003 times)

alcohollica

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Repeat button on javascript
« on: August 03, 2014, 07:54:53 AM »
Hey guys, I have a question I don't know C# programming language so I work in JS, I use free NGUI version.According to my research I found something.I want to make repeat button in JS but all repeat button example is in C#

using UnityEngine;

  1. public class RepeatButtons : MonoBehaviour
  2. {
  3.     public float delay = 1.00f;
  4.     public float interval = 0.25f;
  5.  
  6.     bool mIsPressed = false;
  7.     float mNextClick = 0f;
  8.  
  9.     void OnPress (bool isPressed)
  10.     {
  11.         mIsPressed = isPressed;
  12.         mNextClick = Time.realtimeSinceStartup + delay;
  13.  
  14.         // Perform action as soon as button is pressed.
  15.         if (isPressed)
  16.             PerformAction();
  17.     }
  18.    
  19.     void Update ()
  20.     {
  21.         // Adjusted condition slightly...
  22.         if (mIsPressed && Time.realtimeSinceStartup >= mNextClick)
  23.         {
  24.             mNextClick = Time.realtimeSinceStartup + interval;
  25.             PerformAction();
  26.         }
  27.     }
  28.  
  29.     void PerformAction() {
  30.         //Do something
  31.     }
  32. }

And I make this in Javascript how I do it? I hope to understand what I mean. Thank you :)