Commit d208dd4b authored by 王勇霞's avatar 王勇霞

更新

parent 5432b50e
///////////////////时间相关的方法放这里
/**
* 判断当前时间是否在指定时间区间内,每日,注意没判断起始时间是否肯定小于结束时间
* @param beginTime 形如"9:30","09:30",起始时间
* @param endTime 形如"21:30",结束时间
*/
export function checkAuditDayTime(beginTime: string, endTime: string, currentTimestamp: number = Date.now()): boolean {
return !checkBeforeDayTime(beginTime, currentTimestamp) && checkBeforeDayTime(endTime, currentTimestamp)
}
/**
* 判断当前时间是否在给定时间前,每天
* 精确到分,有需要自行改造截取方法和setHours传参
* @param time 形如"11:30","09:30",小时 0(午夜) ~ 23(晚上11点),分0 ~ 59 之间,负数或超出,会进行进制换算
* @returns 返回true表示当前时间小于传入时间,即未到传入时间
*/
export function checkBeforeDayTime(time: string, currentTimestamp: number = Date.now()): boolean {
var nowDate = new Date(currentTimestamp);
var timeDate = new Date(nowDate);
var index = time.lastIndexOf("\:");
var hour = time.substring(0, index);
var minue = time.substring(index + 1, time.length);
timeDate.setHours(+hour, +minue, 0, 0);
return nowDate.getTime() < timeDate.getTime()
}
/**
* 毫秒剩余时间转成时分秒,具体格式自行修改
* 01时01分01秒
* @param timeStamp
*/
export function getShiFenMiaoByTimeStamp(timeStamp: number): string {
var hours: any = Math.floor((timeStamp % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes: any = Math.floor((timeStamp % (1000 * 60 * 60)) / (1000 * 60));
var seconds: any = Math.floor((timeStamp % (1000 * 60)) / 1000);
hours = hours < 10 ? ('0' + hours) : hours;
minutes = minutes < 10 ? ('0' + minutes) : minutes;
seconds = seconds < 10 ? ('0' + seconds) : seconds;
// return hours + ":" + minutes + ":" + seconds;
return hours + "时" + minutes + "分" + seconds + "秒";
}
/**
* 根据时间戳返回各种格式,自行修改,到时加枚举
* @param timeStamp 时间戳
* @return 20190606 09:05:33 2019-06-06 09:05:33 2019/06/06 09:05:33 2019年3月12日10时9分29秒
*/
export function getDateTime(timeStamp: number): string {
function add0(m: number) {
return m < 10 ? '0' + m : m
}
var time = new Date(timeStamp);
var y = time.getFullYear();
var m = time.getMonth() + 1;
var d = time.getDate();
var h = time.getHours();
var mm = time.getMinutes();
var s = time.getSeconds();
// return "" + y + add0(m) + add0(d) + ' ' + add0(h) + ':' + add0(mm) + ':' + add0(s);
// return "" + y + '-' + add0(m) + '-' + add0(d) + ' ' + add0(h) + ':' + add0(mm) + ':' + add0(s);
// return "" + y + '/' + add0(m) + '/' + add0(d) + ' ' + add0(h) + ':' + add0(mm) + ':' + add0(s);
return y + "年" + m + '月' + d + '日' + h + '时' + mm + '分' + s + '秒'
}
/**
* 日期格式转时间戳
* 时间格式得用/,ios用-有问题,"2019/06/17 00:00:00",,,,ios也不能直接用Number(new Date())
* @param date "2019/06/17 00:00:00" "2019-06-17 00:00:00"
*/
export function getTimeStampByDate(date: string) {
return new Date(date.replace(/-/g, "/")).getTime();
}
/**
* 快速获取年月日时分秒 "2021-02-01 18:32:32"
* @param timeStamp 不传表示当前
*/
export function getDate(timeStamp: number = Date.now()): string {
//有局限性,但是无妨 19暂时年份不会超
return new Date(timeStamp + 8 * 3600 * 1000).toJSON().substr(0, 19).replace("T", " ");
}
/**
* 判断两个时间戳是否为同一天
* @param time1
* @param time2
*/
export function checkSameDay(time1: number, time2: number): boolean {
return new Date(time1).toDateString() === new Date(time2).toDateString()
}
{
root: '/Users/duibagroup/Downloads/duiba-wyx/2023/浙江中烟/跳一跳/project_0307',
registry: 'https://registry.npmmirror.com',
pkgs: [],
production: false,
cacheStrict: false,
cacheDir: null,
env: {
npm_config_registry: 'https://registry.npmmirror.com',
npm_config_argv: '{"remain":[],"cooked":["--fix-bug-versions","--china","--userconfig=/Users/duibagroup/.cnpmrc","--disturl=https://npmmirror.com/mirrors/node","--registry=https://registry.npmmirror.com","-g","pack-textures"],"original":["--fix-bug-versions","--china","--userconfig=/Users/duibagroup/.cnpmrc","--disturl=https://npmmirror.com/mirrors/node","--registry=https://registry.npmmirror.com","-g","pack-textures"]}',
npm_config_user_agent: 'npminstall/7.4.2 npm/? node/v16.13.0 darwin x64',
NODE: '/usr/local/bin/node',
npm_node_execpath: '/usr/local/bin/node',
npm_execpath: '/usr/local/lib/node_modules/cnpm/node_modules/npminstall/bin/install.js',
npm_config_userconfig: '/Users/duibagroup/.cnpmrc',
npm_config_disturl: 'https://npmmirror.com/mirrors/node',
npm_config_r: 'https://registry.npmmirror.com',
NODEJS_ORG_MIRROR: 'https://cdn.npmmirror.com/binaries/node',
NVM_NODEJS_ORG_MIRROR: 'https://cdn.npmmirror.com/binaries/node',
PHANTOMJS_CDNURL: 'https://cdn.npmmirror.com/binaries/phantomjs',
CHROMEDRIVER_CDNURL: 'https://cdn.npmmirror.com/binaries/chromedriver',
OPERADRIVER_CDNURL: 'https://cdn.npmmirror.com/binaries/operadriver',
CYPRESS_DOWNLOAD_PATH_TEMPLATE: 'https://cdn.npmmirror.com/binaries/cypress/${version}/${platform}-${arch}/cypress.zip',
ELECTRON_MIRROR: 'https://cdn.npmmirror.com/binaries/electron/',
ELECTRON_BUILDER_BINARIES_MIRROR: 'https://cdn.npmmirror.com/binaries/electron-builder-binaries/',
SASS_BINARY_SITE: 'https://cdn.npmmirror.com/binaries/node-sass',
SWC_BINARY_SITE: 'https://cdn.npmmirror.com/binaries/node-swc',
NWJS_URLBASE: 'https://cdn.npmmirror.com/binaries/nwjs/v',
PUPPETEER_DOWNLOAD_HOST: 'https://cdn.npmmirror.com/binaries',
PLAYWRIGHT_DOWNLOAD_HOST: 'https://cdn.npmmirror.com/binaries/playwright',
SENTRYCLI_CDNURL: 'https://cdn.npmmirror.com/binaries/sentry-cli',
SAUCECTL_INSTALL_BINARY_MIRROR: 'https://cdn.npmmirror.com/binaries/saucectl',
RE2_DOWNLOAD_MIRROR: 'https://cdn.npmmirror.com/binaries/node-re2',
RE2_DOWNLOAD_SKIP_PATH: 'true',
npm_config_better_sqlite3_binary_host: 'https://cdn.npmmirror.com/binaries/better-sqlite3',
npm_config_keytar_binary_host: 'https://cdn.npmmirror.com/binaries/keytar',
npm_config_sharp_binary_host: 'https://cdn.npmmirror.com/binaries/sharp',
npm_config_sharp_libvips_binary_host: 'https://cdn.npmmirror.com/binaries/sharp-libvips',
npm_config_robotjs_binary_host: 'https://cdn.npmmirror.com/binaries/robotjs',
npm_rootpath: '/Users/duibagroup/Downloads/duiba-wyx/2023/浙江中烟/跳一跳/project_0307',
INIT_CWD: '/Users/duibagroup/Downloads/duiba-wyx/2023/浙江中烟/跳一跳/project_0307',
npm_config_cache: '/Users/duibagroup/.npminstall_tarball'
},
binaryMirrors: {
ENVS: {
NODEJS_ORG_MIRROR: 'https://cdn.npmmirror.com/binaries/node',
NVM_NODEJS_ORG_MIRROR: 'https://cdn.npmmirror.com/binaries/node',
PHANTOMJS_CDNURL: 'https://cdn.npmmirror.com/binaries/phantomjs',
CHROMEDRIVER_CDNURL: 'https://cdn.npmmirror.com/binaries/chromedriver',
OPERADRIVER_CDNURL: 'https://cdn.npmmirror.com/binaries/operadriver',
CYPRESS_DOWNLOAD_PATH_TEMPLATE: 'https://cdn.npmmirror.com/binaries/cypress/${version}/${platform}-${arch}/cypress.zip',
ELECTRON_MIRROR: 'https://cdn.npmmirror.com/binaries/electron/',
ELECTRON_BUILDER_BINARIES_MIRROR: 'https://cdn.npmmirror.com/binaries/electron-builder-binaries/',
SASS_BINARY_SITE: 'https://cdn.npmmirror.com/binaries/node-sass',
SWC_BINARY_SITE: 'https://cdn.npmmirror.com/binaries/node-swc',
NWJS_URLBASE: 'https://cdn.npmmirror.com/binaries/nwjs/v',
PUPPETEER_DOWNLOAD_HOST: 'https://cdn.npmmirror.com/binaries',
PLAYWRIGHT_DOWNLOAD_HOST: 'https://cdn.npmmirror.com/binaries/playwright',
SENTRYCLI_CDNURL: 'https://cdn.npmmirror.com/binaries/sentry-cli',
SAUCECTL_INSTALL_BINARY_MIRROR: 'https://cdn.npmmirror.com/binaries/saucectl',
RE2_DOWNLOAD_MIRROR: 'https://cdn.npmmirror.com/binaries/node-re2',
RE2_DOWNLOAD_SKIP_PATH: 'true',
npm_config_better_sqlite3_binary_host: 'https://cdn.npmmirror.com/binaries/better-sqlite3',
npm_config_keytar_binary_host: 'https://cdn.npmmirror.com/binaries/keytar',
npm_config_sharp_binary_host: 'https://cdn.npmmirror.com/binaries/sharp',
npm_config_sharp_libvips_binary_host: 'https://cdn.npmmirror.com/binaries/sharp-libvips',
npm_config_robotjs_binary_host: 'https://cdn.npmmirror.com/binaries/robotjs'
},
'@ali/s2': { host: 'https://cdn.npmmirror.com/binaries/looksgood-s2' },
sharp: { replaceHostFiles: [Array], replaceHostMap: [Object] },
'@tensorflow/tfjs-node': {
replaceHostFiles: [Array],
replaceHostRegExpMap: [Object],
replaceHostMap: [Object]
},
cypress: {
host: 'https://cdn.npmmirror.com/binaries/cypress',
newPlatforms: [Object]
},
'utf-8-validate': {
host: 'https://cdn.npmmirror.com/binaries/utf-8-validate/v{version}'
},
xprofiler: {
remote_path: './xprofiler/v{version}/',
host: 'https://cdn.npmmirror.com/binaries'
},
leveldown: { host: 'https://cdn.npmmirror.com/binaries/leveldown/v{version}' },
couchbase: { host: 'https://cdn.npmmirror.com/binaries/couchbase/v{version}' },
gl: { host: 'https://cdn.npmmirror.com/binaries/gl/v{version}' },
sqlite3: {
host: 'https://cdn.npmmirror.com/binaries/sqlite3',
remote_path: 'v{version}'
},
'@journeyapps/sqlcipher': { host: 'https://cdn.npmmirror.com/binaries' },
grpc: {
host: 'https://cdn.npmmirror.com/binaries',
remote_path: '{name}/v{version}'
},
'grpc-tools': { host: 'https://cdn.npmmirror.com/binaries' },
wrtc: {
host: 'https://cdn.npmmirror.com/binaries',
remote_path: '{name}/v{version}'
},
fsevents: { host: 'https://cdn.npmmirror.com/binaries/fsevents' },
nodejieba: { host: 'https://cdn.npmmirror.com/binaries/nodejieba' },
canvas: { host: 'https://cdn.npmmirror.com/binaries/canvas' },
'skia-canvas': { host: 'https://cdn.npmmirror.com/binaries/skia-canvas' },
'flow-bin': {
replaceHost: 'https://github.com/facebook/flow/releases/download/v',
host: 'https://cdn.npmmirror.com/binaries/flow/v'
},
'jpegtran-bin': {
replaceHost: [Array],
host: 'https://cdn.npmmirror.com/binaries/jpegtran-bin'
},
'cwebp-bin': {
replaceHost: [Array],
host: 'https://cdn.npmmirror.com/binaries/cwebp-bin'
},
'zopflipng-bin': {
replaceHost: [Array],
host: 'https://cdn.npmmirror.com/binaries/zopflipng-bin'
},
'optipng-bin': {
replaceHost: [Array],
host: 'https://cdn.npmmirror.com/binaries/optipng-bin'
},
mozjpeg: {
replaceHost: [Array],
host: 'https://cdn.npmmirror.com/binaries/mozjpeg-bin'
},
gifsicle: {
replaceHost: [Array],
host: 'https://cdn.npmmirror.com/binaries/gifsicle-bin'
},
'pngquant-bin': {
replaceHost: [Array],
host: 'https://cdn.npmmirror.com/binaries/pngquant-bin',
replaceHostMap: [Object]
},
'pngcrush-bin': {
replaceHost: [Array],
host: 'https://cdn.npmmirror.com/binaries/pngcrush-bin'
},
'jpeg-recompress-bin': {
replaceHost: [Array],
host: 'https://cdn.npmmirror.com/binaries/jpeg-recompress-bin'
},
'advpng-bin': {
replaceHost: [Array],
host: 'https://cdn.npmmirror.com/binaries/advpng-bin'
},
'pngout-bin': {
replaceHost: [Array],
host: 'https://cdn.npmmirror.com/binaries/pngout-bin'
},
'jpegoptim-bin': {
replaceHost: [Array],
host: 'https://cdn.npmmirror.com/binaries/jpegoptim-bin'
},
argon2: { host: 'https://cdn.npmmirror.com/binaries/argon2' },
'ali-zeromq': { host: 'https://cdn.npmmirror.com/binaries/ali-zeromq' },
'ali-usb_ctl': { host: 'https://cdn.npmmirror.com/binaries/ali-usb_ctl' },
'gdal-async': { host: 'https://cdn.npmmirror.com/binaries/node-gdal-async' }
},
forbiddenLicenses: null,
flatten: false,
proxy: undefined,
prune: false,
disableFallbackStore: false,
workspacesMap: Map(0) {},
enableWorkspace: false,
workspaceRoot: '/Users/duibagroup/Downloads/duiba-wyx/2023/浙江中烟/跳一跳/project_0307',
isWorkspaceRoot: true,
isWorkspacePackage: false,
strictSSL: true,
ignoreScripts: false,
ignoreOptionalDependencies: false,
detail: true,
forceLinkLatest: false,
trace: false,
engineStrict: false,
registryOnly: false,
client: false,
autoFixVersion: [Function: autoFixVersion],
targetDir: null,
binDir: null
}
\ No newline at end of file
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>畅玩欢乐城</title>
<meta name="viewport"
content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="full-screen" content="true" />
<meta name="screen-orientation" content="portrait" />
<meta name="x5-fullscreen" content="true" />
<meta name="360-fullscreen" content="true" />
<!-- polyfill -->
<script src="//yun.duiba.com.cn/libs0414/polyfill20210720.js" crossorigin="anonymous"></script>
<!-- 渲染引擎 -->
<script src="//yun.duiba.com.cn/db_games/libs0924/fyge2030.min.js" crossorigin="anonymous"></script>
<!-- svga解析库 -->
<script src="//yun.duiba.com.cn/db_games/libs0924/svgaParser.minWeb.js" crossorigin="anonymous"></script>
<!-- 本地的js,需要souremap调试的用本地js -->
<script src="libs/fyge.min.js"></script>
<!-- <script src="libs/svgaParser.min.js"></script> -->
<!-- <script src="libs/svgaParser.min1.js"></script> -->
<style>
html,
body {
padding: 0;
margin: 0;
border: 0;
width: 100%;
height: 100%;
overflow: hidden;
position: absolute;
background-color: #9a3636;
-webkit-user-select: none;
/* Safari */
-ms-user-select: none;
/* IE 10+ and Edge */
user-select: none;
/* Standard syntax */
outline-style: none;
/* background: linear-gradient(#93dbb7,#ff0,#b5d89a); */
/* background: linear-gradient(#93dbb7,#b5d89a); */
/* 背景图片,解决加载太慢,白屏问题,加了这个下面的__loading__可以删掉了 */
/* background-size: 100%;
background-position: center;
background-image: url("https://yun.duiba.com.cn/db_games/activity/game/1550472986/resource/assets/playscene/playscenebg.jpg"); */
}
</style>
</head>
<body>
<div id="__loading__" style="position:absolute;left:50%;top:50%;margin-left:-45px;color:#ffffff">拼命加载中...</div>
<div id="cusEngine" style="line-height:0;font-size:0;position: absolute;">
<canvas id="canvas" style="width: 100%;height: 100%"></canvas>
</div>
<!-- 帧率检测 -->
<!-- <script src="//yun.duiba.com.cn/db_games/libs0924/stats.js"></script> -->
<!-- <script src="https://yun.duiba.com.cn/db_games/libs0126/stats.js"></script> -->
<script src="//yun.duiba.com.cn/db_games/libs0924/howler.min.js"></script>
<script>"use strict";
//为了duiba-utils有用到appID
var CFG = CFG || {}; //星速台会注入
CFG.appID = '54855';
window.addEventListener("load", function () {
//获取canvas
var canvas = document.getElementById("canvas"); //实例
new Main(canvas) //加鼠标事件,
.stage.addWebMouseEvent(); //淘宝环境自行用stage.onMouseEvent
});
</script>
<!-- 构建的js -->
<script src="//yun.duiba.com.cn/db_games/activity/template/1654672360/output.js" crossorigin="anonymous"></script>
</body>
</html>
\ No newline at end of file
{
"failbg.png": {
"x": 2,
"y": 2,
"w": 568,
"h": 598,
"ox": 0,
"oy": 0,
"sw": 568,
"sh": 598,
"ro": false
},
"knowbtn.png": {
"x": 572,
"y": 2,
"w": 230,
"h": 86,
"ox": 0,
"oy": 0,
"sw": 230,
"sh": 86,
"ro": true
},
"restartbtn.png": {
"x": 2,
"y": 602,
"w": 227,
"h": 90,
"ox": 0,
"oy": 0,
"sw": 227,
"sh": 90,
"ro": false
}
}
\ No newline at end of file
{
"gamebuild.png": {
"x": 2,
"y": 2,
"w": 750,
"h": 496,
"ox": 0,
"oy": 0,
"sw": 750,
"sh": 496,
"ro": false
},
"scorebg.png": {
"x": 2,
"y": 500,
"w": 309,
"h": 79,
"ox": 0,
"oy": 0,
"sw": 309,
"sh": 79,
"ro": false
},
"rightbtn.png": {
"x": 2,
"y": 581,
"w": 206,
"h": 204,
"ox": 0,
"oy": 0,
"sw": 206,
"sh": 204,
"ro": false
},
"leftbtn.png": {
"x": 313,
"y": 500,
"w": 205,
"h": 205,
"ox": 0,
"oy": 0,
"sw": 205,
"sh": 205,
"ro": false
},
"cloud.png": {
"x": 210,
"y": 581,
"w": 199,
"h": 60,
"ox": 0,
"oy": 0,
"sw": 199,
"sh": 60,
"ro": true
},
"cdbg.png": {
"x": 520,
"y": 500,
"w": 196,
"h": 81,
"ox": 0,
"oy": 0,
"sw": 196,
"sh": 81,
"ro": false
},
"controlpeo.png": {
"x": 520,
"y": 583,
"w": 117,
"h": 196,
"ox": 0,
"oy": 0,
"sw": 117,
"sh": 196,
"ro": false
},
"monster.png": {
"x": 639,
"y": 583,
"w": 97,
"h": 116,
"ox": 0,
"oy": 0,
"sw": 97,
"sh": 116,
"ro": false
},
"tianpop.png": {
"x": 639,
"y": 701,
"w": 84,
"h": 94,
"ox": 0,
"oy": 0,
"sw": 84,
"sh": 94,
"ro": true
},
"xiangpop.png": {
"x": 735,
"y": 701,
"w": 84,
"h": 93,
"ox": 0,
"oy": 0,
"sw": 84,
"sh": 93,
"ro": true
},
"closemusic.png": {
"x": 272,
"y": 707,
"w": 78,
"h": 78,
"ox": 0,
"oy": 0,
"sw": 78,
"sh": 78,
"ro": false
},
"openmusic.png": {
"x": 352,
"y": 707,
"w": 78,
"h": 78,
"ox": 0,
"oy": 0,
"sw": 78,
"sh": 78,
"ro": false
}
}
\ No newline at end of file
{
"guide.png": {
"x": 2,
"y": 2,
"w": 590,
"h": 586,
"ox": 0,
"oy": 0,
"sw": 590,
"sh": 586,
"ro": false
}
}
\ No newline at end of file
{
"ruleBg.png": {
"x": 2,
"y": 2,
"w": 568,
"h": 638,
"ox": 0,
"oy": 0,
"sw": 568,
"sh": 638,
"ro": false
}
}
\ No newline at end of file
{
"midbuild.png": {
"x": 2,
"y": 2,
"w": 750,
"h": 493,
"ox": 0,
"oy": 0,
"sw": 750,
"sh": 493,
"ro": false
},
"mifcloud.png": {
"x": 2,
"y": 497,
"w": 750,
"h": 412,
"ox": 0,
"oy": 0,
"sw": 750,
"sh": 412,
"ro": false
},
"titile.png": {
"x": 754,
"y": 2,
"w": 596,
"h": 167,
"ox": 0,
"oy": 0,
"sw": 596,
"sh": 167,
"ro": true
},
"startbtn.png": {
"x": 2,
"y": 911,
"w": 333,
"h": 174,
"ox": 0,
"oy": 0,
"sw": 333,
"sh": 174,
"ro": false
},
"startop.png": {
"x": 754,
"y": 600,
"w": 117,
"h": 196,
"ox": 0,
"oy": 0,
"sw": 117,
"sh": 196,
"ro": false
},
"backbtn.png": {
"x": 754,
"y": 798,
"w": 141,
"h": 53,
"ox": 0,
"oy": 0,
"sw": 141,
"sh": 53,
"ro": false
},
"rulebtn.png": {
"x": 754,
"y": 853,
"w": 140,
"h": 53,
"ox": 0,
"oy": 0,
"sw": 140,
"sh": 53,
"ro": false
}
}
\ No newline at end of file
{
"sucbg.png": {
"x": 2,
"y": 2,
"w": 568,
"h": 502,
"ox": 0,
"oy": 0,
"sw": 568,
"sh": 502,
"ro": false
},
"light.png": {
"x": 2,
"y": 506,
"w": 463,
"h": 468,
"ox": 0,
"oy": 0,
"sw": 463,
"sh": 468,
"ro": true
},
"sucstar.png": {
"x": 472,
"y": 506,
"w": 227,
"h": 87,
"ox": 0,
"oy": 0,
"sw": 227,
"sh": 87,
"ro": true
},
"infoline.png": {
"x": 561,
"y": 506,
"w": 2,
"h": 113,
"ox": 1,
"oy": 1,
"sw": 4,
"sh": 115,
"ro": false
},
"sun.png": {
"x": 472,
"y": 735,
"w": 89,
"h": 83,
"ox": 0,
"oy": 0,
"sw": 89,
"sh": 83,
"ro": false
}
}
\ No newline at end of file
{
"toastBg.png": {
"x": 2,
"y": 2,
"w": 460,
"h": 130,
"ox": 0,
"oy": 0,
"sw": 460,
"sh": 130,
"ro": false
},
"surebtn.png": {
"x": 2,
"y": 134,
"w": 267,
"h": 90,
"ox": 0,
"oy": 0,
"sw": 267,
"sh": 90,
"ro": false
},
"waitingBg.png": {
"x": 2,
"y": 226,
"w": 160,
"h": 180,
"ox": 0,
"oy": 0,
"sw": 160,
"sh": 180,
"ro": true
},
"closebtn.png": {
"x": 184,
"y": 226,
"w": 74,
"h": 74,
"ox": 0,
"oy": 0,
"sw": 74,
"sh": 74,
"ro": false
},
"关闭按钮.png": {
"x": 184,
"y": 302,
"w": 60,
"h": 60,
"ox": 0,
"oy": 0,
"sw": 60,
"sh": 60,
"ro": false
},
"关闭按钮2.png": {
"x": 246,
"y": 302,
"w": 60,
"h": 60,
"ox": 0,
"oy": 0,
"sw": 60,
"sh": 60,
"ro": false
},
"waitingRot.png": {
"x": 260,
"y": 226,
"w": 56,
"h": 56,
"ox": 0,
"oy": 0,
"sw": 56,
"sh": 56,
"ro": false
},
"comCloseBtn.png": {
"x": 271,
"y": 134,
"w": 48,
"h": 48,
"ox": 0,
"oy": 0,
"sw": 48,
"sh": 48,
"ro": false
}
}
\ No newline at end of file
{ {
"groups": [ "groups": [
{
"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",
"atlas": {
"toastBg.png": {
"x": 2,
"y": 2,
"w": 460,
"h": 130,
"ox": 0,
"oy": 0,
"sw": 460,
"sh": 130,
"ro": false
},
"surebtn.png": {
"x": 2,
"y": 134,
"w": 267,
"h": 90,
"ox": 0,
"oy": 0,
"sw": 267,
"sh": 90,
"ro": false
},
"waitingBg.png": {
"x": 2,
"y": 226,
"w": 160,
"h": 180,
"ox": 0,
"oy": 0,
"sw": 160,
"sh": 180,
"ro": true
},
"closebtn.png": {
"x": 184,
"y": 226,
"w": 74,
"h": 74,
"ox": 0,
"oy": 0,
"sw": 74,
"sh": 74,
"ro": false
},
"关闭按钮.png": {
"x": 184,
"y": 302,
"w": 60,
"h": 60,
"ox": 0,
"oy": 0,
"sw": 60,
"sh": 60,
"ro": false
},
"关闭按钮2.png": {
"x": 246,
"y": 302,
"w": 60,
"h": 60,
"ox": 0,
"oy": 0,
"sw": 60,
"sh": 60,
"ro": false
},
"waitingRot.png": {
"x": 260,
"y": 226,
"w": 56,
"h": 56,
"ox": 0,
"oy": 0,
"sw": 56,
"sh": 56,
"ro": false
},
"comCloseBtn.png": {
"x": 271,
"y": 134,
"w": 48,
"h": 48,
"ox": 0,
"oy": 0,
"sw": 48,
"sh": 48,
"ro": false
}
}
},
{ {
"keys": "failbg.png,knowbtn.png,restartbtn.png", "keys": "failbg.png,knowbtn.png,restartbtn.png",
"name": "FailPanel", "name": "FailPanel",
"atlas": { "atlas": "FailPanel.sht"
"failbg.png": {
"x": 2,
"y": 2,
"w": 568,
"h": 598,
"ox": 0,
"oy": 0,
"sw": 568,
"sh": 598,
"ro": false
},
"knowbtn.png": {
"x": 572,
"y": 2,
"w": 230,
"h": 86,
"ox": 0,
"oy": 0,
"sw": 230,
"sh": 86,
"ro": true
},
"restartbtn.png": {
"x": 2,
"y": 602,
"w": 227,
"h": 90,
"ox": 0,
"oy": 0,
"sw": 227,
"sh": 90,
"ro": false
}
}
}, },
{ {
"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,cloud2.png,controlpeo.png,gamebg.jpg,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,word_云.png,word_休.png,word_卷.png,word_在.png,word_心.png,word_意.png,word_无.png,word_晴.png,word_水.png,word_流.png,word_深.png,word_看.png,word_自.png,word_舒.png,word_闲.png,word_静.png",
"name": "GameScene", "name": "GameScene",
"atlas": { "atlas": "GameScene.sht"
"gamebuild.png": {
"x": 2,
"y": 2,
"w": 750,
"h": 496,
"ox": 0,
"oy": 0,
"sw": 750,
"sh": 496,
"ro": false
},
"scorebg.png": {
"x": 2,
"y": 500,
"w": 309,
"h": 79,
"ox": 0,
"oy": 0,
"sw": 309,
"sh": 79,
"ro": false
},
"rightbtn.png": {
"x": 2,
"y": 581,
"w": 206,
"h": 204,
"ox": 0,
"oy": 0,
"sw": 206,
"sh": 204,
"ro": false
},
"leftbtn.png": {
"x": 313,
"y": 500,
"w": 205,
"h": 205,
"ox": 0,
"oy": 0,
"sw": 205,
"sh": 205,
"ro": false
},
"cloud.png": {
"x": 210,
"y": 581,
"w": 199,
"h": 60,
"ox": 0,
"oy": 0,
"sw": 199,
"sh": 60,
"ro": true
},
"cdbg.png": {
"x": 520,
"y": 500,
"w": 196,
"h": 81,
"ox": 0,
"oy": 0,
"sw": 196,
"sh": 81,
"ro": false
},
"controlpeo.png": {
"x": 520,
"y": 583,
"w": 117,
"h": 196,
"ox": 0,
"oy": 0,
"sw": 117,
"sh": 196,
"ro": false
},
"monster.png": {
"x": 639,
"y": 583,
"w": 97,
"h": 116,
"ox": 0,
"oy": 0,
"sw": 97,
"sh": 116,
"ro": false
},
"tianpop.png": {
"x": 639,
"y": 701,
"w": 84,
"h": 94,
"ox": 0,
"oy": 0,
"sw": 84,
"sh": 94,
"ro": true
},
"xiangpop.png": {
"x": 735,
"y": 701,
"w": 84,
"h": 93,
"ox": 0,
"oy": 0,
"sw": 84,
"sh": 93,
"ro": true
},
"closemusic.png": {
"x": 272,
"y": 707,
"w": 78,
"h": 78,
"ox": 0,
"oy": 0,
"sw": 78,
"sh": 78,
"ro": false
},
"openmusic.png": {
"x": 352,
"y": 707,
"w": 78,
"h": 78,
"ox": 0,
"oy": 0,
"sw": 78,
"sh": 78,
"ro": false
}
}
}, },
{ {
"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", "name": "GuidePanel",
"atlas": { "atlas": "GuidePanel.sht"
"guide.png": {
"x": 2,
"y": 2,
"w": 590,
"h": 586,
"ox": 0,
"oy": 0,
"sw": 590,
"sh": 586,
"ro": false
}
}
}, },
{ {
"keys": "ruleBg.png", "keys": "ruleBg.png",
"name": "RulePanel", "name": "RulePanel",
"atlas": { "atlas": "RulePanel.sht"
"ruleBg.png": {
"x": 2,
"y": 2,
"w": 568,
"h": 638,
"ox": 0,
"oy": 0,
"sw": 568,
"sh": 638,
"ro": false
}
}
}, },
{ {
"keys": "backbtn.png,midbuild.png,mifcloud.png,rulebtn.png,startbg.jpg,startbtn.png,startop.png,titile.png", "keys": "backbtn.png,midbuild.png,mifcloud.png,rulebtn.png,startbg.jpg,startbtn.png,startop.png,titile.png",
"name": "StartScene", "name": "StartScene",
"atlas": { "atlas": "StartScene.sht"
"midbuild.png": {
"x": 2,
"y": 2,
"w": 750,
"h": 493,
"ox": 0,
"oy": 0,
"sw": 750,
"sh": 493,
"ro": false
},
"mifcloud.png": {
"x": 2,
"y": 497,
"w": 750,
"h": 412,
"ox": 0,
"oy": 0,
"sw": 750,
"sh": 412,
"ro": false
},
"titile.png": {
"x": 754,
"y": 2,
"w": 596,
"h": 167,
"ox": 0,
"oy": 0,
"sw": 596,
"sh": 167,
"ro": true
},
"startbtn.png": {
"x": 2,
"y": 911,
"w": 333,
"h": 174,
"ox": 0,
"oy": 0,
"sw": 333,
"sh": 174,
"ro": false
},
"startop.png": {
"x": 754,
"y": 600,
"w": 117,
"h": 196,
"ox": 0,
"oy": 0,
"sw": 117,
"sh": 196,
"ro": false
},
"backbtn.png": {
"x": 754,
"y": 798,
"w": 141,
"h": 53,
"ox": 0,
"oy": 0,
"sw": 141,
"sh": 53,
"ro": false
},
"rulebtn.png": {
"x": 754,
"y": 853,
"w": 140,
"h": 53,
"ox": 0,
"oy": 0,
"sw": 140,
"sh": 53,
"ro": false
}
}
}, },
{ {
"keys": "infoline.png,light.png,sucbg.png,sucstar.png,sun.png", "keys": "infoline.png,light.png,sucbg.png,sucstar.png,sun.png",
"name": "SuccessPanel", "name": "SuccessPanel",
"atlas": { "atlas": "SuccessPanel.sht"
"sucbg.png": {
"x": 2,
"y": 2,
"w": 568,
"h": 502,
"ox": 0,
"oy": 0,
"sw": 568,
"sh": 502,
"ro": false
}, },
"light.png": { {
"x": 2, "keys": "bg.mp3,fail.mp3,get.mp3,jump.mp3",
"y": 506, "name": "bgm"
"w": 463,
"h": 468,
"ox": 0,
"oy": 0,
"sw": 463,
"sh": 468,
"ro": true
},
"sucstar.png": {
"x": 472,
"y": 506,
"w": 227,
"h": 87,
"ox": 0,
"oy": 0,
"sw": 227,
"sh": 87,
"ro": true
},
"infoline.png": {
"x": 561,
"y": 506,
"w": 2,
"h": 113,
"ox": 1,
"oy": 1,
"sw": 4,
"sh": 115,
"ro": false
}, },
"sun.png": { {
"x": 472, "keys": "closebtn.png,comCloseBtn.png,surebtn.png,toastBg.png,waitingBg.png,waitingRot.png,关闭按钮.png,关闭按钮2.png",
"y": 735, "name": "common",
"w": 89, "atlas": "common.sht"
"h": 83,
"ox": 0,
"oy": 0,
"sw": 89,
"sh": 83,
"ro": false
}
}
}, },
{ {
"keys": "crypeo.svga,guidecount.svga,jumppeo.svga,popstar.svga,startpeo.svga,startpop.svga", "keys": "atmosphere.svga,crypeo.svga,guidecount.svga,jumppeo.svga,left.svga,light.svga,popstar.svga,right.svga,startbtn.svga,startpeople.svga",
"name": "svga" "name": "svga"
} }
], ],
......
...@@ -264,17 +264,7 @@ ...@@ -264,17 +264,7 @@
"x": 0, "x": 0,
"y": 0, "y": 0,
"type": "container", "type": "container",
"children": [ "children": []
{
"name": "guide",
"x": 80,
"y": 787,
"type": "sprite",
"props": {
"source": "guide.png"
}
}
]
}, },
{ {
"name": "GameScene", "name": "GameScene",
...@@ -292,19 +282,10 @@ ...@@ -292,19 +282,10 @@
}, },
"id": "bg" "id": "bg"
}, },
{
"name": "gamebuild",
"x": 0,
"y": 826,
"type": "sprite",
"props": {
"source": "gamebuild.png"
}
},
{ {
"name": "cloud", "name": "cloud",
"x": 450, "x": 51,
"y": 689, "y": 761,
"type": "sprite", "type": "sprite",
"props": { "props": {
"source": "cloud.png" "source": "cloud.png"
...@@ -312,109 +293,36 @@ ...@@ -312,109 +293,36 @@
"id": "cloud" "id": "cloud"
}, },
{ {
"name": "controlpeo", "name": "cloud2",
"x": 313, "x": 214,
"y": 788, "y": 1065,
"type": "sprite", "type": "sprite",
"props": { "props": {
"source": "controlpeo.png" "source": "cloud2.png"
}, },
"id": "peo" "id": "cloud2"
}, },
{ {
"name": "tianpop", "name": "controlpeo",
"x": 516, "x": 237,
"y": 638, "y": 869,
"type": "sprite",
"props": {
"source": "tianpop.png"
},
"id": "tianpop"
},
{
"name": "xiangpop",
"x": 27,
"y": 786,
"type": "sprite",
"props": {
"source": "xiangpop.png"
},
"id": "xiangpop"
},
{
"name": "monster",
"x": 106,
"y": 419,
"type": "sprite", "type": "sprite",
"props": { "props": {
"source": "monster.png" "source": "controlpeo.png"
}, },
"id": "monster" "id": "peo"
}, },
{ {
"name": "controlbtn", "name": "controlbtn",
"x": 80, "x": 80,
"y": 1164, "y": 1164,
"type": "container", "type": "container",
"children": [ "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": "lrft"
}
]
},
{
"name": "score",
"x": 280,
"y": 244,
"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": "5136",
"size": 44,
"fillColor": "#ffffff",
"textAlpha": 1,
"lineHeight": 44
},
"id": "scorenum"
}
]
}, },
{ {
"name": "countdown", "name": "countdown",
"x": 23, "x": 313,
"y": 244, "y": 330,
"type": "container", "type": "container",
"children": [ "children": [
{ {
...@@ -426,42 +334,8 @@ ...@@ -426,42 +334,8 @@
"source": "cdbg.png" "source": "cdbg.png"
}, },
"id": "cdbg" "id": "cdbg"
},
{
"name": "cdnum",
"x": 94,
"y": 26,
"type": "text",
"props": {
"text": "15s",
"size": 44,
"fillColor": "#ffffff",
"textAlpha": 1,
"lineHeight": 44
},
"id": "cdnum"
} }
] ]
},
{
"name": "closemusic",
"x": 650,
"y": 245,
"type": "sprite",
"props": {
"source": "closemusic.png"
},
"id": "close"
},
{
"name": "openmusic",
"x": 650,
"y": 245,
"type": "sprite",
"props": {
"source": "openmusic.png"
},
"id": "open"
} }
] ]
}, },
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
"name": "FailPanel" "name": "FailPanel"
}, },
{ {
"keys": "cdbg.png,closemusic.png,cloud.png,cloud2.png,controlpeo.png,gamebg.jpg,leftbtn.png,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,openmusic.png,reset.png,rightbtn.png,scorebg.png,tianpop.png,word_云.png,word_休.png,word_卷.png,word_在.png,word_心.png,word_意.png,word_无.png,word_晴.png,word_水.png,word_流.png,word_深.png,word_看.png,word_自.png,word_舒.png,word_闲.png,word_静.png,xiangpop.png", "keys": "cdbg.png,cloud.png,cloud2.png,controlpeo.png,gamebg.jpg,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,word_云.png,word_休.png,word_卷.png,word_在.png,word_心.png,word_意.png,word_无.png,word_晴.png,word_水.png,word_流.png,word_深.png,word_看.png,word_自.png,word_舒.png,word_闲.png,word_静.png",
"name": "GameScene" "name": "GameScene"
}, },
{ {
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
"name": "common" "name": "common"
}, },
{ {
"keys": "atmosphere.svga,crypeo.svga,guidecount.svga,jumppeo.svga,left.svga,popstar.svga,right.svga,startbtn.svga,startpeople.svga", "keys": "atmosphere.svga,crypeo.svga,guidecount.svga,jumppeo.svga,left.svga,light.svga,popstar.svga,right.svga,startbtn.svga,startpeople.svga",
"name": "svga" "name": "svga"
} }
], ],
......
...@@ -2,27 +2,33 @@ export const ResJson = { ...@@ -2,27 +2,33 @@ export const ResJson = {
"groups": [ "groups": [
{ {
"keys": "failbg.png,knowbtn.png,restartbtn.png", "keys": "failbg.png,knowbtn.png,restartbtn.png",
"name": "FailPanel" "name": "FailPanel",
"atlas": "FailPanel.sht"
}, },
{ {
"keys": "cdbg.png,closemusic.png,cloud.png,cloud2.png,controlpeo.png,gamebg.jpg,leftbtn.png,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,openmusic.png,reset.png,rightbtn.png,scorebg.png,tianpop.png,word_云.png,word_休.png,word_卷.png,word_在.png,word_心.png,word_意.png,word_无.png,word_晴.png,word_水.png,word_流.png,word_深.png,word_看.png,word_自.png,word_舒.png,word_闲.png,word_静.png,xiangpop.png", "keys": "cdbg.png,cloud.png,cloud2.png,controlpeo.png,gamebg.jpg,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,word_云.png,word_休.png,word_卷.png,word_在.png,word_心.png,word_意.png,word_无.png,word_晴.png,word_水.png,word_流.png,word_深.png,word_看.png,word_自.png,word_舒.png,word_闲.png,word_静.png",
"name": "GameScene" "name": "GameScene",
"atlas": "GameScene.sht"
}, },
{ {
"keys": "guide.png,step1_img.png,step1_tips.png,step2_img.png,step2_tips.png,step3_img.png,step3_tips.png,step4_img.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" "name": "GuidePanel",
"atlas": "GuidePanel.sht"
}, },
{ {
"keys": "ruleBg.png", "keys": "ruleBg.png",
"name": "RulePanel" "name": "RulePanel",
"atlas": "RulePanel.sht"
}, },
{ {
"keys": "backbtn.png,midbuild.png,mifcloud.png,rulebtn.png,startbg.jpg,startbtn.png,startop.png,titile.png", "keys": "backbtn.png,midbuild.png,mifcloud.png,rulebtn.png,startbg.jpg,startbtn.png,startop.png,titile.png",
"name": "StartScene" "name": "StartScene",
"atlas": "StartScene.sht"
}, },
{ {
"keys": "infoline.png,light.png,sucbg.png,sucstar.png,sun.png", "keys": "infoline.png,light.png,sucbg.png,sucstar.png,sun.png",
"name": "SuccessPanel" "name": "SuccessPanel",
"atlas": "SuccessPanel.sht"
}, },
{ {
"keys": "bg.mp3,fail.mp3,get.mp3,jump.mp3", "keys": "bg.mp3,fail.mp3,get.mp3,jump.mp3",
...@@ -30,12 +36,13 @@ export const ResJson = { ...@@ -30,12 +36,13 @@ export const ResJson = {
}, },
{ {
"keys": "closebtn.png,comCloseBtn.png,surebtn.png,toastBg.png,waitingBg.png,waitingRot.png,关闭按钮.png,关闭按钮2.png", "keys": "closebtn.png,comCloseBtn.png,surebtn.png,toastBg.png,waitingBg.png,waitingRot.png,关闭按钮.png,关闭按钮2.png",
"name": "common" "name": "common",
"atlas": "common.sht"
}, },
{ {
"keys": "atmosphere.svga,crypeo.svga,guidecount.svga,jumppeo.svga,left.svga,popstar.svga,right.svga,startbtn.svga,startpeople.svga", "keys": "atmosphere.svga,crypeo.svga,guidecount.svga,jumppeo.svga,left.svga,light.svga,popstar.svga,right.svga,startbtn.svga,startpeople.svga",
"name": "svga" "name": "svga"
} }
], ],
"path": "./resource/" "path": "https://yun.duiba.com.cn/db_games/activity/template/1678366579/resource/"
} }
\ No newline at end of file
import { Scene } from "../../module/views/Scene";
import * as Matter from "matter-js";
import Role from "./components/Role";
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 { showPanel, showToast, changeScene } from "../../module/ctrls";
import { GuidePanel } from "../panels/GuidePanel";
import { StartScene } from "./StartScene";
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 { layers } from "../../module/views/layers";
export class GameScene extends Scene {
get groupNames() { return ["GameScene"] };
get skinName() { return "GameScene" };
bg: FYGE.Sprite;
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;
isonce = false;
public static instance: GameScene;
initUi() {
}
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
}
this.createPhyWorld()
this.bgCon = this.addChild(new FYGE.Container());
this.setChildIndex(this.bgCon, 2)
this.initMap();
this.scorenum.text = "0"
this.cdnum.text = StartScene.instance.gameInfo.duration
}
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.startGame()
this.countDown(this.time)
}
countDown(time) {
this.timer = setTimeout(() => {
if (Number(this.cdnum.text) <= 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))
}, 1000)
}
startGame() {
this.isonce = false
this.addRole();
this.addEventListener(FYGE.Event.ENTER_FRAME, this.onFarm, this);
this.composites.add(this.world, [this._role.phyBody]);
}
_role; //人物
bgCon; //背景移动
addRole() {
let offset = (1624 - this.stage.viewRect.height) / 2;
let role = this._role = new Role();
role.fx = 380;
role.fy = 980 - offset;
this.bgCon.addChild(role);
// this.composites.add(this.world, [role.phyBody]);
}
engine; // matter引擎初始化
composites;
world;
runner;
ground;
addPropsMap = new Map();
obstaclePropMap = new Map();
private createPhyWorld() {
const { Engine, Render, Runner, Composite, Bodies, World, Composites } = Matter;
this.engine = Engine.create(
{
enableSleeping: true
}
);
this.world = this.engine.world;
this.engine.gravity.y = 1.5;
/** 真正运行 */
this.runner = Runner.create();
Runner.run(this.runner, this.engine);
// @ts-ignore
this.composites = Composite;
Matter.Events.on(this.engine, "collisionStart", this.onCollisionStart.bind(this));
Matter.Events.on(this.engine, "tick", this.onCollisionTick.bind(this));
}
onCollisionTick(e) {
}
onCollisionStart(e) {
let pairs = e.pairs;
pairs.map((p) => {
// 🌹与人的碰撞
if (p.bodyB == this._role.phyBody || p.bodyA == this._role.phyBody) {
if (p.bodyB.gameType?.split("_")[0] == 'addProp' || p.bodyA.gameType?.split("_")[0] == 'addProp') {
console.log("加分")
let body = p.bodyB.gameType?.split("_")[0] == 'addProp' ? p.bodyB : p.bodyA;
let prop = this.addPropsMap.get(body.id);
let num = 1
if (body.gameType.split("_")[1] == "tian") {
num = 1
} else {
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();
this.bgCon.removeChild(prop)
this.addPropsMap.delete(body.id);
} 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);
prop.destroy();
this.bgCon.removeChild(prop)
this.obstaclePropMap.delete(body.id);
// this.removeWorld()
this.composites.remove(this.world, this._role.phyBody);
clearTimeout(this.timer);
this.gameOver()
} else {
if (!this.jumpLock) {
if (Tools.isMusic) {
cusPlaySound("jump", false)
}
this._role.jump()
this.jumpLock = true;
setTimeout(() => {
this.jumpLock = false
}, 300)
}
}
}
});
}
initMap() {
let stageHeight = this.stage.stageHeight;
this.createLineItem(stageHeight - 240, 380, false);
for (let i = 0; i < 10; i++) {
if (i < 4) {
this.createLineItem(stageHeight - (240 * (i + 2)), 0, false);
} else {
this.createLineItem(stageHeight - (240 * (i + 2)));
}
}
}
mapList = [];
createLineItem(h, x?: number, isprop = true) {
let nx = x ? x : Math.floor(Math.random() * 570 + 90);
if (isprop) {
let rate = Math.floor(Math.random() * 20);
switch (true) {
case rate < 18:
// 添加花🌹加分元素
let addProp = new AddProp();
addProp.fx = nx;
addProp.fy = h - 25;
this.bgCon.addChildAt(addProp, 0)
this.composites.add(this.world, [addProp.phyBody]);
this.addPropsMap.set(addProp.phyBody.id, addProp);
break;
case rate >= 19 && rate <= 20:
// 添加障碍元素
let obstacleProp = new ObstacleProp()
obstacleProp.fx = nx;
obstacleProp.fy = h - 40;
this.bgCon.addChildAt(obstacleProp, 0)
this.composites.add(this.world, [obstacleProp.phyBody]);
this.obstaclePropMap.set(obstacleProp.phyBody.id, obstacleProp)
break
default:
break
}
}
let mapItem = new MapItem();
mapItem.fx = nx;
mapItem.fy = h
this.bgCon.addChildAt(mapItem, 0)
this.composites.add(this.world, [mapItem.phyBody]);
let spriteItem = this.createOtherItem(nx, h);
this.mapList.push([mapItem, spriteItem])
}
createOtherItem(x, h) {
let dx = Math.floor(Math.random() * 280 + 90);
if (dx + 90 > x - 90) {
dx = dx + 310
}
let mapItem = new MapItem();
mapItem.fx = dx;
mapItem.fy = h
this.bgCon.addChildAt(mapItem, 0);
this.composites.add(this.world, [mapItem.phyBody]);
return mapItem
}
timer = null;
onFarm() {
let roleY = this._role.y + this.bgCon.y;
if (roleY < 600) {
this.moveMap(600 - roleY)
}
let lastLine = this.mapList[0],
lastItem = lastLine[0];
if (lastItem.y + this.bgCon.y > this.stage.stageHeight + 10) {
lastLine.forEach(item => {
this.composites.remove(this.world, item.phyBody);
item.destroy();
this.bgCon.removeChild(item)
})
this.mapList.shift()
}
let firstLine = this.mapList[this.mapList.length - 1],
firstItem = firstLine[0];
if (firstItem.y + this.bgCon.y > -100) {
this.createLineItem(firstItem.y - 240)
}
// console.log(this._role.y,this.bgCon.y,layers.stageHeight)
if (this._role.y >= -(this.bgCon.y-1624)) {
if (!this.isonce) {
this.composites.remove(this.world, this._role.phyBody);
console.log("siwang")
clearTimeout(this.timer);
this.gameOver()
// 复活需要初始化
this.isonce = true
}
}
}
moveMap(y) {
this.bgCon.y = this.bgCon.y + y;
}
removeWorld(){
this.composites.clear(this.world)
// console.log(this.composites)
this.mapList = [];
this.addPropsMap.clear()
this.obstaclePropMap.clear()
console.log(this.obstaclePropMap)
console.log(this.addPropsMap)
console.log(this.mapList)
}
//游戏结束
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)
}
})
}
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()
}
}
import { Scene } from "../../module/views/Scene"; import { Scene } from "../../module/views/Scene";
import * as Matter from "matter-js";
import Role from "./components/Role"; import Role from "./components/Role";
import AddProp from "./components/AddProp"; import AddProp from "./components/AddProp";
import { RES } from "../../module/RES"; import { RES } from "../../module/RES";
...@@ -17,6 +16,11 @@ import { duiba_md5 } from "../../module/tools/security"; ...@@ -17,6 +16,11 @@ import { duiba_md5 } from "../../module/tools/security";
import { Tools } from "../Tools"; import { Tools } from "../Tools";
import { layers } from "../../module/views/layers"; import { layers } from "../../module/views/layers";
import UI from "../UI"; import UI from "../UI";
export class GameScene extends Scene { export class GameScene extends Scene {
get groupNames() { return ["GameScene"] }; get groupNames() { return ["GameScene"] };
get skinName() { return "GameScene" }; get skinName() { return "GameScene" };
...@@ -29,7 +33,7 @@ export class GameScene extends Scene { ...@@ -29,7 +33,7 @@ export class GameScene extends Scene {
bgCon; //背景移动 bgCon; //背景移动
_role; //人物 _role; //人物
wordList = ['闲', '看', '晴', '云', '自', '卷', '舒', '静', '水', '流', '深', '心', '无', '意', '在', '休']; // 待随机出现的列表 wordList = ['闲', '看', '晴', '云', '自', '卷', '舒', '静', '水', '流', '深', '心', '无', '意', '在', '休']; // 待随机出现的列表
collectList = []; // 已收集列表 collectList: any = []; // 已收集列表
mapList = []; mapList = [];
...@@ -66,8 +70,7 @@ export class GameScene extends Scene { ...@@ -66,8 +70,7 @@ export class GameScene extends Scene {
async start(data) { async start(data) {
super.start(); super.start();
GameScene.instance = this GameScene.instance = this
console.log("新手引导")
// showPanel(GuidePanel);
this.left = new FYGE.SvgaAni(await RES.getResAsync("left.svga")) this.left = new FYGE.SvgaAni(await RES.getResAsync("left.svga"))
...@@ -78,84 +81,62 @@ export class GameScene extends Scene { ...@@ -78,84 +81,62 @@ export class GameScene extends Scene {
this.right = this.addChild(this.right) this.right = this.addChild(this.right)
this.right.position.set(524, 979); this.right.position.set(524, 979);
this.right.startAniRange(1, 1, 1); this.right.startAniRange(1, 1, 1);
this.cdUIRender(this.time)
// 创建模型, 云层 // 创建模型, 云层
this.createPhyWorld()
this.bgCon = this.addChild(new FYGE.Container()); this.bgCon = this.addChild(new FYGE.Container());
this.setChildIndex(this.bgCon, 2) this.setChildIndex(this.bgCon, 2)
this.initCloud(); this.initCloud();
this.upDateInfo(); // 用于开始游戏 ----test console.log("新手引导")
showPanel(GuidePanel);
// this.upDateInfo(); // 用于开始游戏 ----test
// 添加指向的事件 // 添加指向的事件
this.left.addEventListener(FYGE.MouseEvent.CLICK, () => { this.left.addEventListener(FYGE.MouseEvent.CLICK, () => {
let item = this._role.currentIndex < 0 ? this.mapList[0][0] : this.mapList[this._role.currentIndex][0]
let stageHeight = this.stage.stageHeight;
if (item.y + this.bgCon.y - 200 > 0 && !this._role.isMove && this._role.currentIndex%2 == 0){
this.left.startAniRange(1, undefined, 1, () => { this.left.startAniRange(1, undefined, 1, () => {
let item = this._role.currentIndex < 0 ? this.mapList[0] : this.mapList[this._role.currentIndex] console.log('this._role.currentIndex', this._role.currentIndex)
this._role.leftMove({ this._role.leftMove({
item: item item: item
}, this.collectWordTx.bind(this))
}) })
}) }
}) })
this.right.addEventListener(FYGE.MouseEvent.CLICK, () => { this.right.addEventListener(FYGE.MouseEvent.CLICK, () => {
let item = this._role.currentIndex < 0 ? this.mapList[0][0] : this.mapList[this._role.currentIndex][0]
let stageHeight = this.stage.stageHeight;
if (item.y + this.bgCon.y - 200 > 0 && !this._role.isMove && this._role.currentIndex%2 == 1){
this.right.startAniRange(1, undefined, 1, () => { this.right.startAniRange(1, undefined, 1, () => {
console.log('this._role.currentIndex', this._role.currentIndex)
let item = this._role.currentIndex < 0 ? this.mapList[0][0] : this.mapList[this._role.currentIndex][0]
console.log("播放完成") console.log("播放完成")
this._role.rightMove() this._role.rightMove({
}) item: item
}, this.collectWordTx.bind(this))
}) })
// this.createPhyWorld()
// this.bgCon = this.addChild(new FYGE.Container());
// this.setChildIndex(this.bgCon, 2)
// this.initMap();
// this.scorenum.text = "0"
// this.cdnum.text = StartScene.instance.gameInfo.duration
}
engine; // matter引擎初始化
composites;
world;
runner;
ground;
addPropsMap = new Map();
obstaclePropMap = new Map();
private createPhyWorld() {
const { Engine, Render, Runner, Composite, Bodies, World, Composites } = Matter;
this.engine = Engine.create(
{
enableSleeping: true
} }
); })
this.world = this.engine.world;
this.engine.gravity.y = 1.5;
/** 真正运行 */
this.runner = Runner.create();
Runner.run(this.runner, this.engine);
// @ts-ignore
this.composites = Composite;
Matter.Events.on(this.engine, "collisionStart", this.onCollisionStart.bind(this));
Matter.Events.on(this.engine, "tick", this.onCollisionTick.bind(this));
} }
upDateInfo() { upDateInfo() {
this.time = Number(StartScene.instance.gameInfo.duration)
this.cdUIRender(this.time) this.cdUIRender(this.time)
this.startGame() this.startGame()
// this.countDown(this.time) this.countDown(this.time)
} }
startGame() { startGame() {
this.addEventListener(FYGE.Event.ENTER_FRAME, this.onFarm, this); this.addEventListener(FYGE.Event.ENTER_FRAME, this.onFarm, this);
// this.composites.add(this.world, [this._role.phyBody]);
} }
time; time=60;
timer = null; timer = null;
countDown(time) { countDown(time) {
this.timer = setTimeout(() => { this.timer = setTimeout(() => {
// if (this.time <= 0) { if (this.time <= 0) {
// clearTimeout(this.timer); clearTimeout(this.timer);
// this.composites.remove(this.world, this._role.phyBody); this.gameOver()
// this.gameOver() return
// return }
// }
this.time = this.time - 1; this.time = this.time - 1;
this.cdUIRender(this.time) this.cdUIRender(this.time)
this.countDown(this.time) this.countDown(this.time)
...@@ -173,18 +154,21 @@ export class GameScene extends Scene { ...@@ -173,18 +154,21 @@ export class GameScene extends Scene {
}) })
} }
firstCoud;
initCloud() { initCloud() {
let stageHeight = this.stage.stageHeight; let stageHeight = this.stage.stageHeight;
let offset = (1624 - this.stage.viewRect.height) / 2;
// 渲染人物脚下的一朵云层 // 渲染人物脚下的一朵云层
UI.Sp(this.bgCon, 'cloud2.png', 190, stageHeight-310) this.firstCoud = UI.Sp(this.bgCon, 'cloud2.png', 190, 1150 - offset )
// 创建角色 // 创建角色
this.addRole() this.addRole()
// 开始循环添加 // 开始循环添加
for (let i=0; i<7; i++) { for (let i=0; i<15; i++) {
this.createCloudItem(stageHeight - (500 + 150*i), i%2 == 0 ? 'left' : 'right'); this.createCloudItem(stageHeight - (500 + 150*i), i + 1, i%2 == 0 ? 'left' : 'right');
} }
} }
...@@ -194,7 +178,7 @@ export class GameScene extends Scene { ...@@ -194,7 +178,7 @@ export class GameScene extends Scene {
* @param direction 方向 left right * @param direction 方向 left right
* @param isprop * @param isprop
*/ */
createCloudItem(h, direction?: string) { createCloudItem(h, index, direction?: string) {
// 0 - wordList长度之间的随机数 // 0 - wordList长度之间的随机数
let len = this.wordList.length let len = this.wordList.length
let randomIndex; let randomIndex;
...@@ -202,15 +186,14 @@ export class GameScene extends Scene { ...@@ -202,15 +186,14 @@ export class GameScene extends Scene {
randomIndex = Math.floor(Math.random()*len); randomIndex = Math.floor(Math.random()*len);
} }
let wordItem = new Word({ let wordItem = new Word({
wordTx: len == 0 ? '' : this.wordList[randomIndex] wordTx: len == 0 ? '' : this.wordList[randomIndex],
index: index
}) })
// 偏差值 // 偏差值
let deviation = Math.floor(Math.random()*200) - 100; let deviation = Math.floor(Math.random()*200) - 100;
wordItem.fx = (direction === 'left' ? 88 : 440) + deviation + 100; wordItem.fx = (direction === 'left' ? 88 : 440) + deviation + 100;
wordItem.fy = h + 5 wordItem.fy = h + 5
this.bgCon.addChildAt(wordItem, 0) this.bgCon.addChildAt(wordItem, 0)
this.composites.add(this.world, [wordItem.phyBody]);
this.addPropsMap.set(wordItem.phyBody.id, wordItem);
let cloudItem = new Cloud({ let cloudItem = new Cloud({
direction direction
...@@ -219,7 +202,6 @@ export class GameScene extends Scene { ...@@ -219,7 +202,6 @@ export class GameScene extends Scene {
cloudItem.fy = h cloudItem.fy = h
this.bgCon.addChildAt(cloudItem, 0) this.bgCon.addChildAt(cloudItem, 0)
this.mapList.push([wordItem, cloudItem]) this.mapList.push([wordItem, cloudItem])
this.composites.add(this.world, [wordItem.phyBody, cloudItem.phyBody]);
} }
// 添加角色 // 添加角色
...@@ -230,251 +212,66 @@ export class GameScene extends Scene { ...@@ -230,251 +212,66 @@ export class GameScene extends Scene {
role.fy = 1150 - offset; role.fy = 1150 - offset;
this.bgCon.addChild(role); this.bgCon.addChild(role);
// this.composites.add(this.world, [role.phyBody]);
} }
outIndex=0;
onFarm() { onFarm() {
this.moveMap() this.moveMap();
// let roleY = this._role.y + this.bgCon.y;
// if (roleY < 600) {
// this.moveMap(600 - roleY)
// }
// let lastLine = this.mapList[0],
// lastItem = lastLine[0];
// if (lastItem.y + this.bgCon.y > this.stage.stageHeight + 10) {
// lastLine.forEach(item => {
// this.composites.remove(this.world, item.phyBody);
// item.destroy();
// this.bgCon.removeChild(item)
// })
// this.mapList.shift()
// }
// let firstLine = this.mapList[this.mapList.length - 1],
// firstItem = firstLine[0];
// if (firstItem.y + this.bgCon.y > -100) {
// this.createLineItem(firstItem.y - 240)
// }
// // console.log(this._role.y,this.bgCon.y,layers.stageHeight)
// if (this._role.y >= -(this.bgCon.y-1624)) {
// if (!this.isonce) {
// this.composites.remove(this.world, this._role.phyBody);
// console.log("siwang")
// clearTimeout(this.timer);
// this.gameOver()
// // 复活需要初始化
// this.isonce = true
// }
// }
// 判断是否超出屏幕
let stageHeight = this.stage.stageHeight;
// console.log('this.mapList[0]', this.mapList[0].y + this.bgCon.y, this.stage.stageHeight)
if (this.mapList[this.outIndex][0].y + this.bgCon.y - 200 > stageHeight) {
if (this.firstCoud) {
this.bgCon.removeChild(this.firstCoud)
} }
moveMap() { let _index = this.outIndex;
// console.log('this.bgCon', this.bgCon) this.outIndex++
// this.bgCon.y = this.bgCon.y + 1; // console.log("超出屏幕")
this.bgCon.removeChild(this.mapList[_index][0])
this.bgCon.removeChild(this.mapList[_index][1])
let i = this.mapList[this.mapList.length - 1][0].index
// console.log(this.mapList[this.mapList.length - 1][0].index)
this.createCloudItem(stageHeight - (500 + 150*i), i + 1, i%2 == 0 ? 'left' : 'right')
} }
onCollisionTick() {
// 判断人物是否超出
if (this._role.y + this.bgCon.y - 305 > stageHeight) {
let item = this.mapList[this.outIndex + 7][0]
this._role.onFreeFall({
x: item.x,
y: item.y
}, {
item:item
}, this.collectWordTx.bind(this))
} }
onCollisionStart() {
} }
moveMap() {
this.bgCon.y = this.bgCon.y + 2
}
collectWordTx(item) {
this.bgCon.removeChild(item)
if (item.wordTx && !this.collectList.includes(item.wordTx)) {
this.collectList.push(item.wordTx);
let _i = this.wordList.indexOf(item.wordTx);
if (_i > -1) {
this.wordList.splice(_i, 1)
}
}
}
async gameOver() {
this.removeEventListener(FYGE.Event.ENTER_FRAME, this.onFarm, this);
let startInfo = getWebData(WebNetName.startGame).data.currInfo;
let timestamp = new Date().getTime();
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})
}
// onCollisionTick(e) {
// }
// onCollisionStart(e) {
// let pairs = e.pairs;
// pairs.map((p) => {
// // 🌹与人的碰撞
// if (p.bodyB == this._role.phyBody || p.bodyA == this._role.phyBody) {
// if (p.bodyB.gameType?.split("_")[0] == 'addProp' || p.bodyA.gameType?.split("_")[0] == 'addProp') {
// console.log("加分")
// let body = p.bodyB.gameType?.split("_")[0] == 'addProp' ? p.bodyB : p.bodyA;
// let prop = this.addPropsMap.get(body.id);
// let num = 1
// if (body.gameType.split("_")[1] == "tian") {
// num = 1
// } else {
// num = 2
// }
// this._role.addScore('+' + num, '#ffffff')
// this.scorenum.text = Number(this.scorenum.text) + num + '';
// this.score += num
// this.composites.remove(this.world, prop.phyBody);
// prop.destroy();
// this.bgCon.removeChild(prop)
// this.addPropsMap.delete(body.id);
// } else if (p.bodyB.gameType == 'dieProp' || p.bodyA.gameType == 'dieProp') {
// // 死亡💀
// console.log("死亡")
// let body = p.bodyB.gameType == 'dieProp' ? p.bodyB : p.bodyA;
// let prop = this.obstaclePropMap.get(body.id);
// this.composites.remove(this.world, prop.phyBody);
// prop.destroy();
// this.bgCon.removeChild(prop)
// this.obstaclePropMap.delete(body.id);
// // this.removeWorld()
// this.composites.remove(this.world, this._role.phyBody);
// clearTimeout(this.timer);
// this.gameOver()
// } else {
// if (!this.jumpLock) {
// this._role.jump()
// this.jumpLock = true;
// setTimeout(() => {
// this.jumpLock = false
// }, 300)
// }
// }
// }
// });
// }
// initMap() {
// let stageHeight = this.stage.stageHeight;
// this.createLineItem(stageHeight - 240, 380, false);
// for (let i = 0; i < 10; i++) {
// // if (i < 4) {
// // this.createLineItem(stageHeight - (240 * (i + 2)), 0, false);
// // } else {
// // this.createLineItem(stageHeight - (240 * (i + 2)));
// // }
// }
// }
// createLineItem(h, x?: number, isprop = true) {
// let nx = x ? x : Math.floor(Math.random() * 570 + 90);
// if (isprop) {
// let rate = Math.floor(Math.random() * 20);
// switch (true) {
// case rate < 18:
// // 添加花🌹加分元素
// let addProp = new AddProp();
// addProp.fx = nx;
// addProp.fy = h - 25;
// this.bgCon.addChildAt(addProp, 0)
// this.composites.add(this.world, [addProp.phyBody]);
// this.addPropsMap.set(addProp.phyBody.id, addProp);
// break;
// case rate >= 19 && rate <= 20:
// // 添加障碍元素
// let obstacleProp = new ObstacleProp()
// obstacleProp.fx = nx;
// obstacleProp.fy = h - 40;
// this.bgCon.addChildAt(obstacleProp, 0)
// this.composites.add(this.world, [obstacleProp.phyBody]);
// this.obstaclePropMap.set(obstacleProp.phyBody.id, obstacleProp)
// break
// default:
// break
// }
// }
// let mapItem = new MapItem();
// mapItem.fx = nx;
// mapItem.fy = h
// this.bgCon.addChildAt(mapItem, 0)
// this.composites.add(this.world, [mapItem.phyBody]);
// let spriteItem = this.createOtherItem(nx, h);
// this.mapList.push([mapItem, spriteItem])
// }
// createOtherItem(x, h) {
// let dx = Math.floor(Math.random() * 280 + 90);
// if (dx + 90 > x - 90) {
// dx = dx + 310
// }
// let mapItem = new MapItem();
// mapItem.fx = dx;
// mapItem.fy = h
// this.bgCon.addChildAt(mapItem, 0);
// this.composites.add(this.world, [mapItem.phyBody]);
// return mapItem
// }
// removeWorld(){
// this.composites.clear(this.world)
// // console.log(this.composites)
// this.mapList = [];
// this.addPropsMap.clear()
// this.obstaclePropMap.clear()
// console.log(this.obstaclePropMap)
// console.log(this.addPropsMap)
// console.log(this.mapList)
// }
// //游戏结束
// 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)
// }
// })
// }
initEvents() { initEvents() {
super.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()
// })
} }
removeEvents() { removeEvents() {
super.removeEvents(); super.removeEvents();
......
...@@ -47,14 +47,8 @@ export class StartScene extends Scene { ...@@ -47,14 +47,8 @@ export class StartScene extends Scene {
this.indexInfo = data this.indexInfo = data
this.titlelab.text = "今日收集字数( " + data.word + " / 17 )" this.titlelab.text = "今日收集字数( " + data.word + " / 17 )"
// test==-------
for (let i = 0; i < data.gamecfs.length; i++) { // this.openGame()
if (data.gamecfs[i].code == data.gameCode) {
this.gameInfo = data.gamecfs[i]
}
}
// test-------
this.openGame()
} }
openRule() { openRule() {
showPanel(RulePanel) showPanel(RulePanel)
......
import * as Matter from "matter-js";
import { RES } from "../../../module/RES"; import { RES } from "../../../module/RES";
export default class Role extends FYGE.Container { export default class Role extends FYGE.Container {
public phyBody: Matter.Body;
roleImg: FYGE.Sprite; roleImg: FYGE.Sprite;
beforeY = 0;
// direction = 'down';
direction; direction;
jumpSvga; jumpSvga;
downSvga; downSvga;
lightSvga;
currentIndex = -2; currentIndex = -2;
position; position;
item item;
isMove;
constructor(data?) { constructor() {
super(); super();
let roleImg = this.roleImg = new FYGE.Sprite(); let roleImg = this.roleImg = new FYGE.Sprite();
roleImg.texture = RES.getRes("controlpeo.png"); roleImg.texture = RES.getRes("controlpeo.png");
this.getSvga() this.getSvga()
this.phyBody = Matter.Bodies.circle(this.x, this.y,roleImg.width/2, {
friction: 1,
isSensor: false, // 传感器,可以检测到碰撞,但是不参与碰撞
});
this.setPhyPos();
// this.addEventListener( // this.addEventListener(
// FYGE.Event.ADDED_TO_STAGE, // FYGE.Event.ADDED_TO_STAGE,
// () => { // () => {
...@@ -40,96 +32,97 @@ export default class Role extends FYGE.Container { ...@@ -40,96 +32,97 @@ export default class Role extends FYGE.Container {
this.jumpSvga.visible = false this.jumpSvga.visible = false
this.addChild(this.jumpSvga); this.addChild(this.jumpSvga);
this.downSvga = new FYGE.SvgaAni(await RES.getResAsync("crypeo.svga")); this.downSvga = new FYGE.SvgaAni(await RES.getResAsync("crypeo.svga"));
this.downSvga.position.set(-this.downSvga.videoWidth / 2, -this.downSvga.videoHeight / 2) this.downSvga.position.set(-this.downSvga.videoWidth / 2, -this.downSvga.videoHeight / 2)
this.addChild(this.downSvga); this.addChild(this.downSvga);
}
// ------------test this.lightSvga = new FYGE.SvgaAni(await RES.getResAsync("light.svga"));
this.lightSvga.position.set(-this.lightSvga.videoWidth / 2, -this.lightSvga.videoHeight / 2)
die(callback){ this.lightSvga.visible = false
this.jumpSvga.visible = false; this.addChild(this.lightSvga);
this.downSvga.visible = true;
FYGE.Tween.get(this.downSvga)
.to({
y:this.downSvga.y+750
},1000)
.call(()=>{
callback()
})
} }
leftMove(){ leftMove(data, callback){
if (this.currentIndex%2 == 0) { if (this.currentIndex%2 == 0) {
console.log('左移动') if (this.isMove) return
this.isMove = true
this.item = data.item
this.direction = 'left' this.direction = 'left'
Matter.Body.applyForce(this.phyBody, this.phyBody.position, { this.downSvga.visible = false
x: 0.1, this.jumpSvga.visible = true,
y: 0 this.jumpSvga.startAniRange(1, undefined, 1)
}); FYGE.Tween.get(this.position).to({
x: this.item.position.x + 20,
y: this.item.position.y - 110
}, 500, FYGE.Ease.quadInOut)
.call(() => {
// console.log("播放完成")
callback && callback(this.item)
this.currentIndex = this.item.index;
this.downSvga.visible = true
this.jumpSvga.visible = false
this.isMove = false
this.lightSvga.visible = true
this.lightSvga.startAniRange(1, undefined, 1, () => {
this.lightSvga.visible = false
})
})
} }
} }
rightMove(){ rightMove(data, callback){
if (this.currentIndex%2 == 1) { if (this.currentIndex%2 == 1) {
if (this.isMove) return
this.isMove = true
this.item = data.item
console.log('右移动', this.item.position.x)
this.direction = 'right' this.direction = 'right'
Matter.Body.applyForce(this.phyBody, this.phyBody.position, { this.downSvga.visible = false
x: -0.1, this.jumpSvga.visible = true
y: 0 this.jumpSvga.startAniRange(1, undefined, 1)
}); FYGE.Tween.get(this.position).to({
x: this.item.position.x + 20,
y: this.item.position.y - 110
}, 500, FYGE.Ease.quadInOut)
.call(() => {
console.log("播放完成")
callback && callback(this.item)
this.currentIndex = this.item.index
this.downSvga.visible = true
this.jumpSvga.visible = false
this.isMove = false
this.lightSvga.visible = true
this.lightSvga.startAniRange(1, undefined, 1, () => {
this.lightSvga.visible = false
})
})
} }
} }
/** 根据物理刚体,更新当前的坐标。 */ // 人物自由落地
private onFarm() { onFreeFall(position, data, callback) {
if (this.direction == 'left') { this.item = data.item
console.log('----') this.position.set(position.x, position.y - 1000)
Matter.Body.setPosition( this.phyBody, { this.downSvga.visible = false
x:this.phyBody.position.x - 1, this.jumpSvga.visible = true,
y:this.phyBody.position.y - 1 this.jumpSvga.startAniRange(1, undefined, 1)
}) FYGE.Tween.get(this.position, {
this.position.set(this.phyBody.position.x,this.phyBody.position.y) onChange: () => {
// this.downSvga.position.set(1, 1000)
// this.jumpSvga.position.set(1, 1000)
} else {
} }
// console.log("this.beforeY", this.beforeY) }).to({
// if(this.beforeY){ x: position.x + 20,
// if( this.beforeY >this.phyBody.position.y ){ y: position.y - 110
}, 1000, FYGE.Ease.quadInOut)
// this.direction = 'up' .call(() => {
// } console.log("播放完成")
callback && callback(this.item)
// if( this.beforeY < this.phyBody.position.y ){ this.currentIndex = this.item.index;
this.downSvga.visible = true
// this.direction = 'down' this.jumpSvga.visible = false
// } })
// }
// if(this.phyBody.position.x > 750){
// Matter.Body.setPosition( this.phyBody, {
// x:0,
// y:this.phyBody.position.y
// })
// }else if(this.phyBody.position.x<0){
// Matter.Body.setPosition( this.phyBody, {
// x:750,
// y:this.phyBody.position.y
// })
// }else{
// this.x = this.phyBody.position.x;
// this.y = this.phyBody.position.y;
// }
// this.beforeY = this.phyBody.position.y;
} }
addScore(num: number | string, color: string) { addScore(num: number | string, color: string) {
var score = this.addChild(new FYGE.TextField()); var score = this.addChild(new FYGE.TextField());
score.x = -300 / 2; score.x = -300 / 2;
...@@ -179,11 +172,6 @@ export default class Role extends FYGE.Container { ...@@ -179,11 +172,6 @@ export default class Role extends FYGE.Container {
let resy = event.stageY - offsetY; let resy = event.stageY - offsetY;
if (resx < 50 || resx > 700) { return } if (resx < 50 || resx > 700) { return }
this.x = resx; this.x = resx;
// this.y = resy;
Matter.Body.setPosition(this.phyBody, {
x: resx,
y: this.y,
});
}, },
this this
); );
...@@ -199,20 +187,9 @@ export default class Role extends FYGE.Container { ...@@ -199,20 +187,9 @@ export default class Role extends FYGE.Container {
set fx(value: number) { set fx(value: number) {
this.position.x = value; this.position.x = value;
this.setPhyPos();
} }
set fy(value: number) { set fy(value: number) {
this.position.y = value; this.position.y = value;
this.setPhyPos();
} }
setPhyPos() {
Matter.Body.setPosition(this.phyBody, {
x: (this.x),
y: (this.y),
});
}
} }
\ No newline at end of file
...@@ -2,51 +2,27 @@ ...@@ -2,51 +2,27 @@
import * as Matter from "matter-js"; import * as Matter from "matter-js";
import { RES } from "../../../module/RES"; import { RES } from "../../../module/RES";
export default class Word extends FYGE.Container { export default class Word extends FYGE.Container {
public phyBody: Matter.Body;
itemImg: FYGE.Sprite; itemImg: FYGE.Sprite;
wordTx; wordTx;
index
constructor(data?) { constructor(data?) {
super(); super();
this.wordTx = data.wordTx this.wordTx = data.wordTx;
this.index = data.index;
let itemImg = this.itemImg = new FYGE.Sprite(); let itemImg = this.itemImg = new FYGE.Sprite();
itemImg.texture = RES.getRes(`word_${data.wordTx}.png`); itemImg.texture = RES.getRes(`word_${data.wordTx}.png`);
itemImg.position.set(-itemImg.width / 2, -itemImg.height / 2); itemImg.position.set(-itemImg.width / 2, -itemImg.height / 2);
this.addChild(itemImg); this.addChild(itemImg);
this.phyBody = Matter.Bodies.rectangle(this.x, this.y, itemImg.width / 2, itemImg.height / 2, {
isStatic: true,
friction: 1,
isSensor: true, // 传感器,可以检测到碰撞,但是不参与碰撞
});
this.phyBody.gameType = data.wordTx;
setTimeout(() => {
this.setPhyPos();
}, 200)
} }
set fx(value: number) { set fx(value: number) {
this.position.x = value; this.position.x = value;
this.setPhyPos();
} }
set fy(value: number) { set fy(value: number) {
this.position.y = value; this.position.y = value;
this.setPhyPos();
}
setPhyPos() {
try {
Matter.Body.setPosition(this.phyBody, {
x: (this.x),
y: (this.y),
});
} catch (e) { }
} }
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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