Commit 15785ead authored by wildfirecode13's avatar wildfirecode13

11

parent 43c6df38
......@@ -55,7 +55,7 @@
var canvas = document.getElementById("canvas");
canvas.width = document.body.clientWidth * (window.devicePixelRatio || 1)
canvas.height = document.body.clientHeight * (window.devicePixelRatio || 1)
var main = new Main(canvas,{level:1,time:999920});
var main = new Main(canvas,{level:8,time:999920});
console.log(main.stage)
var mouseEvent = main.stage.onMouseEvent.bind(main.stage);
canvas.addEventListener("touchstart", mouseEvent, false);
......
......@@ -29,11 +29,12 @@ export default class FreeScroll extends FYGE.Container {
this.addEventListener(FYGE.MouseEvent.MOUSE_DOWN, (e) => {
let offset = [e.stageX - this.view.x, e.stageY - this.view.y];
//加移动事件
this.addEventListener(FYGE.MouseEvent.MOUSE_MOVE, move, this)
this.addEventListener(FYGE.MouseEvent.MOUSE_UP, up, this)
this.addEventListener(FYGE.MouseEvent.MOUSE_OUT, up, this)
this.stage.addEventListener(FYGE.MouseEvent.MOUSE_MOVE, move, this)
this.stage.addEventListener(FYGE.MouseEvent.MOUSE_UP, up, this)
this.stage.addEventListener(FYGE.MouseEvent.MOUSE_OUT, up, this)
//移动
function move(me) {
console.log(1111)
//赋值
this.view.position.set(me.stageX - offset[0], me.stageY - offset[1])
//x有限制
......@@ -44,9 +45,9 @@ export default class FreeScroll extends FYGE.Container {
if (this.view.y > 0) this.view.y = 0;
}
function up() {
this.removeEventListener(FYGE.MouseEvent.MOUSE_MOVE, move, this);
this.removeEventListener(FYGE.MouseEvent.MOUSE_UP, up, this);
this.removeEventListener(FYGE.MouseEvent.MOUSE_OUT, up, this);
this.stage.removeEventListener(FYGE.MouseEvent.MOUSE_MOVE, move, this);
this.stage.removeEventListener(FYGE.MouseEvent.MOUSE_UP, up, this);
this.stage.removeEventListener(FYGE.MouseEvent.MOUSE_OUT, up, this);
}
}, this)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment