diff --git a/src/page/index/PushCoinGame/game/index.js b/src/page/index/PushCoinGame/game/index.js index e9b1be7..2402db8 100644 --- a/src/page/index/PushCoinGame/game/index.js +++ b/src/page/index/PushCoinGame/game/index.js @@ -55,9 +55,9 @@ class game { init(pointer) { this.vue = pointer; // 初始化画布 - // this.stage = new STAGE().createStage(this); + this.stage = new STAGE().createStage(this); //实例化layout - // this.VIEW = new LAYOUT(this); + this.VIEW = new LAYOUT(this); // 保存帧率 // this.saveMomentFPS = setInterval(() => { @@ -74,65 +74,10 @@ class game { // 初始化主资源加载器 - // this.loadingRes(); - - - // create an engine - this.myEngine = this.Engine.create(); - this.myWorld = this.myEngine.world; - - - // create a renderer - this.myRender = this.Render.create({ - element: this.vue.$refs.container, - engine: this.myEngine, - options: { - width: window.innerWidth, - height: window.innerHeight, - pixelRatio: 1, // 设置像素比 - showAngleIndicator: true, - wireframes: true, - showDebug: false - } - }); - - // create two boxes and a ground - var boxA = this.Bodies.rectangle(100, 200, 80, 80); - var boxB = this.Bodies.rectangle(150, 50, 80, 80); - var boxC = this.Bodies.rectangle(150, 50, 80, 80); - var boxD = this.Bodies.rectangle(150, 50, 80, 80); - var ground = this.Bodies.rectangle(0, 800, 750, 10, { isStatic: true }); - - // this.Composite.add(this.myWorld, [ - // this.Bodies.fromVertices( - // 0, 0, - // [ - // // 顶点坐标 - // { x: 0, y: 0 }, - // { x: 0, y: 890 }, - // { x: 140, y: 815 }, - // { x: 208, y: 614 }, - // { x: 548, y: 614 }, - // { x: 612, y: 815 }, - // { x: 750, y: 890 }, - // { x: 750, y: 0 } - // ], - // { isStatic: true } - // ) - // ]); - // add all of the bodies to the world - this.Composite.add(this.myWorld, [boxA, boxB, boxC, boxD, ground]); - - // create runner - this.Render.run(this.myRender); - - // run the engine - this.myRunner = this.Runner.create(); - this.Runner.run(this.myRunner, this.myEngine); - - - + this.loadingRes(); + // 初始化物理引擎 + this.initMatterEngine(); } @@ -238,6 +183,63 @@ class game { console.log(this.globalSpeed) } + // + initMatterEngine() { + // create an engine + this.myEngine = this.Engine.create(); + this.myWorld = this.myEngine.world; + + + // create a renderer + // this.myRender = this.Render.create({ + // element: this.vue.$refs.container, + // engine: this.myEngine, + // options: { + // width: window.innerWidth, + // height: window.innerHeight, + // pixelRatio: 1, // 设置像素比 + // showAngleIndicator: true, + // wireframes: true, + // showDebug: true + // } + // }); + + // create two boxes and a ground + var boxA = this.Bodies.rectangle(100, 200, 80, 80); + var boxB = this.Bodies.rectangle(150, 50, 80, 80); + var boxC = this.Bodies.rectangle(150, 50, 80, 80); + var boxD = this.Bodies.rectangle(150, 50, 80, 80); + var ground = this.Bodies.rectangle(0, 800, 750, 10, { isStatic: true }); + + // this.Composite.add(this.myWorld, [ + // this.Bodies.fromVertices( + // 0, 0, + // [ + // // 顶点坐标 + // { x: 0, y: 0 }, + // { x: 0, y: 890 }, + // { x: 140, y: 815 }, + // { x: 208, y: 614 }, + // { x: 548, y: 614 }, + // { x: 612, y: 815 }, + // { x: 750, y: 890 }, + // { x: 750, y: 0 } + // ], + // { isStatic: true } + // ) + // ]); + // add all of the bodies to the world + this.Composite.add(this.myWorld, [boxA, boxB, boxC, boxD, ground]); + + // create runner + // this.Render.run(this.myRender); + + // run the engine + // this.myRunner = this.Runner.create(); + // this.Runner.run(this.myRunner, this.myEngine); + this.Engine.run(this.myEngine); + } + //debug mode destroyed //game model diff --git a/src/page/index/PushCoinGame/game/view.js b/src/page/index/PushCoinGame/game/view.js index 4bb6de8..85bc290 100644 --- a/src/page/index/PushCoinGame/game/view.js +++ b/src/page/index/PushCoinGame/game/view.js @@ -95,6 +95,8 @@ class layout { // 创建粒子动画 this.createLoadingParticle(); + console.log(this.loading_bg) + return this }