Commit 6f053187 authored by 王勇霞's avatar 王勇霞

首页更改

parent b2a3b31d
......@@ -32,7 +32,7 @@
height: 100%;
overflow: hidden;
position: absolute;
background-color: #9a3636;
background-color: #54c5f4;
-webkit-user-select: none;
/* Safari */
-ms-user-select: none;
......
resource/GameScene/cdbg.png

9.21 KB | W: | H:

resource/GameScene/cdbg.png

6.09 KB | W: | H:

resource/GameScene/cdbg.png
resource/GameScene/cdbg.png
resource/GameScene/cdbg.png
resource/GameScene/cdbg.png
  • 2-up
  • Swipe
  • Onion skin
resource/GameScene/cloud.png

4.83 KB | W: | H:

resource/GameScene/cloud.png

13.5 KB | W: | H:

resource/GameScene/cloud.png
resource/GameScene/cloud.png
resource/GameScene/cloud.png
resource/GameScene/cloud.png
  • 2-up
  • Swipe
  • Onion skin
resource/GameScene/controlpeo.png

29.9 KB | W: | H:

resource/GameScene/controlpeo.png

23.3 KB | W: | H:

resource/GameScene/controlpeo.png
resource/GameScene/controlpeo.png
resource/GameScene/controlpeo.png
resource/GameScene/controlpeo.png
  • 2-up
  • Swipe
  • Onion skin
resource/GameScene/gamebg.jpg

288 KB | W: | H:

resource/GameScene/gamebg.jpg

347 KB | W: | H:

resource/GameScene/gamebg.jpg
resource/GameScene/gamebg.jpg
resource/GameScene/gamebg.jpg
resource/GameScene/gamebg.jpg
  • 2-up
  • Swipe
  • Onion skin
......@@ -5,11 +5,11 @@
"name": "FailPanel"
},
{
"keys": "cdbg.png,closemusic.png,cloud.png,controlpeo.png,gamebg.jpg,gamebuild.png,leftbtn.png,monster.png,openmusic.png,rightbtn.png,scorebg.png,tianpop.png,xiangpop.png",
"keys": "cdbg.png,cloud.png,controlpeo.png,gamebg.jpg,monster.png,num_0.png,num_1.png,num_2.png,num_3.png,num_4.png,num_5.png,num_6.png,num_7.png,num_8.png,num_9.png,num_s.png,reset.png,tianpop.png,xiangpop.png",
"name": "GameScene"
},
{
"keys": "guide.png",
"keys": "guide.png,step1_img.png,step1_tips.png,step2_img.png,step2_tips.png,step3_img.png,step3_tips.png,step4_img.png",
"name": "GuidePanel"
},
{
......@@ -24,16 +24,12 @@
"keys": "infoline.png,light.png,sucbg.png,sucstar.png,sun.png",
"name": "SuccessPanel"
},
{
"keys": "bg.mp3,fail.mp3,get.mp3,jump.mp3",
"name": "bgm"
},
{
"keys": "closebtn.png,comCloseBtn.png,surebtn.png,toastBg.png,waitingBg.png,waitingRot.png,关闭按钮.png,关闭按钮2.png",
"name": "common"
},
{
"keys": "crypeo.svga,guidecount.svga,jumppeo.svga,popstar.svga,startbtn.svga,startpeo.svga,startpeople.svga,startpop.svga",
"keys": "atmosphere.svga,crypeo.svga,guidecount.svga,jumppeo.svga,left.svga,popstar.svga,right.svga,startbtn.svga,startpeo.svga,startpeople.svga,startpop.svga",
"name": "svga"
}
],
......
......@@ -11,7 +11,6 @@ import { G_EVENT } from "./common/G_EVENT";
import { Tools } from "./Tools";
import { destroyWebNetData } from "./webNet";
import { StartScene } from "./scenes/StartScene";
import { preloadSound } from "./common/SoundWeb";
/**
* 全局事件,为了和小程序交互
......@@ -25,7 +24,12 @@ export class Main {
private requestID;
private _pause: boolean;
private canvas: HTMLCanvasElement
constructor(canvas: HTMLCanvasElement) {
constructor(canvas: HTMLCanvasElement, data = {
time: 60,
longitude: "",
latitude: ""
}) {
Tools.configInfo = data;
var sysInfo;
//淘宝小程序环境就用canvas初始化
if (!window) {//自行处理吧,这么判断也不保险,万一淘宝小程序加进了window
......@@ -80,14 +84,6 @@ export class Main {
console.log("通用资源加载完成")
//h5环境时,隐藏加载中
if (FYGE.getEnv() == "web" && document.getElementById("__loading__")) document.getElementById("__loading__").style.display = "none";
let isIOS = Tools.isIOS()
if(isIOS){
Tools.isMusic = false
}else{
Tools.isMusic = true
}
preloadSound("bg")
changeScene(StartScene)
......
......@@ -5,11 +5,11 @@ export const ResJson = {
"name": "FailPanel"
},
{
"keys": "cdbg.png,closemusic.png,cloud.png,controlpeo.png,gamebg.jpg,gamebuild.png,leftbtn.png,monster.png,openmusic.png,rightbtn.png,scorebg.png,tianpop.png,xiangpop.png",
"keys": "cdbg.png,cloud.png,controlpeo.png,gamebg.jpg,monster.png,num_0.png,num_1.png,num_2.png,num_3.png,num_4.png,num_5.png,num_6.png,num_7.png,num_8.png,num_9.png,num_s.png,reset.png,tianpop.png,xiangpop.png",
"name": "GameScene"
},
{
"keys": "guide.png",
"keys": "guide.png,step1_img.png,step1_tips.png,step2_img.png,step2_tips.png,step3_img.png,step3_tips.png,step4_img.png",
"name": "GuidePanel"
},
{
......@@ -24,16 +24,12 @@ export const ResJson = {
"keys": "infoline.png,light.png,sucbg.png,sucstar.png,sun.png",
"name": "SuccessPanel"
},
{
"keys": "bg.mp3,fail.mp3,get.mp3,jump.mp3",
"name": "bgm"
},
{
"keys": "closebtn.png,comCloseBtn.png,surebtn.png,toastBg.png,waitingBg.png,waitingRot.png,关闭按钮.png,关闭按钮2.png",
"name": "common"
},
{
"keys": "crypeo.svga,guidecount.svga,jumppeo.svga,popstar.svga,startbtn.svga,startpeo.svga,startpeople.svga,startpop.svga",
"keys": "atmosphere.svga,crypeo.svga,guidecount.svga,jumppeo.svga,left.svga,popstar.svga,right.svga,startbtn.svga,startpeo.svga,startpeople.svga,startpop.svga",
"name": "svga"
}
],
......
......@@ -303,127 +303,6 @@ export const SkinJson = {
"source": "gamebg.jpg"
},
"id": "bg"
},
{
"name": "gamebuild",
"x": 0,
"y": 826,
"type": "sprite",
"props": {
"source": "gamebuild.png"
}
},
{
"name": "controlbtn",
"x": 80,
"y": 1164,
"type": "container",
"children": [
{
"name": "rightbtn",
"x": 0,
"y": 0,
"type": "sprite",
"props": {
"source": "rightbtn.png"
},
"id": "right"
},
{
"name": "leftbtn",
"x": 385,
"y": 0,
"type": "sprite",
"props": {
"source": "leftbtn.png"
},
"id": "left"
}
]
},
{
"name": "score",
"x": 280,
"y": 264,
"type": "container",
"children": [
{
"name": "scorebg",
"x": 0,
"y": 0,
"type": "sprite",
"props": {
"source": "scorebg.png"
},
"id": "scorebg"
},
{
"name": "scorenum",
"x": 140,
"y": 26,
"type": "text",
"props": {
"text": "",
"size": 44,
"fillColor": "#ffffff",
"textAlpha": 1,
"lineHeight": 44
},
"id": "scorenum"
}
]
},
{
"name": "countdown",
"x": 23,
"y": 264,
"type": "container",
"children": [
{
"name": "cdbg",
"x": 0,
"y": 0,
"type": "sprite",
"props": {
"source": "cdbg.png"
},
"id": "cdbg"
},
{
"name": "cdnum",
"x": 94,
"y": 26,
"type": "text",
"props": {
"text": "0s",
"size": 44,
"fillColor": "#ffffff",
"textAlpha": 1,
"lineHeight": 44
},
"id": "cdnum"
}
]
},
{
"name": "closemusic",
"x": 650,
"y": 265,
"type": "sprite",
"props": {
"source": "closemusic.png"
},
"id": "close"
},
{
"name": "openmusic",
"x": 650,
"y": 265,
"type": "sprite",
"props": {
"source": "openmusic.png"
},
"id": "open"
}
]
},
......
......@@ -7,7 +7,12 @@ import Ease = FYGE.Ease;
* 定制,记录一些全局量和通用方法
*/
export class Tools {
public static configInfo: {
longitude: string,
latitude: string,
time: number
}
/**
* 缓存key
*/
......@@ -15,8 +20,6 @@ export class Tools {
public static isMember: boolean;
public static isMusic:boolean = true;
/**
* 全局数据,重要数据
*/
......
......@@ -2,7 +2,7 @@ import { Panel } from "../../module/views/Panel";
import { changeScene, getCurrentScene, showPanel, showToast } from "../../module/ctrls";
import { StartScene } from "../scenes/StartScene";
import { GuidePanel } from "./GuidePanel";
import { getWebData, WebNetName, sendLog, LOG_TYPE, getPxTokenSave, sendWebNet } from "../webNet";
import { getWebData, WebNetName, LOG_TYPE, getPxTokenSave, sendWebNet } from "../webNet";
export class FailPanel extends Panel {
get groupNames() { return ["FailPanel"] };
get skinName() { return "FailPanel" };
......@@ -24,18 +24,14 @@ export class FailPanel extends Panel {
this.score.x = 92
this.score.textWidth = 568
this.score.textAlign = FYGE.TEXT_ALIGN.CENTER
sendLog(LOG_TYPE.EXPOSURE, 40)
sendLog(LOG_TYPE.EXPOSURE, 39)
}
back() {
this.hidePanel()
sendLog(LOG_TYPE.CLICK, 40)
changeScene(StartScene)
}
isOpen = false
async restart() {
sendLog(LOG_TYPE.CLICK, 39)
this.btnDelay(this.restartbtn)
if (!this.isOpen) {
this.isOpen = true
......
......@@ -4,10 +4,16 @@ import { RES } from "../../module/RES";
import { getCurrentScene } from "../../module/ctrls";
import { GameScene } from "../scenes/GameScene";
import { StartScene } from "../scenes/StartScene";
import UI from "../UI";
import { Tools } from "../Tools";
export class GuidePanel extends Panel {
get groupNames() { return ["GuidePanel"] };
get groupNames() { return ["GuidePanel", "GameScene"] };
get skinName() { return "GuidePanel" };
rectlayer;
clicklayer;
guideStep = 1;
svga
initUi() {
......@@ -15,35 +21,91 @@ export class GuidePanel extends Panel {
svga
async start(data) {
super.start();
GameScene.instance.scorenum.text = "0"
GameScene.instance.cdnum.text = StartScene.instance.gameInfo.duration
let svgashow = this.svga = new FYGE.SvgaAni(await RES.getResAsync("guidecount.svga"))
this.clicklayer = UI.Rect(this, 750, 1624, 0x000000, 0, 0, 0, 0.01);
this.rectlayer = UI.Ctn(this, 0, 0);
this.rectlayer.mouseEnable = false
this.rectlayer.mouseChildren = false
let svgashow = this.svga = new FYGE.SvgaAni(await RES.getResAsync("guidecount.svga"));
this.svga.position.set(170, 660)
this.svga.visible = false
this.svga.stop()
this.addChild(svgashow)
this.addChild(svgashow);
this.clicklayer.addEventListener(FYGE.MouseEvent.CLICK, () => {
if (this.guideStep < 4) {
this.guideStep++
this.guideUI();
} else if((this.guideStep == 4)) {
this.guideStep++
this.showCount();
}
}, this)
if(getWebData(WebNetName.indexInfo).data.ifFirstPlay){
this.guideUI();
} else {
this.showCount();
}
// GameScene.instance.scorenum.text = "0"
// GameScene.instance.cdnum.text = StartScene.instance.gameInfo.duration
// svgashow.lockStep = true
if(getWebData(WebNetName.startGame).data.firstGame){
svgashow.startAniRange(0,200,1,()=>{
svgashow.startAniRange(200,270,0)
this.svga.addEventListener(FYGE.MouseEvent.CLICK,this.showCount,this)
}
step3_img;
async guideUI() {
this.rectlayer.removeChildren()
if (this.guideStep == 1) {
UI.Sp(this.rectlayer, 'step1_img.png', 48, 860);
let step1_tips = UI.Sp(this.rectlayer, 'step1_tips.png', 188, 776);
FYGE.Tween.get(step1_tips, {
loop: true
})
.to({ alpha: 0.2},500)
.to({ alpha: 1},500)
} else if (this.guideStep == 2) {
UI.Sp(this.rectlayer, 'step2_img.png', 50, 492);
let step2_tips = UI.Sp(this.rectlayer, 'step2_tips.png', 198, 900);
FYGE.Tween.get(step2_tips, {
loop: true
})
this.svga.visible = true
}else{
this.showCount()
.to({ alpha: 0.2},500)
.to({ alpha: 1},500)
} else if (this.guideStep == 3) {
this.step3_img = UI.Sp(this.rectlayer, 'step3_img.png', 311, 333);
this.cdUIRender(Tools.configInfo.time)
let step3_tips = UI.Sp(this.rectlayer, 'step3_tips.png', 236, 850);
FYGE.Tween.get(step3_tips, {
loop: true
})
.to({ alpha: 0.2},500)
.to({ alpha: 1},500)
} else if (this.guideStep == 4){
let atmosphere = new FYGE.SvgaAni(await RES.getResAsync("atmosphere.svga"))
this.rectlayer.addChild(atmosphere)
atmosphere.position.set(18, 324)
UI.Sp(this.rectlayer, 'step4_img.png', 95, 540);
}
}
cdUIRender(num = 60) {
// 先清除所有节点
this.step3_img.removeChildren();
let str = num + 's';
let arr = str.split("");
let startPos = (130 - (30 * arr.length)) / 2
arr.forEach((item, index) => {
UI.Sp(this.step3_img, `num_${item}.png`, startPos + (index * 30), 38)
})
}
showCount(){
this.svga.removeEventListener(FYGE.MouseEvent.CLICK,this.showCount,this)
this.svga.startAniRange(275,undefined,1,()=>{
this.removeChild(this.rectlayer)
this.svga.visible = true
this.svga.startAniRange(1,105,1,()=>{
this.removeChild(this.svga)
this.hidePanel()
getCurrentScene().upDateInfo()
setTimeout(()=>{
this.hidePanel()
getCurrentScene().upDateInfo()
},100)
})
this.svga.visible = true
}
initEvents() {
super.initEvents();
......
......@@ -2,7 +2,7 @@ import { Panel } from "../../module/views/Panel";
import { RES } from "../../module/RES";
import { changeScene } from "../../module/ctrls";
import { StartScene } from "../scenes/StartScene";
import { getWebData, WebNetName, sendLog, LOG_TYPE } from "../webNet";
import { getWebData, WebNetName, LOG_TYPE } from "../webNet";
export class SuccessPanel extends Panel {
get groupNames() { return ["SuccessPanel"] };
get skinName() { return "SuccessPanel" };
......@@ -38,11 +38,9 @@ export class SuccessPanel extends Panel {
let endInfo = getWebData(WebNetName.submitGame).data
this.score.text = endInfo.score+""
this.sunscore.text = "x"+endInfo.sunNum+""
sendLog(LOG_TYPE.EXPOSURE,38)
}
back(){
this.hidePanel()
sendLog(LOG_TYPE.CLICK,38)
changeScene(StartScene)
}
initEvents() {
......
import { Scene } from "../../module/views/Scene";
import * as Matter from "matter-js";
import Role from "./components/Role";
import { RES } from "../../module/RES";
import AddProp from "./components/AddProp";
import ObstacleProp from "./components/ObstacleProp";
import MapItem from "./components/MapItem";
import { getWebData, WebNetName, sendWebNet, sendLog, LOG_TYPE } from "../webNet";
import { getWebData, WebNetName, sendWebNet, LOG_TYPE } from "../webNet";
import { showPanel, showToast, changeScene } from "../../module/ctrls";
import { GuidePanel } from "../panels/GuidePanel";
import { StartScene } from "./StartScene";
......@@ -12,26 +13,25 @@ import { SuccessPanel } from "../panels/SuccessPanel";
import { FailPanel } from "../panels/FailPanel";
import { duiba_md5 } from "../../module/tools/security";
import { Tools } from "../Tools";
import { playAllSound, stopAllSound, cusPlaySound } from "../common/SoundWeb";
import { playAllSound } from "../common/SoundWeb";
import { layers } from "../../module/views/layers";
import UI from "../UI";
export class GameScene extends Scene {
get groupNames() { return ["GameScene"] };
get skinName() { return "GameScene" };
bg: FYGE.Sprite;
left;
right;
cdbg: FYGE.Sprite;
time = Tools.configInfo.time;
// --------
cloud: FYGE.Sprite;
peo: FYGE.Sprite;
tianpop: FYGE.Sprite;
xiangpop: FYGE.Sprite;
monster: FYGE.Sprite;
right: FYGE.Sprite;
left: FYGE.Sprite;
scorebg: FYGE.Sprite;
scorenum: FYGE.TextField;
cdbg: FYGE.Sprite;
cdnum: FYGE.TextField;
close: FYGE.Sprite;
open: FYGE.Sprite;
jumpLock = false;
......@@ -41,67 +41,84 @@ export class GameScene extends Scene {
initUi() {
}
start(data) {
async start(data) {
super.start();
sendLog(LOG_TYPE.EXPOSURE,37)
GameScene.instance = this
showPanel(GuidePanel);
if (Tools.isMusic) {
this.open.visible = true;
this.close.visible = false
cusPlaySound("bg", true)
} else {
this.open.visible = false;
this.close.visible = true
}
// showPanel(GuidePanel);
// 左右按钮
this.left = new FYGE.SvgaAni(await RES.getResAsync("left.svga"))
this.left = this.addChild(this.left)
this.left.position.set(8, 979);
this.left.startAniRange(1, 1, 1);
this.right = new FYGE.SvgaAni(await RES.getResAsync("right.svga"))
this.right = this.addChild(this.right)
this.right.position.set(524, 979);
this.right.startAniRange(1, 1, 1);
this.left.addEventListener(FYGE.MouseEvent.CLICK, () => {
this.left.startAniRange(1, undefined, 1, () => {})
this._role.leftMove()
})
this.right.addEventListener(FYGE.MouseEvent.CLICK, () => {
this.right.startAniRange(1, undefined, 1, () => {})
this._role.rightMove()
})
// 倒计时
this.cdbg = UI.Sp(this, "cdbg.png", 280, 330)
this.cdUIRender(this.time)
// 物理引擎
this.createPhyWorld()
this.bgCon = this.addChild(new FYGE.Container());
this.setChildIndex(this.bgCon, 2)
this.setChildIndex(this.bgCon, 1)
this.initMap();
this.scorenum.text = "0"
this.cdnum.text = StartScene.instance.gameInfo.duration
// TODO_wyx
this.upDateInfo()
}
score;
time;
changeMusic() {
this.open.visible = !this.open.visible
this.close.visible = !this.close.visible
Tools.isMusic = !Tools.isMusic
if (Tools.isMusic) {
// playAllSound()
cusPlaySound("bg", true)
} else {
stopAllSound()
}
}
upDateInfo() {
this.score = 0
this.time = StartScene.instance.gameInfo.duration
this.scorenum.text = this.score + ""
this.cdnum.text = this.time + ""
// this.score = 0
// this.time = StartScene.instance.gameInfo.duration
this.time = Tools.configInfo.time;
this.cdUIRender(this.time)
this.startGame()
this.countDown(this.time)
}
countDown(time) {
if (this.timer) {
clearTimeout(this.timer);
}
this.timer = setTimeout(() => {
if (Number(this.cdnum.text) <= 0) {
if (this.time <= 0) {
clearTimeout(this.timer);
this.composites.remove(this.world, this._role.phyBody);
console.log("zale")
this.gameOver()
return
}
this.cdnum.text = Number(this.cdnum.text) - 1 + ''
this.countDown(Number(this.cdnum.text))
this.time = this.time - 1;
this.cdUIRender(this.time)
this.countDown(this.time)
}, 1000)
}
cdUIRender(num = 60) {
// 先清除所有节点
this.cdbg.removeChildren();
let str = num + 's';
let arr = str.split("");
let startPos = (192 - (30 * arr.length)) / 2
arr.forEach((item, index) => {
UI.Sp(this.cdbg, `num_${item}.png`, startPos + (index * 30), 46)
})
}
startGame() {
this.isonce = false
......@@ -130,6 +147,18 @@ export class GameScene extends Scene {
addPropsMap = new Map();
obstaclePropMap = new Map();
private createPhyWorld() {
// const { Engine, Render, Runner, Composite, Bodies, World, Composites } = Matter;
// // 创建引擎
// const engine = Engine.create();
// // 创建渲染器
// const render = Render.create({
// engine: engine
// })
// Engine.run(engine);
// Render.run(render);
const { Engine, Render, Runner, Composite, Bodies, World, Composites } = Matter;
this.engine = Engine.create(
{
......@@ -147,8 +176,6 @@ export class GameScene extends Scene {
Matter.Events.on(this.engine, "collisionStart", this.onCollisionStart.bind(this));
Matter.Events.on(this.engine, "tick", this.onCollisionTick.bind(this));
}
onCollisionTick(e) {
}
......@@ -168,11 +195,7 @@ export class GameScene extends Scene {
num = 2
}
this._role.addScore('+' + num, '#ffffff')
if (Tools.isMusic) {
cusPlaySound("get", false)
}
this.scorenum.text = Number(this.scorenum.text) + num + '';
this.score += num
this.composites.remove(this.world, prop.phyBody);
prop.destroy();
......@@ -182,9 +205,6 @@ export class GameScene extends Scene {
} else if (p.bodyB.gameType == 'dieProp' || p.bodyA.gameType == 'dieProp') {
// 死亡💀
console.log("死亡")
if (Tools.isMusic) {
cusPlaySound("fail", false)
}
let body = p.bodyB.gameType == 'dieProp' ? p.bodyB : p.bodyA;
let prop = this.obstaclePropMap.get(body.id);
this.composites.remove(this.world, prop.phyBody);
......@@ -197,9 +217,6 @@ export class GameScene extends Scene {
this.gameOver()
} else {
if (!this.jumpLock) {
if (Tools.isMusic) {
cusPlaySound("jump", false)
}
this._role.jump()
this.jumpLock = true;
setTimeout(() => {
......@@ -214,19 +231,19 @@ export class GameScene extends Scene {
initMap() {
let stageHeight = this.stage.stageHeight;
this.createLineItem(stageHeight - 240, 380, false);
this.createLineItem(stageHeight - 100, 380, false);
for (let i = 0; i < 10; i++) {
// for (let i = 0; i < 10; i++) {
if (i < 4) {
this.createLineItem(stageHeight - (240 * (i + 2)), 0, false);
// if (i < 4) {
// this.createLineItem(stageHeight - (240 * (i + 2)), 0, false);
} else {
this.createLineItem(stageHeight - (240 * (i + 2)));
// } else {
// this.createLineItem(stageHeight - (240 * (i + 2)));
}
// }
}
// }
}
......@@ -352,49 +369,35 @@ export class GameScene extends Scene {
async gameOver() {
this.removeEventListener(FYGE.Event.ENTER_FRAME, this.onFarm, this);
this.removeWorld()
let startInfo = getWebData(WebNetName.startGame).data.currInfo
let timestamp = new Date().getTime()
//签名方式: md5(score=分值&startId=游戏开始id&timestamp=timestamp&key=key)
//其中key的值为开始游戏接口里返回的key+固定值9ef16b33920749fb26e8fc2f2913150a, 例如1234569ef16b33920749fb26e8fc2f2913150a
let sign = duiba_md5(`score=${this.score}&startId=${startInfo.startId}&timestamp=${timestamp}&key=${startInfo.key + "9ef16b33920749fb26e8fc2f2913150a"}`)
const { success, data, message } = await sendWebNet(WebNetName.submitGame, { score: this.score, sign: sign, code: startInfo.code, timestamp: timestamp ,startId:startInfo.startId})
this._role.die(() => {
this.bgCon.removeChildren()
this.bgCon.y = 0
if (!success) {
showToast(message || "网络异常,请重试~")
changeScene(StartScene)
return
}
if (data.pass) {
showPanel(SuccessPanel)
} else {
showPanel(FailPanel)
}
})
// let startInfo = getWebData(WebNetName.startGame).data.currInfo
// let timestamp = new Date().getTime()
// //签名方式: md5(score=分值&startId=游戏开始id&timestamp=timestamp&key=key)
// //其中key的值为开始游戏接口里返回的key+固定值9ef16b33920749fb26e8fc2f2913150a, 例如1234569ef16b33920749fb26e8fc2f2913150a
// let sign = duiba_md5(`score=${this.score}&startId=${startInfo.startId}&timestamp=${timestamp}&key=${startInfo.key + "9ef16b33920749fb26e8fc2f2913150a"}`)
// const { success, data, message } = await sendWebNet(WebNetName.submitGame, { score: this.score, sign: sign, code: startInfo.code, timestamp: timestamp ,startId:startInfo.startId})
// this._role.die(() => {
// this.bgCon.removeChildren()
// this.bgCon.y = 0
// if (!success) {
// showToast(message || "网络异常,请重试~")
// changeScene(StartScene)
// return
// }
// if (data.pass) {
// showPanel(SuccessPanel)
// } else {
// showPanel(FailPanel)
// }
// })
}
initEvents() {
super.initEvents();
this.left.addEventListener(FYGE.MouseEvent.CLICK, () => {
sendLog(LOG_TYPE.CLICK,37)
this._role.leftMove()
})
this.right.addEventListener(FYGE.MouseEvent.CLICK, () => {
sendLog(LOG_TYPE.CLICK,37)
this._role.rightMove()
})
this.open.addEventListener(FYGE.MouseEvent.CLICK, this.changeMusic, this)
this.close.addEventListener(FYGE.MouseEvent.CLICK, this.changeMusic, this)
}
removeEvents() {
super.removeEvents();
this.open.removeEventListener(FYGE.MouseEvent.CLICK, this.changeMusic, this)
this.close.removeEventListener(FYGE.MouseEvent.CLICK, this.changeMusic, this)
stopAllSound()
}
}
......@@ -61,8 +61,8 @@ export class StartScene extends Scene {
"sun": 10
}
// this.openGame()
// TODO_wyx
this.openGame()
// for (let i = 0; i < data.gamecfs.length; i++) {
// if (data.gamecfs[i].code == data.gameCode) {
......@@ -75,35 +75,39 @@ export class StartScene extends Scene {
openRule() {
GDispatcher.dispatchEvent("openRule");
}
isOpen = false
startId;
getWordList() {
let dataInfo = getWebData(WebNetName.indexInfo).data.dataInfo;
let hasWordList:any = [];
let noWordList:any = [];
dataInfo.forEach(item => {
if (item.context) {
hasWordList = hasWordList.concat(item.context.split(""))
}
})
allWords.forEach(item => {
if (!hasWordList.includes(item) && !noWordList.includes(item)) {
noWordList.push(item)
}
})
return noWordList
}
async openGame() {
this.btnDelay(this.startbtn)
if (this.indexInfo) {
if (!this.indexInfo.dailyPass) {
if (!this.isOpen) {
this.isOpen = true
let token = ""
const { success, code, data, message } = await sendWebNet(WebNetName.startGame, { token: token })
if (!success) {
this.isOpen = false
if (code == "20004") {
showToast("今日已过关,明日再来~")
} else {
showToast(message || "网络异常,请重试~")
}
return
}
this.isOpen = false
changeScene(GameScene)
}
} else {
showToast("今日已过关,明日再来~")
}
if (this.getWordList().length == 0) {
showToast("您已获取今日全部游戏奖励,\n请明日再来");
return
}
const { success, code, data, desc } = await sendWebNet(WebNetName.startGame, {
activityId: getUrlParams('activityId'),
type: 3
})
if (success) {
this.startId = data.startId;
changeScene(GameScene)
} else {
showToast("网络异常,请重试~")
showToast(desc || "网络开小差了,稍后再试")
}
}
goback() {
GDispatcher.dispatchEvent("backIndex");
......
import * as Matter from "matter-js";
import { RES } from "../../../module/RES";
import UI from "../../UI";
export default class MapItem extends FYGE.Container {
public phyBody: Matter.Body;
itemImg: FYGE.Sprite;
constructor() {
super();
let itemImg = this.itemImg = new FYGE.Sprite();
itemImg.texture = RES.getRes("cloud.png");
itemImg.width = itemImg.width*1.4
itemImg.position.set(-itemImg.width / 2, -10);
this.addChild(itemImg);
// itemImg.position.set(-itemImg.width / 2, -10);
let itemImg = this.itemImg = UI.Sp(this, "cloud.png", 0, 0);
this.phyBody = Matter.Bodies.rectangle(this.x, this.y,itemImg.width,5, {
this.phyBody = Matter.Bodies.rectangle(this.x, this.y,itemImg.width, 5, {
isStatic: true,
friction: 1,
isSensor: true, // 传感器,可以检测到碰撞,但是不参与碰撞
render: {
fillStyle: "blue" // 填充的颜色
}
});
this.phyBody.gameType = 'item'
setTimeout(() => {
this.setPhyPos();
}, 200)
}
......
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