Commit e2806289 authored by wildfirecode13's avatar wildfirecode13

1

parent 2533efe0
This diff is collapsed.
......@@ -46,13 +46,7 @@ function launchWithCustomModule(customModule) {
}, 100);
setTimeout(() => {
engine.globalEvent.dispatchEvent('pictures-start', {
picUrl: "http://yun.duiba.com.cn/aurora/assets/e1593b97c27077b85b92f7eaaeae1ed64a1eb79a.png",
blockUrl: "888",
column:"2",
row:"2",
gameTime:"50"
});
engine.globalEvent.dispatchEvent('pictures-start', { });
const d = engine.gameStage.sceneContainer.getChildAt(0);
......
This diff is collapsed.
This diff is collapsed.
......@@ -46,10 +46,16 @@
},
"assets": [
{
"name": "遮罩",
"url": "//yun.duiba.com.cn/aurora/assets/5b3e30496b2d9fdafb0cf3835fd6704ce10e45b4.png",
"name": "block",
"url": "//yun.duiba.com.cn/aurora/assets/f91184b338ef9540b167eebe7d58e71402e8d9d9.png",
"uuid": "888",
"ext": ".png"
},
{
"name": "ball",
"url": "//yun.duiba.com.cn/aurora/assets/3dc11f2d91659b7e7e1d06a9853cbc9f818e1ea2.png",
"uuid": "999",
"ext": ".png"
}
],
"events": {
......
import { Tool } from "../../../seabed-game/src/game/Tools";
import { getTextureByName } from "../../../answer-game/src/game/utils";
export default class GameView extends engine.Container {
world: p2.World;
factor: number = 10;
isDebug = 1;
isDebug = 0;
constructor() {
super();
this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);
......@@ -20,6 +23,17 @@ export default class GameView extends engine.Container {
this.stage.addEventListener(engine.MouseEvent.CLICK, this.onClick, this);
}
createBitmapByName(name) {
const imgContainer = new engine.Sprite();
const img = new engine.Sprite(getTextureByName(name));
img.anchorX = img.width / 2;
img.anchorY = img.height / 2;
img.x = -img.width / 2;
img.y = -img.height / 2;
imgContainer.addChild(img);
return imgContainer
}
private createBox(width: number, height: number): engine.Shape {
var shape = new engine.Shape();
shape.beginFill(0xfff000);
......@@ -29,6 +43,17 @@ export default class GameView extends engine.Container {
}
onClick(e: engine.MouseEvent) {
// const ball = this.createBitmapByName('ball');
// this.addChild(ball);
// engine.Tween.get(ball, { loop: true }).to({ rotation: 360 }, 1000);
// return;
// const box = this.createBitmapByName('block');
// this.addChild(box);
// engine.Tween.get(box, { loop: true }).to({ rotation: 360 }, 1000);
// return;
// const box = this.createBox(750, 100)
// this.addChild(box);
// box.x = 750/2;
......@@ -48,7 +73,7 @@ export default class GameView extends engine.Container {
if (Math.random() > .5) {
//添加方形刚体
var boxShape: p2.Shape = new p2.Box({ width: 200/factor, height: 100/factor });
var boxShape: p2.Shape = new p2.Box({ width: 306 / factor, height: 172 / factor });
var boxBody: p2.Body = new p2.Body({ mass: 1, position: [positionX, positionY], angularVelocity: 1 });
boxBody.addShape(boxShape);
world.addBody(boxBody);
......@@ -56,14 +81,12 @@ export default class GameView extends engine.Container {
if (this.isDebug) {
display = this.createBox((<p2.Box>boxShape).width * factor, (<p2.Box>boxShape).height * factor);
} else {
// display = self.createBitmapByName("rect");
// display.width = (<p2.Box>boxShape).width * factor;
// display.height = (<p2.Box>boxShape).height * factor;
display = this.createBitmapByName("block");
}
}
else {
//添加圆形刚体
var boxShape: p2.Shape = new p2.Circle({ radius: 200 / 2 / factor });
var boxShape: p2.Shape = new p2.Circle({ radius: 120 / 2 / factor });
var boxBody: p2.Body = new p2.Body({ mass: 1, position: [positionX, positionY] });
boxBody.addShape(boxShape);
world.addBody(boxBody);
......@@ -71,7 +94,7 @@ export default class GameView extends engine.Container {
if (this.isDebug) {
display = this.createBall((<p2.Circle>boxShape).radius * factor);
} else {
// display = self.createBitmapByName("circle");
display = this.createBitmapByName("ball");
}
// display.width = (<p2.Circle>boxShape).radius * 2 * factor;
......
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