Commit 6e97651a authored by zjz1994's avatar zjz1994

弹球暂存

parent f959095d
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
...@@ -44,21 +44,16 @@ function launchWithCustomModule(customModule) { ...@@ -44,21 +44,16 @@ function launchWithCustomModule(customModule) {
}, 100); }, 100);
setTimeout(() => { setTimeout(() => {
engine.globalEvent.dispatchEvent('food-fell-reset', { engine.globalEvent.dispatchEvent('game-reset');
"goodsProbability": [0.8,0.1,0.1], engine.globalEvent.dispatchEvent('game-start',{
"countDown": 30, ballNums:1
"acceleratedSpeed":0.1
}); });
engine.globalEvent.dispatchEvent('food-fell-start');
}, 500); }, 500);
}); });
engine.globalEvent.addEventListener('food-fell-time-update', (e) => { engine.globalEvent.addEventListener('game-pause', (e) => {
console.log(e.type, e.data); console.log(e.type, e.data);
}); });
engine.globalEvent.addEventListener('food-fell-score-update', (e) => { engine.globalEvent.addEventListener('game-resume', (e) => {
console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('food-fell-game-over', (e) => {
console.log(e.type, e.data); console.log(e.type, e.data);
}); });
} }
...@@ -66,7 +61,6 @@ function launchWithCustomModule(customModule) { ...@@ -66,7 +61,6 @@ function launchWithCustomModule(customModule) {
function getAssetByUUID(uuid) { function getAssetByUUID(uuid) {
return engine.resolveCustomAsset(customId, uuid); return engine.resolveCustomAsset(customId, uuid);
} }
function getProps() { function getProps() {
return engine.getProps(customId); return engine.getProps(customId);
} }
...@@ -4,46 +4,94 @@ ...@@ -4,46 +4,94 @@
const assets = [ const assets = [
{ {
"name": "玩家icon", "name": "door",
"url": "//yun.duiba.com.cn/aurora/assets/50a7212a113175fa18c866b005d98f07c558dc77.png", "url": "//yun.duiba.com.cn/aurora/assets/a6dd9ac99733adbe0f175397dc1f94ee16301847.png",
"uuid": "66f23d13-82a5-4cec-9496-301ec240d087", "uuid": "fc8ca082-90b7-4c22-85cf-9165ffaf47bf",
"ext": ".png" "ext": ".png"
}, },
{ {
"name": "雨滴", "name": "",
"url": "//yun.duiba.com.cn/aurora/assets/8564c8c9be3aead71b05a0bab8d7d07ac3f778a1.png", "url": "//yun.duiba.com.cn/aurora/assets/45fca6ffa65282fc61587442c9847b23006c49b0.png",
"uuid": "264a6192-d7bf-45e8-8f15-6ba2c439a532", "uuid": "995b0f29-885a-425d-bb4e-c9f829df4e7d",
"ext": ".png" "ext": ".png"
}, },
{ {
"name": "炸弹", "name": "",
"url": "//yun.duiba.com.cn/aurora/assets/171e92283cd13c013ee1b76d28d252ff08815d47.png", "url": "//yun.duiba.com.cn/aurora/assets/c5fd86a2360a34e13bf09600fb1f5742719489db.png",
"uuid": "eb88b42d-e151-4c1b-94b9-7c16f7bfac29", "uuid": "2a1b3f6e-5bf5-41d1-b6be-39a77728b230",
"ext": ".png" "ext": ".png"
}, },
{ {
"name": "石块", "name": "shootline",
"url": "//yun.duiba.com.cn/aurora/assets/99b0af0c59fe79a415a3f032149cfacc27e3ac2c.png", "url": "//yun.duiba.com.cn/aurora/assets/ac3bc89a4eccadfa48d3a8abfc834973d6db0aad.png",
"uuid": "ab1bdabc-21ba-46bf-9299-6c638f766c88", "uuid": "0f2c1ee9-c965-4780-82f2-2d8595173952",
"ext": ".png" "ext": ".png"
}, },
{ {
"name": "水花", "name": "sq1",
"url": "//yun.duiba.com.cn/aurora/assets/93d37b4a0e367e80e375308a6b4414d72d7666fc.svga", "url": "//yun.duiba.com.cn/aurora/assets/ba9cd3fc1859d4046b6368a45d95f80b35e3fa6e.png",
"uuid": "b521bf94-20e1-44dd-8eca-d24996cbaeae", "uuid": "7b97ea0d-fb86-4842-9fc7-06e6b5ae3882",
"ext": ".svga" "ext": ".png"
},
{
"name": "sq2",
"url": "//yun.duiba.com.cn/aurora/assets/ba6368eb586671cd4045d09126456229dd8dd503.png",
"uuid": "a171bf2c-c6fd-4ba2-aaff-bc8c91a04fe9",
"ext": ".png"
},
{
"name": "sq3",
"url": "//yun.duiba.com.cn/aurora/assets/7960d9aa4b0502c5c791490f575234a66706b63d.png",
"uuid": "d057cc19-66fe-46f6-91c8-cba2686e8d5d",
"ext": ".png"
}, },
{ {
"name": "炸弹", "name": "sq4",
"url": "//yun.duiba.com.cn/aurora/assets/4dd18f0689c663bbcf710a7afc4d929084d97d36.svga", "url": "//yun.duiba.com.cn/aurora/assets/e9e31a95fd93bb2941e98156dc08aaa75b7671bf.png",
"uuid": "322edf39-805b-4e84-9d07-5573dfeebc0e", "uuid": "1865ae57-f5a3-4794-9c43-0b6aa812f971",
"ext": ".svga" "ext": ".png"
},
{
"name": "tri1",
"url": "//yun.duiba.com.cn/aurora/assets/1b4103f506db3ab6739213a30fb3a7d2abc33f3f.png",
"uuid": "b33457fb-4237-4fca-b48c-bc6074bbe29a",
"ext": ".png"
},
{
"name": "tri2",
"url": "//yun.duiba.com.cn/aurora/assets/56b8a873aafed8241f761061204f5f5f890d2a32.png",
"uuid": "738d6649-6e7f-4006-83cc-0b8a904ec071",
"ext": ".png"
}, },
{ {
"name": "玩家", "name": "风扇",
"url": "//yun.duiba.com.cn/aurora/assets/b66300c5d4f27134b0aac3dc90a3220e8ae572eb.svga", "url": "//yun.duiba.com.cn/aurora/assets/9f5cf7feac84bc6000bea0a038c7df419f3d5dfb.png",
"uuid": "71d8dcbc-3931-471a-b585-b3ae01b25aa6", "uuid": "f26b8a49-f8ee-49ac-a24d-4c83858f5c92",
"ext": ".svga" "ext": ".png"
},
{
"name": "风扇1",
"url": "//yun.duiba.com.cn/aurora/assets/48bc2d0380c7a47defad851d5feaf58cd54e7465.png",
"uuid": "e7363682-e025-49ac-a4ef-fc1a61560014",
"ext": ".png"
},
{
"name": "ball",
"url": "//yun.duiba.com.cn/aurora/assets/28dcf9632e585903c87cb234b09d60244d253dde.png",
"uuid": "8a580ff7-2ece-413e-b87a-11b47f2a28ea",
"ext": ".png"
},
{
"name": "circle1",
"url": "//yun.duiba.com.cn/aurora/assets/3c0c22f57ff647f83fbb8811e9e4437c8a1ad0b4.png",
"uuid": "9af5e780-9701-4cb0-afab-9f4aec42a9ca",
"ext": ".png"
},
{
"name": "+1",
"url": "//yun.duiba.com.cn/aurora/assets/d4013a0ed9f5a367ec20be286ba26581c680b20f.png",
"uuid": "aae627c9-dd32-4ae7-b580-baaefdb77a88",
"ext": ".png"
} }
]; ];
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -65,14 +65,14 @@ export default class PlayScene extends engine.Container { ...@@ -65,14 +65,14 @@ export default class PlayScene extends engine.Container {
}; };
constructor(){ constructor(){
super(); super();
// console.log("playscene--constructor");
// this.pausegame(); // this.pausegame();
this.INIT_BALL_NUMS = window['INIT_BALL_NUMS'] = 1; this.INIT_BALL_NUMS = window['INIT_BALL_NUMS'] = 1;
this.initEvents(); this.initEvents();
this.once(engine.Event.ADDED_TO_STAGE, this.initScene, this); this.once(engine.Event.ADDED_TO_STAGE, this.initScene, this);
} }
reset(){ reset(){
const blocks = this.blocks.filter(block=>!isSpecialBody(block)); const blocks = this.blocks.filter(block=>!isSpecialBody(block)||block.type=="specialCircle");
for(const block of blocks){ for(const block of blocks){
this.removeEle(block,this.blocks); this.removeEle(block,this.blocks);
block.view.parent&&block.view.parent.removeChild(block.view); block.view.parent&&block.view.parent.removeChild(block.view);
...@@ -109,10 +109,11 @@ export default class PlayScene extends engine.Container { ...@@ -109,10 +109,11 @@ export default class PlayScene extends engine.Container {
}); });
} }
initScene(){ initScene(){
// console.log("initScene");
// console.log(this.stage.width,this.stage.height); // console.log(this.stage.width,this.stage.height);
this.initUI(); this.initUI();
this.startGame(); // this.startGame();
engine.Tween.get(this['ele1'], { loop: true }).set({ rotation: 0 }).to({ rotation: -360 }, 3000); engine.Tween.get(this['ele1'], { loop: true }).set({ rotation: 0 }).to({ rotation: -360 }, 3000);
engine.Tween.get(this['ele2'], { loop: true }).set({ rotation: 0 }).to({ rotation: 360 }, 3000); engine.Tween.get(this['ele2'], { loop: true }).set({ rotation: 0 }).to({ rotation: 360 }, 3000);
...@@ -129,6 +130,7 @@ export default class PlayScene extends engine.Container { ...@@ -129,6 +130,7 @@ export default class PlayScene extends engine.Container {
createSpecialRegTriangle(this, 232, 1351 - 3 - 5 - 3, 400, 30);//2块斜面地面2 createSpecialRegTriangle(this, 232, 1351 - 3 - 5 - 3, 400, 30);//2块斜面地面2
createSpecialRegTriangle(this, 750 - 232, 1351 - 3 - 5 - 3, 400, -30);//2块斜面地面2 createSpecialRegTriangle(this, 750 - 232, 1351 - 3 - 5 - 3, 400, -30);//2块斜面地面2
this.removeEventListener(engine.Event.ADDED_TO_STAGE,this.initScene,this);
} }
score:engine.Label; score:engine.Label;
...@@ -138,6 +140,7 @@ export default class PlayScene extends engine.Container { ...@@ -138,6 +140,7 @@ export default class PlayScene extends engine.Container {
ele2:engine.Sprite; ele2:engine.Sprite;
ballNums:engine.Label; ballNums:engine.Label;
initUI(){ initUI(){
// console.log("initUI");
this.score = new engine.Label(); this.score = new engine.Label();
this.score.x = 118; this.score.x = 118;
this.score.y = 13; this.score.y = 13;
...@@ -354,10 +357,10 @@ export default class PlayScene extends engine.Container { ...@@ -354,10 +357,10 @@ export default class PlayScene extends engine.Container {
ball.velocity.x *= getBounce(); ball.velocity.x *= getBounce();
ball.velocity.y *= getBounce(); ball.velocity.y *= getBounce();
ball.collideStatus = 2; ball.collideStatus = 2;
if (block.type == 'specialCircle') // if (block.type == 'specialCircle')
console.log('special circle') // console.log('special circle')
else // else
console.log('normal Circle') // console.log('normal Circle')
} }
else if (block instanceof RegTriangle) { else if (block instanceof RegTriangle) {
if (block.type == 'specialRegTriangle') { if (block.type == 'specialRegTriangle') {
......
...@@ -57,7 +57,6 @@ export const getBlocks = (currBallNums: number) => { ...@@ -57,7 +57,6 @@ export const getBlocks = (currBallNums: number) => {
if (currBallNums >= 50) if (currBallNums >= 50)
nums = getNums2(currBallNums); nums = getNums2(currBallNums);
// console.log("添加nums",nums);
blocksInfo.push({ blocksInfo.push({
position: p, position: p,
type: getBlockShape(), type: getBlockShape(),
......
...@@ -13,30 +13,44 @@ export class gameWrapper extends engine.Container{ ...@@ -13,30 +13,44 @@ export class gameWrapper extends engine.Container{
engine.globalEvent.addEventListener("game-resume", this.resume, this); engine.globalEvent.addEventListener("game-resume", this.resume, this);
this.addEventListener(engine.MouseEvent.CLICK, this.onTap, this); this.addEventListener(engine.MouseEvent.CLICK, this.onTap, this);
// console.log("测试wrapper");
let gameView = this._gameView = new PlayScene(); // try{
this.addChild(gameView); // console.log("wrapper-init",getAssetByUUID("fc8ca082-90b7-4c22-85cf-9165ffaf47bf"));
// }catch(err){
// console.error("资源问题",err);
// }
// gameView.reset() // gameView.reset()
// gameView.start() // gameView.start()
} }
reset(event: engine.Event) { reset(event: engine.Event) {
injectProps(event.data); injectProps(event.data);
console.log("game-reset");
if(!this._gameView){
this._gameView = new PlayScene();
this.addChild(this._gameView);
}
this._gameView.visible = true; this._gameView.visible = true;
this._gameView.reset(); this._gameView.reset();
} }
start(event: engine.Event) { start(event: engine.Event) {
injectProps(event.data); injectProps(event.data);
console.log("game-start");
this._status = 1; this._status = 1;
this._gameView.start(); this._gameView.start();
} }
pause() { pause() {
console.log("game-pause");
this._gameView.pausegame(); this._gameView.pausegame();
} }
resume() { resume() {
console.log("game-resume");
this._gameView.resumegame(); this._gameView.resumegame();
} }
......
...@@ -64,13 +64,11 @@ export class Circle extends Body { ...@@ -64,13 +64,11 @@ export class Circle extends Body {
} }
public shake() { public shake() {
console.log("circle震动1-------",this.view.bg.x,this.view.bg.y);
var startx = -this.view.bg.anchorX; var startx = -this.view.bg.anchorX;
var starty = -this.view.bg.anchorY; var starty = -this.view.bg.anchorY;
this.view.bg.x = startx; this.view.bg.x = startx;
this.view.bg.y = starty; this.view.bg.y = starty;
console.log("circle震动2-------",this.view.bg.x,this.view.bg.y);
Tween.to(this.view.bg, 1, { Tween.to(this.view.bg, 1, {
x: startx+3, x: startx+3,
y: starty+3, y: starty+3,
......
...@@ -114,7 +114,6 @@ export class RegPolygon extends Body { ...@@ -114,7 +114,6 @@ export class RegPolygon extends Body {
set num(value) { set num(value) {
if (this._num != value) { if (this._num != value) {
this._num = value; this._num = value;
// console.log("regPolygon-value",value);
this.view.txt.text = value||3 + ""; this.view.txt.text = value||3 + "";
} }
} }
...@@ -154,7 +153,6 @@ export class RegPolygon extends Body { ...@@ -154,7 +153,6 @@ export class RegPolygon extends Body {
v2.x = this.points[i + 1].x +thisvx; v2.x = this.points[i + 1].x +thisvx;
v2.y = this.points[i + 1].y + thisvy; v2.y = this.points[i + 1].y + thisvy;
axes.push(v1.edge(v2).perpendicularNormal()); axes.push(v1.edge(v2).perpendicularNormal());
// console.log(1)
}; };
//将收尾两点的投影轴也加入 //将收尾两点的投影轴也加入
...@@ -164,7 +162,6 @@ export class RegPolygon extends Body { ...@@ -164,7 +162,6 @@ export class RegPolygon extends Body {
v2.x = this.points[0].x + thisvx; v2.x = this.points[0].x + thisvx;
v2.y = this.points[0].y + thisvy; v2.y = this.points[0].y + thisvy;
axes.push(v1.edge(v2).perpendicularNormal()); axes.push(v1.edge(v2).perpendicularNormal());
// console.log(axes)
return axes; return axes;
}; };
...@@ -184,7 +181,6 @@ export class RegPolygon extends Body { ...@@ -184,7 +181,6 @@ export class RegPolygon extends Body {
}; };
polygonCollidesWithCircle(ball) { polygonCollidesWithCircle(ball) {
//console.log('多边形与圆形碰撞检测');
var v1; var v1;
var v2; var v2;
var ballax = ball._viewx; var ballax = ball._viewx;
...@@ -204,7 +200,6 @@ export class RegPolygon extends Body { ...@@ -204,7 +200,6 @@ export class RegPolygon extends Body {
v2 = new Vector(closestPoint.x, closestPoint.y); v2 = new Vector(closestPoint.x, closestPoint.y);
axes.push(v1.subtract(v2).normalize()); axes.push(v1.subtract(v2).normalize());
// console.log("多边形的碰撞",!this.separationOnAxes(axes, ball));
return !this.separationOnAxes(axes, ball); return !this.separationOnAxes(axes, ball);
} }
...@@ -231,7 +226,6 @@ export class RegPolygon extends Body { ...@@ -231,7 +226,6 @@ export class RegPolygon extends Body {
closestPoint = testPoint; closestPoint = testPoint;
} }
}; };
// console.log(closestPoint)
return closestPoint; return closestPoint;
}; };
//检测在投影轴上投影是否有分离 //检测在投影轴上投影是否有分离
...@@ -272,8 +266,6 @@ export class RegPolygon extends Body { ...@@ -272,8 +266,6 @@ export class RegPolygon extends Body {
var speedX = velocity.x / (deta + 1); var speedX = velocity.x / (deta + 1);
var speedY = velocity.y / (deta + 1); var speedY = velocity.y / (deta + 1);
// console.log("多边形碰撞-----1",deta);
// console.log(this.nearestCollideNormal({ x: returnP.x - velocity.x, y: returnP.y - velocity.y }, ball,deta+1,i+1))
for (var i = 0; i <= deta; i++) { for (var i = 0; i <= deta; i++) {
this.ballPosition(ball, deta + 1, i + 1) this.ballPosition(ball, deta + 1, i + 1)
if (!this.polygonCollidesWithCircle(ball)) { if (!this.polygonCollidesWithCircle(ball)) {
...@@ -294,7 +286,6 @@ export class RegPolygon extends Body { ...@@ -294,7 +286,6 @@ export class RegPolygon extends Body {
} }
ball.view.x += ball.velocity.x; ball.view.x += ball.velocity.x;
ball.view.y += ball.velocity.y; ball.view.y += ball.velocity.y;
// console.log("多边形碰撞-----2");
return false; return false;
} else { } else {
return false return false
...@@ -320,19 +311,16 @@ export class RegPolygon extends Body { ...@@ -320,19 +311,16 @@ export class RegPolygon extends Body {
public shake() { public shake() {
console.log("regPolygon震动1----------",this.view.bg.x,this.view.bg.y);
var startx = -this.view.bg.anchorX; var startx = -this.view.bg.anchorX;
var starty = -this.view.bg.anchorY; var starty = -this.view.bg.anchorY;
this.view.bg.x = startx; this.view.bg.x = startx;
this.view.bg.y = starty; this.view.bg.y = starty;
console.log("regPolygon震动2----------",this.view.bg.x,this.view.bg.y);
Tween.to(this.view.bg, 1, { Tween.to(this.view.bg, 1, {
x: startx+3, x: startx+3,
y: starty+3, y: starty+3,
yoyo: 2, yoyo: 2,
useFrame: true, useFrame: true,
onComplete: function () { onComplete: function () {
console.log("regPolygon震动3----------",this.view.bg.x,this.view.bg.y);
} }
}) })
......
...@@ -70,8 +70,6 @@ export class RegTriangle extends RegPolygon { ...@@ -70,8 +70,6 @@ export class RegTriangle extends RegPolygon {
var one = this.linesOri[1].a * returnP.x + this.linesOri[1].b - returnP.y > 0; var one = this.linesOri[1].a * returnP.x + this.linesOri[1].b - returnP.y > 0;
var two = this.linesOri[2].a * returnP.x + this.linesOri[2].b - returnP.y > 0; var two = this.linesOri[2].a * returnP.x + this.linesOri[2].b - returnP.y > 0;
// console.log(this.linesOri[0].a * returnP.x + this.linesOri[0].b,returnP.y)
// console.log(zero,one,two)
//左上边 //左上边
if (zero && !one && two) { if (zero && !one && two) {
return this.sideNormals[0]; return this.sideNormals[0];
......
...@@ -106,7 +106,6 @@ export class Square extends Body { ...@@ -106,7 +106,6 @@ export class Square extends Body {
set num(value) { set num(value) {
if (this._num != value) { if (this._num != value) {
this._num = value; this._num = value;
// console.log("square-vale",value);
this.view.txt.text = value||4 + ""; this.view.txt.text = value||4 + "";
} }
} }
...@@ -136,7 +135,6 @@ export class Square extends Body { ...@@ -136,7 +135,6 @@ export class Square extends Body {
var deta = Math.floor(velocity.length() / ball.radius) + 5 //deta就是插值数量,如为0,则直接取上一帧的法向量 var deta = Math.floor(velocity.length() / ball.radius) + 5 //deta就是插值数量,如为0,则直接取上一帧的法向量
var speedX = velocity.x / (deta + 1); var speedX = velocity.x / (deta + 1);
var speedY = velocity.y / (deta + 1); var speedY = velocity.y / (deta + 1);
// console.log(this.nearestCollideNormal({ x: returnP.x - velocity.x, y: returnP.y - velocity.y }, ball,deta+1,i+1))
for (var i = 0; i <= deta; i++) { for (var i = 0; i <= deta; i++) {
var normal = this.nearestCollideNormal({ x: returnP.x - speedX * (i + 1), y: returnP.y - speedY * (i + 1) }, ball, deta + 1, i + 1) var normal = this.nearestCollideNormal({ x: returnP.x - speedX * (i + 1), y: returnP.y - speedY * (i + 1) }, ball, deta + 1, i + 1)
if (normal) { if (normal) {
...@@ -199,19 +197,16 @@ export class Square extends Body { ...@@ -199,19 +197,16 @@ export class Square extends Body {
public shake() { public shake() {
console.log("square震动1---",this.view.bg.x,this.view.bg.y);
var startx = -this.view.bg.anchorX; var startx = -this.view.bg.anchorX;
var starty = -this.view.bg.anchorY; var starty = -this.view.bg.anchorY;
this.view.bg.x = startx; this.view.bg.x = startx;
this.view.bg.y = starty; this.view.bg.y = starty;
console.log("square震动2---",this.view.bg.x,this.view.bg.y);
Tween.to(this.view.bg, 1, { Tween.to(this.view.bg, 1, {
x: startx+5, x: startx+5,
y: starty+5, y: starty+5,
yoyo: 3, yoyo: 3,
useFrame: true, useFrame: true,
onComplete: function () { onComplete: function () {
console.log("square震动3---",this.view.bg.x,this.view.bg.y);
} }
}) })
......
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