Commit efd335fc authored by wildfirecode's avatar wildfirecode

1

parent a5e05ff4
......@@ -22,4 +22,5 @@
# doc/*.txt
# 会忽略 doc/notes.txt 但不包括 doc/server/arch.txt
node_modules
bin-release
\ No newline at end of file
bin-release
.DS_Store
No preview for this file type
{
"version": "0.2.0",
"configurations": [
{
"name": "Wing 内置播放器调试",
"type": "chrome",
"request": "launch",
"file": "index.html",
//"url": "http://mysite.com/index.html",
"runtimeExecutable": "${execPath}",
"sourceMaps": true,
"webRoot": "${workspaceRoot}",
"preLaunchTask":"build",
"port":5826
},
{
"name": "使用本机 Chrome 调试",
"type": "chrome",
"request": "launch",
"file": "index.html",
//"url": "http://mysite.com/index.html",
"runtimeExecutable": "",
"sourceMaps": true,
"webRoot": "${workspaceRoot}",
"preLaunchTask":"build",
"userDataDir":"${tmpdir}",
"port":5826
}
]
}
\ No newline at end of file
{
"version": "0.1.0",
"command": "egret",
"isShellCommand": true,
"tasks": [
{
"taskName": "build",
"showOutput": "always",
"args": [
"build",
"-sourcemap"
],
"problemMatcher": "$tsc"
},
{
"taskName": "clean",
"showOutput": "always",
"args": [
"build",
"-e"
],
"problemMatcher": "$tsc"
},
{
"taskName": "publish",
"showOutput": "always",
"args": [
"publish"
],
"problemMatcher": "$tsc"
}
]
}
\ No newline at end of file
......@@ -87,9 +87,12 @@ const check_webp_feature = (callback) => {
img.src = "data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA";
}
export const getImgURL = (url: string, cb) => {
check_webp_feature((isSupport) => {
if (isSupport) url += '?x-oss-process=image/format,webp';
cb(url)
export const getImgURL = (url: string):any => {
return new Promise((resolve, reject) => {
check_webp_feature((isSupport) => {
if (isSupport) url += '?x-oss-process=image/format,webp';
resolve(url);
})
})
}
\ No newline at end of file
import PanelCtrl from "../../src/ctrls/panelCtrl";
import SceneCtrl from "../../src/ctrls/sceneCtrl";
import Loading from "../../src/loading/Loading";
import { getResPath } from "../../src/utils";
import layers from "../../src/views/layers";
import { DataManager } from "../tw/manager/DataManager";
import { NetManager } from "../tw/manager/NetManager";
import AssetAdapter from "./adapter/AssetAdapter";
import ThemeAdapter from "./adapter/ThemeAdapter";
export default class MainBase extends eui.UILayer {
protected createChildren(): void {
super.createChildren();
egret.lifecycle.addLifecycleListener((context) => {
// custom lifecycle plugin
})
egret.lifecycle.onPause = () => {
egret.ticker.pause();
}
egret.lifecycle.onResume = () => {
egret.ticker.resume();
}
//inject the custom material parser
//注入自定义的素材解析器
let assetAdapter = new AssetAdapter();
egret.registerImplementation("eui.IAssetAdapter", assetAdapter);
egret.registerImplementation("eui.IThemeAdapter", new ThemeAdapter());
egret.ImageLoader.crossOrigin = "anonymous";
DataManager.ins.gameCfgData = window['CFG'];
DataManager.ins.gameCfgData.gameInfo.gameId = window["gameId"];
layers.init(this);
Loading.init(layers.topLayer);
PanelCtrl.instance.init(layers.popupLayer);
SceneCtrl.instance.init(layers.sceneLayer);
this.stage.scaleMode = egret.StageScaleMode.FIXED_WIDTH;
this.registerModules();
this.runGame().catch(e => {
console.log(e);
})
}
protected registerModules() { }
private async runGame() {
await this.loadResource()
this.createGameScene();
}
private async loadResource() {
try {
await RES.loadConfig("default.res.json", getResPath() + "resource/");
await this.loadTheme();
}
catch (e) {
console.error(e);
}
}
private loadTheme() {
return new Promise((resolve, reject) => {
// load skin theme configuration file, you can manually modify the file. And replace the default skin.
//加载皮肤主题配置文件,可以手动修改这个文件。替换默认皮肤。
let theme = new eui.Theme("resource/default.thm.json", this.stage);
theme.addEventListener(eui.UIEvent.COMPLETE, () => {
resolve();
}, this);
})
}
/**
* 创建场景界面
* Create scene interface
*/
protected createGameScene() {
NetManager.ins.getInfo(() => {
// 等待开奖 ↓
if (DataManager.ins.getInfoData.status.code == 4) {
// 已开奖 ↓
} else if (DataManager.ins.getInfoData.status.code == 5) {
// 正常游戏 ↓
} else {
}
});
}
}
\ No newline at end of file
//////////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2014-present, Egret Technology.
// All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of the Egret nor the
// names of its contributors may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////////////
export default class AssetAdapter implements eui.IAssetAdapter {
/**
* @language zh_CN
......
//////////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2014-present, Egret Technology.
// All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of the Egret nor the
// names of its contributors may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////////////
export default class ThemeAdapter implements eui.IThemeAdapter {
/**
......
{
"type": "activity",
"name": "demo"
"name": "fishing"
}
\ No newline at end of file
{"options":{"layoutMath":"2","sizeMode":"2n","useExtension":1,"layoutGap":1,"extend":0},"projectName":"alert_3","version":5,"files":["../assets/alert/Bitmap-4.png","../assets/alert/Bitmap-2.png","../assets/alert/Bitmap-1.png"]}
\ No newline at end of file
{"options":{"layoutMath":"2","sizeMode":"2n","useExtension":1,"layoutGap":1,"extend":0},"projectName":"loading_2","version":5,"files":["../assets/loading/bg.png","../assets/loading/progress.png"]}
\ No newline at end of file
{"options":{"layoutMath":"2","sizeMode":"2n","useExtension":1,"layoutGap":1,"extend":0},"projectName":"msg_0","version":5,"files":["../assets/msg/msgBg.png","../assets/msg/x.png","../assets/msg/sureBtn.png"]}
\ No newline at end of file
{"options":{"layoutMath":"2","sizeMode":"2n","useExtension":1,"layoutGap":1,"extend":0},"projectName":"playScene_1","version":5,"files":["../assets/playScene/wheelBg2.png","../assets/playScene/wating.png","../assets/playScene/startBtnBg.png","../assets/playScene/sideLightL.png","../assets/playScene/sideLightD.png","../assets/playScene/ruleBtn.png","../assets/playScene/redPacket.png","../assets/playScene/outShell.png","../assets/playScene/myCreditsBg.png","../assets/playScene/multiple3.png","../assets/playScene/multiple.png","../assets/playScene/heartB.png","../assets/playScene/go.png","../assets/playScene/gift.png","../assets/playScene/finger.png","../assets/playScene/earnPanel.png","../assets/playScene/coinIcon.png","../assets/playScene/coinf8.png","../assets/playScene/coinf7.png","../assets/playScene/coinf6.png","../assets/playScene/coinf5.png","../assets/playScene/coinf4.png","../assets/playScene/coinf3.png","../assets/playScene/coinf2.png","../assets/playScene/coinf1.png","../assets/playScene/circleLight2.png","../assets/playScene/circleLight1.png","../assets/playScene/+.png","../assets/playScene/-_.png"]}
\ No newline at end of file
{"options":{"layoutMath":"2","sizeMode":"2n","useExtension":1,"layoutGap":1,"extend":0},"projectName":"rule_4","version":5,"files":["../assets/rule/ruleBg.png","../assets/rule/X.png"]}
\ No newline at end of file
{"mc":{
"coin":{
"frameRate":24,
"labels":[
{"name":"rotate","frame":1,"end":8}
],
"events":[
],
"frames":[
{
"res":"DB0A020",
"x":0,
"y":0
},
{
"res":"11118EED",
"x":0,
"y":0
},
{
"res":"3ED3A22C",
"x":8,
"y":0
},
{
"res":"EA81E94D",
"x":20,
"y":0
},
{
"res":"9D677726",
"x":37,
"y":0
},
{
"res":"7A80B82A",
"x":20,
"y":0
},
{
"res":"AA7CF946",
"x":8,
"y":0
},
{
"res":"2E51F51A",
"x":0,
"y":0
}
]
}},
"res":{
"AA7CF946":{"x":176,"y":97,"w":78,"h":94},
"11118EED":{"x":1,"y":1,"w":93,"h":94},
"EA81E94D":{"x":191,"y":1,"w":53,"h":94},
"2E51F51A":{"x":96,"y":1,"w":93,"h":94},
"7A80B82A":{"x":1,"y":193,"w":53,"h":94},
"3ED3A22C":{"x":96,"y":97,"w":78,"h":94},
"9D677726":{"x":56,"y":193,"w":20,"h":94},
"DB0A020":{"x":1,"y":97,"w":93,"h":94}
}}
\ No newline at end of file
{"mc":{
"go":{
"frameRate":20,
"labels":[
{"name":"light","frame":1,"end":30}
],
"events":[
],
"frames":[
{
"res":"A9D1D9F7",
"x":8,
"y":5
},
{
"res":"A9D1D9F7",
"x":8,
"y":5
},
{
"res":"165B8393",
"x":8,
"y":5
},
{
"res":"165B8393",
"x":8,
"y":5
},
{
"res":"C533ADB8",
"x":8,
"y":5
},
{
"res":"C533ADB8",
"x":8,
"y":5
},
{
"res":"7C56153B",
"x":6,
"y":5
},
{
"res":"C3226410",
"x":6,
"y":5
},
{
"res":"C3226410",
"x":6,
"y":5
},
{
"res":"8A450EA9",
"x":8,
"y":5
},
{
"res":"764FAFD2",
"x":8,
"y":5
},
{
"res":"A86D3DEA",
"x":8,
"y":5
},
{
"res":"F8A55074",
"x":8,
"y":4
},
{
"res":"6DDF7B77",
"x":8,
"y":4
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"AF8A3362",
"x":8,
"y":5
},
{
"res":"10E93F01",
"x":8,
"y":5
}
]
}},
"res":{
"10E93F01":{"x":709,"y":1,"w":174,"h":176},
"C3226410":{"x":1,"y":1,"w":176,"h":176},
"764FAFD2":{"x":1,"y":179,"w":174,"h":176},
"C533ADB8":{"x":1,"y":357,"w":174,"h":176},
"6DDF7B77":{"x":533,"y":1,"w":174,"h":177},
"F8A55074":{"x":357,"y":1,"w":174,"h":177},
"A86D3DEA":{"x":177,"y":179,"w":174,"h":176},
"165B8393":{"x":709,"y":179,"w":174,"h":176},
"A9D1D9F7":{"x":353,"y":180,"w":174,"h":176},
"AF8A3362":{"x":529,"y":180,"w":174,"h":176},
"7C56153B":{"x":179,"y":1,"w":176,"h":176},
"8A450EA9":{"x":177,"y":357,"w":174,"h":176}
}}
\ No newline at end of file
......@@ -4,10 +4,6 @@
"keys": "msgBg_png,x_png,sureBtn_png",
"name": "msg"
},
{
"keys": "wheelBg2_png,wating_png,startBtnBg_png,sideLightL_png,sideLightD_png,ruleBtn_png,redPacket_png,outShell_png,myCreditsBg_png,multiple3_png,multiple_png,heartB_png,goBtn_png,goBtn_json,go_png,gift_png,finger_png,earnPanel_png,coinIcon_png,coinf8_png,coinf7_png,coinf6_png,coinf5_png,coinf4_png,coinf3_png,coinf2_png,coinf1_png,coin_png,coin_json,circleLight2_png,circleLight1_png,+_png,-__png,playSceneBg_jpg",
"name": "playScene"
},
{
"keys": "bg_png,progress_png",
"name": "loading"
......@@ -21,8 +17,8 @@
"name": "rule"
},
{
"keys": "playSceneBg_jpg",
"name": "preload"
"keys": "monkey_png",
"name": "start_monkey"
}
],
"resources": [
......@@ -56,161 +52,6 @@
"type": "image",
"name": "x_png"
},
{
"url": "assets/playScene/+.png",
"type": "image",
"name": "+_png"
},
{
"url": "assets/playScene/-_.png",
"type": "image",
"name": "-__png"
},
{
"url": "assets/playScene/circleLight1.png",
"type": "image",
"name": "circleLight1_png"
},
{
"url": "assets/playScene/circleLight2.png",
"type": "image",
"name": "circleLight2_png"
},
{
"url": "assets/playScene/coin.png",
"type": "image",
"name": "coin_png"
},
{
"url": "assets/playScene/coinIcon.png",
"type": "image",
"name": "coinIcon_png"
},
{
"url": "assets/playScene/coinf1.png",
"type": "image",
"name": "coinf1_png"
},
{
"url": "assets/playScene/coinf2.png",
"type": "image",
"name": "coinf2_png"
},
{
"url": "assets/playScene/coinf3.png",
"type": "image",
"name": "coinf3_png"
},
{
"url": "assets/playScene/coinf4.png",
"type": "image",
"name": "coinf4_png"
},
{
"url": "assets/playScene/coinf5.png",
"type": "image",
"name": "coinf5_png"
},
{
"url": "assets/playScene/coinf6.png",
"type": "image",
"name": "coinf6_png"
},
{
"url": "assets/playScene/coinf7.png",
"type": "image",
"name": "coinf7_png"
},
{
"url": "assets/playScene/coinf8.png",
"type": "image",
"name": "coinf8_png"
},
{
"url": "assets/playScene/earnPanel.png",
"type": "image",
"name": "earnPanel_png"
},
{
"url": "assets/playScene/finger.png",
"type": "image",
"name": "finger_png"
},
{
"url": "assets/playScene/gift.png",
"type": "image",
"name": "gift_png"
},
{
"url": "assets/playScene/go.png",
"type": "image",
"name": "go_png"
},
{
"url": "assets/playScene/goBtn.png",
"type": "image",
"name": "goBtn_png"
},
{
"url": "assets/playScene/heartB.png",
"type": "image",
"name": "heartB_png"
},
{
"url": "assets/playScene/multiple.png",
"type": "image",
"name": "multiple_png"
},
{
"url": "assets/playScene/multiple3.png",
"type": "image",
"name": "multiple3_png"
},
{
"url": "assets/playScene/myCreditsBg.png",
"type": "image",
"name": "myCreditsBg_png"
},
{
"url": "assets/playScene/outShell.png",
"type": "image",
"name": "outShell_png"
},
{
"url": "assets/playScene/redPacket.png",
"type": "image",
"name": "redPacket_png"
},
{
"url": "assets/playScene/ruleBtn.png",
"type": "image",
"name": "ruleBtn_png"
},
{
"url": "assets/playScene/sideLightD.png",
"type": "image",
"name": "sideLightD_png"
},
{
"url": "assets/playScene/sideLightL.png",
"type": "image",
"name": "sideLightL_png"
},
{
"url": "assets/playScene/startBtnBg.png",
"type": "image",
"name": "startBtnBg_png"
},
{
"url": "assets/playScene/wating.png",
"type": "image",
"name": "wating_png"
},
{
"url": "assets/playScene/wheelBg2.png",
"type": "image",
"name": "wheelBg2_png"
},
{
"url": "assets/loading/bg.png",
"type": "image",
......@@ -232,19 +73,14 @@
"name": "ruleBg_png"
},
{
"url": "assets/playScene/coin.json",
"type": "json",
"name": "coin_json"
},
{
"url": "assets/playScene/goBtn.json",
"type": "json",
"name": "goBtn_json"
"url": "assets/startScene/bg.jpg",
"type": "image",
"name": "bg_jpg"
},
{
"url": "assets/playScene/playSceneBg.jpg",
"url": "assets/startScene/monkey/monkey.png",
"type": "image",
"name": "playSceneBg_jpg"
"name": "monkey_png"
}
]
}
\ No newline at end of file
......@@ -5,14 +5,8 @@
"resource/skins/AlertSkin.exml",
"resource/skins/LoadingSkin.exml",
"resource/skins/MsgSkin.exml",
"resource/skins/PlaySkin.exml",
"resource/skins/RuleSkin.exml",
"resource/skins/component/ResultPanel.exml",
"resource/skins/component/WheelBg.exml",
"resource/skins/component/WheelGift.exml",
"resource/skins/ui/IconButtonSkin.exml",
"resource/skins/ui/ProgressBarSkin.exml",
"resource/skins/ui/StartButtonSkin.exml"
"resource/skins/StartSkin.exml"
],
"path": "resource/default.thm.json"
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="PlaySkin" width="750" height="1206" xmlns:e="http://ns.egret.com/eui" xmlns:w="http://ns.egret.com/wing" >
<e:Image id="gamebg" x="0" y="0" source="playSceneBg_jpg"/>
<e:Button id="ruleBtn" label="" skinName="ui.IconButtonSkin" icon="ruleBtn_png" name="ruleBtn" horizontalCenter="-340" verticalCenter="-522.5"/>
<e:Button id="addBtn" label="" icon="+_png" name="addBtn" skinName="ui.IconButtonSkin" horizontalCenter="129.5" verticalCenter="388"/>
<e:Button id="reduceBtn" label="" icon="-__png" name="reduceBtn" skinName="ui.IconButtonSkin" anchorOffsetX="0" anchorOffsetY="0" horizontalCenter="-61.5" verticalCenter="388"/>
<e:Component id="WheelBg" skinName="WheelBg" width="603" height="603" horizontalCenter="0" verticalCenter="-23.5"/>
<e:Image id="outShell" source="outShell_png" verticalCenter="-20.5" horizontalCenter="3.5"/>
<e:Button id="startBtn" label="" icon="startBtnBg_png" horizontalCenter="0.5" verticalCenter="-40" skinName="ui.StartButtonSkin"/>
<e:Label id="unitTxt" text="投入积分" x="201.61" y="960" anchorOffsetX="0" width="63.39" anchorOffsetY="0" height="63.97" textAlign="center" textColor="0xffc303" fontFamily="微软雅黑"/>
<e:Label id="costTxt" text="40" size="40" anchorOffsetX="0" width="132" x="343" y="974.24" textAlign="center"/>
<e:Image id="myCreditsBg" source="myCreditsBg_png" y="884" horizontalCenter="0"/>
<e:Image x="233.31" y="893" anchorOffsetX="0" width="36" anchorOffsetY="0" height="36" source="coinIcon_png"/>
<e:Label id="userCreditsUnitName" text="总积分积分" x="276.8" y="898.34" anchorOffsetX="0" width="156.03" size="22" textColor="0xf7de4c" fontFamily="微软雅黑" height="25.33" anchorOffsetY="0"/>
<e:Label id="userCreditsNum" text="2000" x="384.33" y="895" anchorOffsetX="0" width="129.87" size="30" textAlign="center" textColor="0xf7de4c" height="24"/>
<e:Image id="circleLight1" source="circleLight1_png" y="265" height="630" width="630" horizontalCenter="0"/>
<e:Image id="circleLight2" source="circleLight2_png" width="630" height="630" horizontalCenter="0" verticalCenter="-23"/>
<e:Image id="sideLightD" source="sideLightD_png" x="46" y="396"/>
<e:Image id="sideLightL" source="sideLightL_png" x="-10" y="361.67"/>
<e:Image id="finger" source="finger_png" horizontalCenter="87.5" verticalCenter="44"/>
<e:Panel id="resulePanel" width="374" height="159" skinName="component.ResultPanel" anchorOffsetX="187" anchorOffsetY="79.5" scaleX="0" scaleY="0" horizontalCenter="-1" verticalCenter="-23.5"/>
</e:Skin>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="StartSkin" width="400" height="300" xmlns:e="http://ns.egret.com/eui">
</e:Skin>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="component.ResultPanel" width="378" height="164" xmlns:e="http://ns.egret.com/eui" xmlns:w="http://ns.egret.com/wing">
<e:Image id="bg" source="earnPanel_png" x="0" y="0"/>
<e:Label id="credits" text="0" x="41.5" y="65" size="64" anchorOffsetX="0" width="292" textAlign="center"/>
</e:Skin>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="WheelBg" width="603" height="603" xmlns:e="http://ns.egret.com/eui" xmlns:w="http://ns.egret.com/wing">
<e:Image id="wheelBg" source="wheelBg2_png" anchorOffsetX="301.5" anchorOffsetY="301.5" left="0" top="0"/>
<e:Image source="gift_png" x="176.5" y="76.5" rotation="-22.5"/>
</e:Skin>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="WheelGift" width="92" height="300" xmlns:e="http://ns.egret.com/eui" xmlns:w="http://ns.egret.com/wing">
<e:Image id="gift" source="gift_png" y="61" horizontalCenter="0"/>
</e:Skin>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="ui.IconButtonSkin" xmlns:e="http://ns.egret.com/eui" xmlns:ns1="*" states="up,down,disabled" >
<e:Image id="iconDisplay" source="" horizontalCenter="0" verticalCenter="0" scaleX.down="0.95" scaleY.down="0.95"/>
</e:Skin>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="ui.ProgressBarSkin" xmlns:e="http://ns.egret.com/eui" xmlns:w="http://ns.egret.com/wing">
<e:Image id="thumb" source="loading_progress_thumb" x="3" y="3"/>
<e:Image id="track" source="loading_progress_track" scale9Grid="16,13,2,2" width="404"/>
</e:Skin>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="ui.StartButtonSkin" xmlns:e="http://ns.egret.com/eui" xmlns:ns1="*" states="up,down,disabled,wating" >
<e:Image id="iconDisplay" source="" horizontalCenter="0" verticalCenter="0" scaleX.down="0.95" scaleY.down="0.95"/>
<e:Image source="startBtnBg_png" includeIn="wating" x="0" y="0"/>
<e:Image source="wating_png" includeIn="wating" horizontalCenter="0" verticalCenter="23.5"/>
<e:Image source="startBtnBg_png" includeIn="disabled" x="0" y="0"/>
<e:Image source="go_png" includeIn="disabled" x="62" y="143"/>
<e:Image source="startBtnBg_png" includeIn="down" x="0" y="0" scaleX="0.95" scaleY="0.95"/>
<e:Image source="go_png" includeIn="down" horizontalCenter="0.5" verticalCenter="25.5" scaleX="0.95" scaleY="0.95"/>
<e:Image source="startBtnBg_png" includeIn="up" horizontalCenter="0" verticalCenter="0"/>
<e:Image source="go_png" includeIn="up" horizontalCenter="0.5" verticalCenter="25.5"/>
</e:Skin>
\ No newline at end of file
/**
* 示例自定义插件,您可以查阅 http://developer.egret.com/cn/github/egret-docs/Engine2D/projectConfig/cmdExtensionPlugin/index.html
* 了解如何开发一个自定义插件
*/
export class CustomPlugin implements plugins.Command {
constructor() {
}
async onFile(file: plugins.File) {
// console.log(file.relative)
return file;
}
async onFinish(commandContext: plugins.CommandContext) {
// console.log(commandContext.projectRoot)
// const path = require('path');
// commandContext.createFile('test.txt', new Buffer('123'));
}
}
\ No newline at end of file
export default class LoadingUI extends egret.Sprite implements RES.PromiseTaskReporter {
public constructor() {
super();
this.createView();
}
private textField: egret.TextField;
private createView(): void {
this.textField = new egret.TextField();
this.addChild(this.textField);
this.textField.y = 300;
this.textField.width = 480;
this.textField.height = 100;
this.textField.textAlign = "center";
}
public onProgress(current: number, total: number): void {
this.textField.text = `Loading...${current}/${total}`;
}
}
import { DataManager } from "../libs/tw/manager/DataManager";
import { NetManager } from "../libs/tw/manager/NetManager";
import MainBase from "../libs/tl/MainBase";
import Msg from "./alert/Msg";
import AssetAdapter from "./AssetAdapter";
import PanelCtrl from "./ctrls/panelCtrl";
import SceneCtrl from "./ctrls/sceneCtrl";
import Loading from "./loading/Loading";
import PlayScene from "./playScene/PlayScene";
import RulePanel from "./rulePanel/RulePanel";
import ThemeAdapter from "./ThemeAdapter";
import { ModuleTypes } from "./types/sceneTypes";
import { getResPath } from "./utils";
import layers from "./views/layers";
class Main extends eui.UILayer {
protected createChildren(): void {
super.createChildren();
// alert(1)
egret.lifecycle.addLifecycleListener((context) => {
// custom lifecycle plugin
})
egret.lifecycle.onPause = () => {
egret.ticker.pause();
}
egret.lifecycle.onResume = () => {
egret.ticker.resume();
}
//inject the custom material parser
//注入自定义的素材解析器
let assetAdapter = new AssetAdapter();
egret.registerImplementation("eui.IAssetAdapter", assetAdapter);
egret.registerImplementation("eui.IThemeAdapter", new ThemeAdapter());
egret.ImageLoader.crossOrigin = "anonymous";
DataManager.ins.gameCfgData = window['CFG'];
DataManager.ins.gameCfgData.gameInfo.gameId = window["gameId"];
NetManager.ins.getCredits(()=>{});
layers.init(this);
Loading.init(layers.topLayer);
PanelCtrl.instance.init(layers.popupLayer);
SceneCtrl.instance.init(layers.sceneLayer);
this.stage.scaleMode = egret.StageScaleMode.FIXED_WIDTH;
import StartScene from "./startScene/StartScene";
class Main extends MainBase {
protected registerModules() {
PanelCtrl.instance.registerPanelClass(ModuleTypes.MSG_PANEL, Msg);
PanelCtrl.instance.registerPanelClass(ModuleTypes.RULE_PANEL, RulePanel);
SceneCtrl.instance.registerSceneClass(ModuleTypes.PALY_SCENE, PlayScene);
this.runGame().catch(e => {
console.log(e);
})
SceneCtrl.instance.registerSceneClass(ModuleTypes.START_SCENE, StartScene);
}
private async runGame() {
await this.loadResource()
this.createGameScene();
RES.loadGroup("msg", 10);
}
private async loadResource() {
try {
// const loadingView = new LoadingUI();
// this.stage.addChild(loadingView);
await RES.loadConfig("default.res.json", getResPath() + "resource/");
await this.loadTheme();
// await RES.loadGroup("msg", 10);
// this.stage.removeChild(loadingView);
}
catch (e) {
console.error(e);
}
}
private loadTheme() {
return new Promise((resolve, reject) => {
// load skin theme configuration file, you can manually modify the file. And replace the default skin.
//加载皮肤主题配置文件,可以手动修改这个文件。替换默认皮肤。
let theme = new eui.Theme("resource/default.thm.json", this.stage);
theme.addEventListener(eui.UIEvent.COMPLETE, () => {
resolve();
}, this);
})
}
private textfield: egret.TextField;
/**
* 创建场景界面
* Create scene interface
*/
protected createGameScene(): void {
NetManager.ins.getInfo(() => {
// 等待开奖 ↓
if (DataManager.ins.getInfoData.status.code == 4) {
// 已开奖 ↓
} else if (DataManager.ins.getInfoData.status.code == 5) {
// 正常游戏 ↓
} else {
SceneCtrl.instance.change(ModuleTypes.PALY_SCENE)
}
});
// setTimeout(() => {
// // panelCtrl.showAlertPanel('te111st');
// // Loading.instace.show()
// }, 3000);
protected async createGameScene() {
// await RES.getResAsync('bg_jpg');
SceneCtrl.instance.change(ModuleTypes.START_SCENE);
}
}
......
/**
* 平台数据接口。
* 由于每款游戏通常需要发布到多个平台上,所以提取出一个统一的接口用于开发者获取平台数据信息
* 推荐开发者通过这种方式封装平台逻辑,以保证整体结构的稳定
* 由于不同平台的接口形式各有不同,白鹭推荐开发者将所有接口封装为基于 Promise 的异步形式
*/
declare interface Platform {
getUserInfo(): Promise<any>;
login(): Promise<any>
}
export class DebugPlatform implements Platform {
async getUserInfo() {
return { nickName: "username" }
}
async login() {
}
}
export declare let platform: Platform;
export declare interface Window {
platform: Platform
}
......@@ -6,9 +6,10 @@ export default class ComponentBase extends eui.Component {
super();
this.data = {};
this.skinName = getSkinPath(this.skinKey);
this.addEventListener(egret.Event.COMPLETE, this.onSkinComplete, this);
if (this.skin) {
this.onSkinComplete();
} else {
this.addEventListener(egret.Event.COMPLETE, this.onSkinComplete, this);
}
}
......@@ -29,5 +30,5 @@ export default class ComponentBase extends eui.Component {
destroy() {
this.removeEvents();
}
}
\ No newline at end of file
// import { INetData } from '../../libs/tc/interface/INetData';
// import { DataManager } from '../../libs/tw/manager/DataManager'; import { NetManager } from '../../libs/tw/manager/NetManager';
import { INetData } from '../../libs/tc/interface/INetData';
import PanelCtrl from '../ctrls/panelCtrl';
import { ModuleTypes } from '../types/sceneTypes';
import Scene from "../views/Scene";
import { DataManager } from '../../libs/tw/manager/DataManager';
import { NetManager } from '../../libs/tw/manager/NetManager';
const { TouchEvent } = egret;
export default class PlayScene extends Scene {
// 游戏参数
private userCredits:number = 0;
private unitNum:number = 10;
private unitName:string;
private currCostCredits:number = 0;
private lightCount:number = 0;
private lightRate = 30;
private isLight:boolean = false;
private wbgloop:any;
private multiplesArr:any[] = [];
private angleArr:any[] = [];
private ranArr:any[] = [];
private coinsArr:any[] = [];
private gravity:number = 4.5;
private multiple:number;
// 导出的元件
public bg:eui.Image;
public ruleBtn:eui.Button;
public addBtn:eui.Button;
public reduceBtn:eui.Button;
public WheelBg:eui.Component;
public outShell:eui.Image;
public startBtn:eui.Button;
public unitTxt:eui.Label;
public costTxt:eui.Label;
public myCreditsBg:eui.Image;
public userCreditsUnitName:eui.Label;
public userCreditsNum:eui.Label;
public circleLight1:eui.Image;
public circleLight2:eui.Image;
public sideLightD:eui.Image;
public sideLightL:eui.Image;
public finger:eui.Image;
public resulePanel:eui.Panel;
public rulePanel:eui.Panel;
initEvents() {
this.startBtn.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onClick_startBtn,this);
this.reduceBtn.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onClick_reduceBtn,this);
this.addBtn.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onClick_addBtn,this);
this.ruleBtn.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onClick_ruleBtn,this);
}
removeEvents() {
this.startBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.onClick_startBtn,this);
this.reduceBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.onClick_reduceBtn,this);
this.addBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.onClick_addBtn,this);
this.ruleBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.onClick_ruleBtn,this);
}
start() {
this.once(egret.Event.ADDED_TO_STAGE,this.onLoad,this);
this.circleLight1.$touchEnabled = false;
this.circleLight2.$touchEnabled = false;
this.finger.$touchEnabled = false;
this.sideLightL.visible = false;
this.userCredits = DataManager.ins.getInfoData ? DataManager.ins.getInfoData.credits : 0;
this.unitName = DataManager.ins.getCreditsData ? `${DataManager.ins.getCreditsData.unitName}` : `积分`;
if(this.userCredits<10){
this.currCostCredits = 0;
}else if(this.userCredits <= 200){
this.currCostCredits = 10;
}else if(this.userCredits <= 500){
this.currCostCredits = 20;
}else if(this.userCredits <= 1000){
this.currCostCredits = 30;
}else if(this.userCredits <= 5000){
this.currCostCredits = 50;
}else if(this.userCredits <= 10000){
this.currCostCredits = 100;
}else if(this.userCredits > 10000){
this.currCostCredits = 200;
}
this.costTxt.text = `${this.currCostCredits}`;
this.unitTxt.text = `投入${this.unitName}`;
this.userCreditsUnitName.text = `总${this.unitName}`;
this.userCreditsNum.text = `${this.userCredits}`;
let fingerTw = egret.Tween.get( this.finger, {loop: true} );
fingerTw.to({scaleX:0.9, scaleY:0.9}, 500).to({scaleX:1, scaleY:1}, 500)
this.WheelBg['realRotation'] = 0;
console.log(this.WheelBg)
// 按从小到大排序
this.multiplesArr = [0, 0.2, 0.4, 0.5, 0.8, 1.0, 1.1, 1.2, 1.4, 1.5, 2];
let unitAngle = 360/16;
this.angleArr = [13*unitAngle, 11*unitAngle, 0, 5*unitAngle, 8*unitAngle, 14*unitAngle, 12*unitAngle, 6*unitAngle, 10*unitAngle, 3*unitAngle, 2*unitAngle];
this.ranArr = [1/11,1/11,1/11,1/11,1/11,1/11,1/11,1/11,1/11,1/11,1/11];
}
private timeOnEnterFrame:number = 0;
private onLoad(event:egret.Event) {
this.addEventListener(egret.Event.ENTER_FRAME,this.onEnterFrame,this);
}
private onEnterFrame(e:egret.Event){
let scope = this;
scope.lightCount ++;
if(scope.lightCount%scope.lightRate == 0){
scope.isLight = !scope.isLight;
}
scope.circleLight2.visible = scope.isLight;
if(scope.coinsArr.length > 0){
for(let c = scope.coinsArr.length-1; c>=0;c--){
scope.coinsArr[c].x += scope.coinsArr[c].dirX * scope.coinsArr[c].vx;
scope.coinsArr[c].y -= scope.coinsArr[c].vy;
scope.coinsArr[c].vy -= scope.gravity;
}
}
}
// 开始游戏
private onClick_startBtn(e:egret.TouchEvent){
if(window['requirelogin']) {
window['requirelogin']();
return;
}
if(this.userCredits < 10){
let data = {msg:`${this.unitName}不足最小投值10${this.unitName}快去赚取${this.unitName}吧`, type:'creditsOut'}
PanelCtrl.instance.show(ModuleTypes.MSG_PANEL, data)
return;
}
let scope = this;
let wbg = egret.Tween.get( this.WheelBg, {onChange: scope.onWbgRotationChange.bind(scope)});
scope.removeChild(scope.goAni)
let func:Function;
wbg.to({realRotation:(scope.WheelBg['realRotation'] + 3600)}, 2000, egret.Ease.quartIn).call( func = function(){
let _rotation = scope.WheelBg['realRotation'] + 360;
scope.wbgloop = egret.Tween.get( scope.WheelBg, {onChange: scope.onWbgRotationChange.bind(scope), loop: true});
scope.wbgloop.to({realRotation: _rotation}, 300).call(()=>{
_rotation = scope.WheelBg['realRotation'] + 360;
});
});
this.finger.visible = false;
this.lightRate = 5;
this.sideLightL.visible = true;
this.buttonEnable(false);
this.startBtn.currentState = 'wating';
this.doStart(this.doStartResult.bind(this), false, this.currCostCredits, 1);
}
// 开始游戏接口
public doStart(callback: Function, isAgain = false, credits?: number, customizedType?: number): void {
if(window['requirelogin']) {
window['requirelogin']();
return;
}
NetManager.ins.doStart((success: boolean) => {
if(success) {
this.getStartStatus(callback, customizedType);
} else {
callback(success);
}
},
isAgain,
credits,
customizedType);
}
// 查询开始状态
private getStartStatus(callback: Function, customizedType?: number): void {
const param: any = {
ticketId: DataManager.ins.doStartData.ticketId
};
if (customizedType) {
param.customizedType = customizedType
}
const net: INetData = {
name: 'getStartStatus',
uri: '/ngapi/getStartStatus',
type: 'post',
dataType: 'json',
param: param,
callback: callback,
pollingCount: 5,
pollingCheck: () => { return DataManager.ins.getData('getStartStatus').code != 1; }
};
NetManager.ins.send(net)
}
// 开始的回调
private doStartResult(success:boolean){
let scope = this;
if(!success) {
this.defaultErr()
return;
}
let upperCreditsLimit = DataManager.ins.getData('getStartStatus').upperCreditsLimit ? DataManager.ins.getData('getStartStatus').upperCreditsLimit : scope.currCostCredits;
// 取得的返回最大倍数
let maxMultiple = upperCreditsLimit/scope.currCostCredits;
console.log(`最大倍数:${maxMultiple}`)
// 改变数组
let newMultiplesArr:any[] = [];
for(let m = 0; m<scope.multiplesArr.length; m++){
if(scope.multiplesArr[m] < maxMultiple){
newMultiplesArr.push(scope.multiplesArr[m]);
}
}
// 更新用户积分文案
scope.userCreditsNum.text = `${DataManager.ins.getInfoData ? DataManager.ins.getInfoData.credits : scope.userCredits}`
// 拿到倍数
let newAngleArr:any[] = [];
let newRanArr:any[] = [];
let arr:any[] = [];
for(let i = 0; i < newMultiplesArr.length; i++){
newAngleArr.push(scope.angleArr[i]);
newRanArr.push(scope.ranArr[i]);
let num = Math.round(120 * newRanArr[i]);
let a = (new Array(num))["fill"](newAngleArr[i]);
arr = arr.concat(a);
}
let randomT = (e, n?) => {
return e && "number" == typeof e.length && e.length ? e[Math.floor(Math.random() * e.length)] : ("number" != typeof n && (n = e || 1, e = 0), e + Math.random() * (n - e))
}
let targetAngle = randomT(arr);
let i = scope.angleArr.indexOf(targetAngle);
let multiple = scope.multiplesArr[i];
this.multiple = multiple;
console.log(`随机倍数:${multiple}`)
let timeout = setTimeout(() => {
clearTimeout(timeout)
egret.Tween.removeTweens( scope.WheelBg );
let tw = egret.Tween.get( scope.WheelBg, {onChange:scope.onWbgRotationChange.bind(scope)} );
let _rotation = Math.random() > 0.5 ? scope.WheelBg['realRotation'] + ( 360 - scope.WheelBg['realRotation'] % 360 ) + targetAngle + 1440 + Math.random() * 8 : scope.WheelBg['realRotation'] + ( 360 - scope.WheelBg['realRotation'] % 360 ) + targetAngle + 1440 - Math.random() * 8;
tw.to({realRotation:_rotation}, 8000 ,egret.Ease.quartOut).call(()=>{
scope.startBtn.currentState = 'up';
scope.buttonEnable(false)
scope.sideLightL.visible = false;
scope.lightRate = 30;
scope.coinsFall(true)
});
}, 1000);
// 延时提交分数
let timeout2 = setTimeout(()=>{
this.gameSubmitData(this.gameSubmitResult.bind(this), this.currCostCredits * multiple, false, 1);
},500)
}
private gameSubmitResult(){
NetManager.ins.getInfo(()=>{})
console.log('提交成功')
}
/**
* 提交游戏成绩
* @param callback
* @param score 得分
* @param allDynamics 防作弊数据
* @param checkScore 是否校验得分
* @param customizedType 定制类型 1推币机
*/
protected gameSubmitData(callback: Function, score: number, checkScore?: boolean, customizedType?: number): void {
NetManager.ins.gameSubmit(
(success: boolean) => {
if(success) {
this.getSubmitResult(callback, DataManager.ins.gameSubmitData.orderId);
} else {
callback(success);
}
},
DataManager.ins.doStartData.ticketId,
score,
'[]',
DataManager.ins.doStartData.submitToken,
'',
checkScore,
customizedType);
}
/**
* 查询提交结果
* @param callback
* @param orderId
*/
private getSubmitResult(callback: Function, orderId: number): void {
NetManager.ins.getSubmitResult(callback, orderId, () => {
return DataManager.ins.gameGetSubmitResultData.flag;
});
}
// 默认出错——转到0后弹错误窗
private defaultErr(){
let timeout = setTimeout(() => {
clearTimeout(timeout)
egret.Tween.removeTweens( this.WheelBg );
let tw = egret.Tween.get( this.WheelBg, {onChange:this.onWbgRotationChange.bind(this)} );
this.multiple = 0;
let _rotation = this.WheelBg['realRotation'] + ( 360 - this.WheelBg['realRotation'] % 360 ) + 360*13/16 + 1440;
tw.to({realRotation:_rotation}, 8000 ,egret.Ease.quartOut).call(()=>{
this.startBtn.currentState = 'up';
this.buttonEnable(true);
this.sideLightL.visible = false;
this.lightRate = 30;
this.coinsFall(false)
});
}, 2000);
}
private onWbgRotationChange(){
this.WheelBg.rotation = this.WheelBg['realRotation'];
}
// 减号
private onClick_reduceBtn(e:egret.TouchEvent){
if(window['requirelogin']) {
window['requirelogin']();
return;
}
if((this.currCostCredits - this.unitNum) > 0 && (this.userCredits - this.unitNum) > 0 ){
this.currCostCredits -= this.unitNum;
}
this.costTxt.text = `${this.currCostCredits}`;
}
// 加号
private onClick_addBtn(e:egret.TouchEvent){
if(window['requirelogin']) {
window['requirelogin']();
return;
}
if((this.currCostCredits + this.unitNum) <= this.userCredits && this.currCostCredits < 500){
this.currCostCredits += this.unitNum;
}
this.costTxt.text = `${this.currCostCredits}`;
}
// 规则按钮
private onClick_ruleBtn(e:egret.TouchEvent){
PanelCtrl.instance.show(ModuleTypes.RULE_PANEL);
}
// 加载动画资源
private goAni:any;
protected childrenCreated():void{
super.childrenCreated();
this.ayncLoad2Mc("goBtn_json");
this.ayncLoad2Mc("coin_json");
}
private ayncLoad2Mc( resname : string) : void{
let scope = this;
RES.getResAsync(resname,
(data: any,key: string): void => {
if(key == "coin_json") {
scope.ayncLoad2Mc("coin_png");
}else if(key == "coin_png") {
for(let i=0;i<100;i++){
let data2mc = RES.getRes("coin_json");
let texture2mc = RES.getRes("coin_png");
let mcFactory : egret.MovieClipDataFactory = new egret.MovieClipDataFactory(data2mc,texture2mc);
let mc:egret.MovieClip = new egret.MovieClip(mcFactory.generateMovieClipData("coin"));
scope.coinsArr.push(mc);
}
}else if(key == "goBtn_json") {
scope.ayncLoad2Mc("goBtn_png");
}else if(key == "goBtn_png") {
let data2mc = RES.getRes("goBtn_json");
let texture2mc = RES.getRes("goBtn_png");
let mcFactory : egret.MovieClipDataFactory = new egret.MovieClipDataFactory(data2mc,texture2mc);
let mc:egret.MovieClip = new egret.MovieClip(mcFactory.generateMovieClipData("go"));
mc.gotoAndPlay('light', -1);
scope.goAni = mc;
scope.addChild(scope.goAni)
scope.addChild(scope.finger)
mc.x = 279;
mc.y = 494;
}
},
this);
}
// 金币掉落效果
private coinsFall(isSuccess:boolean):void{
let scope = this;
let count = 0;
let coinsFall = setInterval(()=>{
if(count<100){
scope.addChild(scope.coinsArr[count]);
scope.coinsArr[count].gotoAndPlay('rotate', -1);
if(Math.random()>0.5){
scope.coinsArr[count].dirX = 1;
}else{
scope.coinsArr[count].dirX = -1;
}
scope.coinsArr[count].vy = Math.random() * 60;
scope.coinsArr[count].vx = Math.random() * 30;
scope.coinsArr[count].x = this.stage.stageWidth/2 - scope.coinsArr[count].width/2;
scope.coinsArr[count].y = 500;
count++;
this.addChild(this.resulePanel)
}else{
if(!isSuccess){
// 失败
let msg = DataManager.ins.doStartData ? DataManager.ins.doStartData.message : `网络出了点小问题请退出后重试`;
let data = {msg:msg, type:'err'}
PanelCtrl.instance.show(ModuleTypes.MSG_PANEL, data)
}
clearInterval(coinsFall)
}
},10)
scope.showResultPanel()
}
private currEarnCredits:number = 0;
private showResultPanel(){
let scope = this;
scope.currEarnCredits = scope.currCostCredits * scope.multiple;
let resultPanelTw = egret.Tween.get( scope.resulePanel );
resultPanelTw.to({scaleX:1, scaleY:1}, 300).wait(2000).call(()=>{
scope.resulePanel.scaleX = 0;
scope.resulePanel.scaleY = 0;
scope.buttonEnable(true);
scope.addChild(scope.goAni);
})
this.resulePanel['credits'].text = `0`;
let credits:any = {num:0};
credits.num = Number(this.resulePanel['credits'].text);
let creditTw = egret.Tween.get( credits , { onChange:onCreditsChange});
creditTw.to({num: this.currEarnCredits},1000)
function onCreditsChange(){
let c = Math.floor(credits.num);
scope.resulePanel['credits'].text = `${c}`
}
}
// 按钮状态
private buttonEnable(enabled:boolean){
this.startBtn.enabled = enabled;
this.addBtn.enabled = enabled;
this.reduceBtn.enabled = enabled;
this.ruleBtn.enabled = enabled;
}
protected get skinKey() { return 'Play' }
}
\ No newline at end of file
import { getImgURL } from "../../libs/tc/util/GFun";
import Scene from "../views/Scene";
import { getResPath } from "../utils";
const { TouchEvent } = egret;
export default class StartScene extends Scene {
start(data?) {
this.createBg();
}
async createBg() {
let url = getResPath() + 'resource/assets/startScene/bg.jpg';
url = await getImgURL(url);
RES.getResByUrl(url, (picData) => {
const pic = new egret.Bitmap(picData);
this.addChild(pic);
}, this, RES.ResourceItem.TYPE_IMAGE);
}
protected get skinKey() { return 'Start' }
}
\ 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