(Intermediate) 1. Timers
Login
-
Join
Home
Games
Game Engine
Resources
Tutorials
Description:
Learn how to create a counter using a timer. Also explains how to remove a timer.
Author:
LastEnd
Topic:
Scripting
Last Tutorial:
(Beginner) 9. Classes
Script:
Scripting_RegisterClass("engine") Scripting_RegisterClass("ui") count = 0 -- Do not edit this method. It is generated by the visual designer function InitializeComponent() dialog = UI.Dialog.Add("dialog", 0, 0, 1328, 700, true, -16777216, -16777216, -16777216, -16777216, 0, -987833, "", 0, false, true, true, false, true, "Arial", 24, false, false) lblCount = UI.Label.Add("lblCount", dialog, [[0]], 142, 68, 87, 43, 0, 0, "Segoe UI", 36, true, false, -1) UI.Label.SetAlign(dialog, lblCount, "Center") Window_Resize() end--* -- Do not edit this method. It is generated by the visual designer function Window_Resize() local _width = Engine.GetWindowWidth() local _height = Engine.GetWindowHeight() UI.Dialog.SetSize(dialog, _width, _height) end--* function countIt() count = count + 1 UI.Label.SetText(dialog, lblCount, count) if count == 10 then Engine.RemoveTimer("timerCount") UI.Label.SetText(dialog, lblCount, "Done") end end function init() InitializeComponent() Engine.AddTimer(1000, "countIt()", "timerCount") end init()
ALL COMMENTS (
0
)
You need to
LOGIN
or
SIGN UP
before you can post comments.
Policy
-
Support
-
Contact
-
Terms of Service
-
Lost Serial
-
Site Map
-
Feedback