Commit ec05804f authored by zjz1994's avatar zjz1994

代码暂存

parent 75054211
{
"name": "拼图",
"desc": "拼图模块1.0",
"props": {
"MAX_COL": {
"alias": "图片分成几列",
"type": "number",
"default": 3
},
"MAX_ROW": {
"alias": "图片分成几行",
"type": "number",
"default": 4
},
"W": {
"alias": "图片的宽度",
"type": "number",
"default": 620
},
"H": {
"alias": "图片的高度",
"type": "number",
"default": 620
},
"OFFSET_X": {
"alias": "OFFSET_X",
"type": "number",
"default": 0
},
"OFFSET_Y": {
"alias": "OFFSET_Y",
"type": "number",
"default": 0
},
"GAP": {
"alias": "图片间隙",
"type": "number",
"default": 0
},
"GAME_TIME": {
"alias": "游戏时间",
"type": "number",
"default": 30
}
},
"assets": [
{
"name": "遮罩",
"url": "//yun.duiba.com.cn/aurora/assets/5b3e30496b2d9fdafb0cf3835fd6704ce10e45b4.png",
"uuid": "888",
"ext": ".png"
},
{
"name": "框3",
"url": "//yun.duiba.com.cn/aurora/assets/521e08c574bd76c7dcf708cd6f8c4906e3707f06.png",
"uuid": "kuang3",
"ext": ".png"
},
{
"name": "框4",
"url": "//yun.duiba.com.cn/aurora/assets/1c384d986504d5aabfffeb5125dc67e73ce1b539.png",
"uuid": "kuang4",
"ext": ".png"
}
],
"events": {
"in": {
"pictures-start": {
"alias": "开始",
"data": {
"rows": 3,
"cols": 3,
"picUrl": "图片",
"gametime": 30
}
},
"pictures-pause": {
"alias": "停止"
},
"pictures-resume": {
"alias": "继续"
}
},
"out": {
"pictures-time-update": {
"alias": "倒计时更新",
"data": {
"time": "剩余时间"
}
},
"pictures-game-over": {
"alias": "游戏结束",
"data": {
"reason": "结束(1:成功,2失败)"
}
}
}
},
"id": "pintu",
"code": "(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :\n\ttypeof define === 'function' && define.amd ? define(['tslib'], factory) :\n\t(global = global || self, global.pintu = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n\tvar props = {};\r\n\tfunction prepareProps() {\r\n\t var metaProps = getProps();\r\n\t engine.injectProp(props, metaProps);\r\n\t}\r\n\tfunction injectProps(p) {\r\n\t engine.injectProp(props, p);\r\n\t}\r\n\t//# sourceMappingURL=props.js.map\n\n\tfunction getTexture(uuid) {\r\n\t return engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n\t}\r\n\tfunction getTextureByName(name) {\r\n\t return getTexture(engine.getAssetByName(name).uuid);\r\n\t}\r\n\tfunction loadImageByUrl(url) {\r\n\t return new Promise(function (resolve) {\r\n\t if (engine.TextureCache[url]) {\r\n\t resolve(engine.TextureCache[url]);\r\n\t }\r\n\t else {\r\n\t var t = engine.Texture.from(url);\r\n\t t.addEventListener(\"loaded\", function () { resolve(t); });\r\n\t }\r\n\t });\r\n\t}\r\n\t//# sourceMappingURL=utils.js.map\n\n\tvar qietu = (function (url, rows, cols, parent) { return tslib.__awaiter(void 0, void 0, void 0, function () {\r\n\t var t, mwid, mhei, picarr, picnames, r, startx, endx, c, starty, endy, uvs, itexture, itexname, e_1;\r\n\t return tslib.__generator(this, function (_a) {\r\n\t switch (_a.label) {\r\n\t case 0:\r\n\t _a.trys.push([0, 2, , 3]);\r\n\t return [4, loadImageByUrl(url)];\r\n\t case 1:\r\n\t t = _a.sent();\r\n\t mwid = t.width / rows;\r\n\t mhei = t.height / cols;\r\n\t picarr = {};\r\n\t picnames = [];\r\n\t for (r = 0; r < rows; r++) {\r\n\t startx = r / rows;\r\n\t endx = (r + 1) / rows;\r\n\t for (c = 0; c < cols; c++) {\r\n\t starty = c / cols;\r\n\t endy = (c + 1) / cols;\r\n\t uvs = new Float32Array([\r\n\t starty,\r\n\t startx,\r\n\t endy,\r\n\t startx,\r\n\t endy,\r\n\t endx,\r\n\t starty,\r\n\t endx\r\n\t ]);\r\n\t itexture = new engine.Sprite(t);\r\n\t itexture.uvs = uvs;\r\n\t itexture.width = mwid;\r\n\t itexture.height = mhei;\r\n\t itexname = \"pic_\" + c + \"_\" + r;\r\n\t itexture.name = itexname;\r\n\t picarr[itexname] = itexture;\r\n\t picnames.push(itexname);\r\n\t }\r\n\t }\r\n\t return [2, {\r\n\t res: true,\r\n\t picarr: picarr,\r\n\t mwid: mwid,\r\n\t mhei: mhei,\r\n\t picnames: picnames\r\n\t }];\r\n\t case 2:\r\n\t e_1 = _a.sent();\r\n\t console.error(\"图片加载失败\", e_1);\r\n\t console.log(url, rows, cols);\r\n\t return [2, {\r\n\t res: false\r\n\t }];\r\n\t case 3: return [2];\r\n\t }\r\n\t });\r\n\t}); });\r\n\t//# sourceMappingURL=qietu.js.map\n\n\tvar GameView = (function (_super) {\r\n\t tslib.__extends(GameView, _super);\r\n\t function GameView() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.ingame = false;\r\n\t _this.selectImgArr = [];\r\n\t _this.sucposData = {};\r\n\t _this.once(engine.Event.ADDED_TO_STAGE, _this.initScene, _this);\r\n\t return _this;\r\n\t }\r\n\t GameView.prototype.initScene = function () {\r\n\t this.lineShape = new engine.Shape();\r\n\t this.selectimg3 = new engine.Image(getTextureByName(\"框3\"));\r\n\t this.selectimg4 = new engine.Image(getTextureByName(\"框4\"));\r\n\t this.dicont = new engine.Container();\r\n\t this.linecont = new engine.Container();\r\n\t this.blockcont = new engine.Container();\r\n\t this.addChild(this.dicont);\r\n\t this.addChild(this.linecont);\r\n\t this.addChild(this.blockcont);\r\n\t this.linecont.addChild(this.lineShape);\r\n\t };\r\n\t GameView.prototype.start = function () {\r\n\t return tslib.__awaiter(this, void 0, void 0, function () {\r\n\t var picUrl, result, res, picarr, mwid, mhei, picnames, gap, r, c, ipicx, ipicy, npicname, selidx, ipicname, ipic, rl, cl;\r\n\t return tslib.__generator(this, function (_a) {\r\n\t switch (_a.label) {\r\n\t case 0:\r\n\t this.dicont.removeChildren();\r\n\t picUrl = props.picUrl;\r\n\t this.gametime = props.gametime;\r\n\t this.showtime = props.gametime;\r\n\t this.rows = props.rows;\r\n\t this.cols = props.cols;\r\n\t this.nselectimg = null;\r\n\t if (this.rows == 3) {\r\n\t this.nselectimg = this.selectimg3;\r\n\t }\r\n\t if (this.rows == 4) {\r\n\t this.nselectimg = this.selectimg4;\r\n\t }\r\n\t this.passtime = 0;\r\n\t this.selectImgArr = new Array();\r\n\t this.sucposData = {};\r\n\t return [4, qietu(picUrl, this.rows, this.cols, this.dicont)];\r\n\t case 1:\r\n\t result = _a.sent();\r\n\t res = result.res;\r\n\t if (res) {\r\n\t picarr = result.picarr;\r\n\t mwid = result.mwid;\r\n\t mhei = result.mhei;\r\n\t picnames = result.picnames;\r\n\t gap = 2;\r\n\t for (r = 0; r < this.rows; r++) {\r\n\t for (c = 0; c < this.cols; c++) {\r\n\t ipicx = mwid * c + gap;\r\n\t ipicy = mhei * r + gap;\r\n\t npicname = \"pic_\" + c + \"_\" + r;\r\n\t this.sucposData[npicname] = r + \"_\" + c;\r\n\t selidx = Math.floor(Math.random() * picnames.length);\r\n\t ipicname = picnames[selidx];\r\n\t if (r == c && r != this.rows - 1) {\r\n\t while (ipicname == npicname) {\r\n\t selidx = Math.floor(Math.random() * picnames.length);\r\n\t ipicname = picnames[selidx];\r\n\t }\r\n\t }\r\n\t ipic = picarr[ipicname];\r\n\t picnames.splice(selidx, 1);\r\n\t this.dicont.addChild(ipic);\r\n\t ipic.x = ipicx;\r\n\t ipic.y = ipicy;\r\n\t ipic[\"postr\"] = r + \"_\" + c;\r\n\t ipic.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.touchPic, this);\r\n\t }\r\n\t }\r\n\t this.lineShape.clear();\r\n\t this.lineShape.beginStroke(0x0069df, 4, engine.LINE_CAP.BUTT, engine.LINE_JOIN.BEVEL, 100);\r\n\t this.lineShape.moveTo(0 + gap, 0 + gap);\r\n\t this.lineShape.lineTo(mhei * this.cols + gap, 0 + gap);\r\n\t this.lineShape.lineTo(mhei * this.cols + gap, mwid * this.rows + gap);\r\n\t this.lineShape.lineTo(0 + gap, mwid * this.rows + gap);\r\n\t this.lineShape.lineTo(0 + gap, 0 + gap);\r\n\t for (rl = 1; rl < this.rows; rl++) {\r\n\t this.lineShape.moveTo(0 + gap, rl * mhei + gap);\r\n\t this.lineShape.lineTo(mwid * this.cols + gap, rl * mhei + gap);\r\n\t }\r\n\t for (cl = 1; cl < this.cols; cl++) {\r\n\t this.lineShape.moveTo(cl * mwid + gap, 0 + gap);\r\n\t this.lineShape.lineTo(cl * mwid + gap, this.rows * mhei + gap);\r\n\t }\r\n\t this.lineShape.endStroke();\r\n\t this.ticker = setInterval(this.update, 30);\r\n\t }\r\n\t else {\r\n\t console.error(\"图片处理失败\");\r\n\t }\r\n\t return [2];\r\n\t }\r\n\t });\r\n\t });\r\n\t };\r\n\t GameView.prototype.pause = function () {\r\n\t this.ingame = false;\r\n\t };\r\n\t GameView.prototype.resume = function () {\r\n\t this.ingame = true;\r\n\t };\r\n\t GameView.prototype.update = function () {\r\n\t var ntime = Date.now();\r\n\t if (!this.lastframetime) {\r\n\t this.lastframetime = ntime;\r\n\t return;\r\n\t }\r\n\t if (this.ingame) {\r\n\t var passtime = (ntime - this.lastframetime) / 1000;\r\n\t this.passtime += passtime;\r\n\t var showtime1 = Math.round(this.gametime - this.passtime);\r\n\t if (this.showtime != showtime1) {\r\n\t this.showtime = showtime1;\r\n\t if (this.showtime <= 0) {\r\n\t this.showtime = 0;\r\n\t this.gameover(2);\r\n\t }\r\n\t engine.globalEvent.dispatchEvent(\"pictures-time-update\", {\r\n\t time: this.showtime\r\n\t });\r\n\t }\r\n\t }\r\n\t this.lastframetime = ntime;\r\n\t };\r\n\t GameView.prototype.touchPic = function (e) {\r\n\t if (!this.ingame) {\r\n\t return;\r\n\t }\r\n\t var selectname = e.target.name;\r\n\t var spx = e.target.x;\r\n\t var spy = e.target.y;\r\n\t var gap = 2;\r\n\t if (this.selectImgArr.length == 0) {\r\n\t if (this.nselectimg) {\r\n\t this.blockcont.addChild(this.nselectimg);\r\n\t this.nselectimg.x = spx - gap;\r\n\t this.nselectimg.y = spy - gap;\r\n\t }\r\n\t this.selectImgArr.push(selectname);\r\n\t }\r\n\t else if (this.selectImgArr.length == 1) {\r\n\t if (selectname == this.selectImgArr[0]) {\r\n\t return;\r\n\t }\r\n\t else {\r\n\t this.selectImgArr.push(selectname);\r\n\t this.changeImgPos();\r\n\t }\r\n\t }\r\n\t };\r\n\t GameView.prototype.changeImgPos = function () {\r\n\t var img1name = this.selectImgArr[0];\r\n\t var img2name = this.selectImgArr[1];\r\n\t var img1 = this.dicont.getChildByName(img1name);\r\n\t var img2 = this.dicont.getChildByName(img2name);\r\n\t var imgpos1x = img1.x;\r\n\t var imgpos1y = img1.y;\r\n\t var imgpos2x = img2.x;\r\n\t var imgpos2y = img2.y;\r\n\t var imgpostr1 = img1.postr;\r\n\t var imgpostr2 = img2.postr;\r\n\t img1.x = imgpos2x;\r\n\t img1.y = imgpos2y;\r\n\t img1.postr = imgpostr2;\r\n\t img2.x = imgpos1x;\r\n\t img2.y = imgpos1y;\r\n\t img2.postr = imgpostr1;\r\n\t this.selectImgArr = new Array();\r\n\t if (this.nselectimg) {\r\n\t this.blockcont.removeChild(this.nselectimg);\r\n\t }\r\n\t var isuc = this.checkSuccess();\r\n\t if (isuc) {\r\n\t console.error(\"成功过关\");\r\n\t this.gameover(1);\r\n\t }\r\n\t };\r\n\t GameView.prototype.checkSuccess = function () {\r\n\t var isuc = true;\r\n\t for (var r = 0; r < this.rows; r++) {\r\n\t for (var c = 0; c < this.cols; c++) {\r\n\t var ipicname = \"pic_\" + c + \"_\" + r;\r\n\t var npicstr = r + \"_\" + c;\r\n\t var ipic = this.dicont.getChildByName(ipicname);\r\n\t var ipostr = ipic.postr;\r\n\t if (npicstr != ipostr) {\r\n\t isuc = false;\r\n\t break;\r\n\t }\r\n\t }\r\n\t }\r\n\t return isuc;\r\n\t };\r\n\t GameView.prototype.gameover = function (reason) {\r\n\t this.ingame = false;\r\n\t this.ticker && clearInterval(this.ticker);\r\n\t engine.globalEvent.dispatchEvent('pictures-game-over', {\r\n\t reason: reason,\r\n\t time: this.passtime\r\n\t });\r\n\t };\r\n\t return GameView;\r\n\t}(engine.Container));\n\n\tvar GameWrapper = (function (_super) {\r\n\t tslib.__extends(GameWrapper, _super);\r\n\t function GameWrapper() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this._gameView = new GameView();\r\n\t _this.addChild(_this._gameView);\r\n\t engine.globalEvent.addEventListener('pictures-start', _this.start, _this);\r\n\t engine.globalEvent.addEventListener('pictures-pause', _this.pause, _this);\r\n\t engine.globalEvent.addEventListener('pictures-resume', _this.resume, _this);\r\n\t return _this;\r\n\t }\r\n\t GameWrapper.prototype.start = function (event) {\r\n\t injectProps(event.data);\r\n\t this._gameView.start();\r\n\t };\r\n\t GameWrapper.prototype.pause = function (event) {\r\n\t this._gameView.pause();\r\n\t };\r\n\t GameWrapper.prototype.resume = function (event) {\r\n\t this._gameView.resume();\r\n\t };\r\n\t return GameWrapper;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=GameWrapper.js.map\n\n\tfunction index (props) {\r\n\t prepareProps();\r\n\t injectProps(props);\r\n\t var instance = new GameWrapper();\r\n\t return instance;\r\n\t}\r\n\t//# sourceMappingURL=index.js.map\n\n\treturn index;\n\n})));\n"
}
/**
* Created by renjianfeng on 2020-03-13.
*/
const customId = 'pintu';
(async function () {
let customModule = await fetch(`../meta.json`);
customModule = await customModule.json();
console.log(customModule);
await loadAssets(customModule.assets);
launchWithCustomModule(customModule);
})();
function launchWithCustomModule(customModule) {
//engine.registerCustomCodeModule(customModule);
engine.registerCustomModule(customId, window[customId]);
const { props: propsOption, assets } = customModule;
let props = engine.computeProps(customModuleProps, propsOption);
const customModuleIns = {
id: customId,
props,
assets,
};
engine.registerCustomModules([customModuleIns]);
engine.launchWithConfig({
options: {
entrySceneView: 'entry',
},
assets: [],
views: [{
name: 'entry',
type: 'node',
properties: {
x: 0,
y: 0,
}
}],
customs: [],
}, null, function () {
setTimeout(() => {
engine.addCustomModule(customId, engine.gameStage.sceneContainer.getChildAt(0));
}, 100);
setTimeout(() => {
engine.globalEvent.dispatchEvent('pictures-start', {
picUrl: "//yun.duiba.com.cn/aurora/assets/eb952d8bfd900cb9367368ddf8048d66c44a52a0.png",
rows:3,
cols:3,
gametime:30
});
// const d = engine.gameStage.sceneContainer.getChildAt(0);
// engine.gameStage.sceneContainer.getChildAt(0).x = (d.stage.width-props.W)/2;
// engine.gameStage.sceneContainer.getChildAt(0).y = (d.stage.height-props.H)/2;
}, 1000);
// setTimeout(() => {
// engine.globalEvent.dispatchEvent('pictures-start', {
// picUrl: "http://yun.duiba.com.cn/aurora/assets/e1593b97c27077b85b92f7eaaeae1ed64a1eb79a.png",
// // picUrl: "http://yun.duiba.com.cn/aurora/assets/d23e73d37ec01931e48cbd0a4095367044c5675c.png"
// blockUrl: "888"
// });
// }, 30*1000);
});
engine.globalEvent.addEventListener('pictures-time-update', (e) => {
// console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('pictures-game-fail', (e) => {
console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('pictures-game-success', (e) => {
console.log(e.type, e.data);
});
}
function getAssetByUUID(uuid) {
return engine.resolveCustomAsset(customId, uuid);
}
function getProps() {
return engine.getProps(customId);
}
<!DOCTYPE html>
<html lang="en">
<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"/>
<style>
html,
body {
padding: 0;
margin: 0;
border: 0;
width: 100%;
height: 100%;
overflow: hidden;
position: absolute;
background-color: gray;
}
.game-container{
width: 100%;
height: 100%;
line-height:0;
font-size:0;
}
</style>
</head>
<body>
<div id="game-container" class="game-container"></div>
<script crossorigin="anonymous" src="//yun.duiba.com.cn/editor/zeroing/libs/engine.1de84ff79dba19e949088de63aa75af51a515e5c.js"></script>
<script crossorigin="anonymous" src="//yun.duiba.com.cn/editor/zeroing/libs/svga.fd3923ae6e664251ca7981801a65809cc5f36bc3.js"></script>
<!-- <script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.ebc906f6b50b8da0a669f77027981d5f3cb560ce.js"></script> -->
<!-- <script src="http://localhost:4002/debug/engine.js"></script>
<script src="http://localhost:4003/debug/engine-svga.js"></script> -->
<!--<script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.9a9dbfda4cb2dd5508ecddfe3d95dfd88063f7b5.js"></script>-->
<script src="app.js"></script>
<script src="props.js"></script>
<script src="load-assets.js"></script>
<script src="main.js"></script>
<script>
</script>
</body>
\ No newline at end of file
/**
* Created by rockyl on 2020-01-21.
*/
const assets = [
{
"name": "玩家icon",
"url": "//yun.duiba.com.cn/aurora/assets/5b3e30496b2d9fdafb0cf3835fd6704ce10e45b4.png",
"uuid": "888",
"ext": ".png"
},
{
"name": "雨滴",
"url": "//yun.duiba.com.cn/aurora/assets/8564c8c9be3aead71b05a0bab8d7d07ac3f778a1.png",
"uuid": "264a6192-d7bf-45e8-8f15-6ba2c439a532",
"ext": ".png"
},
{
"name": "炸弹",
"url": "//yun.duiba.com.cn/aurora/assets/171e92283cd13c013ee1b76d28d252ff08815d47.png",
"uuid": "eb88b42d-e151-4c1b-94b9-7c16f7bfac29",
"ext": ".png"
},
{
"name": "石块",
"url": "//yun.duiba.com.cn/aurora/assets/99b0af0c59fe79a415a3f032149cfacc27e3ac2c.png",
"uuid": "ab1bdabc-21ba-46bf-9299-6c638f766c88",
"ext": ".png"
},
{
"name": "水花",
"url": "//yun.duiba.com.cn/aurora/assets/93d37b4a0e367e80e375308a6b4414d72d7666fc.svga",
"uuid": "b521bf94-20e1-44dd-8eca-d24996cbaeae",
"ext": ".svga"
},
{
"name": "炸弹",
"url": "//yun.duiba.com.cn/aurora/assets/4dd18f0689c663bbcf710a7afc4d929084d97d36.svga",
"uuid": "322edf39-805b-4e84-9d07-5573dfeebc0e",
"ext": ".svga"
},
{
"name": "玩家",
"url": "//yun.duiba.com.cn/aurora/assets/b66300c5d4f27134b0aac3dc90a3220e8ae572eb.svga",
"uuid": "71d8dcbc-3931-471a-b585-b3ae01b25aa6",
"ext": ".svga"
}
];
function loadAssets(customModuleAssets, onProgress, onComplete){
return engine.loadAssets(assets.concat(...customModuleAssets), onProgress, onComplete);
}
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :
typeof define === 'function' && define.amd ? define(['tslib'], factory) :
(global = global || self, global.pintu = factory(global.tslib));
}(this, (function (tslib) { 'use strict';
var props = {};
function prepareProps() {
var metaProps = getProps();
engine.injectProp(props, metaProps);
}
function injectProps(p) {
engine.injectProp(props, p);
}
//# sourceMappingURL=props.js.map
function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
function loadImageByUrl(url) {
return new Promise(function (resolve) {
if (engine.TextureCache[url]) {
resolve(engine.TextureCache[url]);
}
else {
var t = engine.Texture.from(url);
t.addEventListener("loaded", function () { resolve(t); });
}
});
}
//# sourceMappingURL=utils.js.map
var qietu = (function (url, rows, cols, parent) { return tslib.__awaiter(void 0, void 0, void 0, function () {
var t, mwid, mhei, picarr, picnames, r, startx, endx, c, starty, endy, uvs, itexture, itexname, e_1;
return tslib.__generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4, loadImageByUrl(url)];
case 1:
t = _a.sent();
mwid = t.width / rows;
mhei = t.height / cols;
picarr = {};
picnames = [];
for (r = 0; r < rows; r++) {
startx = r / rows;
endx = (r + 1) / rows;
for (c = 0; c < cols; c++) {
starty = c / cols;
endy = (c + 1) / cols;
uvs = new Float32Array([
starty,
startx,
endy,
startx,
endy,
endx,
starty,
endx
]);
itexture = new engine.Sprite(t);
itexture.uvs = uvs;
itexture.width = mwid;
itexture.height = mhei;
itexname = "pic_" + c + "_" + r;
itexture.name = itexname;
picarr[itexname] = itexture;
picnames.push(itexname);
}
}
return [2, {
res: true,
picarr: picarr,
mwid: mwid,
mhei: mhei,
picnames: picnames
}];
case 2:
e_1 = _a.sent();
console.error("图片加载失败", e_1);
console.log(url, rows, cols);
return [2, {
res: false
}];
case 3: return [2];
}
});
}); });
//# sourceMappingURL=qietu.js.map
var GameView = (function (_super) {
tslib.__extends(GameView, _super);
function GameView() {
var _this = _super.call(this) || this;
_this.ingame = false;
_this.selectImgArr = [];
_this.sucposData = {};
_this.once(engine.Event.ADDED_TO_STAGE, _this.initScene, _this);
return _this;
}
GameView.prototype.initScene = function () {
this.lineShape = new engine.Shape();
this.selectimg3 = new engine.Image(getTextureByName("框3"));
this.selectimg4 = new engine.Image(getTextureByName("框4"));
this.dicont = new engine.Container();
this.linecont = new engine.Container();
this.blockcont = new engine.Container();
this.addChild(this.dicont);
this.addChild(this.linecont);
this.addChild(this.blockcont);
this.linecont.addChild(this.lineShape);
};
GameView.prototype.start = function () {
return tslib.__awaiter(this, void 0, void 0, function () {
var picUrl, result, res, picarr, mwid, mhei, picnames, gap, r, c, ipicx, ipicy, npicname, selidx, ipicname, ipic, rl, cl;
return tslib.__generator(this, function (_a) {
switch (_a.label) {
case 0:
this.dicont.removeChildren();
picUrl = props.picUrl;
this.gametime = props.gametime;
this.showtime = props.gametime;
this.rows = props.rows;
this.cols = props.cols;
this.nselectimg = null;
if (this.rows == 3) {
this.nselectimg = this.selectimg3;
}
if (this.rows == 4) {
this.nselectimg = this.selectimg4;
}
this.passtime = 0;
this.selectImgArr = new Array();
this.sucposData = {};
return [4, qietu(picUrl, this.rows, this.cols, this.dicont)];
case 1:
result = _a.sent();
res = result.res;
if (res) {
picarr = result.picarr;
mwid = result.mwid;
mhei = result.mhei;
picnames = result.picnames;
gap = 2;
for (r = 0; r < this.rows; r++) {
for (c = 0; c < this.cols; c++) {
ipicx = mwid * c + gap;
ipicy = mhei * r + gap;
npicname = "pic_" + c + "_" + r;
this.sucposData[npicname] = r + "_" + c;
selidx = Math.floor(Math.random() * picnames.length);
ipicname = picnames[selidx];
if (r == c && r != this.rows - 1) {
while (ipicname == npicname) {
selidx = Math.floor(Math.random() * picnames.length);
ipicname = picnames[selidx];
}
}
ipic = picarr[ipicname];
picnames.splice(selidx, 1);
this.dicont.addChild(ipic);
ipic.x = ipicx;
ipic.y = ipicy;
ipic["postr"] = r + "_" + c;
ipic.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.touchPic, this);
}
}
this.lineShape.clear();
this.lineShape.beginStroke(0x0069df, 4, engine.LINE_CAP.BUTT, engine.LINE_JOIN.BEVEL, 100);
this.lineShape.moveTo(0 + gap, 0 + gap);
this.lineShape.lineTo(mhei * this.cols + gap, 0 + gap);
this.lineShape.lineTo(mhei * this.cols + gap, mwid * this.rows + gap);
this.lineShape.lineTo(0 + gap, mwid * this.rows + gap);
this.lineShape.lineTo(0 + gap, 0 + gap);
for (rl = 1; rl < this.rows; rl++) {
this.lineShape.moveTo(0 + gap, rl * mhei + gap);
this.lineShape.lineTo(mwid * this.cols + gap, rl * mhei + gap);
}
for (cl = 1; cl < this.cols; cl++) {
this.lineShape.moveTo(cl * mwid + gap, 0 + gap);
this.lineShape.lineTo(cl * mwid + gap, this.rows * mhei + gap);
}
this.lineShape.endStroke();
this.ticker = setInterval(this.update, 30);
}
else {
console.error("图片处理失败");
}
return [2];
}
});
});
};
GameView.prototype.pause = function () {
this.ingame = false;
};
GameView.prototype.resume = function () {
this.ingame = true;
};
GameView.prototype.update = function () {
var ntime = Date.now();
if (!this.lastframetime) {
this.lastframetime = ntime;
return;
}
if (this.ingame) {
var passtime = (ntime - this.lastframetime) / 1000;
this.passtime += passtime;
var showtime1 = Math.round(this.gametime - this.passtime);
if (this.showtime != showtime1) {
this.showtime = showtime1;
if (this.showtime <= 0) {
this.showtime = 0;
this.gameover(2);
}
engine.globalEvent.dispatchEvent("pictures-time-update", {
time: this.showtime
});
}
}
this.lastframetime = ntime;
};
GameView.prototype.touchPic = function (e) {
if (!this.ingame) {
return;
}
var selectname = e.target.name;
var spx = e.target.x;
var spy = e.target.y;
var gap = 2;
if (this.selectImgArr.length == 0) {
if (this.nselectimg) {
this.blockcont.addChild(this.nselectimg);
this.nselectimg.x = spx - gap;
this.nselectimg.y = spy - gap;
}
this.selectImgArr.push(selectname);
}
else if (this.selectImgArr.length == 1) {
if (selectname == this.selectImgArr[0]) {
return;
}
else {
this.selectImgArr.push(selectname);
this.changeImgPos();
}
}
};
GameView.prototype.changeImgPos = function () {
var img1name = this.selectImgArr[0];
var img2name = this.selectImgArr[1];
var img1 = this.dicont.getChildByName(img1name);
var img2 = this.dicont.getChildByName(img2name);
var imgpos1x = img1.x;
var imgpos1y = img1.y;
var imgpos2x = img2.x;
var imgpos2y = img2.y;
var imgpostr1 = img1.postr;
var imgpostr2 = img2.postr;
img1.x = imgpos2x;
img1.y = imgpos2y;
img1.postr = imgpostr2;
img2.x = imgpos1x;
img2.y = imgpos1y;
img2.postr = imgpostr1;
this.selectImgArr = new Array();
if (this.nselectimg) {
this.blockcont.removeChild(this.nselectimg);
}
var isuc = this.checkSuccess();
if (isuc) {
console.error("成功过关");
this.gameover(1);
}
};
GameView.prototype.checkSuccess = function () {
var isuc = true;
for (var r = 0; r < this.rows; r++) {
for (var c = 0; c < this.cols; c++) {
var ipicname = "pic_" + c + "_" + r;
var npicstr = r + "_" + c;
var ipic = this.dicont.getChildByName(ipicname);
var ipostr = ipic.postr;
if (npicstr != ipostr) {
isuc = false;
break;
}
}
}
return isuc;
};
GameView.prototype.gameover = function (reason) {
this.ingame = false;
this.ticker && clearInterval(this.ticker);
engine.globalEvent.dispatchEvent('pictures-game-over', {
reason: reason,
time: this.passtime
});
};
return GameView;
}(engine.Container));
var GameWrapper = (function (_super) {
tslib.__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
_this._gameView = new GameView();
_this.addChild(_this._gameView);
engine.globalEvent.addEventListener('pictures-start', _this.start, _this);
engine.globalEvent.addEventListener('pictures-pause', _this.pause, _this);
engine.globalEvent.addEventListener('pictures-resume', _this.resume, _this);
return _this;
}
GameWrapper.prototype.start = function (event) {
injectProps(event.data);
this._gameView.start();
};
GameWrapper.prototype.pause = function (event) {
this._gameView.pause();
};
GameWrapper.prototype.resume = function (event) {
this._gameView.resume();
};
return GameWrapper;
}(engine.Container));
//# sourceMappingURL=GameWrapper.js.map
function index (props) {
prepareProps();
injectProps(props);
var instance = new GameWrapper();
return instance;
}
//# sourceMappingURL=index.js.map
return index;
})));
//# sourceMappingURL=main.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sources":["src/custom/pintu/src/props.ts","src/custom/pintu/src/game/utils.ts","src/custom/pintu/src/game/qietu.ts","src/custom/pintu/src/game/GameView.ts","src/custom/pintu/src/game/GameWrapper.ts","src/custom/pintu/src/index.ts"],"sourcesContent":["/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\n\r\nexport let props: any = {};\r\n\r\nexport function prepareProps() {\r\n\tlet metaProps = getProps();\r\n\r\n\tengine.injectProp(props, metaProps);\r\n}\r\n\r\nexport function injectProps(p) {\r\n\tengine.injectProp(props, p);\r\n}\r\n","/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\n\r\nexport function getTexture(uuid) {\r\n\treturn engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n}\r\n\r\nexport function getTextureByName(name) {\r\n\treturn getTexture(engine.getAssetByName(name).uuid);\r\n}\r\n\r\nexport function playSound(name) {\r\n\tengine.playSound(engine.getAssetByName(name).uuid, {keep: true});\r\n}\r\nexport function createSvga(name, anchorName?) {\r\n\tlet inst = new svga.Svga();\r\n\tinst.source = 'asset://' + engine.getAssetByName(name).uuid;\r\n\treturn inst;\r\n}\r\n\r\nexport function loadImageByUrl(url){\r\n\treturn new Promise((resolve) => {\r\n\t\tif (engine.TextureCache[url]) {\r\n\t\t\tresolve(engine.TextureCache[url])\r\n\t\t} else {\r\n\t\t\tvar t = engine.Texture.from(url);\r\n\t\t\tt.addEventListener(\"loaded\", () => { resolve(t) })\r\n\t\t}\r\n\t})\r\n}","import { props } from \"../props\";\r\nimport { loadImageByUrl } from \"./utils\";\r\nconst urls = [];\r\nconst picMap = {};\r\nconst posMap = {};\r\nexport default async(url:string, rows:number, cols:number,parent:engine.Container) => {\r\n try{\r\n let t:engine.Texture = await loadImageByUrl(url) as engine.Texture;\r\n \r\n let mwid = t.width/rows;\r\n let mhei = t.height/cols;\r\n\r\n let picarr = {};\r\n let picnames = [];\r\n for(let r=0;r<rows;r++){\r\n let startx = r/rows;\r\n let endx = (r+1)/rows;\r\n // linedraw.moveTo()\r\n for(let c=0;c<cols;c++){\r\n let starty = c/cols;\r\n let endy = (c+1)/cols;\r\n\r\n let uvs = new Float32Array([\r\n starty,\r\n startx,\r\n endy,\r\n startx,\r\n endy,\r\n endx,\r\n starty,\r\n endx\r\n ]);\r\n\r\n let itexture = new engine.Sprite(t);\r\n itexture.uvs = uvs;\r\n\r\n itexture.width = mwid;\r\n itexture.height = mhei;\r\n let itexname = \"pic_\"+c+\"_\"+r;\r\n itexture.name = itexname;\r\n picarr[itexname] = itexture;\r\n picnames.push(itexname);\r\n }\r\n }\r\n return {\r\n res:true,\r\n picarr:picarr,\r\n mwid:mwid,\r\n mhei:mhei,\r\n picnames:picnames\r\n };\r\n }catch(e){\r\n console.error(\"图片加载失败\",e);\r\n console.log(url,rows,cols);\r\n return {\r\n res:false\r\n };\r\n }\r\n};\r\n","/**\r\n * Created by rockyl on 2018/8/16.\r\n */\r\n\r\nimport { props } from \"../props\";\r\nimport qietu from \"./qietu\";\r\nimport { getTexture, loadImageByUrl,getTextureByName } from \"./utils\";\r\nimport ObjectPool = engine.ObjectPool;\r\n\r\nexport default class GameView extends engine.Container {\r\n rows:number;\r\n cols:number;\r\n\r\n passtime:number;\r\n gametime:number;\r\n showtime:number;\r\n\r\n lastframetime:number;\r\n\r\n ingame:boolean = false;\r\n\r\n ticker;\r\n\r\n selectimg3:engine.Image;\r\n selectimg4:engine.Image;\r\n nselectimg:engine.Image;\r\n\r\n selectImgArr:Array<string> = [];\r\n sucposData:Object = {};\r\n\r\n dicont:engine.Container;\r\n linecont:engine.Container;\r\n blockcont:engine.Container;\r\n\r\n lineShape:engine.Shape;\r\n constructor() {\r\n super();\r\n this.once(engine.Event.ADDED_TO_STAGE, this.initScene, this);\r\n }\r\n initScene(){\r\n this.lineShape = new engine.Shape();\r\n this.selectimg3 = new engine.Image(getTextureByName(\"框3\"));\r\n this.selectimg4 = new engine.Image(getTextureByName(\"框4\"));\r\n //底图\r\n this.dicont = new engine.Container();\r\n //线\r\n this.linecont = new engine.Container();\r\n //亮片\r\n this.blockcont = new engine.Container();\r\n\r\n this.addChild(this.dicont);\r\n this.addChild(this.linecont);\r\n this.addChild(this.blockcont);\r\n \r\n this.linecont.addChild(this.lineShape);\r\n }\r\n async start() {\r\n this.dicont.removeChildren();\r\n\r\n let picUrl = props.picUrl;\r\n this.gametime = props.gametime;\r\n this.showtime = props.gametime;\r\n\r\n this.rows = props.rows;\r\n this.cols = props.cols;\r\n\r\n this.nselectimg = null;\r\n if(this.rows==3){\r\n this.nselectimg = this.selectimg3;\r\n }\r\n if(this.rows==4){\r\n this.nselectimg = this.selectimg4;\r\n }\r\n\r\n this.passtime = 0;\r\n \r\n this.selectImgArr = new Array();\r\n this.sucposData = {};\r\n let result = await qietu(picUrl,this.rows,this.cols,this.dicont);\r\n let res = result.res;\r\n if(res){\r\n let picarr = result.picarr;\r\n let mwid = result.mwid;\r\n let mhei = result.mhei;\r\n let picnames = result.picnames;\r\n let gap = 2;\r\n for(let r=0;r<this.rows;r++){\r\n for(let c=0;c<this.cols;c++){\r\n let ipicx = mwid*c+gap;\r\n let ipicy = mhei*r+gap;\r\n let npicname = \"pic_\"+c+\"_\"+r;\r\n\r\n this.sucposData[npicname] = r+\"_\"+c;\r\n\r\n let selidx = Math.floor(Math.random()*picnames.length);\r\n let ipicname:string = picnames[selidx];\r\n if(r==c&&r!=this.rows-1){\r\n while(ipicname==npicname){\r\n selidx = Math.floor(Math.random()*picnames.length);\r\n ipicname = picnames[selidx];\r\n }\r\n }\r\n let ipic = picarr[ipicname];\r\n picnames.splice(selidx,1);\r\n this.dicont.addChild(ipic);\r\n ipic.x = ipicx;\r\n ipic.y = ipicy;\r\n ipic[\"postr\"] = r+\"_\"+c;\r\n\r\n ipic.addEventListener(engine.MouseEvent.MOUSE_DOWN,\r\n this.touchPic,this);\r\n }\r\n }\r\n //框线\r\n this.lineShape.clear();\r\n this.lineShape.beginStroke(0x0069df,4,engine.LINE_CAP.BUTT,engine.LINE_JOIN.BEVEL,100);\r\n\r\n this.lineShape.moveTo(0+gap,0+gap);\r\n this.lineShape.lineTo(mhei*this.cols+gap,0+gap);\r\n this.lineShape.lineTo(mhei*this.cols+gap,mwid*this.rows+gap);\r\n this.lineShape.lineTo(0+gap,mwid*this.rows+gap);\r\n this.lineShape.lineTo(0+gap,0+gap);\r\n\r\n for(let rl=1;rl<this.rows;rl++){\r\n this.lineShape.moveTo(0+gap,rl*mhei+gap);\r\n this.lineShape.lineTo(mwid*this.cols+gap,rl*mhei+gap);\r\n }\r\n for(let cl=1;cl<this.cols;cl++){\r\n this.lineShape.moveTo(cl*mwid+gap,0+gap);\r\n this.lineShape.lineTo(cl*mwid+gap,this.rows*mhei+gap);\r\n }\r\n this.lineShape.endStroke();\r\n \r\n\r\n this.ticker = setInterval(this.update, 30);\r\n }else{\r\n console.error(\"图片处理失败\");\r\n }\r\n }\r\n pause(){\r\n this.ingame = false;\r\n }\r\n resume(){\r\n this.ingame = true;\r\n }\r\n\r\n\r\n update() {\r\n let ntime = Date.now();\r\n if(!this.lastframetime){\r\n this.lastframetime = ntime;\r\n return;\r\n }\r\n if(this.ingame){\r\n let passtime = (ntime - this.lastframetime)/1000;\r\n this.passtime += passtime;\r\n let showtime1 = Math.round(this.gametime - this.passtime);\r\n // console.log(passtime,this.passtime,this.gametime,this.showtime);\r\n if(this.showtime!=showtime1){\r\n this.showtime = showtime1;\r\n if(this.showtime<=0){\r\n this.showtime = 0;\r\n this.gameover(2);\r\n }\r\n // console.log(\"倒计时\",this.showtime);\r\n engine.globalEvent.dispatchEvent(\"pictures-time-update\",{\r\n time:this.showtime\r\n });\r\n }\r\n }\r\n this.lastframetime = ntime;\r\n }\r\n\r\n touchPic(e:engine.MouseEvent){\r\n if(!this.ingame){\r\n return;\r\n }\r\n // console.log(e.target.name);\r\n let selectname = e.target.name;\r\n let spx = e.target.x;\r\n let spy = e.target.y;\r\n let gap = 2;\r\n if(this.selectImgArr.length==0){\r\n if(this.nselectimg){\r\n this.blockcont.addChild(this.nselectimg);\r\n this.nselectimg.x = spx-gap;\r\n this.nselectimg.y = spy-gap;\r\n }\r\n this.selectImgArr.push(selectname);\r\n }else if(this.selectImgArr.length==1){\r\n if(selectname==this.selectImgArr[0]){\r\n return;\r\n }else{\r\n this.selectImgArr.push(selectname);\r\n this.changeImgPos();\r\n }\r\n }\r\n }\r\n changeImgPos(){\r\n let img1name = this.selectImgArr[0];\r\n let img2name = this.selectImgArr[1];\r\n\r\n let img1 = this.dicont.getChildByName(img1name);\r\n let img2 = this.dicont.getChildByName(img2name);\r\n\r\n let imgpos1x = img1.x;\r\n let imgpos1y = img1.y;\r\n let imgpos2x = img2.x;\r\n let imgpos2y = img2.y;\r\n\r\n let imgpostr1 = img1.postr;\r\n let imgpostr2 = img2.postr;\r\n\r\n img1.x = imgpos2x;\r\n img1.y = imgpos2y;\r\n img1.postr = imgpostr2;\r\n\r\n img2.x = imgpos1x;\r\n img2.y = imgpos1y;\r\n img2.postr = imgpostr1;\r\n\r\n this.selectImgArr = new Array();\r\n \r\n if(this.nselectimg){\r\n this.blockcont.removeChild(this.nselectimg);\r\n }\r\n let isuc = this.checkSuccess();\r\n if(isuc){\r\n console.error(\"成功过关\");\r\n this.gameover(1);\r\n }\r\n }\r\n checkSuccess(){\r\n let isuc:boolean = true;\r\n for(let r=0;r<this.rows;r++){\r\n for(let c=0;c<this.cols;c++){\r\n let ipicname = \"pic_\"+c+\"_\"+r;\r\n let npicstr = r+\"_\"+c;\r\n let ipic = this.dicont.getChildByName(ipicname);\r\n let ipostr = ipic.postr;\r\n if(npicstr!=ipostr){\r\n isuc = false;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n return isuc;\r\n\r\n }\r\n /**\r\n * \r\n * @param reason 1成功,2失败\r\n */\r\n private gameover(reason:number) {\r\n this.ingame = false;\r\n this.ticker&&clearInterval(this.ticker);\r\n engine.globalEvent.dispatchEvent('pictures-game-over', {\r\n reason:reason,\r\n time: this.passtime \r\n });\r\n }\r\n\r\n}\r\n","/**\r\n * Created by rockyl on 2020-01-09.\r\n */\r\n\r\nimport GameView from \"./GameView\";\r\nimport { injectProps } from \"../props\";\r\n\r\n\r\nexport class GameWrapper extends engine.Container {\r\n\t// private _status;\r\n\tprivate _gameView: GameView;\r\n\r\n\r\n\r\n\r\n\r\n\tconstructor() {\r\n\t\tsuper();\r\n\r\n\t\t//创建实例\r\n\t\tthis._gameView = new GameView();\r\n\t\tthis.addChild(this._gameView);\r\n\r\n\t\tengine.globalEvent.addEventListener('pictures-start', this.start, this);\r\n\t\tengine.globalEvent.addEventListener('pictures-pause', this.pause, this);\r\n\t\tengine.globalEvent.addEventListener('pictures-resume', this.resume, this);\r\n\t}\r\n\r\n\tstart(event: engine.Event) {\r\n\t\tinjectProps(event.data);\r\n\r\n\t\t// this._status = 1;\r\n\r\n\t\tthis._gameView.start();\r\n\t}\r\n\tpause(event: engine.Event) {\r\n\t\t\r\n\t\tthis._gameView.pause();\r\n\t}\r\n\tresume(event:engine.Event){\r\n\t\tthis._gameView.resume();\r\n\t}\r\n}\r\n","/**\r\n * Created by rockyl on 2019-11-20.\r\n */\r\n\r\nimport {GameWrapper} from \"./game/GameWrapper\";\r\nimport {injectProps, prepareProps} from \"./props\";\r\n\r\nexport default function (props) {\r\n\tprepareProps();\r\n\tinjectProps(props);\r\n\r\n\tlet instance = new GameWrapper();\r\n\t\r\n\tre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K,EAAE,KAAI,CAAC,CAAC;SACxE,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,gBAAgB,EAAE,KAAI,CAAC,KAAK,EAAE,KAAI,CAAC,CAAC;SACxE,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,iBAAiB,EAAE,KAAI,CAAC,MAAM,EAAE,KAAI,CAAC,CAAC;;MAC1E;KAED,2BAAK,GAAL,UAAM,KAAmB;SACxB,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SAIxB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;MACvB;KACD,2BAAK,GAAL,UAAM,KAAmB;SAExB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;MACvB;KACD,4BAAM,GAAN,UAAO,KAAkB;SACxB,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;MACxB;KACF,kBAAC;CAAD,CAAC,CAlCgC,MAAM,CAAC,SAAS,GAkChD;;;iBCnCwB,KAAK;KAC7B,YAAY,EAAE,CAAC;KACf,WAAW,CAAC,KAAK,CAAC,CAAC;KAEnB,IAAI,QAAQ,GAAG,IAAI,WAAW,EAAE,CAAC;KAEjC,OAAO,QAAQ,CAAC;CACjB,CAAC;;;;;;;;;"}
\ No newline at end of file
/**
* Created by rockyl on 2020-01-21.
*/
let customModuleProps = {
};
{
"name": "拼图",
"desc": "拼图模块1.0",
"props": {
"MAX_COL": {
"alias": "图片分成几列",
"type": "number",
"default": 3
},
"MAX_ROW": {
"alias": "图片分成几行",
"type": "number",
"default": 4
},
"W": {
"alias": "图片的宽度",
"type": "number",
"default": 620
},
"H": {
"alias": "图片的高度",
"type": "number",
"default": 620
},
"OFFSET_X": {
"alias": "OFFSET_X",
"type": "number",
"default": 0
},
"OFFSET_Y": {
"alias": "OFFSET_Y",
"type": "number",
"default": 0
},
"GAP": {
"alias": "图片间隙",
"type": "number",
"default": 0
},
"GAME_TIME": {
"alias": "游戏时间",
"type": "number",
"default": 30
}
},
"assets": [
{
"name": "遮罩",
"url": "//yun.duiba.com.cn/aurora/assets/5b3e30496b2d9fdafb0cf3835fd6704ce10e45b4.png",
"uuid": "888",
"ext": ".png"
},
{
"name": "框3",
"url": "//yun.duiba.com.cn/aurora/assets/521e08c574bd76c7dcf708cd6f8c4906e3707f06.png",
"uuid": "kuang3",
"ext": ".png"
},
{
"name": "框4",
"url": "//yun.duiba.com.cn/aurora/assets/1c384d986504d5aabfffeb5125dc67e73ce1b539.png",
"uuid": "kuang4",
"ext": ".png"
}
],
"events": {
"in": {
"pictures-start": {
"alias": "开始",
"data": {
"rows":3,
"cols":3,
"picUrl":"图片",
"gametime":30
}
},
"pictures-pause": {
"alias": "停止"
},
"pictures-resume":{
"alias":"继续"
}
},
"out": {
"pictures-time-update": {
"alias": "倒计时更新",
"data": {
"time":"剩余时间"
}
},
"pictures-game-over": {
"alias": "游戏结束",
"data": {
"reason": "结束(1:成功,2失败)"
}
}
}
}
}
\ No newline at end of file
/**
* Created by rockyl on 2018/8/16.
*/
import { props } from "../props";
import qietu from "./qietu";
import { getTexture, loadImageByUrl,getTextureByName } from "./utils";
import ObjectPool = engine.ObjectPool;
export default class GameView extends engine.Container {
rows:number;
cols:number;
passtime:number;
gametime:number;
showtime:number;
lastframetime:number;
ingame:boolean = false;
ticker;
selectimg3:engine.Image;
selectimg4:engine.Image;
nselectimg:engine.Image;
selectImgArr:Array<string> = [];
sucposData:Object = {};
dicont:engine.Container;
linecont:engine.Container;
blockcont:engine.Container;
lineShape:engine.Shape;
constructor() {
super();
this.once(engine.Event.ADDED_TO_STAGE, this.initScene, this);
}
initScene(){
this.lineShape = new engine.Shape();
this.selectimg3 = new engine.Image(getTextureByName("框3"));
this.selectimg4 = new engine.Image(getTextureByName("框4"));
//底图
this.dicont = new engine.Container();
//线
this.linecont = new engine.Container();
//亮片
this.blockcont = new engine.Container();
this.addChild(this.dicont);
this.addChild(this.linecont);
this.addChild(this.blockcont);
this.linecont.addChild(this.lineShape);
}
async start() {
this.dicont.removeChildren();
let picUrl = props.picUrl;
this.gametime = props.gametime;
this.showtime = props.gametime;
this.rows = props.rows;
this.cols = props.cols;
this.nselectimg = null;
if(this.rows==3){
this.nselectimg = this.selectimg3;
}
if(this.rows==4){
this.nselectimg = this.selectimg4;
}
this.passtime = 0;
this.selectImgArr = new Array();
this.sucposData = {};
let result = await qietu(picUrl,this.rows,this.cols,this.dicont);
let res = result.res;
if(res){
let picarr = result.picarr;
let mwid = result.mwid;
let mhei = result.mhei;
let picnames = result.picnames;
let gap = 2;
for(let r=0;r<this.rows;r++){
for(let c=0;c<this.cols;c++){
let ipicx = mwid*c+gap;
let ipicy = mhei*r+gap;
let npicname = "pic_"+c+"_"+r;
this.sucposData[npicname] = r+"_"+c;
let selidx = Math.floor(Math.random()*picnames.length);
let ipicname:string = picnames[selidx];
if(r==c&&r!=this.rows-1){
while(ipicname==npicname){
selidx = Math.floor(Math.random()*picnames.length);
ipicname = picnames[selidx];
}
}
let ipic = picarr[ipicname];
picnames.splice(selidx,1);
this.dicont.addChild(ipic);
ipic.x = ipicx;
ipic.y = ipicy;
ipic["postr"] = r+"_"+c;
ipic.addEventListener(engine.MouseEvent.MOUSE_DOWN,
this.touchPic,this);
}
}
//框线
this.lineShape.clear();
this.lineShape.beginStroke(0x0069df,4,engine.LINE_CAP.BUTT,engine.LINE_JOIN.BEVEL,100);
this.lineShape.moveTo(0+gap,0+gap);
this.lineShape.lineTo(mhei*this.cols+gap,0+gap);
this.lineShape.lineTo(mhei*this.cols+gap,mwid*this.rows+gap);
this.lineShape.lineTo(0+gap,mwid*this.rows+gap);
this.lineShape.lineTo(0+gap,0+gap);
for(let rl=1;rl<this.rows;rl++){
this.lineShape.moveTo(0+gap,rl*mhei+gap);
this.lineShape.lineTo(mwid*this.cols+gap,rl*mhei+gap);
}
for(let cl=1;cl<this.cols;cl++){
this.lineShape.moveTo(cl*mwid+gap,0+gap);
this.lineShape.lineTo(cl*mwid+gap,this.rows*mhei+gap);
}
this.lineShape.endStroke();
this.ticker = setInterval(this.update, 30);
}else{
console.error("图片处理失败");
}
}
pause(){
this.ingame = false;
}
resume(){
this.ingame = true;
}
update() {
let ntime = Date.now();
if(!this.lastframetime){
this.lastframetime = ntime;
return;
}
if(this.ingame){
let passtime = (ntime - this.lastframetime)/1000;
this.passtime += passtime;
let showtime1 = Math.round(this.gametime - this.passtime);
// console.log(passtime,this.passtime,this.gametime,this.showtime);
if(this.showtime!=showtime1){
this.showtime = showtime1;
if(this.showtime<=0){
this.showtime = 0;
this.gameover(2);
}
// console.log("倒计时",this.showtime);
engine.globalEvent.dispatchEvent("pictures-time-update",{
time:this.showtime
});
}
}
this.lastframetime = ntime;
}
touchPic(e:engine.MouseEvent){
if(!this.ingame){
return;
}
// console.log(e.target.name);
let selectname = e.target.name;
let spx = e.target.x;
let spy = e.target.y;
let gap = 2;
if(this.selectImgArr.length==0){
if(this.nselectimg){
this.blockcont.addChild(this.nselectimg);
this.nselectimg.x = spx-gap;
this.nselectimg.y = spy-gap;
}
this.selectImgArr.push(selectname);
}else if(this.selectImgArr.length==1){
if(selectname==this.selectImgArr[0]){
return;
}else{
this.selectImgArr.push(selectname);
this.changeImgPos();
}
}
}
changeImgPos(){
let img1name = this.selectImgArr[0];
let img2name = this.selectImgArr[1];
let img1 = this.dicont.getChildByName(img1name);
let img2 = this.dicont.getChildByName(img2name);
let imgpos1x = img1.x;
let imgpos1y = img1.y;
let imgpos2x = img2.x;
let imgpos2y = img2.y;
let imgpostr1 = img1.postr;
let imgpostr2 = img2.postr;
img1.x = imgpos2x;
img1.y = imgpos2y;
img1.postr = imgpostr2;
img2.x = imgpos1x;
img2.y = imgpos1y;
img2.postr = imgpostr1;
this.selectImgArr = new Array();
if(this.nselectimg){
this.blockcont.removeChild(this.nselectimg);
}
let isuc = this.checkSuccess();
if(isuc){
console.error("成功过关");
this.gameover(1);
}
}
checkSuccess(){
let isuc:boolean = true;
for(let r=0;r<this.rows;r++){
for(let c=0;c<this.cols;c++){
let ipicname = "pic_"+c+"_"+r;
let npicstr = r+"_"+c;
let ipic = this.dicont.getChildByName(ipicname);
let ipostr = ipic.postr;
if(npicstr!=ipostr){
isuc = false;
break;
}
}
}
return isuc;
}
/**
*
* @param reason 1成功,2失败
*/
private gameover(reason:number) {
this.ingame = false;
this.ticker&&clearInterval(this.ticker);
engine.globalEvent.dispatchEvent('pictures-game-over', {
reason:reason,
time: this.passtime
});
}
}
/**
* Created by rockyl on 2020-01-09.
*/
import GameView from "./GameView";
import { injectProps } from "../props";
export class GameWrapper extends engine.Container {
// private _status;
private _gameView: GameView;
constructor() {
super();
//创建实例
this._gameView = new GameView();
this.addChild(this._gameView);
engine.globalEvent.addEventListener('pictures-start', this.start, this);
engine.globalEvent.addEventListener('pictures-pause', this.pause, this);
engine.globalEvent.addEventListener('pictures-resume', this.resume, this);
}
start(event: engine.Event) {
injectProps(event.data);
// this._status = 1;
this._gameView.start();
}
pause(event: engine.Event) {
this._gameView.pause();
}
resume(event:engine.Event){
this._gameView.resume();
}
}
import { props } from "../props";
import { loadImageByUrl } from "./utils";
const urls = [];
const picMap = {};
const posMap = {};
export default async(url:string, rows:number, cols:number,parent:engine.Container) => {
try{
let t:engine.Texture = await loadImageByUrl(url) as engine.Texture;
let mwid = t.width/rows;
let mhei = t.height/cols;
let picarr = {};
let picnames = [];
for(let r=0;r<rows;r++){
let startx = r/rows;
let endx = (r+1)/rows;
// linedraw.moveTo()
for(let c=0;c<cols;c++){
let starty = c/cols;
let endy = (c+1)/cols;
let uvs = new Float32Array([
starty,
startx,
endy,
startx,
endy,
endx,
starty,
endx
]);
let itexture = new engine.Sprite(t);
itexture.uvs = uvs;
itexture.width = mwid;
itexture.height = mhei;
let itexname = "pic_"+c+"_"+r;
itexture.name = itexname;
picarr[itexname] = itexture;
picnames.push(itexname);
}
}
return {
res:true,
picarr:picarr,
mwid:mwid,
mhei:mhei,
picnames:picnames
};
}catch(e){
console.error("图片加载失败",e);
console.log(url,rows,cols);
return {
res:false
};
}
};
/**
* Created by rockyl on 2020-01-21.
*/
export function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
export function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
export function playSound(name) {
engine.playSound(engine.getAssetByName(name).uuid, {keep: true});
}
export function createSvga(name, anchorName?) {
let inst = new svga.Svga();
inst.source = 'asset://' + engine.getAssetByName(name).uuid;
return inst;
}
export function loadImageByUrl(url){
return new Promise((resolve) => {
if (engine.TextureCache[url]) {
resolve(engine.TextureCache[url])
} else {
var t = engine.Texture.from(url);
t.addEventListener("loaded", () => { resolve(t) })
}
})
}
\ No newline at end of file
/**
* Created by rockyl on 2019-11-20.
*/
import {GameWrapper} from "./game/GameWrapper";
import {injectProps, prepareProps} from "./props";
export default function (props) {
prepareProps();
injectProps(props);
let instance = new GameWrapper();
return instance;
}
/**
* Created by rockyl on 2020-01-21.
*/
export let props: any = {};
export function prepareProps() {
let metaProps = getProps();
engine.injectProp(props, metaProps);
}
export function injectProps(p) {
engine.injectProp(props, p);
}
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