[LayaAir 1.0]圆环不跟随 sprite 一起缩放?
直线可跟随滚轮缩放, 圆环不缩放,具体见代码
import WebGL = Laya.WebGL;
import Browser = Laya.Browser;
import Point = Geometry.Point;
// 程序入口
class GameMain{
constructor()
{
Laya.init(Browser.width, Browser.height, WebGL);
this.CreateCircle();
// this.CreateRectangle();
}
private firstSp: Laya.Sprite;
private _adaptSp: Laya.Sprite;
private _pointList : Point[];
private _rootSp : Laya.Sprite;
public CreateCircle() {
this._rootSp = new Laya.Sprite();
this.firstSp = new Laya.Sprite();
this.firstSp.graphics.drawRect(0, -100, 200, 200, null, "#ffffff");
this.firstSp.graphics.drawLine(0, 0, 100, 100, "#ffffff", 5);
this.firstSp.graphics.drawCircle(100, 100, 20, null, "ffffff");
Laya.stage.on(Laya.Event.MOUSE_WHEEL, this, this.MouseWheel);
this._rootSp.hitArea = new Laya.Rectangle(0, 0, 10000, 10000)
this._rootSp.addChild(this.firstSp);
Laya.stage.addChild(this._rootSp);
}
private MouseWheel(e: Laya.Event) {
let xs = this.firstSp.scaleX;
if (e.delta > 0) {
xs = xs * 1.2;
}
else {
xs /= 1.2;
}
this.firstSp.scale(xs, xs);
}
}
new GameMain();
import WebGL = Laya.WebGL;
import Browser = Laya.Browser;
import Point = Geometry.Point;
// 程序入口
class GameMain{
constructor()
{
Laya.init(Browser.width, Browser.height, WebGL);
this.CreateCircle();
// this.CreateRectangle();
}
private firstSp: Laya.Sprite;
private _adaptSp: Laya.Sprite;
private _pointList : Point[];
private _rootSp : Laya.Sprite;
public CreateCircle() {
this._rootSp = new Laya.Sprite();
this.firstSp = new Laya.Sprite();
this.firstSp.graphics.drawRect(0, -100, 200, 200, null, "#ffffff");
this.firstSp.graphics.drawLine(0, 0, 100, 100, "#ffffff", 5);
this.firstSp.graphics.drawCircle(100, 100, 20, null, "ffffff");
Laya.stage.on(Laya.Event.MOUSE_WHEEL, this, this.MouseWheel);
this._rootSp.hitArea = new Laya.Rectangle(0, 0, 10000, 10000)
this._rootSp.addChild(this.firstSp);
Laya.stage.addChild(this._rootSp);
}
private MouseWheel(e: Laya.Event) {
let xs = this.firstSp.scaleX;
if (e.delta > 0) {
xs = xs * 1.2;
}
else {
xs /= 1.2;
}
this.firstSp.scale(xs, xs);
}
}
new GameMain();
没有找到相关结果
已邀请:
1 个回复
青刀快马
赞同来自: 180*****391
Laya.init(Browser.width, Browser.height);