Commit f56db825 authored by wildfirecode13's avatar wildfirecode13

1

parent 48ed6490
......@@ -24,9 +24,13 @@ class GameStage extends WidgetBase {
const ground = new Ground({ data: groundData, display: createGroundDisplay(groundData) })
this.addGround(ground);
setTimeout(() => {
this.removeGround(ground)
}, 3000);
const groundData1 = { x: 400, y: this.stage.viewRect.height /3 * 2, width: 200, height: 10 };
const ground1 = new Ground({ data: groundData1, display: createGroundDisplay(groundData1) })
this.addGround(ground1);
// setTimeout(() => {
// this.removeGround(ground)
// }, 3000);
}
grounds;
......@@ -44,8 +48,9 @@ class GameStage extends WidgetBase {
}
addbodys() {
const ball = new Body({
display: 'ball',
display: 'box',
initialVelocityY: 0,
initialVelocityX: 2,
accelerationY: 2,
restitution: 0
});
......@@ -57,7 +62,7 @@ class GameStage extends WidgetBase {
restitution: 0
});
block.x = 300;
block.x = 620;
this.addChild(block);
this.bodys.push(block);
......@@ -78,7 +83,9 @@ class GameStage extends WidgetBase {
for (let i = 0; i < this.grounds.length; i++) {
const ground = this.grounds[i];
// console.log(y0, ground.y)
if (y0 > ground.y) {
const dis0 = body.width / 2 + ground.data.width / 2;
const dis1 = Math.abs(body.x + body.width / 2 - ground.data.x - ground.data.width / 2);
if (y0 > ground.y && dis1 < dis0) {
body.y = ground.y - body.height;
body.velocityY = -body.velocityY * body.restitution;
break;
......
......@@ -29,7 +29,7 @@
},
{
"name": "box",
"url": "//yun.duiba.com.cn/aurora/assets/6fb4612326d4e78b715a83d1114fa2d96fb8adcb.png",
"url": "//yun.duiba.com.cn/aurora/assets/2ded44a3459c08e000d08b60dd6248d283fe2c80.png",
"uuid": "box",
"ext": ".png"
},
......
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