Commit 335b1357 authored by wildfirecode's avatar wildfirecode

1

parent 973419b0
module.exports = { module.exports = {
devPort: 8080 devPort: 8080,
proxy: {
'/ngapi/*': 'http://localhost:3000',
'/plugin/*': 'http://localhost:3000',
'/ngame/*': 'http://localhost:3000',
'/activityCommon/*': 'http://localhost:3000',
'/ctool/*': 'http://localhost:3000',
'/activityVist/*': 'http://localhost:3000',
'/collectGoods/*': 'http://localhost:3000',
'/activityPlugDrawInfo/*': 'http://localhost:3000',
'/collectRule/*': 'http://localhost:3000',
'/hdtool/*': 'http://localhost:3000',
'/activityPlugin/*': 'http://localhost:3000',
'/summer/*': 'http://localhost:3000'
}
} }
// const path = require('path'); // const path = require('path');
......
...@@ -3,6 +3,7 @@ import Ball from "./Ball"; ...@@ -3,6 +3,7 @@ import Ball from "./Ball";
import World from "./World"; import World from "./World";
import { FACTOR } from "./consts"; import { FACTOR } from "./consts";
import Brick from "./Brick"; import Brick from "./Brick";
import Wall from "./Wall";
export default class Gun extends egret.Sprite { export default class Gun extends egret.Sprite {
_root: egret.DisplayObjectContainer; _root: egret.DisplayObjectContainer;
...@@ -24,7 +25,7 @@ export default class Gun extends egret.Sprite { ...@@ -24,7 +25,7 @@ export default class Gun extends egret.Sprite {
const ball = this.addBall(); const ball = this.addBall();
ball.mass = 0; ball.mass = 0;
this._world.bodies.forEach(body => { this._world.bodies.forEach(body => {
if (body instanceof Brick) { if (body instanceof Brick || body instanceof Wall) {
this._world.setMaterial(ball, body); this._world.setMaterial(ball, body);
} }
}) })
...@@ -53,6 +54,9 @@ export default class Gun extends egret.Sprite { ...@@ -53,6 +54,9 @@ export default class Gun extends egret.Sprite {
} }
onTouchEnd(e: egret.TouchEvent): any { onTouchEnd(e: egret.TouchEvent): any {
setTimeout(() => {
this.enable();
}, 500);
this.hideLine(); this.hideLine();
this.stage.removeEventListener(egret.TouchEvent.TOUCH_MOVE, this.onTouchMove, this); this.stage.removeEventListener(egret.TouchEvent.TOUCH_MOVE, this.onTouchMove, this);
...@@ -92,6 +96,7 @@ export default class Gun extends egret.Sprite { ...@@ -92,6 +96,7 @@ export default class Gun extends egret.Sprite {
} }
hideLine() { hideLine() {
if (this._line.parent)
this.removeChild(this._line) this.removeChild(this._line)
} }
} }
\ No newline at end of file
...@@ -3,6 +3,7 @@ import Gun from "./Gun"; ...@@ -3,6 +3,7 @@ import Gun from "./Gun";
import World from "./World"; import World from "./World";
import Brick from "./Brick"; import Brick from "./Brick";
import { FACTOR } from "./consts"; import { FACTOR } from "./consts";
import Wall from "./Wall";
export class Main extends eui.UILayer { export class Main extends eui.UILayer {
private _gun: Gun; private _gun: Gun;
...@@ -20,6 +21,7 @@ export class Main extends eui.UILayer { ...@@ -20,6 +21,7 @@ export class Main extends eui.UILayer {
this._gun.y = 100; this._gun.y = 100;
this._gun.enable(); this._gun.enable();
this.createGround();
this.updateBrickBody(); this.updateBrickBody();
...@@ -27,11 +29,29 @@ export class Main extends eui.UILayer { ...@@ -27,11 +29,29 @@ export class Main extends eui.UILayer {
this.addEventListener(egret.Event.ENTER_FRAME, this.loop, this); this.addEventListener(egret.Event.ENTER_FRAME, this.loop, this);
} }
createGround() {
const left = new Wall(true);
const right = new Wall(false);
this._world.addBody(left);
this._world.addBody(right);
this._world.skin.addChild(left.skin);
this._world.skin.addChild(right.skin);
left.position = [left.skin.width / 2, left.skin.height / 2];
right.position = [this.stage.stageWidth - right.skin.width / 2, right.skin.height / 2];
this._world.addBody(left);
this._world.addBody(right);
right.updateSkin();
left.updateSkin();
}
updateBrickBody(): void { updateBrickBody(): void {
for (var i = 0; i < 1; i++) { const xlist = [150, 300, 450, 600];
for (var i = 0; i < xlist.length; i++) {
var brick = new Brick(); var brick = new Brick();
var x = this.stage.stageWidth >> 1; // var x = 100 this.stage.stageWidth - 100 ;
var y = 1000; var x = xlist[i];
var y = Math.random() * 100 + 800;
brick.position = [x / FACTOR, y / FACTOR]; brick.position = [x / FACTOR, y / FACTOR];
brick.updateSkin(); brick.updateSkin();
brick.angle = (-Math.random() * Math.PI / 4) + (Math.random() * Math.PI / 4); brick.angle = (-Math.random() * Math.PI / 4) + (Math.random() * Math.PI / 4);
......
import { addImage } from "./utils";
import { FACTOR } from "./consts";
/**
* 被打的砖块
*/
export default class Wall extends p2.Body {
_skin: egret.DisplayObject;
_isLeft: boolean;
leftOrRight() { return this._isLeft }
constructor(isLeft) {
super();
this._isLeft = isLeft;
this.type = p2.Body.KINEMATIC;
this.init();
}
init() {
const skinName = this._isLeft ? 'left_png' : 'right_png';
this._skin = addImage(skinName);
this._skin.anchorOffsetX = this._skin.width / 2;
this._skin.anchorOffsetY = this._skin.height / 2;
const width = this._skin.width / FACTOR;
const height = this._skin.height / FACTOR;
const shape = new p2.Box({ width: width, height: height });
this.addShape(shape);
shape.collisionMask = 6;//010与001为0,010与110为1
}
updateSkin() {
this._skin.x = this.position[0] * FACTOR;
this._skin.y = this.position[1] * FACTOR;
this._skin.rotation = this.angle * 180 / Math.PI;
}
get skin() { return this._skin }
}
\ No newline at end of file
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