/**
* name
*/
module game{
export class btnMove extends Laya.Button{
private speed:number = 5;
constructor(){
super();
Laya.init(0,860,WebGL);
console.log("this = " + typeof(this.name));
this.on(Laya.Event.MOUSE_DOWN,this,this.onClick);
}
private onClick():void{
let hero:Laya.Image; //= this.parent.getChildByName("hero1") as Laya.Image;
//需要强装类型
hero = this.parent.getChildByName("hero1") as Laya.Image;
if (this.name == "btnforMoveRight") {
console.log("btn = " + this.name);
hero.x += this.speed;
hero.scaleX = 1;
}
else if (this.name == "btnforMoveLeft") {
console.log("btn = " + this.name);
hero.x -= this.speed;
hero.scaleX = -1;
}
}
}
}
因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- awee.cn 版权所有 湘ICP备2023022495号-5
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务