/**
* name
*/
module game{
export class btnMove extends Laya.Button{
private speed:number = 5;
constructor(){
super();
Laya.init(640,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;
}
}
}
}