Commit 417b6dd0 authored by wildfirecode's avatar wildfirecode

1

parent 0f026042
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
<body> <body>
<div style="margin: auto;width: 100%;height: 100%;" class="egret-player" data-entry-class="Main" data-orientation="auto" <div style="margin: auto;width: 100%;height: 100%;" class="egret-player" data-entry-class="Main" data-orientation="auto"
data-scale-mode="showAll" data-frame-rate="60" data-content-width="750" data-content-height="1624" data-scale-mode="showAll" data-frame-rate="60" data-content-width="750" data-content-height="1624"
data-multi-fingered="2" data-show-fps="false" data-show-log="false" data-show-fps-style="x:0,y:0,size:12,textColor:0xffffff,bgAlpha:0.9"> data-multi-fingered="2" data-show-fps="true" data-show-log="false" data-show-fps-style="x:0,y:0,size:12,textColor:0xffffff,bgAlpha:0.9">
</div> </div>
<script src="libs/decomp.min.js"></script> <script src="libs/decomp.min.js"></script>
...@@ -79,7 +79,7 @@ ...@@ -79,7 +79,7 @@
</script> </script>
<script src="output.js"></script> <script src="output.js"></script>
<!-- <div id="debugCanvas" style="position:absolute;opacity: 0.8;pointer-events: none"></div> --> <!-- <div id="debugCanvas" style="position:absolute;opacity: 0.9;pointer-events: none"></div> -->
</body> </body>
</html> </html>
\ No newline at end of file
{"options":{"layoutMath":"2","sizeMode":"2n","useExtension":1,"layoutGap":1,"extend":0},"projectName":"preload","version":5,"files":["../assets/startScene/basket_bottom.png"]}
\ No newline at end of file
{"options":{"layoutMath":"2","sizeMode":"2n","useExtension":1,"layoutGap":1,"extend":0},"projectName":"rule","version":5,"files":["../assets/rule/X.png","../assets/rule/ruleBg.png"]}
\ No newline at end of file
{"options":{"layoutMath":"2","sizeMode":"2n","useExtension":1,"layoutGap":1,"extend":0},"projectName":"start","version":5,"files":["../assets/startScene/basket_top.png","../assets/startScene/bubble.png","../assets/startScene/glass.png","../assets/startScene/optionBtn.png","../assets/startScene/rankBtn.png","../assets/startScene/recordbtn.png","../assets/startScene/ruleBtn.png","../assets/startScene/start_btn_gray.png","../assets/startScene/start_btn.png"]}
\ No newline at end of file
...@@ -2,10 +2,10 @@ import MovieClip from "./movieclip/MovieClip"; ...@@ -2,10 +2,10 @@ import MovieClip from "./movieclip/MovieClip";
export default class BaseItem extends egret.Sprite { export default class BaseItem extends egret.Sprite {
_mc: MovieClip; _mc: MovieClip;
// type: string type: string
constructor(mc: MovieClip, type?: string) { constructor(mc: MovieClip, type?: string) {
super(); super();
// this.type = type; this.type = type;
this._mc = mc; this._mc = mc;
const bubble: egret.Texture = RES.getRes('bubble_png'); const bubble: egret.Texture = RES.getRes('bubble_png');
const bubblePic = new egret.Bitmap(bubble); const bubblePic = new egret.Bitmap(bubble);
......
...@@ -47,7 +47,7 @@ export default class EgretRender { ...@@ -47,7 +47,7 @@ export default class EgretRender {
const y2 = Math.round(body.position.y) const y2 = Math.round(body.position.y)
const distanceX = Math.abs(x1 - x2); const distanceX = Math.abs(x1 - x2);
const distanceY = Math.abs(y1 - y2); const distanceY = Math.abs(y1 - y2);
const precision = 0;//精度 const precision = 1;//精度
if (distanceX > precision || distanceY > precision) { if (distanceX > precision || distanceY > precision) {
if (display instanceof BaseItem) display.mc.resume(); if (display instanceof BaseItem) display.mc.resume();
} else { } else {
......
...@@ -4,15 +4,17 @@ import EgretRender from "../physics/EgretRender"; ...@@ -4,15 +4,17 @@ import EgretRender from "../physics/EgretRender";
import { bubble, bubbleGroup, bubbleMask, award } from "./collisionConfig"; import { bubble, bubbleGroup, bubbleMask, award } from "./collisionConfig";
import createBox from "./createBox"; import createBox from "./createBox";
import createBubblePic from "./createBubblePic"; import createBubblePic from "./createBubblePic";
import { startStandbyBubbles, stopStandbyBubbles } from "./standbyBubbles";
import createItems from "./createItems"; import createItems from "./createItems";
import random from "./random";
import { startStandbyBubblesLeft, stopStandbyBubblesRight, startStandbyBubblesRight, stopStandbyBubblesLeft } from "./standbyBubbles";
export default class StartScene extends StartSceneBase { export default class StartScene extends StartSceneBase {
_engine: Matter.Engine; _engine: Matter.Engine;
_egretRender: EgretRender; _egretRender: EgretRender;
private _debugRender: DebugRender; private _debugRender: DebugRender;
private _lastTimestamp = 0; private _lastTimestamp = 0;
_startStandbyBubbles: number; _startStandbyBubblesLeft: number;
_startStandbyBubblesRight: number;
async start(data?) { async start(data?) {
super.start(); super.start();
egret.lifecycle.onPause = () => { egret.lifecycle.onPause = () => {
...@@ -80,16 +82,21 @@ export default class StartScene extends StartSceneBase { ...@@ -80,16 +82,21 @@ export default class StartScene extends StartSceneBase {
Matter.Events.on(this._engine, 'beforeUpdate', () => { Matter.Events.on(this._engine, 'beforeUpdate', () => {
if (!this.addForce) return if (!this.addForce) return
this.addForce = false; this.addForce = false;
const scale = 1.7; const scale = 2.2;
for (let i = 0; i < 8; i++) { for (let i = 0; i < 11; i++) {
setTimeout(() => { setTimeout(() => {
const r = Math.random() * 5 + 8; const r = random(10, 14);
const bubblePic = createBubblePic(r);//默认球的尺寸100 const bubblePic = createBubblePic(r);//默认球的尺寸100
const body = this._egretRender.circle(this.stageX, 870, r, bubblePic, const start = this.stageX < 375 ? { x: 208, y: 821 } : { x: 549, y: 821 };
const basex = 0.01;
const fx = this.stageX < 375 ? random(-basex, basex) : random(-basex, basex);
const padding = 50;
const startx = random(start.x-padding,start.x+padding);
const body = this._egretRender.circle(startx, start.y, r, bubblePic,
{ {
density: 0.001 * 3, density: 0.001 * 3,
restitution: 1, restitution: 1,
force: { x: Math.random() * .02 - .01, y: -0.02 * scale }, force: { x: fx * scale, y: -0.02 * scale },
collisionFilter: { group: bubbleGroup, category: bubble, mask: bubbleMask } collisionFilter: { group: bubbleGroup, category: bubble, mask: bubbleMask }
} }
); );
...@@ -105,21 +112,31 @@ export default class StartScene extends StartSceneBase { ...@@ -105,21 +112,31 @@ export default class StartScene extends StartSceneBase {
this.stage.addEventListener(egret.TouchEvent.TOUCH_TAP, (e: egret.TouchEvent) => { this.stage.addEventListener(egret.TouchEvent.TOUCH_TAP, (e: egret.TouchEvent) => {
this.addForce = true; this.addForce = true;
this.stageX = e.stageX; this.stageX = e.stageX;
stopStandbyBubbles(); if (this.stageX < 375) {
clearTimeout(this._startStandbyBubbles); stopStandbyBubblesLeft();
this._startStandbyBubbles = setTimeout(() => { clearTimeout(this._startStandbyBubblesLeft);
startStandbyBubbles(this._egretRender); this._startStandbyBubblesLeft = setTimeout(() => {
}, 1000); startStandbyBubblesLeft(this._egretRender);
}, 1000);
} else {
stopStandbyBubblesRight();
clearTimeout(this._startStandbyBubblesRight);
this._startStandbyBubblesRight = setTimeout(() => {
startStandbyBubblesRight(this._egretRender);
}, 1000);
}
}, this); }, this);
startStandbyBubbles(this._egretRender); startStandbyBubblesLeft(this._egretRender);
startStandbyBubblesRight(this._egretRender);
} }
check() { check() {
const center = 378; const center = 382;
const paddingX = 60; const paddingX = 50;
const ypos = 420; const ypos = 440;
const h = 60; const h = 40;
// this._egretRender._root.graphics.beginFill(0xff0000, 1); // this._egretRender._root.graphics.beginFill(0xff0000, 1);
// this._egretRender._root.graphics.drawRect(center - paddingX, ypos, paddingX * 2, h); // this._egretRender._root.graphics.drawRect(center - paddingX, ypos, paddingX * 2, h);
// this._egretRender._root.graphics.endFill(); // this._egretRender._root.graphics.endFill();
...@@ -127,18 +144,27 @@ export default class StartScene extends StartSceneBase { ...@@ -127,18 +144,27 @@ export default class StartScene extends StartSceneBase {
const bodies = Matter.Composite.allBodies(this._engine.world); const bodies = Matter.Composite.allBodies(this._engine.world);
const isAward = (i: Matter.Body) => { return i.collisionFilter.group == award } const isAward = (i: Matter.Body) => { return i.collisionFilter.group == award }
bodies.forEach(i => { bodies.forEach(i => {
if (!isAward(i) || i['prepareToDispose']) return; if (!isAward(i)) return;
if (i['timer']) {
const t0 = Date.now() - i['timer'];
if (t0 > 3000)//3s之内不可再用
{
delete i['timer'];
console.log('重新可用', Date.now() / 1000)
}
}
const { x, y } = i.position; const { x, y } = i.position;
const xResult = x > (center - paddingX) && x < (center + paddingX); const xResult = x > (center - paddingX) && x < (center + paddingX);
const yResult = y > ypos && y < (ypos + h); const yResult = y > ypos && y < (ypos + h);
if (xResult && yResult) { if (xResult && yResult && i.velocity.y > 0 && !i['timer']) {
console.log('有了'); i['timer'] = Date.now();
i['prepareToDispose'] = 1; if (i.label == 'boom') {
i['display'] && egret.Tween.get(i['display']).to({ alpha: 0 }, 500).call(() => { console.log('boom');
delete i['prepareToDispose']; this._egretRender.remove(i);
this._egretRender.removeBody(i); }
this._egretRender.removeDisplay(i); else {
}) console.log('不是boom,重用', Date.now() / 1000);
}
// this.onGetAward(); // this.onGetAward();
} }
}) })
...@@ -148,14 +174,13 @@ export default class StartScene extends StartSceneBase { ...@@ -148,14 +174,13 @@ export default class StartScene extends StartSceneBase {
egret.startTick(this.onTick, this); egret.startTick(this.onTick, this);
} }
// onGetAward() {
onGetAward() { // egret.stopTick(this.onTick, this);
egret.stopTick(this.onTick, this); // setTimeout(() => {
setTimeout(() => { // this._lastTimestamp = 0;
this._lastTimestamp = 0; // this.runEngine();
this.runEngine(); // }, 1000);
}, 1000); // }
}
private onTick(timestamp: number) { private onTick(timestamp: number) {
if (this._lastTimestamp === 0) { if (this._lastTimestamp === 0) {
......
...@@ -10,9 +10,19 @@ const createBox = (_this: StartScene) => { ...@@ -10,9 +10,19 @@ const createBox = (_this: StartScene) => {
const body2 = Matter.Bodies.fromVertices(425 - 10 - 100 - 10 - 10 + 1, 30 + 100 + 10 + 10 + 6, [path2], { isStatic: true, collisionFilter: { group: wall, category: wall, mask: wallMask } }, true); const body2 = Matter.Bodies.fromVertices(425 - 10 - 100 - 10 - 10 + 1, 30 + 100 + 10 + 10 + 6, [path2], { isStatic: true, collisionFilter: { group: wall, category: wall, mask: wallMask } }, true);
Matter.World.add(_this._engine.world, body2); Matter.World.add(_this._engine.world, body2);
const basketpath = Matter.Vertices.fromPath('290 434 385 502 468 434 466 434 384 488 292 434', null); const basketpath1 = Matter.Vertices.fromPath('290 432 324 476 326 476 292 432 ', null);
const basketbody = Matter.Bodies.fromVertices(375 + 8 - 2, 400 + 58 + 5 + 4, [basketpath], { isStatic: true, collisionFilter: { group: basket, category: basket, mask: basketMask } }, true); const basketbody1 = Matter.Bodies.fromVertices(311, 452, [basketpath1], { isStatic: true, collisionFilter: { group: basket, category: basket, mask: basketMask } }, true);
Matter.World.add(_this._engine.world, basketbody); Matter.World.add(_this._engine.world, basketbody1);
const basketpath2 = Matter.Vertices.fromPath('471 435 443 481 441 481 469 435', null);
const basketbody2 = Matter.Bodies.fromVertices(449, 452, [basketpath2], { isStatic: true, collisionFilter: { group: basket, category: basket, mask: basketMask } }, true);
Matter.World.add(_this._engine.world, basketbody2);
//153 823
const w = 100;
const h = 50;
const rect = _this._egretRender.rectangle(153 + w / 2, 833 + h / 2, w, h, null, { isStatic: true, collisionFilter: { group: wall, category: wall, mask: wallMask } });
const rect2 = _this._egretRender.rectangle(553 - 10 - 30 - 5 + w / 2, 833 + h / 2, w, h, null, { isStatic: true, collisionFilter: { group: wall, category: wall, mask: wallMask } });
} }
export default createBox export default createBox
\ No newline at end of file
...@@ -5,7 +5,7 @@ import { award, awardMask } from "./collisionConfig"; ...@@ -5,7 +5,7 @@ import { award, awardMask } from "./collisionConfig";
export default (_this: StartScene) => { export default (_this: StartScene) => {
let count = 0; let count = 0;
const coinsFall = setInterval(() => { const coinsFall = setInterval(() => {
if (count < 20) { if (count < 15) {
let scale; let scale;
scale = 0.7 + Math.random() * 0.3; scale = 0.7 + Math.random() * 0.3;
const baseItem = createItem(scale); const baseItem = createItem(scale);
...@@ -17,7 +17,7 @@ export default (_this: StartScene) => { ...@@ -17,7 +17,7 @@ export default (_this: StartScene) => {
{ {
collisionFilter: { group: award, category: award, mask: awardMask }, collisionFilter: { group: award, category: award, mask: awardMask },
angle: angle, angle: angle,
// label label: baseItem.type
}); });
count++; count++;
} else { } else {
......
const random = (start, end) => {
const n = end - start;
return Math.random() * n + start;
}
export default random
\ No newline at end of file
import { bubbleStandbyGroup, bubbleStandby, bubbleStandbyMask } from "./collisionConfig"; import { bubbleStandbyGroup, bubbleStandby, bubbleStandbyMask } from "./collisionConfig";
import createBubblePic from "./createBubblePic"; import createBubblePic from "./createBubblePic";
import EgretRender from "../physics/EgretRender"; import EgretRender from "../physics/EgretRender";
import random from "./random";
let timer; let timerLeft;
export const startStandbyBubbles = (egretRender:EgretRender) => { let timerRight;
timer = setInterval(() => { export const startStandbyBubblesLeft = (egretRender: EgretRender) => {
const scale = .3; timerLeft = setInterval(() => {
const scaleX = .1; const scale = 0.2;
const p = Math.random() > .5 ? { x: 206, y: 832 } : { x: 551, y: 832 }; const p1 = { x: 206, y: 832 };
for (let i = 0; i < 10; i++) { const r = random(8, 10);
setTimeout(() => { const bubblePic = createBubblePic(r);
const r = Math.random() * 3 + 6; const body = egretRender.circle(p1.x, p1.y, r, bubblePic, {
const bubblePic = createBubblePic(r); restitution: 0,
const body = egretRender.circle(p.x, p.y, r, bubblePic, { frictionAir: 0,
restitution: 0, force: { x: random(-0.005, 0.005) * scale, y: -0.02 * scale },
force: { x: (Math.random() * .02 - .01) * scaleX, y: -0.02 * scale }, collisionFilter: { group: bubbleStandbyGroup, category: bubbleStandby, mask: bubbleStandbyMask }
collisionFilter: { group: bubbleStandbyGroup, category: bubbleStandby, mask: bubbleStandbyMask } });
}); setTimeout(() => {
setTimeout(() => { egretRender.remove(body);
egretRender.remove(body) }, 1000);
}, 800); }, 700);
}, i * 50);
}
console.log('自动吹');
}, 2000);
} }
export const stopStandbyBubbles = () => { export const startStandbyBubblesRight = (egretRender: EgretRender) => {
clearInterval(timer) timerRight = setInterval(() => {
const scale = 0.2;
const p2 = { x: 551, y: 832 };
const r2 = random(8, 10);
const bubblePic2 = createBubblePic(r2);
const body2 = egretRender.circle(p2.x, p2.y, r2, bubblePic2, {
restitution: 0,
frictionAir: 0,
force: { x: random(-0.005, 0.005) * scale, y: -0.02 * scale },
collisionFilter: { group: bubbleStandbyGroup, category: bubbleStandby, mask: bubbleStandbyMask }
});
setTimeout(() => {
egretRender.remove(body2);
}, 1000);
}, 700);
}
export const stopStandbyBubblesLeft = () => {
clearInterval(timerLeft)
}
export const stopStandbyBubblesRight = () => {
clearInterval(timerRight)
} }
\ 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