Skip to content

类: ProgressBar

进度条

示例

ts
const progressbar = new LM.ProgressBar()
 // 设置颜色类型  0 是图片类型
   progressbar.sourceType = 1
   // 设置尺寸
   progressbar.w = 200
   progressbar.h = 40
   // 设置最大进度
   progressbar.max = 100
   // 设置当前进度
   progressbar.current = 30
   // 设置方向
   progressbar.direction = 0
   // 设置进度颜色
   progressbar.progress = "#00FF00"
   // 设置背景颜色
   progressbar.background = "#FF0000"
   // 设置进度条的边框
   progressbar.progress_padding = 3

继承

构造函数

构造函数

new ProgressBar(params?): ProgressBar

参数

params?

any

返回

ProgressBar

重写了

UIBaseView.constructor

属性

属性类型描述

alias

string

别名 用于标识/获取组件

示例

ts
let img = new LM.ImgView()
// 给控件起一个名字
img.alias = "img01"

alpha

number

对象的透明度

Range

示例

let img = new LM.ImgView()
// 修改透明度
img.alpha = 100

background

string

下层资源 图片链接或者颜色

backgroundColor

string

背景色

示例

ts
let img = new LM.ImgView()
// 修改控件的背景色
img.backgroundColor = "#FF0000"

current

number

当前值

direction

0 | 1 | 2 | 3

进度方向 0-3 对应左右上下

h

number

已被弃用

自v1.3.0起废弃,请使用新的height 对象的宽度 宽高都被设置时才会生效

示例

obj.h = 100

height

number

容器高度(不建议直接使用)

isPenetrable

boolean

是否可穿透 默认可穿透 当使用Container创建父子级关系时 需要把自己穿透都打开才能触发到Container的点击事件

max

number

最大值

mouseThrough

boolean

已被弃用

自v1.3.0起废弃,请使用新的 isPenetrable 是否可穿透 默认可穿透 当使用Container创建父子级关系时 需要把自己穿透都打开才能触发到Container的点击事件

progress

string

上层资源 图片链接或者颜色

progress_padding

number

内边距

scaleX

number

x轴缩放

Range

scaleY

number

y轴缩放

Range

sourceType

0 | 1

资源类型 0:为图片 1:颜色

touchEable

boolean

已被弃用

自v1.3.0起废弃,请使用新的touchEnabled 是否可点击(默认可点击)

touchEnabled

boolean

是否可点击(默认可点击)

visible

boolean

组件是否可见

示例

ts
let img = new LM.ImgView()
// 隐藏该控件
img.visible = false

w

number

已被弃用

自v1.3.0起废弃,请使用新的width 对象的宽度 宽高都被设置时才会生效

示例

obj.w = 100

width

number

容器宽度(不建议直接使用)

worldX

number

对象的全局x坐标 (建议不要频繁设置获取,相较于x比较耗性能)

worldY

number

对象的全局y坐标 (建议不要频繁设置获取,相较于y比较耗性能)

x

number

对象的x坐标

示例

obj.x = 100

y

number

对象的y坐标

示例

obj.y = 100

z

number

对象的层级

示例

let img = new LM.ImgView()
this.addChild(img) //注意:需要先添加到父容器后再设置层级,否则层级设置无效。
img.z = 100

zoomCenterX

number

縮放中心点x 默认为0

Range

zoomCenterY

number

縮放中心点y 默认为0

Range

zoomX

number

x轴缩放

Range

zoomY

number

y轴缩放

Range

方法

addChild()

addChild<T>(child): void

添加一个子对象

类型参数

T

T extends UIBaseView

参数

child

T

返回

void

示例

ts
// 声明一张图片
let img = new LM.ImgView()
// 设置图片的路劲
img.src = "ui/bg.png"
// 添加到当前容器中
this.addChild(img)

继承自

UIBaseView.addChild


click()

click(fn): any

参数

fn

Function

返回

any

已被弃用

自v1.3.0起废弃,请使用新的onClick 点击行为

示例

ts
let img = new LM.ImgView()
// 为这张图片注册了点击事件
img.click( 
   () => {
     console.log("点击了改控件")
   }
)

继承自

UIBaseView.click


dispose()

dispose(): void

销毁组件

返回

void

继承自

UIBaseView.dispose


getParent()

getParent(): UIBaseView

获取父级

返回

UIBaseView

继承自

UIBaseView.getParent


getSaveData()

getSaveData(): any

获取组件的存档信息

返回

any

继承自

UIBaseView.getSaveData


onClick()

onClick(fn): any

点击行为

参数

fn

Function

返回

any

示例

ts
let img = new LM.ImgView()
// 为这张图片注册了点击事件
img.onClick( 
   () => {
     console.log("点击了改控件")
   }
)

继承自

UIBaseView.onClick


onTouchCancel()

onTouchCancel(fn): any

鼠标移出

参数

fn

Function

返回

any

示例

ts
let img = new LM.ImgView()
// 注册了移出事件
img.touchOut(()=>{console.log("移出")})

继承自

UIBaseView.onTouchCancel


onTouchDown()

onTouchDown(fn): any

按下行为

参数

fn

Function

返回

any

示例

ts
let text = new LM.TextView()
// 注册了按下事件
text.onTouchDown(()=>{console.log("按下")})

继承自

UIBaseView.onTouchDown


onTouchMove()

onTouchMove(fn): any

鼠标移动行为

参数

fn

Function

返回

any

示例

ts
let text = new LM.TextView()
// 注册了移动事件
text.onTouchMove(()=>{console.log("移动了")})

继承自

UIBaseView.onTouchMove


onTouchUp()

onTouchUp(fn): any

抬起行为

参数

fn

Function

返回

any

示例

ts
let img = new LM.ImgView()
// 注册了抬起事件
img.onTouchUp(()=>{console.log("抬起")})

继承自

UIBaseView.onTouchUp


removeFromParent()

removeFromParent(): void

从父级移除

返回

void

继承自

UIBaseView.removeFromParent


touchCancel()

touchCancel(fn): any

参数

fn

Function

返回

any

已被弃用

自v1.3.0起废弃,请使用新的onTouchCancel 鼠标移出

示例

ts
let img = new LM.ImgView()
// 注册了移出事件
img.touchOut(()=>{console.log("移出")})

继承自

UIBaseView.touchCancel


touchDown()

touchDown(fn): any

参数

fn

Function

返回

any

已被弃用

自v1.3.0起废弃,请使用新的onTouchDown 按下行为

示例

ts
let text = new LM.TextView()
// 注册了按下事件
text.touchDown(()=>{console.log("按下")})

继承自

UIBaseView.touchDown


touchMove()

touchMove(fn): any

参数

fn

Function

返回

any

已被弃用

自v1.3.0起废弃,请使用新的onTouchMove 鼠标移动行为

示例

ts
let text = new LM.TextView()
// 注册了移动事件
text.touchMove(()=>{console.log("移动了")})

继承自

UIBaseView.touchMove


touchUp()

touchUp(fn): any

参数

fn

Function

返回

any

已被弃用

自v1.3.0起废弃,请使用新的onTouchUp 抬起行为

示例

ts
let img = new LM.ImgView()
// 注册了抬起事件
img.touchUp(()=>{console.log("抬起")})

继承自

UIBaseView.touchUp