标签:get target private OLE eve for tar mouse lex
private MouseWheel(e: Laya.Event) { console.log("event"); let currentSp = e.target as Laya.Sprite; let parentSp = currentSp.parent as Laya.Sprite; console.log("before scale"); console.log(parentSp.mouseX, parentSp.mouseY); this.Zoom(currentSp, parentSp.mouseX, parentSp.mouseY, e.delta); } private Zoom(sp: Laya.Sprite, x: number, y: number, delta: number) { let oldScale = sp.scaleX; let scale = delta > 0 ? 1.1:1/1.1; let newScale = sp.scaleX * scale; // newScale = newScale < 0.1 ? 0.1 : (newScale > 5 ? 5 : newScale); // 获取在缩放比例下,光标相对偏移位置 sp.x = sp.x - (x - sp.x) * (newScale - oldScale) / oldScale; sp.y = sp.y - (y - sp.y) * (newScale - oldScale) / oldScale; sp.scale(newScale, newScale); } }
标签:get target private OLE eve for tar mouse lex
原文地址:https://www.cnblogs.com/yaolin1228/p/10293753.html