按钮添加事件
this.owner.on(Laya.Event.CLICK,this.owner,function(){console.log("ok")}); export default class Test extends Laya.Script { constructor() { super(); } private self: any = null; onAwake(){ this.self = this.owner; this.self.clickHandler = Laya.Handler.create(this,this.on_button_click,null,false); } on_button_click(): void { console.log("ok"); } } TS位置/宽高/缩放/顶点
export default class Test extends Laya.Script { constructor() { super(); } private self: any = null; onAwake(){ this.self = this.owner; this.self.pos(200,200).size(100,100).scale(5,5).pivot(50,50); } }transform
export default class Test extends Laya.Script { constructor() { super(); } private self: any = null; onAwake(){ this.self = this.owner; let mtx = Laya.Matrix.create(); this.self.transform = mtx; this.self.transform.translate(200,200); this.self.transform.scale(2,2); } }坐标转换
局部转全局
export default class Test extends Laya.Script { constructor() { super(); } private self: any = null; onAwake(){ this.self = this.owner; let p = Laya.Point.create(); p.x = 0; p.y = 0; this.self.localToGlobal(p,false); console.log(p); } }全局转局部
export default class Test extends Laya.Script { constructor() { super(); } private self: any = null; onAwake(){ this.self = this.owner; let p = Laya.Point.create(); p.x = 10; p.y = 10; this.self.globalToLocal(p,false); console.log(p); } }本地转父节点
export default class Test extends Laya.Script { constructor() { super(); } private self: any = null; onAwake(){ this.self = this.owner; let p = Laya.Point.create(); p.x = 0; p.y = 0; this.self.toParentPoint(p); console.log(p); } }父节点转本地
export default class Test extends Laya.Script { constructor() { super(); } private self: any = null; onAwake(){ this.self = this.owner; let p = Laya.Point.create(); p.x = 100; p.y = 100; this.self.fromParentPoint(p); console.log(p); } }舞台转本地
export default class Test extends Laya.Script { constructor() { super(); } private self: any = null; onAwake(){ this.self = this.owner; let p = Laya.Point.create(); p.x = 100; p.y = 100; this.self.fromStagePoint(p); console.log(p); } }