Commit 04df65de authored by 邱旭's avatar 邱旭

测试模块

parent f8b4cc70
......@@ -95,10 +95,7 @@
canvas.width = document.body.clientWidth * (window.devicePixelRatio || 1)
canvas.height = document.body.clientHeight * (window.devicePixelRatio || 1)
var main = new output.Game(canvas);
var mouseEvent = main.stage.onMouseEvent.bind(main.stage);
canvas.addEventListener("touchstart", mouseEvent, false);
canvas.addEventListener('touchmove', mouseEvent, false);
canvas.addEventListener('touchend', mouseEvent, false);
main.initWebEvent();
window.stage = main.stage
})
</script>
......
{
"name": "game_template",
"version": "0.0.1",
"description": "game_template",
"name": "receive_game",
"version": "1.0.0",
"description": "接红包基础模版",
"main": "released/output.js",
"module": "released/output.module.js",
"scripts": {
......@@ -22,7 +22,6 @@
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.1.1",
"@rollup/plugin-typescript": "^8.3.0",
"address": "^1.2.0",
"ali-oss": "^4.11.4",
"chalk": "^2.3.0",
"co": "^4.6.0",
......@@ -47,8 +46,9 @@
"rollup-plugin-serve": "^1.1.0",
"rollup-plugin-terser": "^7.0.2",
"tslint": "^5.9.1",
"typescript": "^4.5.4"
"typescript": "^4.5.4",
"address": "^1.2.0"
},
"author": "MrKwon",
"author": "haiyoucuv",
"license": "ISC"
}
......@@ -15,31 +15,38 @@ files.forEach(function (file) {
//继续读每个子文件夹,json和png名字有相同的,只留json,
let sonFiles = fs.readdirSync(fPath);
//没有文件
if (!sonFiles.length) return
if (!sonFiles.length) return;
//取出所有json
const jsons = sonFiles.filter((f) => {
return f.substr(-5) === ".json"
return f.substr(-5) === ".json";
});
//去掉json所带png的图片
sonFiles = sonFiles.filter((f) => { return jsons.indexOf(f.substring(0, f.length - 4) + ".json") === -1 })
sonFiles = sonFiles.filter((f) => { return jsons.indexOf(f.substring(0, f.length - 4) + ".json") === -1 });
//去掉mac上的缓存文件
sonFiles = sonFiles.filter((f) => { return f !== '.DS_Store' })
sonFiles = sonFiles.filter((f) => { return f !== '.DS_Store' });
const group = {
keys: "",
name: file
name: file,
};
for (let i = 0; i < sonFiles.length; i++) {
if (i !== 0) group.keys += ",";
group.keys += sonFiles[i]
group.keys += sonFiles[i];
}
obj.groups.push(group)
obj.groups.push(group);
}
})
obj.path="./resource/"
console.log("资源更新完成")
obj.path="./resource/";
const writeStr = JSON.stringify(obj, "", "\t");
//生成json
fs.writeFileSync(readPath + "res.json", JSON.stringify(obj, "", "\t"));
fs.writeFileSync(readPath + "res.json", writeStr);
//TS也更新
const endPath = './src/';
const endFile = `export const ResJson = ${JSON.stringify(obj, "", "\t")}`;
const endFile = `export const ResJson = ${writeStr.replace(
`"path": "./resource/"`,
`"path": location.origin + "/resource/"`
)}`;
fs.writeFileSync(endPath + "ResJson.ts", endFile);
console.log("资源更新完成");
......@@ -138,6 +138,13 @@ export class Game {
changeScene(IndexScene, { from: "main" });
}
initWebEvent(){
const mouseEvent = this.stage.onMouseEvent.bind(this.stage);
this.canvas.addEventListener("touchstart", mouseEvent, false);
this.canvas.addEventListener('touchmove', mouseEvent, false);
this.canvas.addEventListener('touchend', mouseEvent, false);
}
run() {
this._pause = false;
// @ts-ignore Tween计时清零
......
......@@ -2,681 +2,52 @@ export const ResJson = {
"groups": [
{
"keys": "helpBg.png,helpBtn.png",
"name": "HelpPanel",
"atlas": {
"helpBg.png": {
"x": 2,
"y": 2,
"w": 581,
"h": 547,
"ox": 0,
"oy": 0,
"sw": 581,
"sh": 547,
"ro": false
},
"helpBtn.png": {
"x": 2,
"y": 551,
"w": 418,
"h": 102,
"ox": 0,
"oy": 0,
"sw": 418,
"sh": 102,
"ro": false
}
}
"name": "HelpPanel"
},
{
"keys": "5cab5037-81fc-4246-96e5-b1353f339275.png,7458bc9a-d07d-4a7c-972b-4de7ed7c040d.png,7e4500a1-83be-4686-a46b-67147ed44ddd.png,845ae874-998e-4f68-8e79-641eb77466f3.png,a122de8a-beed-4442-9252-8c047986f371.png,ad9681a6-9eb2-40ad-8c2c-0b3ad121a00d.png,b48ee079-b3d7-4371-b294-944200eccba9.png,cd1a775d-36c9-4c8e-9c67-8191070068e9.png",
"name": "LoadingEffect",
"atlas": {
"5cab5037-81fc-4246-96e5-b1353f339275.png": {
"x": 2,
"y": 2,
"w": 516,
"h": 108,
"ox": 0,
"oy": 0,
"sw": 516,
"sh": 108,
"ro": false
},
"b48ee079-b3d7-4371-b294-944200eccba9.png": {
"x": 2,
"y": 112,
"w": 137,
"h": 74,
"ox": 0,
"oy": 0,
"sw": 137,
"sh": 74,
"ro": false
},
"a122de8a-beed-4442-9252-8c047986f371.png": {
"x": 141,
"y": 112,
"w": 134,
"h": 24,
"ox": 0,
"oy": 0,
"sw": 134,
"sh": 24,
"ro": false
},
"cd1a775d-36c9-4c8e-9c67-8191070068e9.png": {
"x": 2,
"y": 188,
"w": 123,
"h": 104,
"ox": 0,
"oy": 0,
"sw": 123,
"sh": 104,
"ro": false
},
"7458bc9a-d07d-4a7c-972b-4de7ed7c040d.png": {
"x": 127,
"y": 188,
"w": 48,
"h": 30,
"ox": 0,
"oy": 0,
"sw": 48,
"sh": 30,
"ro": true
},
"ad9681a6-9eb2-40ad-8c2c-0b3ad121a00d.png": {
"x": 141,
"y": 138,
"w": 23,
"h": 36,
"ox": 0,
"oy": 0,
"sw": 23,
"sh": 36,
"ro": false
},
"845ae874-998e-4f68-8e79-641eb77466f3.png": {
"x": 127,
"y": 238,
"w": 24,
"h": 25,
"ox": 0,
"oy": 0,
"sw": 24,
"sh": 25,
"ro": false
},
"7e4500a1-83be-4686-a46b-67147ed44ddd.png": {
"x": 141,
"y": 176,
"w": 5,
"h": 6,
"ox": 0,
"oy": 0,
"sw": 5,
"sh": 6,
"ro": false
}
}
"name": "LoadingEffect"
},
{
"keys": "noTimeBg.png,noTimeBtn.png",
"name": "NoTimePanel",
"atlas": {
"noTimeBg.png": {
"x": 2,
"y": 2,
"w": 581,
"h": 547,
"ox": 0,
"oy": 0,
"sw": 581,
"sh": 547,
"ro": false
},
"noTimeBtn.png": {
"x": 2,
"y": 551,
"w": 418,
"h": 102,
"ox": 0,
"oy": 0,
"sw": 418,
"sh": 102,
"ro": false
}
}
"name": "NoTimePanel"
},
{
"keys": "overBtn.png,overNoPrizeBg.png,overPrizeBg.png",
"name": "OverPanel",
"atlas": {
"overPrizeBg.png": {
"x": 2,
"y": 2,
"w": 581,
"h": 843,
"ox": 0,
"oy": 0,
"sw": 581,
"sh": 843,
"ro": false
},
"overNoPrizeBg.png": {
"x": 585,
"y": 2,
"w": 581,
"h": 577,
"ox": 0,
"oy": 0,
"sw": 581,
"sh": 577,
"ro": true
},
"overBtn.png": {
"x": 585,
"y": 585,
"w": 418,
"h": 102,
"ox": 0,
"oy": 0,
"sw": 418,
"sh": 102,
"ro": false
}
}
"name": "OverPanel"
},
{
"keys": "rankBg.png,rankIcon.png",
"name": "RankPanel",
"atlas": {
"rankBg.png": {
"x": 2,
"y": 2,
"w": 581,
"h": 944,
"ox": 0,
"oy": 0,
"sw": 581,
"sh": 944,
"ro": false
},
"rankIcon.png": {
"x": 585,
"y": 2,
"w": 34,
"h": 42,
"ox": 0,
"oy": 0,
"sw": 34,
"sh": 42,
"ro": false
}
}
"name": "RankPanel"
},
{
"keys": "rankNoPrizeBg.png,rankNoPrizeBtn.png,rankPrizeBg.png,rankPrizeBtn.png",
"name": "RankPrizePanel",
"atlas": {
"rankPrizeBg.png": {
"x": 2,
"y": 2,
"w": 581,
"h": 717,
"ox": 0,
"oy": 0,
"sw": 581,
"sh": 717,
"ro": false
},
"rankNoPrizeBg.png": {
"x": 585,
"y": 2,
"w": 581,
"h": 546,
"ox": 0,
"oy": 0,
"sw": 581,
"sh": 546,
"ro": true
},
"rankNoPrizeBtn.png": {
"x": 585,
"y": 585,
"w": 418,
"h": 102,
"ox": 0,
"oy": 0,
"sw": 418,
"sh": 102,
"ro": false
},
"rankPrizeBtn.png": {
"x": 2,
"y": 721,
"w": 418,
"h": 102,
"ox": 0,
"oy": 0,
"sw": 418,
"sh": 102,
"ro": false
}
}
"name": "RankPrizePanel"
},
{
"keys": "reviveBg.png,reviveCancel.png,reviveOk.png",
"name": "RevivePanel",
"atlas": {
"reviveBg.png": {
"x": 2,
"y": 2,
"w": 581,
"h": 508,
"ox": 0,
"oy": 0,
"sw": 581,
"sh": 508,
"ro": false
},
"reviveOk.png": {
"x": 2,
"y": 512,
"w": 233,
"h": 89,
"ox": 0,
"oy": 0,
"sw": 233,
"sh": 89,
"ro": false
},
"reviveCancel.png": {
"x": 237,
"y": 512,
"w": 224,
"h": 85,
"ox": 0,
"oy": 0,
"sw": 224,
"sh": 85,
"ro": false
}
}
"name": "RevivePanel"
},
{
"keys": "rulePanelBg.png,rulePanelBtn.png",
"name": "RulePanel",
"atlas": {
"rulePanelBg.png": {
"x": 2,
"y": 2,
"w": 581,
"h": 717,
"ox": 0,
"oy": 0,
"sw": 581,
"sh": 717,
"ro": false
},
"rulePanelBtn.png": {
"x": 585,
"y": 2,
"w": 418,
"h": 102,
"ox": 0,
"oy": 0,
"sw": 418,
"sh": 102,
"ro": true
}
}
"name": "RulePanel"
},
{
"keys": "comCloseBtn.png,com_bg.jpg,toastBg.png,waitingBg.png,waitingRot.png",
"name": "common",
"atlas": {
"toastBg.png": {
"x": 2,
"y": 2,
"w": 460,
"h": 130,
"ox": 0,
"oy": 0,
"sw": 460,
"sh": 130,
"ro": false
},
"waitingBg.png": {
"x": 2,
"y": 134,
"w": 160,
"h": 180,
"ox": 0,
"oy": 0,
"sw": 160,
"sh": 180,
"ro": true
},
"comCloseBtn.png": {
"x": 184,
"y": 134,
"w": 58,
"h": 58,
"ox": 0,
"oy": 0,
"sw": 58,
"sh": 58,
"ro": false
},
"waitingRot.png": {
"x": 184,
"y": 194,
"w": 56,
"h": 56,
"ox": 0,
"oy": 0,
"sw": 56,
"sh": 56,
"ro": false
}
}
"name": "common"
},
{
"keys": "gameMusicOff.png,gameMusicOn.png,gameScore+.png,gameScore0.png,gameScore1.png,gameScore2.png,gameScore3.png,gameScore4.png,gameScore5.png,gameScore6.png,gameScore7.png,gameScore8.png,gameScore9.png,guide.png",
"name": "game",
"atlas": {
"guide.png": {
"x": 2,
"y": 2,
"w": 320,
"h": 416,
"ox": 0,
"oy": 0,
"sw": 320,
"sh": 416,
"ro": false
},
"gameMusicOff.png": {
"x": 324,
"y": 2,
"w": 82,
"h": 82,
"ox": 0,
"oy": 0,
"sw": 82,
"sh": 82,
"ro": false
},
"gameMusicOn.png": {
"x": 324,
"y": 86,
"w": 82,
"h": 82,
"ox": 0,
"oy": 0,
"sw": 82,
"sh": 82,
"ro": false
},
"gameScore0.png": {
"x": 324,
"y": 170,
"w": 44,
"h": 56,
"ox": 2,
"oy": 0,
"sw": 47,
"sh": 56,
"ro": true
},
"gameScore1.png": {
"x": 324,
"y": 216,
"w": 28,
"h": 56,
"ox": 2,
"oy": 0,
"sw": 32,
"sh": 56,
"ro": true
},
"gameScore2.png": {
"x": 324,
"y": 246,
"w": 44,
"h": 56,
"ox": 2,
"oy": 0,
"sw": 47,
"sh": 56,
"ro": true
},
"gameScore3.png": {
"x": 324,
"y": 292,
"w": 44,
"h": 56,
"ox": 2,
"oy": 0,
"sw": 47,
"sh": 56,
"ro": true
},
"gameScore4.png": {
"x": 324,
"y": 338,
"w": 44,
"h": 56,
"ox": 2,
"oy": 0,
"sw": 48,
"sh": 56,
"ro": false
},
"gameScore5.png": {
"x": 408,
"y": 2,
"w": 44,
"h": 56,
"ox": 2,
"oy": 0,
"sw": 47,
"sh": 56,
"ro": false
},
"gameScore6.png": {
"x": 408,
"y": 60,
"w": 44,
"h": 56,
"ox": 2,
"oy": 0,
"sw": 47,
"sh": 56,
"ro": false
},
"gameScore7.png": {
"x": 408,
"y": 118,
"w": 44,
"h": 56,
"ox": 2,
"oy": 0,
"sw": 47,
"sh": 56,
"ro": false
},
"gameScore8.png": {
"x": 382,
"y": 176,
"w": 44,
"h": 56,
"ox": 2,
"oy": 0,
"sw": 47,
"sh": 56,
"ro": true
},
"gameScore9.png": {
"x": 382,
"y": 222,
"w": 44,
"h": 56,
"ox": 2,
"oy": 0,
"sw": 47,
"sh": 56,
"ro": true
},
"gameScore+.png": {
"x": 382,
"y": 268,
"w": 42,
"h": 40,
"ox": 2,
"oy": 8,
"sw": 46,
"sh": 56,
"ro": false
}
}
"name": "game"
},
{
"keys": "btnTipBg.png,prizeBtn.png,progressBg.png,progressFill.png,progressLabel.png,rankBtn.png,ruleBtn.png,startBtn.png,taskBtn.png",
"name": "index",
"atlas": {
"progressBg.png": {
"x": 2,
"y": 2,
"w": 750,
"h": 188,
"ox": 0,
"oy": 0,
"sw": 750,
"sh": 188,
"ro": false
},
"progressFill.png": {
"x": 2,
"y": 192,
"w": 615,
"h": 20,
"ox": 0,
"oy": 0,
"sw": 615,
"sh": 20,
"ro": false
},
"startBtn.png": {
"x": 2,
"y": 214,
"w": 490,
"h": 111,
"ox": 0,
"oy": 0,
"sw": 490,
"sh": 111,
"ro": false
},
"prizeBtn.png": {
"x": 494,
"y": 214,
"w": 153,
"h": 51,
"ox": 0,
"oy": 0,
"sw": 153,
"sh": 51,
"ro": false
},
"taskBtn.png": {
"x": 494,
"y": 267,
"w": 151,
"h": 51,
"ox": 0,
"oy": 0,
"sw": 151,
"sh": 51,
"ro": false
},
"btnTipBg.png": {
"x": 2,
"y": 327,
"w": 147,
"h": 36,
"ox": 0,
"oy": 0,
"sw": 147,
"sh": 36,
"ro": false
},
"ruleBtn.png": {
"x": 649,
"y": 192,
"w": 102,
"h": 42,
"ox": 0,
"oy": 0,
"sw": 102,
"sh": 42,
"ro": false
},
"rankBtn.png": {
"x": 494,
"y": 320,
"w": 98,
"h": 43,
"ox": 0,
"oy": 0,
"sw": 98,
"sh": 43,
"ro": false
},
"progressLabel.png": {
"x": 151,
"y": 327,
"w": 87,
"h": 31,
"ox": 0,
"oy": 0,
"sw": 87,
"sh": 31,
"ro": false
}
}
"name": "index"
},
{
"keys": "loading_effect.png,loading_title.png",
"name": "loading",
"atlas": {
"loading_effect.png": {
"x": 2,
"y": 2,
"w": 665,
"h": 121,
"ox": 0,
"oy": 0,
"sw": 665,
"sh": 121,
"ro": false
},
"loading_title.png": {
"x": 2,
"y": 125,
"w": 531,
"h": 146,
"ox": 0,
"oy": 0,
"sw": 531,
"sh": 146,
"ro": false
}
}
"name": "loading"
}
],
"path": "https://yun.duiba.com.cn/db_games/activity/template/1654149695/resource/"
"path": location.origin + "/resource/"
}
\ No newline at end of file
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>new_game_template</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"/>
<script src="//yun.duiba.com.cn/js-libs/rem/1.1.3/rem.min.js"></script>
<!--<script crossorigin src="//yun.duiba.com.cn/db_games/libs220606/react/react.development.js"></script>-->
<script crossorigin src="//yun.duiba.com.cn/db_games/libs220606/react/react.production.min.js"></script>
<!--<script crossorigin src="//yun.duiba.com.cn/db_games/libs220606/react/react-dom.development.js"></script>-->
<script crossorigin src="//yun.duiba.com.cn/db_games/libs220606/react/react-dom.production.min.js"></script>
<!-- polyfill -->
<script src="//yun.duiba.com.cn/db_games/libs0924/polyfill_220525.js" crossorigin="anonymous"></script>
<!-- 渲染引擎 -->
<script src="//yun.duiba.com.cn/db_games/libs0924/fyge2044.min.js" crossorigin="anonymous"></script>
<!--<script src="libs/fyge.min.js" crossorigin="anonymous"></script>-->
<!-- svga解析库 -->
<script src="//yun.duiba.com.cn/db_games/libs0924/svgaParser.minWeb.js" crossorigin="anonymous"></script>
<!-- 放声音的 -->
<script src="//yun.duiba.com.cn/db_games/libs0924/howler.min.js" crossorigin="anonymous"></script>
</head>
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
<script src="./build/output.js" crossorigin="anonymous"></script>
</body>
</html>
{
"name": "test",
"version": "1.0.0",
"description": "test",
"scripts": {
"testDev": "rollup -c rollup.test.mjs -w"
},
"peerDependencies": {
"react": "^17.0.2",
"react-dom": "17.0.2"
},
"devDependencies": {
"@babel/preset-env": "^7.18.2",
"@babel/preset-react": "^7.17.12",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.1.1",
"less-loader": "^11.0.0",
"rollup": "^2.61.1",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-livereload": "^2.0.5",
"rollup-plugin-progress": "^1.1.2",
"rollup-plugin-serve": "^1.1.0",
"less": "^4.1.2",
"rollup-plugin-styles": "^4.0.0",
"@rollup/plugin-babel": "^5.3.1",
"rollup-plugin-peer-deps-external": "^2.2.4"
},
"author": "haiyoucuv",
"license": "ISC"
}
/*
* rollup.test.mjs
* Created by 还有醋v on 2022/6/6.
* Copyright © 2021 haiyoucuv. All rights reserved.
*/
import json from "@rollup/plugin-json";
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "rollup-plugin-commonjs";
import livereload from "rollup-plugin-livereload";
import progress from "rollup-plugin-progress";
import serve from "rollup-plugin-serve";
import babel from "@rollup/plugin-babel";
import peerDepsExternal from "rollup-plugin-peer-deps-external";
import styles from "rollup-plugin-styles";
export default {
input: "src/app.jsx",
cache: true,
output: {
file: "build/output.js",
format: "umd",
sourcemap: true,
},
external: [
'react',
'react-dom',
'classname',
'**/node_modules/**'
],
plugins: [
peerDepsExternal(),
progress(),
styles(),
babel.babel({
presets: [
"@babel/preset-env",
"@babel/preset-react"
],
babelHelpers: "bundled"
}),
resolve({
jsnext: true,
preferBuiltins: true,
browser: true,
extensions: [".js", ".jsx"],
}),
commonjs({
extensions: [".js", ".jsx"],
}),
json(),
livereload(),
],
};
/*
* GamePage.jsx
* Created by 还有醋v on 2022/6/6.
* Copyright © 2022 haiyoucuv. All rights reserved.
*/
import React, { Component } from 'react';
import { Game } from "../../../build/output.module";
import './GamePage.less';
export default class GamePage extends Component {
div = null;
game = null;
constructor(props) {
super(props);
this.state = {};
}
componentDidMount() {
const canvas = document.createElement("canvas");
canvas.style = "width:100%;height:100%";
this.div.appendChild(canvas);
this.game = new Game(canvas);
this.game.initWebEvent();
}
componentWillUnmount() {
this.game.destroy()
}
render() {
return <div
className="game-page"
ref={(div) => this.div = div}
/>;
}
}
/*
* Game.less
* Created by 还有醋v on 2022/6/6.
* Copyright © 2022 haiyoucuv. All rights reserved.
*/
.game-page{
width: 100%;
height: 100%;
}
import GamePage from "./GamePage/GamePage";
import React, { Component } from "react";
import ReactDOM from "react-dom";
import "./app.less";
class App extends Component {
componentDidMount() {
}
render() {
return <GamePage/>;
}
}
ReactDOM.render(<App/>, document.getElementById("root"));
* {
margin: 0;
padding: 0;
}
html,
body {
font-size: 24px;
width: 100%;
height: 100%;
-webkit-text-size-adjust: 100% !important;
text-size-adjust: 100% !important;
-moz-text-size-adjust: 100% !important;
overflow: hidden;
}
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