Commit 5e07311b authored by wildfirecode's avatar wildfirecode

1

parent a1ff9446
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<e:Image id="progressfg" source="进度条-已显示_png" x="56.5" y="1498"/> <e:Image id="progressfg" source="进度条-已显示_png" x="56.5" y="1498"/>
<e:Image id="x3" source="目标_png" x="106" y="1514"/> <e:Image id="x3" source="目标_png" x="106" y="1514"/>
<e:Image id="noname" source="奖品_png" x="103" y="1553"/> <e:Image id="noname" source="奖品_png" x="103" y="1553"/>
<e:Label id="condition" text="本轮需要获得3个甜筒" verticalAlign="middle" textAlign="center" size="16" y="1437.34" x="201" width="334" textColor="0xfcfcfc" fontFamily="Tahoma"/> <e:Label id="condition" text="本轮需要获得3个甜筒" verticalAlign="middle" textAlign="center" size="18" y="1437.34" x="201" width="334" fontFamily="Tahoma" textColor="0xe8dcdc"/>
<e:Image id="guide" source="dot_png" x="0" y="0" width="750" height="1624" touchEnabled="false" visible="false"/> <e:Image id="guide" source="dot_png" x="0" y="0" width="750" height="1624" touchEnabled="false" visible="false"/>
<e:Label id="exemptionTxt" text="*兑换项与活动均与设备制造商Apple Inc.公司无关*" width="100%" verticalAlign="middle" textAlign="center" size="12" y="1609.67" x="0" textColor="0x000000"/> <e:Label id="exemptionTxt" text="*兑换项与活动均与设备制造商Apple Inc.公司无关*" width="100%" verticalAlign="middle" textAlign="center" size="12" y="1609.67" x="0" textColor="0x000000"/>
<e:Button id="rightBtn" label="" y="1292.31" scaleX="1" scaleY="1" alpha="1" x="550.33"> <e:Button id="rightBtn" label="" y="1292.31" scaleX="1" scaleY="1" alpha="1" x="550.33">
......
...@@ -6,6 +6,7 @@ import check from "./check"; ...@@ -6,6 +6,7 @@ import check from "./check";
import check2 from "./check2"; import check2 from "./check2";
import createBox from "./createBox"; import createBox from "./createBox";
import createItems from "./createItems"; import createItems from "./createItems";
import { initLevel, updateLevelView } from "./level";
export default class StartScene extends StartSceneBase { export default class StartScene extends StartSceneBase {
_engine: Matter.Engine; _engine: Matter.Engine;
...@@ -41,7 +42,8 @@ export default class StartScene extends StartSceneBase { ...@@ -41,7 +42,8 @@ export default class StartScene extends StartSceneBase {
async start(data?) { async start(data?) {
super.start(); super.start();
initLevel(this);
updateLevelView();
egret.lifecycle.onPause = () => { egret.lifecycle.onPause = () => {
console.log("app 进入后台"); console.log("app 进入后台");
egret.ticker.pause(); // 关闭渲染与心跳 egret.ticker.pause(); // 关闭渲染与心跳
......
...@@ -2,6 +2,7 @@ import { award } from "./collisionConfig"; ...@@ -2,6 +2,7 @@ import { award } from "./collisionConfig";
import LabelType from "./LabelType"; import LabelType from "./LabelType";
import StartScene from "./StartScene"; import StartScene from "./StartScene";
import vibrate from "./vibrate"; import vibrate from "./vibrate";
import { addItem, isLevelPass, updateLevelView, nextLevel } from "./level";
const check = (_this: StartScene) => { const check = (_this: StartScene) => {
const center = 109; const center = 109;
...@@ -48,13 +49,19 @@ const check = (_this: StartScene) => { ...@@ -48,13 +49,19 @@ const check = (_this: StartScene) => {
// console.log(i.label); // console.log(i.label);
if (i.label == LabelType.Boom) { if (i.label == LabelType.Boom) {
_this._egretRender.remove(i); _this._egretRender.remove(i);
if(xResult && yResult){ if (xResult && yResult) {
}else{ } else {
vibrate(_this, 2); vibrate(_this, 2);
} }
} }
else { else {
if (xResult2 && yResult2) {
addItem(i.label);
if (isLevelPass()) {
nextLevel();
}
}
// console.log('不是boom', Date.now() / 1000); // console.log('不是boom', Date.now() / 1000);
_this._egretRender.remove(i); _this._egretRender.remove(i);
} }
......
...@@ -7,8 +7,8 @@ import StartScene from "./StartScene"; ...@@ -7,8 +7,8 @@ import StartScene from "./StartScene";
const startY = 984; const startY = 984;
const startX = 100; const startX = 100;
const restitution = 0.7; const restitution = 0.7;
// const types = [LabelType.Gift2]; const types = [LabelType.Candy2,LabelType.Donut,LabelType.Egg];
const types = [LabelType.Boom, LabelType.IceCream, LabelType.Donut, LabelType.Candy2, LabelType.Gift2, LabelType.Egg]; // const types = [LabelType.Boom, LabelType.IceCream, LabelType.Donut, LabelType.Candy2, LabelType.Gift2, LabelType.Egg];
const frameInterval =60; const frameInterval =60;
export default (_this: StartScene) => { export default (_this: StartScene) => {
......
import LabelType from "./LabelType";
import StartScene from "./StartScene";
const groups = [LabelType.Candy2, LabelType.Donut, LabelType.Egg, LabelType.Gift2, LabelType.IceCream]
let currentLv;
currentLv = groups[0];
let data: any = {};
let that: StartScene;
const MAX = 3;
export const initLevel = ($that: StartScene) => {
that = $that;
updateLevelView();
initProgressBar();
updateProgressBar(currentLv);
}
export const isLevelPass = () => {
return getProgress(currentLv) == MAX
}
export const addItem = (type) => {
if (currentLv != type) return;
if (data[type] == undefined)
data[type] = 0;
data[type]++;
if (data[type] > MAX)
data[type] = MAX;
updateLevelView();
}
export const clear = () => {
}
export const nextLevel = () => {
const i = groups.indexOf(currentLv);
currentLv = groups[i + 1];
updateLevelView();
}
export const updateLevelView = () => {
hideAllGroup();
that[currentLv].visible = true;
setProgress(currentLv, getProgress(currentLv));
}
const getProgress = (type) => {
if (data[type] == undefined)
return 0
return data[type];
}
const setProgress = (type, progress) => {
hideAllItem(type);
if (progress == 0) {
that[`${type}_0_1`].visible = true;//0是背景
that[`${type}_0_2`].visible = true;
that[`${type}_0_3`].visible = true;
that[`${type}_1_1`].visible = false;
that[`${type}_1_2`].visible = false;
that[`${type}_1_3`].visible = false;
}
if (progress == 1) {
that[`${type}_0_1`].visible = false;//0是背景
that[`${type}_0_2`].visible = true;
that[`${type}_0_3`].visible = true;
that[`${type}_1_1`].visible = true;
that[`${type}_1_2`].visible = false;
that[`${type}_1_3`].visible = false;
}
if (progress == 2) {
that[`${type}_0_1`].visible = false;//0是背景
that[`${type}_0_2`].visible = false;
that[`${type}_0_3`].visible = true;
that[`${type}_1_1`].visible = true;
that[`${type}_1_2`].visible = true;
that[`${type}_1_3`].visible = false;
}
if (progress == 3) {
that[`${type}_0_1`].visible = false;//0是背景
that[`${type}_0_2`].visible = false;
that[`${type}_0_3`].visible = false;
that[`${type}_1_1`].visible = true;
that[`${type}_1_2`].visible = true;
that[`${type}_1_3`].visible = true;
}
}
const hideAllGroup = () => {
groups.forEach(group => {
that[group].visible = false;
})
}
const hideAllItem = (type) => {
const names = getItemNames(type);
names.forEach(name => that[name].visible = false);
}
const getItemNames = (type) => {
const list = [];
for (let i = 1; i <= 3; i++) {
list.push(`_0_${i}`);
}
for (let i = 1; i <= 3; i++) {
list.push(`_1_${i}`);
}
return list.map(item => `${type}${item}`)
}
const initProgressBar = () => {
const progressfg = that['progressfg'];
const rect = new egret.Shape();
rect.graphics.beginFill(0);
rect.graphics.drawRect(0, 0, 558, 60);
rect.graphics.endFill();
progressfg.mask = rect;
progressfg['rect']=rect;
}
const updateProgressBar = (type) => {
const progressfg = that['progressfg'];
const rect:egret.Shape= progressfg['rect'];
rect.graphics.clear();
rect.graphics.beginFill(0);
rect.graphics.drawRect(0, 0, 1, 60);
rect.graphics.endFill();
// progressfg
}
\ No newline at end of file
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
"prefer-for-of": true, "prefer-for-of": true,
"no-inferrable-types": true, "no-inferrable-types": true,
// "no-magic-numbers": true, // "no-magic-numbers": true,
"cyclomatic-complexity": true // "cyclomatic-complexity": true
}, },
"rulesDirectory": [] "rulesDirectory": []
} }
\ 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