onDragEnd(){
//console.info(this.sp.x+"==="+this.sp.y);
//console.info(this.sp.pivotX+"==="+this.sp.pivotY);
let dx:number = 450 - this.sp.x;
let dy:number = 700 - this.sp.y;
console.info(dx+"<>"+dy);
this.sp.pivotX += dx;
this.sp.pivotY += dy;
this.sp.x += dx;
this.sp.y += dy;
}
onkeydown(){
if(this.sp.scaleX>1.2){
this.sp.scale(1,1);
}else{
this.sp.scale(1.5,1.5);
}
}
private sp:Laya.Sprite;
private lastDistance: number = 0;
constructor() {
Laya.init(900, 1400);
Laya.loader.load([{ url: "res/atlas/comp.atlas", type: Loader.ATLAS }], Handler.create(this, this.onLoaded));
Laya.stage.scaleMode = Laya.Stage.SCALE_EXACTFIT;
Laya.stage.on(Laya.Event.MOUSE_UP, this, this.onMouseUp);
Laya.stage.on(Laya.Event.KEY_DOWN,this,this.onkeydown);
}
onLoaded(){
this.sp = new Laya.Sprite;
this.sp.loadImage("comp/map.jpg");
this.sp.pivot(450,700)
this.sp.pos(450,700);
this.sp.on(Laya.Event.MOUSE_DOWN, this, this.onMouseDown);
this.sp.on(Laya.Event.DRAG_END,this,this.onDragEnd);
Laya.stage.addChild(this.sp);
}
太晚了 明天有時間的話 編輯此文