Difference between revisions of "Timer:pause"

From GiderosMobile
(Created page with "__NOTOC__ '''Available since:''' Gideros 2011.6<br/> '''Class:''' Timer<br/> === Description === Pauses the timer. <source lang="lua"> Timer:pause() </source> === Exampl...")
 
m (Text replacement - "</source>" to "</syntaxhighlight>")
 
(One intermediate revision by the same user not shown)
Line 5: Line 5:
 
=== Description ===
 
=== Description ===
 
Pauses the timer.
 
Pauses the timer.
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
Timer:pause()
 
Timer:pause()
</source>
+
</syntaxhighlight>
  
 
=== Example ===
 
=== Example ===
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
local pix = Pixel.new(0x00FFaa, 1, 64, 64)
 
local pix = Pixel.new(0x00FFaa, 1, 64, 64)
 
pix:setAnchorPoint(0.5, 0.5)
 
pix:setAnchorPoint(0.5, 0.5)
Line 27: Line 27:
 
timer:addEventListener(Event.TIMER, onTimer, timer)
 
timer:addEventListener(Event.TIMER, onTimer, timer)
 
timer:start()
 
timer:start()
</source>
+
</syntaxhighlight>
  
 
{{Timer}}
 
{{Timer}}

Latest revision as of 14:33, 13 July 2023

Available since: Gideros 2011.6
Class: Timer

Description

Pauses the timer.

Timer:pause()

Example

local pix = Pixel.new(0x00FFaa, 1, 64, 64)
pix:setAnchorPoint(0.5, 0.5)
pix:setPosition(128, 128)
stage:addChild(pix)

local timer = Timer.new(24, 360)

function onTimer(e)
	pix:setRotation(pix:getRotation() + 0.5)
	if pix:getRotation() > 90 then
		timer:pause()
	end
end

timer:addEventListener(Event.TIMER, onTimer, timer)
timer:start()