Commit 7687b148 authored by wildfirecode's avatar wildfirecode

1

parent 01ff34fa
...@@ -8,6 +8,18 @@ export default class TestAsset extends StarterBase { ...@@ -8,6 +8,18 @@ export default class TestAsset extends StarterBase {
this.createGround(); this.createGround();
this.createBodies(); this.createBodies();
this.createDebug(); this.createDebug();
this.stage.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.addOneBox, this);
}
private addOneBox(e: egret.TouchEvent): void {
var positionX: number = Math.floor(e.stageX);
var positionY: number = Math.floor(e.stageY);
if (Math.random() < 0.5) {
this.createBox(positionX, positionY);
} else {
this.createDesk(positionX, positionY);
}
} }
private createBodies(): void { private createBodies(): void {
...@@ -85,22 +97,10 @@ export default class TestAsset extends StarterBase { ...@@ -85,22 +97,10 @@ export default class TestAsset extends StarterBase {
var stageHeight: number = this.stage.stageHeight; var stageHeight: number = this.stage.stageHeight;
var groundShape: p2.Plane = new p2.Plane(); var groundShape: p2.Plane = new p2.Plane();
var groundBody: p2.Body = new p2.Body(); var groundBody: p2.Body = new p2.Body();
groundBody.position[1] = 1600 / this.factor; groundBody.position[1] = stageHeight / this.factor;
groundBody.angle = Math.PI; groundBody.angle = Math.PI;
groundBody.addShape(groundShape); groundBody.addShape(groundShape);
this.world.addBody(groundBody); this.world.addBody(groundBody);
// let planeShape: p2.Plane = new p2.Plane();
// this.planeBody = new p2.Body({
// type: p2.Body.STATIC, //刚体类型
// position: [0, this.stage.stageHeight], //刚体的位置
// });
// this.planeBody.angle = Math.PI;//Plane相当于地面,默认面向Y轴方向。将地面翻转180度
// this.planeBody.displays = [];
// this.planeBody.addShape(planeShape);
// this.world.addBody(this.planeBody);
} }
loop(): void { loop(): void {
......
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