UI.Bar: Difference between revisions

From GiderosMobile
Created page with "__NOTOC__ === Description === Create a Bar widget. <syntaxhighlight lang="lua"> UI.Bar.new(maximum) </syntaxhighlight> === Parameters === '''maximum''': (number) the bar max..."
 
No edit summary
Line 1: Line 1:
__NOTOC__
__NOTOC__
=== Description ===
=== Description ===
Create a Bar widget.
Create a Bar widget.

Revision as of 14:51, 13 October 2023

Description

Create a Bar widget.

UI.Bar.new(maximum)

Parameters

maximum: (number) the bar maximum value

Functions

setValue: (number) sets the bar current value
setMaximum: (number) sets the bar maximum value
setSize: (number, number) sets the bar size

Example

local maxvalue = 200
local value = 102
local gui = UI.Bar.new(maxvalue)
gui:setSize(400, 32)
gui:setPosition(64,64)
stage:addChild(gui)

local way = 1
stage:addEventListener(Event.ENTER_FRAME, function(e)
	value += 3*way
	if value < 0 then way=1 end
	if value > maxvalue then way=-1 end
	gui:setValue(value)
end)