[]Laya.stage.mouseX; Laya.stage.mouseY取到的坐标用来赋给画曲线方法的起点;在左顶点正常,越往右下角起点就越偏移了
// 程序入口
class GameMain {
private ps: Laya.Sprite;
a: number;
b: number;
path: Array<number> = ;
constructor() {
Laya.init(1600, 1400);
Laya.stage.bgColor = "#000000";
this.ps = new Laya.Sprite();
Laya.stage.on(Laya.Event.MOUSE_DOWN, this, this.down2)
Laya.stage.on(Laya.Event.MOUSE_UP, this, this.up2)
Laya.stage.addChild(this.ps);
}
down2() {
this.a = Laya.stage.mouseX;
this.b = Laya.stage.mouseY;
console.log("鼠标点击的点" + this.a, this.b)
Laya.stage.on(Laya.Event.MOUSE_MOVE, this, this.move2)
}
move2() {
this.path.push(Laya.stage.mouseX, Laya.stage.mouseY);
// console.log("移动的点集合" + this.path);
this.ps.graphics.drawCurves(this.a, this.b, this.path, "#fff")
// console.log("222鼠标点击的点" + this.a, this.b)
}
up2() {
console.log("移动的点集合" + this.path);
// Laya.stage.off(Laya.Event.MOUSE_DOWN, this, this.down2)
Laya.stage.off(Laya.Event.MOUSE_MOVE, this, this.move2)
this.path=;
}
}
new GameMain();
class GameMain {
private ps: Laya.Sprite;
a: number;
b: number;
path: Array<number> = ;
constructor() {
Laya.init(1600, 1400);
Laya.stage.bgColor = "#000000";
this.ps = new Laya.Sprite();
Laya.stage.on(Laya.Event.MOUSE_DOWN, this, this.down2)
Laya.stage.on(Laya.Event.MOUSE_UP, this, this.up2)
Laya.stage.addChild(this.ps);
}
down2() {
this.a = Laya.stage.mouseX;
this.b = Laya.stage.mouseY;
console.log("鼠标点击的点" + this.a, this.b)
Laya.stage.on(Laya.Event.MOUSE_MOVE, this, this.move2)
}
move2() {
this.path.push(Laya.stage.mouseX, Laya.stage.mouseY);
// console.log("移动的点集合" + this.path);
this.ps.graphics.drawCurves(this.a, this.b, this.path, "#fff")
// console.log("222鼠标点击的点" + this.a, this.b)
}
up2() {
console.log("移动的点集合" + this.path);
// Laya.stage.off(Laya.Event.MOUSE_DOWN, this, this.down2)
Laya.stage.off(Laya.Event.MOUSE_MOVE, this, this.move2)
this.path=;
}
}
new GameMain();
没有找到相关结果
已邀请:
要回复问题请先登录
1 个回复
Monica - 知识达人
赞同来自: