Commit 0a4fe5ff authored by 汪欢's avatar 汪欢

cloud

parent b5cf2632
{
"name": "拼图",
"desc": "拼图模块1.0",
"props": {
"MAX_COL": {
"alias": "图片分成几列",
"type": "number",
"default": 3
},
"MAX_ROW": {
"alias": "图片分成几行",
"type": "number",
"default": 4
},
"OFFSET_X": {
"alias": "OFFSET_X",
"type": "number",
"default": 0
},
"OFFSET_Y": {
"alias": "OFFSET_Y",
"type": "number",
"default": 0
},
"GAME_TIME": {
"alias": "游戏时间",
"type": "number",
"default": 30
},
"GAP": {
"alias": "图片间隙",
"type": "number",
"default": 0
}
},
"assets": [
{
"name": "被遮罩",
"url": "//yun.duiba.com.cn/aurora/assets/c9d66b3e2381fdc7503cdcef9b7173f067a0b96d.png",
"uuid": "8a8e79b6-2c6f-441b-81ae-c441465abfb0",
"ext": ".png"
},
{
"name": "遮罩",
"url": "//yun.duiba.com.cn/aurora/assets/70ade7c1efa699c8662379f406319188fb6aebc5.png",
"uuid": "024d67e9-ed7f-4481-94ca-a15bd5226cad",
"ext": ".png"
},
{
"name": "衣服湿润度",
"url": "//yun.duiba.com.cn/aurora/assets/f59b03b7441b4da17d8e7567b44c6fe92ce9eb50.png",
"uuid": "ed0e8931-2557-4527-bcfc-9071f90d5737",
"ext": ".png"
},
{
"name": "背景",
"url": "//yun.duiba.com.cn/aurora/assets/d0e22ae58b6e8519b969ed207197a31820790349.png",
"uuid": "5ab43bdc-a6ce-46fb-99c2-a806f57f7484",
"ext": ".png"
},
{
"name": "倒计时",
"url": "//yun.duiba.com.cn/aurora/assets/97e5c35fa0503b5d28168fe7d22fb179f1279e21.png",
"uuid": "b7d2a60a-9e60-4eca-be80-a991abea47c9",
"ext": ".png"
},
{
"name": "云1",
"url": "//yun.duiba.com.cn/aurora/assets/429981638472e8f02ce2a780f3b05be72d13b943.png",
"uuid": "1e1a6993-9da0-4813-b1bd-00f2dbae2af2",
"ext": ".png"
},
{
"name": "云2",
"url": "//yun.duiba.com.cn/aurora/assets/c900fe3536b2119b1a917540e1aac5380363d9d1.png",
"uuid": "6ed0e2e7-3ba3-4967-8fe0-39667792e343",
"ext": ".png"
},
{
"name": "太阳",
"url": "//yun.duiba.com.cn/aurora/assets/f4ad009080bac141589b7f8eb88d6e66da732cd9.png",
"uuid": "0f05aaae-338a-439a-82b0-20efcee5cca4",
"ext": ".png"
},
{
"name": "常态1",
"url": "//yun.duiba.com.cn/aurora/assets/3a1e9ec8247078fc92af538ea8ee29c73b532b93.png",
"uuid": "487c1ca7-dea5-4732-b4b6-acb5406ee3a4",
"ext": ".png"
},
{
"name": "吃力1",
"url": "//yun.duiba.com.cn/aurora/assets/40f906478c4fe90f9b68392df0031d382502f8d9.png",
"uuid": "b876771a-a5d1-47f4-bd45-5978519c521a",
"ext": ".png"
},
{
"name": "沮丧1",
"url": "//yun.duiba.com.cn/aurora/assets/f76eb798d2ccff84f53780c37d802830c5f6071c.png",
"uuid": "ff43517a-27bb-4f73-948c-d7a4fa7b4c69",
"ext": ".png"
},
{
"name": "常态2",
"url": "//yun.duiba.com.cn/aurora/assets/875fd6ba38735682fe27d010338277238672f310.png",
"uuid": "4f8d0a7e-9db3-408e-81f2-fdd323ba6094",
"ext": ".png"
},
{
"name": "吃力2",
"url": "//yun.duiba.com.cn/aurora/assets/753b58a25ee4b617afe0a14767036b63681f0809.png",
"uuid": "71e07cee-fd6d-40bb-ac0b-5bb28c87276e",
"ext": ".png"
},
{
"name": "沮丧2",
"url": "//yun.duiba.com.cn/aurora/assets/17682be2c0e9f299315bf4e17598ea2e3c8e11ce.png",
"uuid": "2cd9f1bb-d0d8-42ea-941b-dcd0428e474d",
"ext": ".png"
},
{
"name": "撑伞按钮",
"url": "//yun.duiba.com.cn/aurora/assets/2d15942ed213e1d0ae953925565d80f93cec4701.png",
"uuid": "9e347bef-6e91-4c92-ba5f-f9a52e656207",
"ext": ".png"
},
{
"name": "伞",
"url": "//yun.duiba.com.cn/aurora/assets/a4c14c17dc144611164c70f905f1d35a2aa1812f.png",
"uuid": "c7129f77-92a6-479e-9994-7d4b39040a15",
"ext": ".png"
},
{
"name": "雨滴",
"url": "//yun.duiba.com.cn/aurora/assets/a1bf1b1622759aabec29e857e325039c147bac54.png",
"uuid": "07f74bf6-416f-445e-98d5-021efe4c9fdc",
"ext": ".png"
},
{
"name": "",
"url": "//yun.duiba.com.cn/aurora/assets/1cded0d917c44d22ddce058f239e1cfac1b506c2.png",
"uuid": "57d4067e-c32f-4b12-a8fc-185753726fc6",
"ext": ".png"
},
{
"name": "击中",
"url": "//yun.duiba.com.cn/aurora/assets/251402a1991ef00a124ddd91f519a30147285e00.png",
"uuid": "38ec6627-efa8-4f7a-9bdc-3c73cea717f1",
"ext": ".png"
},
{
"name": "关闭",
"url": "//yun.duiba.com.cn/aurora/assets/6900f3a3b592c1b9cd3925fb9b66b6ec673a8c43.png",
"uuid": "e4a82aee-4472-4b06-bd75-02fb64f1c8c8",
"ext": ".png"
}
],
"events": {
"in": {
"pictures-start": {
"alias": "开始",
"data": {
"picUrl": "图片路径",
"blockUrl": "blockUrl",
"GAME_TIME": "每局的游戏时间",
"MAX_ROW": "行",
"MAX_COL": "列",
"W": "宽",
"H": "高",
"GAP": "图片间隙",
"OFFSET_X": "OFFSET_X",
"OFFSET_Y": "OFFSET_Y"
}
},
"pictures-stop": {
"alias": "停止"
}
},
"out": {
"cloud-time-update": {
"alias": "倒计时更新",
"data": {
"time": "剩余时间"
}
},
"cloud-game-fail": {
"alias": "游戏结束",
"data": {
"reason": "结束原因(1:时间到了)"
}
},
"cloud-game-success": {
"alias": "游戏成功",
"data": {
"time": "游戏消耗时间"
}
}
}
},
"id": "getAwayFromCloud",
"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.getAwayFromCloud = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n\tfunction getTexture(uuid) {\r\n\t return engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n\t}\r\n\t//# sourceMappingURL=utils.js.map\n\n\tvar Human = (function (_super) {\r\n\t tslib.__extends(Human, _super);\r\n\t function Human() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.humanArray = [\r\n\t '487c1ca7-dea5-4732-b4b6-acb5406ee3a4',\r\n\t '71e07cee-fd6d-40bb-ac0b-5bb28c87276e',\r\n\t '2cd9f1bb-d0d8-42ea-941b-dcd0428e474d'\r\n\t ];\r\n\t _this.human = new engine.Sprite(getTexture(_this.humanArray[0]));\r\n\t _this.addChild(_this.human);\r\n\t _this.width = _this.human.width;\r\n\t _this.height = _this.human.height;\r\n\t return _this;\r\n\t }\r\n\t Human.prototype.facialChange = function (num) {\r\n\t var face = new engine.Sprite(getTexture(this.humanArray[num]));\r\n\t this.human.addChild(face);\r\n\t return face;\r\n\t };\r\n\t Human.prototype.removeFace = function (face) {\r\n\t this.human.removeChild(face);\r\n\t };\r\n\t return Human;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=Human.js.map\n\n\tvar Moist = (function (_super) {\r\n\t tslib.__extends(Moist, _super);\r\n\t function Moist() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.moistBg = new engine.Sprite(getTexture('8a8e79b6-2c6f-441b-81ae-c441465abfb0'));\r\n\t _this.moist = new engine.Sprite(getTexture('024d67e9-ed7f-4481-94ca-a15bd5226cad'));\r\n\t _this.moistCover = new engine.Sprite(getTexture('024d67e9-ed7f-4481-94ca-a15bd5226cad'));\r\n\t _this.txt = new engine.TextInput();\r\n\t _this.hintpic = new engine.Sprite(getTexture('ed0e8931-2557-4527-bcfc-9071f90d5737'));\r\n\t _this.percent = 0;\r\n\t _this.addChild(_this.moistBg);\r\n\t _this.moistBg.addChild(_this.moist);\r\n\t _this.moist.mask = _this.moistCover;\r\n\t _this.txt.text = _this.percent * 100 + '%';\r\n\t _this.txt.size = 30;\r\n\t _this.txt.fillColor = '#7A83C5';\r\n\t _this.addChild(_this.txt);\r\n\t _this.txt.x = 0;\r\n\t _this.txt.y = -50;\r\n\t _this.hintpic.x = -10;\r\n\t _this.hintpic.y = 440;\r\n\t _this.addChild(_this.hintpic);\r\n\t return _this;\r\n\t }\r\n\t Moist.prototype.cover = function (percent) {\r\n\t this.moistCover.anchorY = 416;\r\n\t this.moistBg.addChild(this.moistCover);\r\n\t this.moistCover.scaleY = percent;\r\n\t };\r\n\t Moist.prototype.stopScale = function () {\r\n\t this.moistCover.scaleY = 1;\r\n\t this.txt.text = '100%';\r\n\t };\r\n\t Moist.prototype.updateText = function (percent) {\r\n\t var a = percent * 100;\r\n\t if (a <= 90) {\r\n\t this.txt.text = a.toPrecision(2) + '%';\r\n\t }\r\n\t else {\r\n\t this.txt.text = a.toPrecision(3) + '%';\r\n\t }\r\n\t };\r\n\t return Moist;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=Moist.js.map\n\n\tvar TimeCounter = (function (_super) {\r\n\t tslib.__extends(TimeCounter, _super);\r\n\t function TimeCounter() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.timeCounter = new engine.Sprite(getTexture('b7d2a60a-9e60-4eca-be80-a991abea47c9'));\r\n\t _this.time = 20;\r\n\t _this.addChild(_this.timeCounter);\r\n\t _this.timeCounter.x = 256;\r\n\t _this.timeCounter.y = 50;\r\n\t _this.timeText = new engine.TextInput();\r\n\t _this.timeText.text = _this.time + 's';\r\n\t _this.timeText.size = 48;\r\n\t _this.timeText.fillColor = '#7A83C5';\r\n\t _this.timeCounter.addChild(_this.timeText);\r\n\t _this.timeText.x = 100;\r\n\t _this.timeText.y = 15;\r\n\t return _this;\r\n\t }\r\n\t TimeCounter.prototype.updateTime = function (time) {\r\n\t this.time = time;\r\n\t this.timeText.text = this.time + 's';\r\n\t };\r\n\t return TimeCounter;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=TimeCounter.js.map\n\n\tvar CloudRain = (function (_super) {\r\n\t tslib.__extends(CloudRain, _super);\r\n\t function CloudRain() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.clound1 = new engine.Sprite(getTexture('1e1a6993-9da0-4813-b1bd-00f2dbae2af2'));\r\n\t _this.clound2 = new engine.Sprite(getTexture('6ed0e2e7-3ba3-4967-8fe0-39667792e343'));\r\n\t _this.sun = new engine.Sprite(getTexture(\"0f05aaae-338a-439a-82b0-20efcee5cca4\"));\r\n\t _this.sun.x = 90;\r\n\t _this.sun.y = 120;\r\n\t _this.addChild(_this.sun);\r\n\t _this.addChild(_this.clound1);\r\n\t _this.addChild(_this.clound2);\r\n\t _this.clound1.x = 100;\r\n\t _this.clound1.y = 220;\r\n\t _this.clound2.x = 150;\r\n\t _this.clound2.y = 220;\r\n\t return _this;\r\n\t }\r\n\t CloudRain.prototype.succeed = function () {\r\n\t var _this = this;\r\n\t var a = 0;\r\n\t var ld = Date.now();\r\n\t this.addEventListener(engine.Event.ENTER_FRAME, function () {\r\n\t var dt = Date.now() - ld;\r\n\t a += dt;\r\n\t if (a > 100) {\r\n\t _this.clound1.x -= (800 * dt) / 1000;\r\n\t _this.clound2.x += (820 * dt) / 1000;\r\n\t if (_this.clound1.x <= -380) {\r\n\t _this.clound1.x = -380;\r\n\t }\r\n\t if (_this.clound2.x >= 750) {\r\n\t _this.clound2.x = 750;\r\n\t }\r\n\t _this.sun.y -= (150 * dt) / 1000;\r\n\t if (_this.sun.y <= 60) {\r\n\t _this.sun.y = 60;\r\n\t }\r\n\t }\r\n\t ld = Date.now();\r\n\t });\r\n\t };\r\n\t return CloudRain;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=CloudRain.js.map\n\n\tvar GameTest = (function (_super) {\r\n\t tslib.__extends(GameTest, _super);\r\n\t function GameTest() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.dripArray = [];\r\n\t _this.clicknum = 0;\r\n\t _this.R = 250;\r\n\t _this.D = 340;\r\n\t _this.con = new engine.Sprite();\r\n\t _this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);\r\n\t return _this;\r\n\t }\r\n\t GameTest.prototype.setup = function () {\r\n\t var playBg = new engine.Sprite(getTexture(\"5ab43bdc-a6ce-46fb-99c2-a806f57f7484\"));\r\n\t this.addChild(playBg);\r\n\t this.humanbeing = new Human();\r\n\t this.humanbeing.x = 290;\r\n\t this.humanbeing.y = 750;\r\n\t this.addChild(this.humanbeing);\r\n\t console.log(\"xxxxxx\", this.stage.width, this.stage.height, this.width, this.height);\r\n\t this.rightHand = new engine.Sprite(getTexture(\"c7129f77-92a6-479e-9994-7d4b39040a15\"));\r\n\t this.rightHand.x = -70;\r\n\t this.rightHand.y = -65;\r\n\t this.rightHand.anchorX = 196;\r\n\t this.rightHand.anchorY = 253;\r\n\t this.humanbeing.addChild(this.rightHand);\r\n\t this.playBtn = new engine.Sprite(getTexture(\"9e347bef-6e91-4c92-ba5f-f9a52e656207\"));\r\n\t this.playBtn.x = 138;\r\n\t this.playBtn.y = 1150;\r\n\t this.addChild(this.playBtn);\r\n\t this.moists = new Moist();\r\n\t this.moists.x = 20;\r\n\t this.moists.y = 450;\r\n\t this.addChild(this.moists);\r\n\t this.cloud = new CloudRain();\r\n\t this.addChild(this.cloud);\r\n\t };\r\n\t GameTest.prototype.start = function () {\r\n\t var _this = this;\r\n\t var middleX = this.humanbeing.x + this.humanbeing.width / 2;\r\n\t var validX1 = this.humanbeing.x;\r\n\t var validX2 = this.humanbeing.x + this.humanbeing.width;\r\n\t for (var i = 0; i < 1000; i++) {\r\n\t var y = -Math.sqrt(this.R * this.R - (i - middleX - 50) * (i - middleX - 50)) +\r\n\t (this.humanbeing.y + 180);\r\n\t var img = new engine.Sprite(getTexture(\"e4a82aee-4472-4b06-bd75-02fb64f1c8c8\"));\r\n\t img.width = 2;\r\n\t img.height = 2;\r\n\t img.x = i;\r\n\t img.y = y;\r\n\t this.con.addChild(img);\r\n\t }\r\n\t this.addChild(this.con);\r\n\t var point1 = new engine.Graphics();\r\n\t point1.beginFill(0xff0000);\r\n\t point1.drawRect(0, 0, 10, 10);\r\n\t point1.y = 100;\r\n\t point1.endFill();\r\n\t this.rightHand.addChild(point1);\r\n\t var point2 = new engine.Graphics();\r\n\t point2.beginFill(0xff0000);\r\n\t point2.drawRect(0, 0, 10, 10);\r\n\t point2.x = 170;\r\n\t point2.endFill();\r\n\t this.rightHand.addChild(point2);\r\n\t var point3 = new engine.Graphics();\r\n\t point3.beginFill(0xff0000);\r\n\t point3.drawRect(0, 0, 10, 10);\r\n\t point3.x = 330;\r\n\t point3.y = 100;\r\n\t point3.endFill();\r\n\t this.rightHand.addChild(point3);\r\n\t this.timeCounter = new TimeCounter();\r\n\t this.addChild(this.timeCounter);\r\n\t var ld = Date.now();\r\n\t var a = 0;\r\n\t var b = 0;\r\n\t var drip = new engine.Sprite(getTexture(\"07f74bf6-416f-445e-98d5-021efe4c9fdc\"));\r\n\t drip.x =\r\n\t Math.random() * (this.humanbeing.x + 160) +\r\n\t (this.humanbeing.x - 160);\r\n\t drip.worldMatrix.ty = Math.random() * 100 + 300;\r\n\t this.dripArray.push(drip);\r\n\t this.addChild(drip);\r\n\t this.addEventListener(engine.Event.ENTER_FRAME, function () {\r\n\t var dt = Date.now() - ld;\r\n\t a += dt;\r\n\t b += dt;\r\n\t if (a > 200) {\r\n\t a = 0;\r\n\t if (_this.timeCounter.time > 0) {\r\n\t var drip_1 = new engine.Sprite(getTexture(\"07f74bf6-416f-445e-98d5-021efe4c9fdc\"));\r\n\t drip_1.x =\r\n\t Math.random() * (_this.humanbeing.x + 160) +\r\n\t (_this.humanbeing.x - 160);\r\n\t drip_1.worldMatrix.ty = Math.random() * 100 + 300;\r\n\t _this.dripArray.push(drip_1);\r\n\t _this.addChild(drip_1);\r\n\t }\r\n\t }\r\n\t var _loop_1 = function (drip_2) {\r\n\t drip_2.y += (300 * dt) / 1000;\r\n\t if (drip_2.y > _this.stage.height) {\r\n\t var index_1 = _this.dripArray.indexOf(drip_2);\r\n\t _this.removeChild(drip_2);\r\n\t _this.dripArray = _this.dripArray.filter(function (ele, i) { return i != index_1; });\r\n\t }\r\n\t };\r\n\t for (var _i = 0, _a = _this.dripArray; _i < _a.length; _i++) {\r\n\t var drip_2 = _a[_i];\r\n\t _loop_1(drip_2);\r\n\t }\r\n\t if (b >= 1000) {\r\n\t b = 0;\r\n\t _this.timeCounter.time -= 1;\r\n\t if (_this.timeCounter.time <= 0) {\r\n\t _this.timeCounter.time = 0;\r\n\t }\r\n\t _this.timeCounter.updateTime(_this.timeCounter.time);\r\n\t if (_this.timeCounter.time <= 0) {\r\n\t console.log(\"游戏成功!\");\r\n\t _this.success();\r\n\t }\r\n\t }\r\n\t var wind = -40;\r\n\t _this.rightHand.rotation += wind / 60;\r\n\t if (_this.rightHand.rotation <= -90) {\r\n\t _this.rightHand.rotation = -90;\r\n\t }\r\n\t else if (_this.rightHand.rotation >= 90) {\r\n\t _this.rightHand.rotation = 90;\r\n\t }\r\n\t ld = Date.now();\r\n\t _this.angle = Math.asin(_this.D / 2 / _this.R) * 57.18;\r\n\t _this.rightHand.name = \"aaa\";\r\n\t if (_this.stage.height > 1334) ;\r\n\t var k12 = (point1.worldMatrix.ty - point2.worldMatrix.ty) /\r\n\t (point1.worldMatrix.tx - point2.worldMatrix.tx);\r\n\t var k23 = (point2.worldMatrix.ty - point3.worldMatrix.ty) /\r\n\t (point2.worldMatrix.tx - point3.worldMatrix.tx);\r\n\t var px1 = point1.worldMatrix.tx;\r\n\t var px2 = point2.worldMatrix.tx;\r\n\t var px3 = point3.worldMatrix.tx;\r\n\t var maxX = px1 >= px2 ? (px1 >= px3 ? px1 : px3) : px2 >= px3 ? px2 : px3;\r\n\t var minX = px1 >= px2 ? (px2 >= px3 ? px3 : px2) : px1 >= px3 ? px3 : px1;\r\n\t var _loop_2 = function (drip_3) {\r\n\t var b12 = point1.worldMatrix.ty -\r\n\t point1.worldMatrix.tx * k12 - 50;\r\n\t var b23 = point2.worldMatrix.ty -\r\n\t point2.worldMatrix.tx * k23 - 50;\r\n\t var y12 = k12 * drip_3.x + b12;\r\n\t var y23 = k23 * drip_3.x + b23;\r\n\t if (drip_3.x > minX && drip_3.x < maxX) {\r\n\t if (drip_3.x < px2) {\r\n\t if (drip_3.worldMatrix.ty >= y12) {\r\n\t var index_2 = _this.dripArray.indexOf(drip_3);\r\n\t _this.removeChild(drip_3);\r\n\t _this.dripArray = _this.dripArray.filter(function (ele, i) { return i != index_2; });\r\n\t }\r\n\t }\r\n\t if (drip_3.x >= px2) {\r\n\t if (drip_3.worldMatrix.ty >= y23) {\r\n\t var index_3 = _this.dripArray.indexOf(drip_3);\r\n\t _this.removeChild(drip_3);\r\n\t _this.dripArray = _this.dripArray.filter(function (ele, i) { return i != index_3; });\r\n\t }\r\n\t }\r\n\t }\r\n\t if (drip_3.x > _this.humanbeing.x &&\r\n\t drip_3.x < _this.humanbeing.x + _this.humanbeing.width) {\r\n\t if (drip_3.y >= _this.humanbeing.y) {\r\n\t _this.moists.percent += 0.1;\r\n\t _this.moists.cover(_this.moists.percent);\r\n\t _this.moists.updateText(_this.moists.percent);\r\n\t if (_this.moists.percent >= 1) {\r\n\t _this.moists.stopScale();\r\n\t console.log(\"游戏结束!\");\r\n\t _this.stop();\r\n\t }\r\n\t _this.removeChild(drip_3);\r\n\t var face_1 = _this.humanbeing.facialChange(2);\r\n\t face_1.x = 7;\r\n\t face_1.y = 22;\r\n\t setTimeout(function () {\r\n\t _this.humanbeing.removeFace(face_1);\r\n\t }, 1000);\r\n\t console.log(\"\");\r\n\t var index_4 = _this.dripArray.indexOf(drip_3);\r\n\t _this.dripArray = _this.dripArray.filter(function (ele, i) { return i != index_4; });\r\n\t }\r\n\t }\r\n\t };\r\n\t for (var _b = 0, _c = _this.dripArray; _b < _c.length; _b++) {\r\n\t var drip_3 = _c[_b];\r\n\t _loop_2(drip_3);\r\n\t }\r\n\t ld = Date.now();\r\n\t });\r\n\t this.playBtn.addEventListener(engine.MouseEvent.CLICK, this.onClick, this);\r\n\t };\r\n\t GameTest.prototype.onClick = function () {\r\n\t this.clicknum += 1;\r\n\t this.rightHand.rotation += 10 * this.clicknum;\r\n\t this.clicknum = 0;\r\n\t };\r\n\t GameTest.prototype.stop = function () {\r\n\t engine.globalEvent.dispatchEvent(\"cloud-game-fail\", { reason: 1 });\r\n\t };\r\n\t GameTest.prototype.success = function () {\r\n\t this.cloud.succeed();\r\n\t engine.globalEvent.dispatchEvent(\"cloud-game-success\", {\r\n\t moist: this.moists.percent,\r\n\t });\r\n\t };\r\n\t return GameTest;\r\n\t}(engine.Container));\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\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 engine.globalEvent.addEventListener('pictures-start', _this.start, _this);\r\n\t engine.globalEvent.addEventListener('pictures-stop', _this.stop, _this);\r\n\t var gameTest = _this._gameTest = new GameTest();\r\n\t _this.addChild(gameTest);\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._gameTest.start();\r\n\t };\r\n\t GameWrapper.prototype.stop = function (event) {\r\n\t this._gameTest.stop();\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"
}
......@@ -40,7 +40,7 @@
"GAME_TIME": {
"alias": "游戏时间",
"type": "number",
"default": 50
"default": 10
}
},
"assets": [
......@@ -86,5 +86,5 @@
}
},
"id": "pictures",
"code": "\"use strict\";var tslib=require(\"tslib\"),props={};function prepareProps(){var t=getProps();engine.injectProp(props,t)}function injectProps(t){engine.injectProp(props,t)}var MAX_COL,MAX_ROW,W,H,GAP,GAME_TIME,w,h,picMap={},posMap={},qietu=function(n,r,o,a){if(picMap[r]){for(var t=0,e=picMap[r];t<e.length;t++){var i=e[t];n.addChild(i)}return[picMap[r],posMap[r]]}for(var p=props.W,h=props.H,c=props.GAP,d=[],u=[],s=function(s){for(var t=function(e){var i=engine.Sprite.fromImage(r);d.push(i),i.scaleX=1/o,i.scaleY=1/a,n.addChild(i),i.x=e*(p/o+c),i.y=s*(h/a+c),u.push([i.x,i.y]),i.addEventListener(engine.Event.COMPLETE,function(){var t=new Float32Array([e/o,s/a,(e+1)/o,s/a,(e+1)/o,(s+1)/a,e/o,(s+1)/a]);i.uvs=t})},e=0;e<o;e++)t(e)},g=0;g<a;g++)s(g);return picMap[r]=d.concat([]),posMap[r]=u.concat([]),[d,u]};function getIndexFromRC(t,e,i){return t*i+e}function getRandomArray(t){t.sort(function(){return.5-Math.random()})}var GameView=function(e){function t(){var t=e.call(this)||this;return t._timeCounter=0,t.listenStageOn=1,t.once(engine.Event.ADDED_TO_STAGE,t.setup,t),t}return tslib.__extends(t,e),t.prototype.start=function(){var t=this;if(this.guideHole||(this.guideHole=new engine.Image,this.guideHole.source=\"asset://\"+props.blockUrl,this.guideHole.mouseChildren=this.guideHole.mouseEnabled=!1),this.pictures)for(var e=0,i=this.pictures;e<i.length;e++){var s=i[e];s&&s.parent&&s.parent.removeChild(s)}console.log(\"on start\"),engine.globalEvent.dispatchEvent(\"pictures-time-update\",{second:this.getSecond()});var n=qietu(this.picturesWrapper,props.picUrl,MAX_COL,MAX_ROW);this.picturesWrapper.addChild(this.guideHole),console.log(this.picturesWrapper),this.pictures=n[0],this.rightList=this.pictures.concat([]);var r=n[1];getRandomArray(this.pictures);var o,a=0;for(o=this.pictures.length;a<o;a++){this.dragPic=this.pictures[a],this.pictures[a].addEventListener(engine.MouseEvent.MOUSE_DOWN,this.onDown,this);var p=r[a],h=p[0],c=p[1];this.dragPic.x=h,this.dragPic.y=c}this._timer=setInterval(function(){t.onTimer()},10)},t.prototype.onTimer=function(){GAME_TIME-=.01,(GAME_TIME=(GAME_TIME=this.afterPointTwo(GAME_TIME)).toFixed(2))<10&&(GAME_TIME=\"0\"+GAME_TIME),engine.globalEvent.dispatchEvent(\"pictures-time-update\",{second:this.getSecond()}),0==this.getSecond()&&(this.stop(),engine.globalEvent.dispatchEvent(\"pictures-game-fail\",{reason:1}))},t.prototype.afterPointTwo=function(t){var e=parseFloat(t);if(!isNaN(e))return e=Math.round(100*e)/100},t.prototype.getSecond=function(){return GAME_TIME},t.prototype.stop=function(){GAME_TIME=props.GAME_TIME,clearInterval(this._timer)},t.prototype.createRects=function(){},t.prototype.setup=function(){MAX_COL=props.MAX_COL,MAX_ROW=props.MAX_ROW,GAME_TIME=props.GAME_TIME,W=props.W,H=props.H,GAP=props.GAP,w=W/MAX_COL,h=H/MAX_ROW,console.log(\"onSteup\",props);var t=new engine.Sprite;this.picturesWrapper=t,this.addChild(t)},t.prototype.onDown=function(t){this.dragPic=t.target,this.picturesWrapper.addChild(this.dragPic),this.localPicX=t.localX/MAX_COL,this.localPicY=t.localY/MAX_ROW,this.distanceX=this.dragPic.x,this.distanceY=this.dragPic.y,this.indexJ=Math.floor(this.distanceX/(w+GAP)),this.indexI=Math.floor(this.distanceY/(h+GAP)),this.index=this.indexI*MAX_COL+this.indexJ,this.centerX=Math.floor(t.clientX/w)*w+w/2,this.centerY=Math.floor(t.clientY/h)*h+h/2,this.stage.addEventListener(engine.MouseEvent.MOUSE_MOVE,this.onMove,this),this.stage.addEventListener(engine.MouseEvent.MOUSE_UP,this.stageOnUp,this)},t.prototype.stageOnUp=function(t){this.stage.removeEventListener(engine.MouseEvent.MOUSE_MOVE,this.onMove,this),this.stage.removeEventListener(engine.MouseEvent.MOUSE_UP,this.stageOnUp,this),(this.centerY<0||this.centerX<0)&&(this.dragPic.x=this.distanceX,this.dragPic.y=this.distanceY),this.picturesWrapper.addChild(this.guideHole);var e=Math.floor(this.centerX/(w+GAP)),i=Math.floor(this.centerY/(h+GAP));if(e<MAX_COL&&i<MAX_ROW){var s=getIndexFromRC(i,e,MAX_COL),n=this.pictures[s],r=n.x,o=n.y;n.x=this.distanceX,n.y=this.distanceY,this.dragPic.x=r,this.dragPic.y=o;var a=this.pictures.indexOf(n),p=this.pictures.indexOf(this.dragPic);this.pictures[a]=this.dragPic,this.pictures[p]=n,p===a&&(this.dragPic.x=this.distanceX,this.dragPic.y=this.distanceY);for(var c=!0,d=0;d<this.rightList.length;d++)if(this.rightList[d]!=this.pictures[d]){c=!1;break}c&&this.onSuccess()}else this.dragPic.x=this.distanceX,this.dragPic.y=this.distanceY},t.prototype.onSuccess=function(){console.log(\"拼图成功!\"),engine.globalEvent.dispatchEvent(\"pictures-game-success\",{time:this._timeCounter}),this.stop()},t.prototype.onMove=function(t){this.dragPic.x=t.stageX-this.localPicX-(750-props.W)/2,this.dragPic.y=t.stageY-this.localPicY-(this.stage.height-props.H)/2,console.log(\"fuck on this.stage.height\",this.stage.height),this.centerX=this.dragPic.x+w/2,this.centerY=this.dragPic.y+h/2},t}(engine.Container),GameWrapper=function(i){function t(){var t=i.call(this)||this;engine.globalEvent.addEventListener(\"pictures-start\",t.start,t),engine.globalEvent.addEventListener(\"pictures-stop\",t.stop,t);var e=t._gameView=new GameView;return t.addChild(e),t}return tslib.__extends(t,i),t.prototype.start=function(t){injectProps(t.data),this._gameView.start()},t.prototype.stop=function(t){this._gameView.stop()},t}(engine.Container);function index(t){return prepareProps(),injectProps(t),new GameWrapper}module.exports=index;\n"
"code": "\"use strict\";var tslib=require(\"tslib\"),props={};function prepareProps(){var t=getProps();engine.injectProp(props,t)}function injectProps(t){engine.injectProp(props,t)}var MAX_COL,MAX_ROW,W,H,GAP,GAME_TIME,w,h,picMap={},posMap={},qietu=function(n,r,o,a){if(picMap[r]){for(var t=0,e=picMap[r];t<e.length;t++){var i=e[t];n.addChild(i)}return[picMap[r],posMap[r]]}for(var p=props.W,h=props.H,c=props.GAP,d=[],g=[],s=0;s<a;s++)!function(s){for(var t=0;t<o;t++)!function(e){var i=engine.Sprite.fromImage(r);d.push(i),i.scaleX=1/o,i.scaleY=1/a,n.addChild(i),i.x=e*(p/o+c),i.y=s*(h/a+c),g.push([i.x,i.y]),i.addEventListener(engine.Event.COMPLETE,function(){var t=new Float32Array([e/o,s/a,(e+1)/o,s/a,(e+1)/o,(s+1)/a,e/o,(s+1)/a]);i.uvs=t})}(t)}(s);return picMap[r]=d.concat([]),posMap[r]=g.concat([]),[d,g]};function getIndexFromRC(t,e,i){return t*i+e}function getRandomArray(t){t.sort(function(){return.5-Math.random()})}var GameView=function(e){function t(){var t=e.call(this)||this;return t._timeCounter=0,t.listenStageOn=1,t.once(engine.Event.ADDED_TO_STAGE,t.setup,t),t}return tslib.__extends(t,e),t.prototype.start=function(){var t=this;if(this.guideHole||(this.guideHole=new engine.Image,this.guideHole.source=\"asset://\"+props.blockUrl,this.guideHole.mouseChildren=this.guideHole.mouseEnabled=!1),this.pictures)for(var e=0,i=this.pictures;e<i.length;e++){var s=i[e];s&&s.parent&&s.parent.removeChild(s)}console.log(\"on start\"),engine.globalEvent.dispatchEvent(\"pictures-time-update\",{second:this.getSecond()});var n=qietu(this.picturesWrapper,props.picUrl,MAX_COL,MAX_ROW);this.picturesWrapper.addChild(this.guideHole),console.log(this.picturesWrapper),this.pictures=n[0],this.rightList=this.pictures.concat([]);var r=n[1];getRandomArray(this.pictures);for(var o=0,a=this.pictures.length;o<a;o++){this.dragPic=this.pictures[o],this.pictures[o].addEventListener(engine.MouseEvent.MOUSE_DOWN,this.onDown,this);var p=r[o],h=p[0],c=p[1];this.dragPic.x=h,this.dragPic.y=c}this._timer=setInterval(function(){t.onTimer()},10),this.date=(new Date).getTime()},t.prototype.onTimer=function(){var t=(new Date).getTime(),e=(t-this.date)/1e3;this.date=t,console.log(e,\"gap\"),(GAME_TIME-=e)<0&&(GAME_TIME=0),(GAME_TIME=(GAME_TIME=this.afterPointTwo(GAME_TIME)).toFixed(2))<10&&(GAME_TIME=\"0\"+GAME_TIME),console.log(GAME_TIME),engine.globalEvent.dispatchEvent(\"pictures-time-update\",{second:this.getSecond()}),0==this.getSecond()&&(this.stop(),engine.globalEvent.dispatchEvent(\"pictures-game-fail\",{reason:1}))},t.prototype.afterPointTwo=function(t){var e=parseFloat(t);if(!isNaN(e))return e=Math.round(100*e)/100},t.prototype.getSecond=function(){return GAME_TIME},t.prototype.stop=function(){GAME_TIME=props.GAME_TIME,clearInterval(this._timer);for(var t=this.pictures.length,e=0;e<t;e++)this.pictures[e].removeAllEventListener();this.stage.removeEventListener(engine.MouseEvent.MOUSE_UP,this.stageOnUp,this)},t.prototype.createRects=function(){},t.prototype.setup=function(){MAX_COL=props.MAX_COL,MAX_ROW=props.MAX_ROW,GAME_TIME=props.GAME_TIME,W=props.W,H=props.H,GAP=props.GAP,w=W/MAX_COL,h=H/MAX_ROW,console.log(\"onSteup\",props);var t=new engine.Sprite;this.picturesWrapper=t,this.addChild(t)},t.prototype.onDown=function(t){var e=(750-props.W)/2,i=(this.stage.height-props.H)/2;this.dragPic=t.target,this.picturesWrapper.addChild(this.dragPic),this.localPicX=t.localX/MAX_COL,this.localPicY=t.localY/MAX_ROW,this.distanceX=this.dragPic.x,this.distanceY=this.dragPic.y,this.indexJ=Math.floor(this.distanceX/(w+GAP)),this.indexI=Math.floor(this.distanceY/(h+GAP)),this.index=this.indexI*MAX_COL+this.indexJ,this.centerX=Math.floor((t.clientX-e)/w)*w+w/2,this.centerY=Math.floor((t.clientY-i)/h)*h+h/2,this.stage.addEventListener(engine.MouseEvent.MOUSE_MOVE,this.onMove,this),this.stage.addEventListener(engine.MouseEvent.MOUSE_UP,this.stageOnUp,this)},t.prototype.stageOnUp=function(t){var e=(750-props.W)/2,i=(this.stage.height-props.H)/2;this.stage.removeEventListener(engine.MouseEvent.MOUSE_MOVE,this.onMove,this),this.stage.removeEventListener(engine.MouseEvent.MOUSE_UP,this.stageOnUp,this),(this.centerY<i||this.centerX<e)&&(this.dragPic.x=this.distanceX,this.dragPic.y=this.distanceY);var s=Math.floor(this.centerX/(w+GAP)),n=Math.floor(this.centerY/(h+GAP));if(this.picturesWrapper.addChild(this.guideHole),0<=s&&s<MAX_COL&&0<=n&&n<MAX_ROW){var r=getIndexFromRC(n,s,MAX_COL),o=this.pictures[r],a=o.x+e,p=o.y+i;o.x=this.distanceX,o.y=this.distanceY,this.dragPic.x=a-e,this.dragPic.y=p-i;var c=this.pictures.indexOf(o),d=this.pictures.indexOf(this.dragPic);this.pictures[c]=this.dragPic,this.pictures[d]=o,d===c&&(this.dragPic.x=this.distanceX,this.dragPic.y=this.distanceY);for(var g=!0,u=0;u<this.rightList.length;u++)if(this.rightList[u]!=this.pictures[u]){g=!1;break}g&&this.onSuccess()}else this.dragPic.x=this.distanceX,this.dragPic.y=this.distanceY},t.prototype.onSuccess=function(){console.log(\"拼图成功!\"),engine.globalEvent.dispatchEvent(\"pictures-game-success\",{time:GAME_TIME}),this.stop()},t.prototype.onMove=function(t){this.dragPic.x=t.stageX-this.localPicX-(750-props.W)/2,this.dragPic.y=t.stageY-this.localPicY-(this.stage.height-props.H)/2,this.centerX=this.dragPic.x+w/2,this.centerY=this.dragPic.y+h/2},t}(engine.Container),GameWrapper=function(i){function t(){var t=i.call(this)||this;engine.globalEvent.addEventListener(\"pictures-start\",t.start,t),engine.globalEvent.addEventListener(\"pictures-stop\",t.stop,t);var e=t._gameView=new GameView;return t.addChild(e),t}return tslib.__extends(t,i),t.prototype.start=function(t){injectProps(t.data),this._gameView.start()},t.prototype.stop=function(t){this._gameView.stop()},t}(engine.Container);function index(t){return prepareProps(),injectProps(t),new GameWrapper}module.exports=index;\n"
}
{
"name": "拼图",
"desc": "拼图模块1.0",
"props": {
"MAX_COL": {
"alias": "图片分成几列",
"type": "number",
"default": 3
},
"MAX_ROW": {
"alias": "图片分成几行",
"type": "number",
"default": 4
},
"W": {
"alias": "图片的宽度",
"type": "number",
"default": 618
},
"H": {
"alias": "图片的高度",
"type": "number",
"default": 827
},
"OFFSET_X": {
"alias": "OFFSET_X",
"type": "number",
"default": 0
},
"OFFSET_Y": {
"alias": "OFFSET_Y",
"type": "number",
"default": 0
},
"GAME_TIME": {
"alias": "游戏时间",
"type": "number",
"default": 30
},
"GAP": {
"alias": "图片间隙",
"type": "number",
"default": 0
}
},
"assets": [
{
"name": "遮罩",
"url": "//yun.duiba.com.cn/aurora/assets/5b3e30496b2d9fdafb0cf3835fd6704ce10e45b4.png",
"uuid": "888",
"ext": ".png"
},
{
"name": "背景",
"url": " //yun.duiba.com.cn/aurora/assets/57725dcf8cb23905afb87f42d7aba2ffa4c8d2d1.png",
"uuid": "308742a0-0ea2-4610-b34a-a230add82021",
"ext": ".png"
},
{
"name": "飞机",
"url": "//yun.duiba.com.cn/aurora/assets/1d2ba15cb8baf3e5783a9f865673dcf9a2421f19.png",
"uuid": "32ec481a-3f75-4c36-95ed-ee97aa936517",
"ext": ".png"
},
{
"name": "开始按钮",
"url": "//yun.duiba.com.cn/aurora/assets/2bed3a9e3cae15a6332397ca675c5d44849eaac2.png",
"uuid": "855e3d77-ffff-443d-b884-4f67a2ebe458",
"ext": ".png"
},
{
"name": "游戏背景",
"url": "//yun.duiba.com.cn/aurora/assets/5f56d60285f0e3b253716bc938a3c28cbb288cdf.png",
"uuid": "76820072-df5a-4ab7-8cb7-10c8cd8605c8",
"ext": ".png"
},
{
"name": "子弹",
"url": "//yun.duiba.com.cn/aurora/assets/06b3baba53973c01be8943b7a002e58de3bea7cf.png",
"uuid": "18852543-1f1d-498b-af64-88cd3b343758",
"ext": ".png"
},
{
"name": "敌机",
"url": "//yun.duiba.com.cn/aurora/assets/fc3b2a4349b098183b2b20c8a754b8b182d73806.png",
"uuid": "780b6b63-3abd-4246-94ba-2a3fbdb3c5af",
"ext": ".png"
},
{
"name": "small敌机",
"url": "//yun.duiba.com.cn/aurora/assets/1cded0d917c44d22ddce058f239e1cfac1b506c2.png",
"uuid": "57d4067e-c32f-4b12-a8fc-185753726fc6",
"ext": ".png"
},
{
"name": "击中",
"url": "//yun.duiba.com.cn/aurora/assets/251402a1991ef00a124ddd91f519a30147285e00.png",
"uuid": "38ec6627-efa8-4f7a-9bdc-3c73cea717f1",
"ext": ".png"
}
],
"events": {
"in": {
"pictures-start": {
"alias": "开始",
"data": {
"picUrl": "图片路径",
"blockUrl": "blockUrl",
"GAME_TIME": "每局的游戏时间",
"MAX_ROW": "行",
"MAX_COL": "列",
"W": "宽",
"H": "高",
"GAP": "图片间隙",
"OFFSET_X": "OFFSET_X",
"OFFSET_Y": "OFFSET_Y"
}
},
"pictures-stop": {
"alias": "停止"
}
},
"out": {
"pictures-time-update": {
"alias": "倒计时更新",
"data": {
"time": "剩余时间"
}
},
"pictures-game-fail": {
"alias": "游戏结束",
"data": {
"reason": "结束原因(1:时间到了)"
}
},
"pictures-game-success": {
"alias": "游戏成功",
"data": {
"time": "游戏消耗时间"
}
}
}
},
"id": "playWithPlane",
"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.playWithPlane = 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\t//# sourceMappingURL=utils.js.map\n\n\tvar Ball = (function (_super) {\r\n\t tslib.__extends(Ball, _super);\r\n\t function Ball() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.plane = new engine.Sprite();\r\n\t _this.addChild(_this.plane);\r\n\t return _this;\r\n\t }\r\n\t Ball.prototype.setPosition = function () { };\r\n\t Ball.prototype.died = function () { };\r\n\t return Ball;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=Ball.js.map\n\n\tvar SmallPlane = (function (_super) {\r\n\t tslib.__extends(SmallPlane, _super);\r\n\t function SmallPlane() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this._life = 3;\r\n\t _this.smallPlane = new engine.Sprite(getTexture('57d4067e-c32f-4b12-a8fc-185753726fc6'));\r\n\t _this.life = 3;\r\n\t _this.name = \"smallBall\";\r\n\t _this.addChild(_this.smallPlane);\r\n\t return _this;\r\n\t }\r\n\t SmallPlane.prototype.setPosition = function () {\r\n\t this.x = Math.random() * (750 - this.width);\r\n\t this.y = Math.random() * (this.height);\r\n\t };\r\n\t SmallPlane.prototype.died = function () {\r\n\t };\r\n\t return SmallPlane;\r\n\t}(Ball));\r\n\t//# sourceMappingURL=SmallBall.js.map\n\n\tvar Bullets = (function (_super) {\r\n\t tslib.__extends(Bullets, _super);\r\n\t function Bullets(_harm) {\r\n\t if (_harm === void 0) { _harm = 1; }\r\n\t var _this = _super.call(this) || this;\r\n\t _this.bulletPic = new engine.Sprite(getTexture('18852543-1f1d-498b-af64-88cd3b343758'));\r\n\t _this.bullets = [];\r\n\t _this.harm = _harm;\r\n\t _this.addChild(_this.bulletPic);\r\n\t return _this;\r\n\t }\r\n\t Bullets.prototype.addBullet = function (planeModel) {\r\n\t var bullet = new engine.Sprite(getTexture('18852543-1f1d-498b-af64-88cd3b343758'));\r\n\t bullet.x = planeModel ? planeModel.x + planeModel.width / 2 - bullet.width / 2 : 375 - bullet.width / 2;\r\n\t bullet.y = 1150;\r\n\t return bullet;\r\n\t };\r\n\t Bullets.prototype.createBullet = function (planeModel) {\r\n\t this.x = planeModel.x + planeModel.width / 2 - this.bulletPic.width / 2;\r\n\t this.y = 1150;\r\n\t };\r\n\t Bullets.prototype.addBulletNum = function (w) {\r\n\t };\r\n\t return Bullets;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=Bullets.js.map\n\n\tvar TestView = (function (_super) {\r\n\t tslib.__extends(TestView, _super);\r\n\t function TestView() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.planeArray = [\r\n\t {\r\n\t type: 'smallBall',\r\n\t enemyPlane: []\r\n\t },\r\n\t {\r\n\t type: 'middleBall',\r\n\t enemyPlane: []\r\n\t },\r\n\t {\r\n\t type: 'largeBall',\r\n\t enemyPlane: []\r\n\t }\r\n\t ];\r\n\t _this.bulletArray = [];\r\n\t _this.score = 0;\r\n\t _this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);\r\n\t return _this;\r\n\t }\r\n\t TestView.prototype.setup = function () {\r\n\t this.stageBg = new engine.Sprite(getTexture('308742a0-0ea2-4610-b34a-a230add82021'));\r\n\t this.addChild(this.stageBg);\r\n\t this.gameBg = new engine.Sprite(getTexture('76820072-df5a-4ab7-8cb7-10c8cd8605c8'));\r\n\t this.startBtn = new engine.Sprite(getTexture('855e3d77-ffff-443d-b884-4f67a2ebe458'));\r\n\t this.startBtn.x = (750 - this.startBtn.width) / 2;\r\n\t this.startBtn.y = (this.stage.height - this.startBtn.height) / 2 + 300;\r\n\t this.stageBg.addChild(this.startBtn);\r\n\t this.startBtn.addEventListener(engine.MouseEvent.CLICK, this.onClick, this);\r\n\t };\r\n\t TestView.prototype.start = function () {\r\n\t var _this = this;\r\n\t this.planeModel = new engine.Sprite(getTexture('32ec481a-3f75-4c36-95ed-ee97aa936517'));\r\n\t this.planeModel.x = (750 - this.planeModel.width) / 2;\r\n\t this.planeModel.y = (this.stage.height - this.planeModel.height);\r\n\t this.planeModel.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDown, this);\r\n\t this.gameBg.addChild(this.planeModel);\r\n\t var boom = new engine.Sprite(getTexture('38ec6627-efa8-4f7a-9bdc-3c73cea717f1'));\r\n\t setInterval(function () {\r\n\t var smallBall = new SmallPlane();\r\n\t smallBall.setPosition();\r\n\t console.log(_this.planeArray);\r\n\t for (var _i = 0, _a = _this.planeArray; _i < _a.length; _i++) {\r\n\t var planearray = _a[_i];\r\n\t if (planearray.type == smallBall.name) {\r\n\t console.log(planearray.enemyPlane);\r\n\t planearray.enemyPlane.push(smallBall);\r\n\t }\r\n\t }\r\n\t _this.gameBg.addChild(smallBall);\r\n\t }, 500);\r\n\t setInterval(function () {\r\n\t for (var _i = 0, _a = _this.planeArray; _i < _a.length; _i++) {\r\n\t var planearray = _a[_i];\r\n\t if (planearray.type === 'smallBall') {\r\n\t var _loop_1 = function (sball) {\r\n\t console.log(sball);\r\n\t sball.y += 1;\r\n\t if (sball.y > _this.stage.height) {\r\n\t _this.gameBg.removeChild(sball);\r\n\t var index_1 = planearray.enemyPlane.indexOf(sball);\r\n\t planearray.enemyPlane = planearray.enemyPlane.filter(function (ele, i) { return i != index_1; });\r\n\t }\r\n\t };\r\n\t for (var _b = 0, _c = planearray.enemyPlane; _b < _c.length; _b++) {\r\n\t var sball = _c[_b];\r\n\t _loop_1(sball);\r\n\t }\r\n\t }\r\n\t }\r\n\t }, 16);\r\n\t setInterval(function () {\r\n\t var bullet = new Bullets();\r\n\t bullet.createBullet(_this.planeModel);\r\n\t _this.bulletArray.push(bullet);\r\n\t _this.gameBg.addChild(bullet);\r\n\t }, 40);\r\n\t setInterval(function () {\r\n\t console.log(_this.score);\r\n\t var _loop_2 = function (bullet) {\r\n\t bullet.y -= 35;\r\n\t if (bullet.y < -40) {\r\n\t _this.gameBg.removeChild(bullet);\r\n\t var index_2 = _this.bulletArray.indexOf(bullet);\r\n\t _this.bulletArray = _this.bulletArray.filter(function (ele, i) { return i != index_2; });\r\n\t }\r\n\t for (var _i = 0, _a = _this.planeArray; _i < _a.length; _i++) {\r\n\t var planearray = _a[_i];\r\n\t if (planearray.type === 'smallBall') {\r\n\t var _loop_3 = function (splane) {\r\n\t var y = bullet.y - splane.y;\r\n\t var bulletRight = bullet.x + bullet.width;\r\n\t var planeRange = splane.x + splane.width;\r\n\t if (bulletRight > splane.x && bulletRight < planeRange || bullet.x > splane.x && bullet.x < planeRange) {\r\n\t if (y <= 0) {\r\n\t splane.life -= bullet.harm;\r\n\t _this.score += bullet.harm;\r\n\t _this.gameBg.removeChild(bullet);\r\n\t var index_3 = _this.bulletArray.indexOf(bullet);\r\n\t _this.bulletArray = _this.bulletArray.filter(function (ele, i) { return i != index_3; });\r\n\t if (splane.life === 0) {\r\n\t _this.gameBg.removeChild(splane);\r\n\t var ind_1 = planearray.enemyPlane.indexOf(splane);\r\n\t planearray.enemyPlane = planearray.enemyPlane.filter(function (ele, i) { return i != ind_1; });\r\n\t boom.x = splane.x;\r\n\t boom.y = splane.y;\r\n\t _this.gameBg.addChild(boom);\r\n\t setTimeout(function () {\r\n\t _this.gameBg.removeChild(boom);\r\n\t }, 1500);\r\n\t }\r\n\t }\r\n\t }\r\n\t };\r\n\t for (var _b = 0, _c = planearray.enemyPlane; _b < _c.length; _b++) {\r\n\t var splane = _c[_b];\r\n\t _loop_3(splane);\r\n\t }\r\n\t }\r\n\t }\r\n\t };\r\n\t for (var _i = 0, _a = _this.bulletArray; _i < _a.length; _i++) {\r\n\t var bullet = _a[_i];\r\n\t _loop_2(bullet);\r\n\t }\r\n\t }, 16);\r\n\t };\r\n\t TestView.prototype.onClick = function () {\r\n\t this.addChild(this.gameBg);\r\n\t this.gameBg.addChild(this.planeModel);\r\n\t };\r\n\t TestView.prototype.onDown = function (e) {\r\n\t this.mouseX = e.localX;\r\n\t this.mouseY = e.localY;\r\n\t this.stage.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMove, this);\r\n\t this.planeModel.x = e.stageX - this.mouseX;\r\n\t this.planeCenterX = this.planeModel.x + this.planeModel.width / 2;\r\n\t };\r\n\t TestView.prototype.onMove = function (e) {\r\n\t this.centerX = this.planeModel.width / 2;\r\n\t var movedCenter = this.centerX + e.stageX - this.mouseX;\r\n\t if (movedCenter < 0) {\r\n\t this.planeModel.x = -this.centerX;\r\n\t }\r\n\t else if (movedCenter > 750) {\r\n\t this.planeModel.x = 750 - this.centerX;\r\n\t }\r\n\t else {\r\n\t this.planeModel.x = e.stageX - this.mouseX;\r\n\t this.planeCenterX = this.planeModel.x + this.planeModel.width / 2;\r\n\t }\r\n\t };\r\n\t TestView.prototype.stop = function () {\r\n\t };\r\n\t return TestView;\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 engine.globalEvent.addEventListener('pictures-start', _this.start, _this);\r\n\t engine.globalEvent.addEventListener('pictures-stop', _this.stop, _this);\r\n\t var testView = _this._testView = new TestView();\r\n\t _this.addChild(testView);\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._testView.start();\r\n\t };\r\n\t GameWrapper.prototype.stop = function (event) {\r\n\t this._testView.stop();\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"
}
{
"name": "拼图",
"desc": "拼图模块1.0",
"props": {
"MAX_COL": {
"alias": "图片分成几列",
"type": "number",
"default": 3
},
"MAX_ROW": {
"alias": "图片分成几行",
"type": "number",
"default": 4
},
"W": {
"alias": "图片的宽度",
"type": "number",
"default": 618
},
"H": {
"alias": "图片的高度",
"type": "number",
"default": 827
},
"OFFSET_X": {
"alias": "OFFSET_X",
"type": "number",
"default": 0
},
"OFFSET_Y": {
"alias": "OFFSET_Y",
"type": "number",
"default": 0
},
"GAME_TIME": {
"alias": "游戏时间",
"type": "number",
"default": 30
},
"GAP": {
"alias": "图片间隙",
"type": "number",
"default": 0
}
},
"assets": [
{
"name": "遮罩",
"url": "//yun.duiba.com.cn/aurora/assets/5b3e30496b2d9fdafb0cf3835fd6704ce10e45b4.png",
"uuid": "888",
"ext": ".png"
}
],
"events": {
"in": {
"pictures-start": {
"alias": "开始",
"data": {
"picUrl": "图片路径",
"blockUrl": "blockUrl",
"GAME_TIME": "每局的游戏时间",
"MAX_ROW": "行",
"MAX_COL": "列",
"W": "宽",
"H": "高",
"GAP": "图片间隙",
"OFFSET_X": "OFFSET_X",
"OFFSET_Y": "OFFSET_Y"
}
},
"pictures-stop": {
"alias": "停止"
}
},
"out": {
"pictures-time-update": {
"alias": "倒计时更新",
"data": {
"time": "剩余时间"
}
},
"pictures-game-fail": {
"alias": "游戏结束",
"data": {
"reason": "结束原因(1:时间到了)"
}
},
"pictures-game-success": {
"alias": "游戏成功",
"data": {
"time": "游戏消耗时间"
}
}
}
},
"id": "rounds-pic",
"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['rounds-pic'] = 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\tvar qietu = (function (parent, url, MAX_COL, MAX_ROW) {\r\n\t var W = props.W;\r\n\t var H = props.H;\r\n\t var GAP = props.GAP;\r\n\t var spr = [];\r\n\t var pos = [];\r\n\t var _loop_1 = function (row) {\r\n\t var _loop_2 = function (col) {\r\n\t var child = new engine.Sprite();\r\n\t child.scaleX = 1 / MAX_COL;\r\n\t child.scaleY = 1 / MAX_ROW;\r\n\t parent.addChild(child);\r\n\t child.x = col * (W / MAX_COL + GAP);\r\n\t child.y = row * (H / MAX_ROW + GAP);\r\n\t pos.push([child.x, child.y]);\r\n\t spr.push(child);\r\n\t child.addEventListener(engine.Event.COMPLETE, function () {\r\n\t var uvs = new Float32Array([\r\n\t col / MAX_COL,\r\n\t row / MAX_ROW,\r\n\t (col + 1) / MAX_COL,\r\n\t row / MAX_ROW,\r\n\t (col + 1) / MAX_COL,\r\n\t (row + 1) / MAX_ROW,\r\n\t col / MAX_COL,\r\n\t (row + 1) / MAX_ROW,\r\n\t ]);\r\n\t child.uvs = uvs;\r\n\t });\r\n\t child.texture = engine.Texture.fromImage(url);\r\n\t };\r\n\t for (var col = 0; col < MAX_COL; col++) {\r\n\t _loop_2(col);\r\n\t }\r\n\t };\r\n\t for (var row = 0; row < MAX_ROW; row++) {\r\n\t _loop_1(row);\r\n\t }\r\n\t console.log(spr);\r\n\t return [spr, pos];\r\n\t});\r\n\t//# sourceMappingURL=qietu.js.map\n\n\tfunction getIndexFromRC(row, col, maxCol) {\r\n\t var index;\r\n\t index = row * maxCol + col;\r\n\t return index;\r\n\t}\r\n\tfunction getRandomArray(array) {\r\n\t array.sort(function () {\r\n\t return 0.5 - Math.random();\r\n\t });\r\n\t}\n\n\tvar MAX_COL;\r\n\tvar MAX_ROW;\r\n\tvar W;\r\n\tvar H;\r\n\tvar GAP;\r\n\tvar GAME_TIME;\r\n\tvar w;\r\n\tvar h;\r\n\tvar picUrl;\r\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._timeCounter = 0;\r\n\t _this._result = [];\r\n\t _this.listenStageOn = 1;\r\n\t _this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);\r\n\t return _this;\r\n\t }\r\n\t GameView.prototype.start = function () {\r\n\t var _this = this;\r\n\t picUrl = props.picUrl;\r\n\t MAX_COL = props.MAX_COL;\r\n\t MAX_ROW = props.MAX_ROW;\r\n\t GAME_TIME = props.GAME_TIME;\r\n\t W = props.W;\r\n\t H = props.H;\r\n\t GAP = props.GAP;\r\n\t w = W / MAX_COL;\r\n\t h = H / MAX_ROW;\r\n\t console.log('on start');\r\n\t engine.globalEvent.dispatchEvent('pictures-time-update', {\r\n\t second: this.getSecond(),\r\n\t });\r\n\t if (this._result.length !== 0) {\r\n\t this._result = [];\r\n\t }\r\n\t this._result = qietu(this.picturesWrapper, picUrl, MAX_COL, MAX_ROW);\r\n\t this.pictures = this._result[0];\r\n\t if (this.rightList !== null) {\r\n\t this.rightList = [];\r\n\t }\r\n\t this.rightList = this.pictures.concat([]);\r\n\t var posList = this._result[1];\r\n\t getRandomArray(this.pictures);\r\n\t var i = 0;\r\n\t var len;\r\n\t len = this.pictures.length;\r\n\t for (; i < len; i++) {\r\n\t this.dragPic = this.pictures[i];\r\n\t this.pictures[i].addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDown, this);\r\n\t var _a = posList[i], x = _a[0], y = _a[1];\r\n\t this.dragPic.x = x;\r\n\t this.dragPic.y = y;\r\n\t }\r\n\t this._timer = setInterval(function () {\r\n\t _this.onTimer();\r\n\t }, 10);\r\n\t this.date = new Date().getTime();\r\n\t };\r\n\t GameView.prototype.onTimer = function () {\r\n\t var date = new Date().getTime();\r\n\t var gap = ((date - this.date) / 1000);\r\n\t this.date = date;\r\n\t GAME_TIME -= gap;\r\n\t if (GAME_TIME < 0) {\r\n\t GAME_TIME = 0;\r\n\t }\r\n\t GAME_TIME = this.afterPointTwo(GAME_TIME);\r\n\t GAME_TIME = GAME_TIME.toFixed(2);\r\n\t if (GAME_TIME < 10) {\r\n\t GAME_TIME = '0' + GAME_TIME;\r\n\t }\r\n\t engine.globalEvent.dispatchEvent('pictures-time-update', {\r\n\t second: this.getSecond(),\r\n\t });\r\n\t if (this.getSecond() == 0) {\r\n\t this.stop();\r\n\t engine.globalEvent.dispatchEvent('pictures-game-fail', {\r\n\t reason: 1\r\n\t });\r\n\t this.stage.removeEventListener(engine.MouseEvent.MOUSE_UP, this.stageOnUp, this);\r\n\t }\r\n\t };\r\n\t GameView.prototype.afterPointTwo = function (n) {\r\n\t var floatN = parseFloat(n);\r\n\t if (isNaN(floatN)) {\r\n\t return;\r\n\t }\r\n\t floatN = Math.round(floatN * 100) / 100;\r\n\t return floatN;\r\n\t };\r\n\t GameView.prototype.getSecond = function () {\r\n\t return GAME_TIME;\r\n\t };\r\n\t GameView.prototype.stop = function () {\r\n\t GAME_TIME = props.GAME_TIME;\r\n\t clearInterval(this._timer);\r\n\t var len = this.pictures.length;\r\n\t for (var i = 0; i < len; i++) {\r\n\t this.pictures[i].removeAllEventListener();\r\n\t }\r\n\t };\r\n\t GameView.prototype.createRects = function () { };\r\n\t GameView.prototype.setup = function () {\r\n\t console.log('onSteup', props);\r\n\t var parent = new engine.Sprite();\r\n\t this.picturesWrapper = parent;\r\n\t this.addChild(parent);\r\n\t };\r\n\t GameView.prototype.onDown = function (e) {\r\n\t var stageLeft = (750 - props.W) / 2;\r\n\t var stageTop = (this.stage.height - props.H) / 2;\r\n\t this.dragPic = e.target;\r\n\t this.picturesWrapper.addChild(this.dragPic);\r\n\t this.localPicX = e.localX / MAX_COL;\r\n\t this.localPicY = e.localY / MAX_ROW;\r\n\t this.distanceX = this.dragPic.x;\r\n\t this.distanceY = this.dragPic.y;\r\n\t this.indexJ = Math.floor((this.distanceX) / (w + GAP));\r\n\t this.indexI = Math.floor((this.distanceY) / (h + GAP));\r\n\t this.index = (this.indexI) * MAX_COL + this.indexJ;\r\n\t this.centerX = Math.floor((e.clientX - stageLeft) / w) * w + w / 2;\r\n\t this.centerY = Math.floor((e.clientY - stageTop) / h) * h + h / 2;\r\n\t this.stage.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMove, this);\r\n\t this.stage.addEventListener(engine.MouseEvent.MOUSE_UP, this.stageOnUp, this);\r\n\t };\r\n\t GameView.prototype.stageOnUp = function (e) {\r\n\t var stageLeft = (750 - props.W) / 2;\r\n\t var stageTop = (this.stage.height - props.H) / 2;\r\n\t this.stage.removeEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMove, this);\r\n\t this.stage.removeEventListener(engine.MouseEvent.MOUSE_UP, this.stageOnUp, this);\r\n\t if (this.centerY < stageTop || this.centerX < stageLeft) {\r\n\t this.dragPic.x = this.distanceX;\r\n\t this.dragPic.y = this.distanceY;\r\n\t }\r\n\t var curJ = Math.floor(this.centerX / (w + GAP));\r\n\t var curI = Math.floor(this.centerY / (h + GAP));\r\n\t if (0 <= curJ && curJ < (MAX_COL) && 0 <= curI && curI < (MAX_ROW)) {\r\n\t var index = getIndexFromRC(curI, curJ, MAX_COL);\r\n\t var dropPic = this.pictures[index];\r\n\t var dropPicX = dropPic.x + stageLeft;\r\n\t var dropPicy = dropPic.y + stageTop;\r\n\t dropPic.x = this.distanceX;\r\n\t dropPic.y = this.distanceY;\r\n\t this.dragPic.x = dropPicX - stageLeft;\r\n\t this.dragPic.y = dropPicy - stageTop;\r\n\t var dropPicIndex = this.pictures.indexOf(dropPic);\r\n\t var dragPicIndex = this.pictures.indexOf(this.dragPic);\r\n\t this.pictures[dropPicIndex] = this.dragPic;\r\n\t this.pictures[dragPicIndex] = dropPic;\r\n\t if (dragPicIndex === dropPicIndex) {\r\n\t this.dragPic.x = this.distanceX;\r\n\t this.dragPic.y = this.distanceY;\r\n\t }\r\n\t var result = true;\r\n\t for (var j = 0; j < this.rightList.length; j++) {\r\n\t if (this.rightList[j] != this.pictures[j]) {\r\n\t result = false;\r\n\t break;\r\n\t }\r\n\t }\r\n\t if (result) {\r\n\t this.onSuccess();\r\n\t }\r\n\t }\r\n\t else {\r\n\t this.dragPic.x = this.distanceX;\r\n\t this.dragPic.y = this.distanceY;\r\n\t }\r\n\t };\r\n\t GameView.prototype.onSuccess = function () {\r\n\t console.log('拼图成功!');\r\n\t engine.globalEvent.dispatchEvent('pictures-game-success', { time: GAME_TIME });\r\n\t this.stop();\r\n\t props.GAME_TIME *= 0.9;\r\n\t ++props.MAX_ROW;\r\n\t ++props.MAX_COL;\r\n\t };\r\n\t GameView.prototype.onMove = function (e) {\r\n\t this.dragPic.x = e.stageX - this.localPicX - (750 - props.W) / 2;\r\n\t this.dragPic.y = e.stageY - this.localPicY - (this.stage.height - props.H) / 2;\r\n\t this.centerX = this.dragPic.x + w / 2;\r\n\t this.centerY = this.dragPic.y + h / 2;\r\n\t };\r\n\t return GameView;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=GameView.js.map\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 engine.globalEvent.addEventListener('pictures-start', _this.start, _this);\r\n\t engine.globalEvent.addEventListener('pictures-stop', _this.stop, _this);\r\n\t var gameView = _this._gameView = new GameView();\r\n\t _this.addChild(gameView);\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.stop = function (event) {\r\n\t this._gameView.stop();\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 = 'getAwayFromCloud';
(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/f57e4cbfe6bb27333c8d53ed1031624c4e0500aa.pnghttp://yun.duiba.com.cn/aurora/assets/e1593b97c27077b85b92f7eaaeae1ed64a1eb79a.png",
blockUrl: "c9ff7c30-2734-417d-a811-d88b6b7140b8",
});
// 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('cloud-time-update', (e) => {
// console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('cloud-game-fail', (e) => {
console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('cloud-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.getAwayFromCloud = factory(global.tslib));
}(this, (function (tslib) { 'use strict';
function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
//# sourceMappingURL=utils.js.map
var Human = (function (_super) {
tslib.__extends(Human, _super);
function Human() {
var _this = _super.call(this) || this;
_this.humanArray = [
'487c1ca7-dea5-4732-b4b6-acb5406ee3a4',
'71e07cee-fd6d-40bb-ac0b-5bb28c87276e',
'2cd9f1bb-d0d8-42ea-941b-dcd0428e474d'
];
_this.human = new engine.Sprite(getTexture(_this.humanArray[0]));
_this.addChild(_this.human);
_this.width = _this.human.width;
_this.height = _this.human.height;
return _this;
}
Human.prototype.facialChange = function (num) {
var face = new engine.Sprite(getTexture(this.humanArray[num]));
this.human.addChild(face);
return face;
};
Human.prototype.removeFace = function (face) {
this.human.removeChild(face);
};
return Human;
}(engine.Container));
//# sourceMappingURL=Human.js.map
var Moist = (function (_super) {
tslib.__extends(Moist, _super);
function Moist() {
var _this = _super.call(this) || this;
_this.moistBg = new engine.Sprite(getTexture('8a8e79b6-2c6f-441b-81ae-c441465abfb0'));
_this.moist = new engine.Sprite(getTexture('024d67e9-ed7f-4481-94ca-a15bd5226cad'));
_this.moistCover = new engine.Sprite(getTexture('024d67e9-ed7f-4481-94ca-a15bd5226cad'));
_this.txt = new engine.TextInput();
_this.hintpic = new engine.Sprite(getTexture('ed0e8931-2557-4527-bcfc-9071f90d5737'));
_this.percent = 0;
_this.addChild(_this.moistBg);
_this.moistBg.addChild(_this.moist);
_this.moist.mask = _this.moistCover;
_this.txt.text = _this.percent * 100 + '%';
_this.txt.size = 30;
_this.txt.fillColor = '#7A83C5';
_this.addChild(_this.txt);
_this.txt.x = 0;
_this.txt.y = -50;
_this.hintpic.x = -10;
_this.hintpic.y = 440;
_this.addChild(_this.hintpic);
return _this;
}
Moist.prototype.cover = function (percent) {
this.moistCover.anchorY = 416;
this.moistBg.addChild(this.moistCover);
this.moistCover.scaleY = percent;
};
Moist.prototype.stopScale = function () {
this.moistCover.scaleY = 1;
this.txt.text = '100%';
};
Moist.prototype.updateText = function (percent) {
var a = percent * 100;
if (a <= 90) {
this.txt.text = a.toPrecision(2) + '%';
}
else {
this.txt.text = a.toPrecision(3) + '%';
}
};
return Moist;
}(engine.Container));
//# sourceMappingURL=Moist.js.map
var TimeCounter = (function (_super) {
tslib.__extends(TimeCounter, _super);
function TimeCounter() {
var _this = _super.call(this) || this;
_this.timeCounter = new engine.Sprite(getTexture('b7d2a60a-9e60-4eca-be80-a991abea47c9'));
_this.time = 20;
_this.addChild(_this.timeCounter);
_this.timeCounter.x = 256;
_this.timeCounter.y = 50;
_this.timeText = new engine.TextInput();
_this.timeText.text = _this.time + 's';
_this.timeText.size = 48;
_this.timeText.fillColor = '#7A83C5';
_this.timeCounter.addChild(_this.timeText);
_this.timeText.x = 100;
_this.timeText.y = 15;
return _this;
}
TimeCounter.prototype.updateTime = function (time) {
this.time = time;
this.timeText.text = this.time + 's';
};
return TimeCounter;
}(engine.Container));
//# sourceMappingURL=TimeCounter.js.map
var CloudRain = (function (_super) {
tslib.__extends(CloudRain, _super);
function CloudRain() {
var _this = _super.call(this) || this;
_this.clound1 = new engine.Sprite(getTexture('1e1a6993-9da0-4813-b1bd-00f2dbae2af2'));
_this.clound2 = new engine.Sprite(getTexture('6ed0e2e7-3ba3-4967-8fe0-39667792e343'));
_this.sun = new engine.Sprite(getTexture("0f05aaae-338a-439a-82b0-20efcee5cca4"));
_this.sun.x = 90;
_this.sun.y = 120;
_this.addChild(_this.sun);
_this.addChild(_this.clound1);
_this.addChild(_this.clound2);
_this.clound1.x = 100;
_this.clound1.y = 220;
_this.clound2.x = 150;
_this.clound2.y = 220;
return _this;
}
CloudRain.prototype.succeed = function () {
var _this = this;
var a = 0;
var ld = Date.now();
this.addEventListener(engine.Event.ENTER_FRAME, function () {
var dt = Date.now() - ld;
a += dt;
if (a > 100) {
_this.clound1.x -= (800 * dt) / 1000;
_this.clound2.x += (820 * dt) / 1000;
if (_this.clound1.x <= -380) {
_this.clound1.x = -380;
}
if (_this.clound2.x >= 750) {
_this.clound2.x = 750;
}
_this.sun.y -= (150 * dt) / 1000;
if (_this.sun.y <= 60) {
_this.sun.y = 60;
}
}
ld = Date.now();
});
};
return CloudRain;
}(engine.Container));
//# sourceMappingURL=CloudRain.js.map
var GameTest = (function (_super) {
tslib.__extends(GameTest, _super);
function GameTest() {
var _this = _super.call(this) || this;
_this.dripArray = [];
_this.clicknum = 0;
_this.R = 250;
_this.D = 340;
_this.con = new engine.Sprite();
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
return _this;
}
GameTest.prototype.setup = function () {
var playBg = new engine.Sprite(getTexture("5ab43bdc-a6ce-46fb-99c2-a806f57f7484"));
this.addChild(playBg);
this.humanbeing = new Human();
this.humanbeing.x = 290;
this.humanbeing.y = 750;
this.addChild(this.humanbeing);
console.log("xxxxxx", this.stage.width, this.stage.height, this.width, this.height);
this.rightHand = new engine.Sprite(getTexture("c7129f77-92a6-479e-9994-7d4b39040a15"));
this.rightHand.x = -70;
this.rightHand.y = -65;
this.rightHand.anchorX = 196;
this.rightHand.anchorY = 253;
this.humanbeing.addChild(this.rightHand);
this.playBtn = new engine.Sprite(getTexture("9e347bef-6e91-4c92-ba5f-f9a52e656207"));
this.playBtn.x = 138;
this.playBtn.y = 1150;
this.addChild(this.playBtn);
this.moists = new Moist();
this.moists.x = 20;
this.moists.y = 450;
this.addChild(this.moists);
this.cloud = new CloudRain();
this.addChild(this.cloud);
};
GameTest.prototype.start = function () {
var _this = this;
var middleX = this.humanbeing.x + this.humanbeing.width / 2;
var validX1 = this.humanbeing.x;
var validX2 = this.humanbeing.x + this.humanbeing.width;
for (var i = 0; i < 1000; i++) {
var y = -Math.sqrt(this.R * this.R - (i - middleX - 50) * (i - middleX - 50)) +
(this.humanbeing.y + 180);
var img = new engine.Sprite(getTexture("e4a82aee-4472-4b06-bd75-02fb64f1c8c8"));
img.width = 2;
img.height = 2;
img.x = i;
img.y = y;
this.con.addChild(img);
}
this.addChild(this.con);
var point1 = new engine.Graphics();
point1.beginFill(0xff0000);
point1.drawRect(0, 0, 10, 10);
point1.y = 100;
point1.endFill();
this.rightHand.addChild(point1);
var point2 = new engine.Graphics();
point2.beginFill(0xff0000);
point2.drawRect(0, 0, 10, 10);
point2.x = 170;
point2.endFill();
this.rightHand.addChild(point2);
var point3 = new engine.Graphics();
point3.beginFill(0xff0000);
point3.drawRect(0, 0, 10, 10);
point3.x = 330;
point3.y = 100;
point3.endFill();
this.rightHand.addChild(point3);
this.timeCounter = new TimeCounter();
this.addChild(this.timeCounter);
var ld = Date.now();
var a = 0;
var b = 0;
var drip = new engine.Sprite(getTexture("07f74bf6-416f-445e-98d5-021efe4c9fdc"));
drip.x =
Math.random() * (this.humanbeing.x + 160) +
(this.humanbeing.x - 160);
drip.worldMatrix.ty = Math.random() * 100 + 300;
this.dripArray.push(drip);
this.addChild(drip);
this.addEventListener(engine.Event.ENTER_FRAME, function () {
var dt = Date.now() - ld;
a += dt;
b += dt;
if (a > 200) {
a = 0;
if (_this.timeCounter.time > 0) {
var drip_1 = new engine.Sprite(getTexture("07f74bf6-416f-445e-98d5-021efe4c9fdc"));
drip_1.x =
Math.random() * (_this.humanbeing.x + 160) +
(_this.humanbeing.x - 160);
drip_1.worldMatrix.ty = Math.random() * 100 + 300;
_this.dripArray.push(drip_1);
_this.addChild(drip_1);
}
}
var _loop_1 = function (drip_2) {
drip_2.y += (300 * dt) / 1000;
if (drip_2.y > _this.stage.height) {
var index_1 = _this.dripArray.indexOf(drip_2);
_this.removeChild(drip_2);
_this.dripArray = _this.dripArray.filter(function (ele, i) { return i != index_1; });
}
};
for (var _i = 0, _a = _this.dripArray; _i < _a.length; _i++) {
var drip_2 = _a[_i];
_loop_1(drip_2);
}
if (b >= 1000) {
b = 0;
_this.timeCounter.time -= 1;
if (_this.timeCounter.time <= 0) {
_this.timeCounter.time = 0;
}
_this.timeCounter.updateTime(_this.timeCounter.time);
if (_this.timeCounter.time <= 0) {
console.log("游戏成功!");
_this.success();
}
}
var wind = -40;
_this.rightHand.rotation += wind / 60;
if (_this.rightHand.rotation <= -90) {
_this.rightHand.rotation = -90;
}
else if (_this.rightHand.rotation >= 90) {
_this.rightHand.rotation = 90;
}
ld = Date.now();
_this.angle = Math.asin(_this.D / 2 / _this.R) * 57.18;
_this.rightHand.name = "aaa";
if (_this.stage.height > 1334) ;
var k12 = (point1.worldMatrix.ty - point2.worldMatrix.ty) /
(point1.worldMatrix.tx - point2.worldMatrix.tx);
var k23 = (point2.worldMatrix.ty - point3.worldMatrix.ty) /
(point2.worldMatrix.tx - point3.worldMatrix.tx);
var px1 = point1.worldMatrix.tx;
var px2 = point2.worldMatrix.tx;
var px3 = point3.worldMatrix.tx;
var maxX = px1 >= px2 ? (px1 >= px3 ? px1 : px3) : px2 >= px3 ? px2 : px3;
var minX = px1 >= px2 ? (px2 >= px3 ? px3 : px2) : px1 >= px3 ? px3 : px1;
var _loop_2 = function (drip_3) {
var b12 = point1.worldMatrix.ty -
point1.worldMatrix.tx * k12 - 50;
var b23 = point2.worldMatrix.ty -
point2.worldMatrix.tx * k23 - 50;
var y12 = k12 * drip_3.x + b12;
var y23 = k23 * drip_3.x + b23;
if (drip_3.x > minX && drip_3.x < maxX) {
if (drip_3.x < px2) {
if (drip_3.worldMatrix.ty >= y12) {
var index_2 = _this.dripArray.indexOf(drip_3);
_this.removeChild(drip_3);
_this.dripArray = _this.dripArray.filter(function (ele, i) { return i != index_2; });
}
}
if (drip_3.x >= px2) {
if (drip_3.worldMatrix.ty >= y23) {
var index_3 = _this.dripArray.indexOf(drip_3);
_this.removeChild(drip_3);
_this.dripArray = _this.dripArray.filter(function (ele, i) { return i != index_3; });
}
}
}
if (drip_3.x > _this.humanbeing.x &&
drip_3.x < _this.humanbeing.x + _this.humanbeing.width) {
if (drip_3.y >= _this.humanbeing.y) {
_this.moists.percent += 0.1;
_this.moists.cover(_this.moists.percent);
_this.moists.updateText(_this.moists.percent);
if (_this.moists.percent >= 1) {
_this.moists.stopScale();
console.log("游戏结束!");
_this.stop();
}
_this.removeChild(drip_3);
var face_1 = _this.humanbeing.facialChange(2);
face_1.x = 7;
face_1.y = 22;
setTimeout(function () {
_this.humanbeing.removeFace(face_1);
}, 1000);
console.log("人");
var index_4 = _this.dripArray.indexOf(drip_3);
_this.dripArray = _this.dripArray.filter(function (ele, i) { return i != index_4; });
}
}
};
for (var _b = 0, _c = _this.dripArray; _b < _c.length; _b++) {
var drip_3 = _c[_b];
_loop_2(drip_3);
}
ld = Date.now();
});
this.playBtn.addEventListener(engine.MouseEvent.CLICK, this.onClick, this);
};
GameTest.prototype.onClick = function () {
this.clicknum += 1;
this.rightHand.rotation += 10 * this.clicknum;
this.clicknum = 0;
};
GameTest.prototype.stop = function () {
engine.globalEvent.dispatchEvent("cloud-game-fail", { reason: 1 });
};
GameTest.prototype.success = function () {
this.cloud.succeed();
engine.globalEvent.dispatchEvent("cloud-game-success", {
moist: this.moists.percent,
});
};
return GameTest;
}(engine.Container));
var props = {};
function prepareProps() {
var metaProps = getProps();
engine.injectProp(props, metaProps);
}
function injectProps(p) {
engine.injectProp(props, p);
}
//# sourceMappingURL=props.js.map
var GameWrapper = (function (_super) {
tslib.__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('pictures-start', _this.start, _this);
engine.globalEvent.addEventListener('pictures-stop', _this.stop, _this);
var gameTest = _this._gameTest = new GameTest();
_this.addChild(gameTest);
return _this;
}
GameWrapper.prototype.start = function (event) {
injectProps(event.data);
this._gameTest.start();
};
GameWrapper.prototype.stop = function (event) {
this._gameTest.stop();
};
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/getAwayFromCloud/src/game/utils.ts","src/custom/getAwayFromCloud/src/game/Human.ts","src/custom/getAwayFromCloud/src/game/Moist.ts","src/custom/getAwayFromCloud/src/game/TimeCounter.ts","src/custom/getAwayFromCloud/src/game/CloudRain.ts","src/custom/getAwayFromCloud/src/game/GameTest.ts","src/custom/getAwayFromCloud/src/props.ts","src/custom/getAwayFromCloud/src/game/GameWrapper.ts","src/custom/getAwayFromCloud/src/index.ts"],"sourcesContent":["/**\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 getIndexFromRC(row,col,maxCol){\r\n\tlet index;\r\n\tindex = row * maxCol + col ;\r\n\treturn index\r\n}\r\n\r\n\r\n\r\n\r\nexport function getRandomArray(array){\r\n\tarray.sort(function() {\r\n\t\treturn .5 - Math.random();\r\n\t});\r\n}","import {getTexture} from './utils'\r\n\r\nexport default class Human extends engine.Container{\r\n \r\n //常态,吃力,沮丧\r\n humanArray = [\r\n '487c1ca7-dea5-4732-b4b6-acb5406ee3a4',\r\n '71e07cee-fd6d-40bb-ac0b-5bb28c87276e',\r\n '2cd9f1bb-d0d8-42ea-941b-dcd0428e474d'\r\n ]\r\n //三张面部表情\r\n human:engine.Sprite = new engine.Sprite(getTexture(this.humanArray[0]))\r\n\r\n constructor(){\r\n super();\r\n this.addChild(this.human)\r\n this.width = this.human.width;\r\n this.height = this.human.height;\r\n }\r\n\r\n facialChange(num){\r\n let face = new engine.Sprite(getTexture(this.humanArray[num]));\r\n this.human.addChild(face);\r\n return face;\r\n }\r\n\r\n removeFace(face){\r\n this.human.removeChild(face);\r\n }\r\n}","import {getTexture} from './utils'\r\n\r\nexport default class Moist extends engine.Container{\r\n\r\n percent:number\r\n moistBg:engine.Sprite = new engine.Sprite(getTexture('8a8e79b6-2c6f-441b-81ae-c441465abfb0'))\r\n moist:engine.Sprite = new engine.Sprite(getTexture('024d67e9-ed7f-4481-94ca-a15bd5226cad'))\r\n moistCover:any = new engine.Sprite(getTexture('024d67e9-ed7f-4481-94ca-a15bd5226cad'))\r\n txt = new engine.TextInput();\r\n hintpic:engine.Sprite = new engine.Sprite(getTexture('ed0e8931-2557-4527-bcfc-9071f90d5737'))\r\n constructor(){\r\n super();\r\n this.percent = 0;\r\n this.addChild(this.moistBg)\r\n this.moistBg.addChild(this.moist)\r\n this.moist.mask = this.moistCover;\r\n\r\n\r\n this.txt.text = this.percent*100+'%';\r\n this.txt.size = 30;\r\n this.txt.fillColor = '#7A83C5';\r\n this.addChild(this.txt)\r\n this.txt.x = 0;\r\n this.txt.y = -50;\r\n\r\n this.hintpic.x = -10;\r\n this.hintpic.y = 440;\r\n this.addChild(this.hintpic)\r\n }\r\n\r\n cover(percent){\r\n this.moistCover.anchorY = 416;\r\n this.moistBg.addChild(this.moistCover)\r\n this.moistCover.scaleY = percent;\r\n }\r\n\r\n stopScale(){\r\n this.moistCover.scaleY = 1;\r\n this.txt.text = '100%';\r\n }\r\n\r\n updateText(percent){\r\n let a = percent * 100;\r\n if(a <=90){\r\n this.txt.text = a.toPrecision(2)+'%';\r\n }else{\r\n this.txt.text = a.toPrecision(3)+'%';\r\n }\r\n }\r\n\r\n}","import {getTexture} from './utils'\r\n\r\nexport default class TimeCounter extends engine.Container{\r\n timeCounter:engine.Sprite = new engine.Sprite(getTexture('b7d2a60a-9e60-4eca-be80-a991abea47c9'));\r\n timeText:any;\r\n time:number\r\n constructor(){\r\n super()\r\n this.time = 20\r\n this.addChild(this.timeCounter)\r\n\r\n this.timeCounter.x = 256;\r\n this.timeCounter.y = 50;\r\n // 计时文本\r\n this.timeText = new engine.TextInput();\r\n this.timeText.text = this.time +'s';\r\n this.timeText.size = 48;\r\n this.timeText.fillColor = '#7A83C5';\r\n this.timeCounter.addChild(this.timeText);\r\n this.timeText.x = 100;\r\n this.timeText.y = 15;\r\n }\r\n\r\n updateTime(time){\r\n this.time = time;\r\n this.timeText.text = this.time + 's'\r\n }\r\n\r\n\r\n}","import {getTexture} from './utils'\r\n\r\nexport default class CloudRain extends engine.Container{\r\n\r\n clound1:engine.Sprite = new engine.Sprite(getTexture('1e1a6993-9da0-4813-b1bd-00f2dbae2af2'))\r\n clound2:engine.Sprite = new engine.Sprite(getTexture('6ed0e2e7-3ba3-4967-8fe0-39667792e343'))\r\n sun = new engine.Sprite(getTexture(\"0f05aaae-338a-439a-82b0-20efcee5cca4\"));\r\n \r\n constructor(){\r\n super()\r\n this.sun.x = 90;\r\n this.sun.y = 120;\r\n this.addChild(this.sun)\r\n\r\n this.addChild(this.clound1);\r\n this.addChild(this.clound2);\r\n\r\n this.clound1.x = 100;\r\n this.clound1.y = 220;\r\n this.clound2.x = 150;\r\n this.clound2.y = 220;\r\n\r\n }\r\n\r\n succeed(){\r\n // 380 580\r\n let a = 0\r\n let ld = Date.now();\r\n this.addEventListener(engine.Event.ENTER_FRAME,()=>{\r\n let dt = Date.now() - ld;\r\n a += dt;\r\n if(a>100){\r\n this.clound1.x -= (800 * dt) / 1000;\r\n this.clound2.x += (820*dt)/1000;\r\n if(this.clound1.x <= -380){\r\n this.clound1.x = -380;\r\n }\r\n if(this.clound2.x >= 750){\r\n this.clound2.x = 750;\r\n }\r\n\r\n this.sun.y -= (150 * dt) / 1000;\r\n if(this.sun.y <= 60){\r\n this.sun.y = 60;\r\n }\r\n }\r\n ld = Date.now();\r\n })\r\n }\r\n\r\n\r\n \r\n\r\n\r\n\r\n}","import { getTexture } from \"./utils\";\r\n\r\nimport Human from \"./Human\";\r\nimport Moist from \"./Moist\";\r\nimport TimeCounter from \"./TimeCounter\";\r\nimport CloudRain from \"./CloudRain\";\r\n\r\nexport default class GameTest extends engine.Container {\r\n constructor() {\r\n super();\r\n this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);\r\n }\r\n\r\n rightHand: engine.Sprite;\r\n ambrella: engine.Sprite;\r\n playBtn: engine.Sprite;\r\n human: engine.Sprite;\r\n\r\n humanbeing: Human;\r\n moists: Moist;\r\n contain: any;\r\n timeCounter: TimeCounter;\r\n cloudRain: CloudRain;\r\n cloud: CloudRain;\r\n\r\n setup() {\r\n let playBg = new engine.Sprite(\r\n getTexture(\"5ab43bdc-a6ce-46fb-99c2-a806f57f7484\")\r\n );\r\n this.addChild(playBg);\r\n\r\n // this.human = new engine.Sprite(\r\n // getTexture(\"487c1ca7-dea5-4732-b4b6-acb5406ee3a4\")\r\n // );\r\n // this.human.x = 290;\r\n // this.human.y = 900;\r\n // 人\r\n this.humanbeing = new Human();\r\n this.humanbeing.x = 290;\r\n // this.humanbeing.y = 900;\r\n this.humanbeing.y = 750;\r\n this.addChild(this.humanbeing);\r\n\r\n // this.contain = new engine.Sprite()\r\n console.log(\r\n \"xxxxxx\",\r\n this.stage.width,\r\n this.stage.height,\r\n this.width,\r\n this.height\r\n );\r\n\r\n // 手和伞为一个整体\r\n this.rightHand = new engine.Sprite(\r\n getTexture(\"c7129f77-92a6-479e-9994-7d4b39040a15\")\r\n );\r\n this.rightHand.x = -70;\r\n this.rightHand.y = -65;\r\n this.rightHand.anchorX = 196;\r\n this.rightHand.anchorY = 253;\r\n\r\n this.humanbeing.addChild(this.rightHand);\r\n\r\n // this.addChild(this.human);\r\n // this.human.addChild(this.rightHand);\r\n\r\n this.playBtn = new engine.Sprite(\r\n getTexture(\"9e347bef-6e91-4c92-ba5f-f9a52e656207\")\r\n );\r\n this.playBtn.x = 138;\r\n this.playBtn.y = 1150;\r\n this.addChild(this.playBtn);\r\n // 湿润度\r\n this.moists = new Moist();\r\n this.moists.x = 20;\r\n this.moists.y = 450;\r\n this.addChild(this.moists);\r\n\r\n // 云\r\n this.cloud = new CloudRain();\r\n this.addChild(this.cloud);\r\n }\r\n\r\n dripArray: any[] = [];\r\n clicknum: number = 0;\r\n R: number = 250;\r\n D: number = 340;\r\n angle: number;\r\n\r\n con: engine.Sprite = new engine.Sprite();\r\n\r\n start() {\r\n const middleX = this.humanbeing.x + this.humanbeing.width / 2;\r\n const validX1 = this.humanbeing.x;\r\n const validX2 = this.humanbeing.x + this.humanbeing.width;\r\n\r\n // 弧形参考线\r\n for (let i = 0; i < 1000; i++) {\r\n let y =\r\n -Math.sqrt(\r\n this.R * this.R - (i - middleX - 50) * (i - middleX - 50)\r\n ) +\r\n (this.humanbeing.y + 180);\r\n\r\n let img = new engine.Sprite(\r\n getTexture(\"e4a82aee-4472-4b06-bd75-02fb64f1c8c8\")\r\n );\r\n img.width = 2;\r\n img.height = 2;\r\n img.x = i;\r\n img.y = y;\r\n this.con.addChild(img);\r\n }\r\n this.addChild(this.con);\r\n\r\n // 位移\r\n // setInterval(()=>{\r\n // for(let drip of this.dripArray){\r\n // drip.worldMatrix.ty += 10;\r\n // if(drip.y > this.stage.height){\r\n // this.removeChild(drip);\r\n // let index = this.dripArray.indexOf(drip)\r\n // this.dripArray = this.dripArray.filter((ele,i)=>i != index)\r\n // }\r\n // }\r\n // },100)\r\n\r\n let point1 = new engine.Graphics();\r\n point1.beginFill(0xff0000);\r\n point1.drawRect(0, 0, 10, 10);\r\n point1.y = 100;\r\n point1.endFill();\r\n // this.addChild(point1)\r\n this.rightHand.addChild(point1);\r\n\r\n let point2 = new engine.Graphics();\r\n point2.beginFill(0xff0000);\r\n point2.drawRect(0, 0, 10, 10);\r\n point2.x = 170;\r\n point2.endFill();\r\n // this.addChild(point2)\r\n this.rightHand.addChild(point2);\r\n\r\n let point3 = new engine.Graphics();\r\n point3.beginFill(0xff0000);\r\n point3.drawRect(0, 0, 10, 10);\r\n point3.x = 330;\r\n point3.y = 100;\r\n point3.endFill();\r\n // this.addChild(point3)\r\n this.rightHand.addChild(point3);\r\n\r\n //计时器\r\n this.timeCounter = new TimeCounter();\r\n this.addChild(this.timeCounter);\r\n // setInterval(()=>{\r\n // this.timeCounter.time -= 1;\r\n // this.timeCounter.updateTime(this.timeCounter.time);\r\n // if(this.timeCounter.time <= 0){\r\n // console.log('游戏结束!');\r\n\r\n // }\r\n // },1000)\r\n\r\n let ld = Date.now();\r\n\r\n let a = 0;\r\n let b = 0;\r\n \r\n let drip = new engine.Sprite(\r\n getTexture(\"07f74bf6-416f-445e-98d5-021efe4c9fdc\")\r\n );\r\n drip.x =\r\n Math.random() * (this.humanbeing.x + 160) +\r\n (this.humanbeing.x - 160);\r\n drip.worldMatrix.ty = Math.random() * 100 + 300;\r\n this.dripArray.push(drip);\r\n this.addChild(drip);\r\n\r\n this.addEventListener(engine.Event.ENTER_FRAME, () => {\r\n let dt = Date.now() - ld;\r\n\r\n a += dt;\r\n b += dt;\r\n\r\n if (a > 200) {\r\n a = 0;\r\n if (this.timeCounter.time > 0) {\r\n let drip = new engine.Sprite(\r\n getTexture(\"07f74bf6-416f-445e-98d5-021efe4c9fdc\")\r\n );\r\n drip.x =\r\n Math.random() * (this.humanbeing.x + 160) +\r\n (this.humanbeing.x - 160);\r\n drip.worldMatrix.ty = Math.random() * 100 + 300;\r\n this.dripArray.push(drip);\r\n this.addChild(drip);\r\n }\r\n\r\n // this.cloudRain = new CloudRain();\r\n // let x = Math.random() * (this.humanbeing.x + 160) + (this.humanbeing.x - 160);\r\n // let y = Math.random() * (100) + 200;\r\n // this.cloudRain.setPosition(x,y);\r\n\r\n // this.dripArray.push(this.cloudRain);\r\n }\r\n\r\n // 位移\r\n for (let drip of this.dripArray) {\r\n drip.y += (300 * dt) / 1000;\r\n if (drip.y > this.stage.height) {\r\n let index = this.dripArray.indexOf(drip);\r\n this.removeChild(drip);\r\n this.dripArray = this.dripArray.filter(\r\n (ele, i) => i != index\r\n );\r\n }\r\n }\r\n //计时器\r\n if (b >= 1000) {\r\n b = 0;\r\n this.timeCounter.time -= 1;\r\n if (this.timeCounter.time <= 0) {\r\n this.timeCounter.time = 0;\r\n }\r\n this.timeCounter.updateTime(this.timeCounter.time);\r\n\r\n if (this.timeCounter.time <= 0) {\r\n console.log(\"游戏成功!\");\r\n // 云动画\r\n // 雨水结束\r\n // 太阳出来\r\n this.success();\r\n // this.removeEventListener(engine.Event.END_FRAME,()=>{})\r\n }\r\n }\r\n\r\n // for(let cloudrain of this.dripArray){\r\n // cloudrain.drip.y += (300 * dt) / 1000;\r\n // if (cloudrain.drip.y > this.stage.height) {\r\n // this.removeChild(cloudrain);\r\n // let index = this.dripArray.indexOf(cloudrain);\r\n // this.dripArray = this.dripArray.filter(\r\n // (ele, i) => i != index\r\n // );\r\n // }\r\n // }\r\n\r\n let wind = -40;\r\n this.rightHand.rotation += wind / 60;\r\n\r\n if (this.rightHand.rotation <= -90) {\r\n this.rightHand.rotation = -90;\r\n } else if (this.rightHand.rotation >= 90) {\r\n this.rightHand.rotation = 90;\r\n }\r\n ld = Date.now();\r\n\r\n // return;\r\n // 扇形的角度\r\n this.angle = Math.asin(this.D / 2 / this.R) * 57.18;\r\n\r\n // 伞的偏移角度距离水平位置\r\n let validMaxX;\r\n let validMinX;\r\n // 伞的圆函数\r\n let ambrellaFuncY;\r\n\r\n this.rightHand.name = \"aaa\";\r\n\r\n // a.worldMatrix.tx\r\n\r\n // point1,2线性方程斜率\r\n let aa = 0;\r\n if (this.stage.height > 1334) {\r\n aa = 290;\r\n }\r\n let k12 =\r\n (point1.worldMatrix.ty - point2.worldMatrix.ty) /\r\n (point1.worldMatrix.tx - point2.worldMatrix.tx);\r\n let k23 =\r\n (point2.worldMatrix.ty - point3.worldMatrix.ty) /\r\n (point2.worldMatrix.tx - point3.worldMatrix.tx);\r\n\r\n let px1 = point1.worldMatrix.tx;\r\n let px2 = point2.worldMatrix.tx;\r\n let px3 = point3.worldMatrix.tx;\r\n let maxX =\r\n px1 >= px2 ? (px1 >= px3 ? px1 : px3) : px2 >= px3 ? px2 : px3;\r\n let minX =\r\n px1 >= px2 ? (px2 >= px3 ? px3 : px2) : px1 >= px3 ? px3 : px1;\r\n\r\n // let x2 = (middleX + this.R) < maxX ? (middleX+this.R):maxX;\r\n for (let drip of this.dripArray) {\r\n // point1,2线性方程\r\n let b12 =\r\n point1.worldMatrix.ty -\r\n point1.worldMatrix.tx * k12 - 50;\r\n let b23 =\r\n point2.worldMatrix.ty -\r\n point2.worldMatrix.tx * k23 - 50;\r\n let y12 = k12 * drip.x + b12;\r\n let y23 = k23 * drip.x + b23;\r\n if (drip.x > minX && drip.x < maxX) {\r\n // 伞碰撞12\r\n if (drip.x < px2) {\r\n // if (Math.abs(y12 -drip.worldMatrix.ty) <= 20) {\r\n if (drip.worldMatrix.ty >= y12) {\r\n let index = this.dripArray.indexOf(drip);\r\n this.removeChild(drip);\r\n this.dripArray = this.dripArray.filter(\r\n (ele, i) => i != index\r\n );\r\n }\r\n // }\r\n }\r\n // 23\r\n if (drip.x >= px2) {\r\n // if (Math.abs(y23 -drip.worldMatrix.ty) <= 20) {\r\n if (drip.worldMatrix.ty >= y23) {\r\n let index = this.dripArray.indexOf(drip);\r\n this.removeChild(drip);\r\n this.dripArray = this.dripArray.filter(\r\n (ele, i) => i != index\r\n );\r\n }\r\n // }\r\n }\r\n }\r\n\r\n // 碰人\r\n if (\r\n drip.x > this.humanbeing.x &&\r\n drip.x < this.humanbeing.x + this.humanbeing.width\r\n ) {\r\n if (drip.y >= this.humanbeing.y) {\r\n this.moists.percent += 0.1;\r\n this.moists.cover(this.moists.percent);\r\n this.moists.updateText(this.moists.percent);\r\n\r\n if (this.moists.percent >= 1) {\r\n // 游戏结束\r\n this.moists.stopScale();\r\n console.log(\"游戏结束!\");\r\n // 清除事件\r\n this.stop();\r\n }\r\n\r\n this.removeChild(drip);\r\n let face = this.humanbeing.facialChange(2);\r\n face.x = 7;\r\n face.y = 22;\r\n setTimeout(() => {\r\n this.humanbeing.removeFace(face);\r\n }, 1000);\r\n console.log(\"人\");\r\n\r\n let index = this.dripArray.indexOf(drip);\r\n this.dripArray = this.dripArray.filter(\r\n (ele, i) => i != index\r\n );\r\n }\r\n }\r\n }\r\n\r\n ld = Date.now();\r\n });\r\n\r\n this.playBtn.addEventListener(\r\n engine.MouseEvent.CLICK,\r\n this.onClick,\r\n this\r\n );\r\n // this.rightHand.rotation = 0;\r\n }\r\n\r\n onClick() {\r\n this.clicknum += 1;\r\n this.rightHand.rotation += 10 * this.clicknum;\r\n this.clicknum = 0;\r\n }\r\n stop() {\r\n // this.removeAllEventListener();\r\n // this.playBtn.removeAllEventListener();\r\n engine.globalEvent.dispatchEvent(\"cloud-game-fail\", { reason: 1 });\r\n }\r\n\r\n success() {\r\n this.cloud.succeed();\r\n engine.globalEvent.dispatchEvent(\"cloud-game-success\", {\r\n moist: this.moists.percent,\r\n });\r\n }\r\n}\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\nimport GameView from \"./GameView\";\r\nimport GameTest from \"./GameTest\";\r\n\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\tprivate _gameTest: GameTest;\r\n\r\n\r\n\r\n\r\n\r\n\tconstructor() {\r\n\t\tsuper();\r\n\r\n\t\tengine.globalEvent.addEventListener('pictures-start', this.start, this);\r\n\t\tengine.globalEvent.addEventListener('pictures-stop', this.stop, this);\r\n\r\n\t\t//创建实例\r\n\t\t// let gameView = this._gameView = new GameView();\r\n\t\tlet gameTest = this._gameTest = new GameTest();\r\n\t\tthis.addChild(gameTest);\r\n\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\t// this._gameView.start();\r\n\t\tthis._gameTest.start();\r\n\t}\r\n\tstop(event: engine.Event) {\r\n\t\t\r\n\t\t// this._gameView.stop();\r\n\t\tthis._gameTest.stop();\r\n\t}\r\n}\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\treturn instance;\r\n}\r\n"],"names":["__extends"],"mappings":";;;;;;UAIgB,UAAU,CAAC,IAAI;KAC9B,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;CACvD,CAAC;;;CCJD;KAAmCA,+BAAgB;KAW/C;SAAA,YACI,iBAAO,SAIV;SAbD,gBAAU,GAAG;aACT,sCAAsC;aACtC,sCAAsC;aACtC,sCAAsC;UACzC,CAAA;SAED,WAAK,GAAiB,IAAI,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,KAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;SAInE,KAAI,CAAC,QAAQ,CAAC,KAAI,CAAC,KAAK,CAAC,CAAA;SACzB,KAAI,CAAC,KAAK,GAAG,K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,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;CAC7B,CAAC;;;CCLD;KAAiCA,qCAAgB;KAShD;SAAA,YACC,iBAAO,SAUP;SARA,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,gBAAgB,EAAE,KAAI,CAAC,KAAK,EAAE,KAAI,CAAC,CAAC;SACxE,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,eAAe,EAAE,KAAI,CAAC,IAAI,EAAE,KAAI,CAAC,CAAC;SAItE,IAAI,QAAQ,GAAG,KAAI,CAAC,SAAS,GAAG,IAAI,QAAQ,EAAE,CAAC;SAC/C,KAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;;MAExB;KAED,2BAAK,GAAL,UAAM,KAAmB;SACxB,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SAKxB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;MACvB;KACD,0BAAI,GAAJ,UAAK,KAAmB;SAGvB,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;MACtB;KACF,kBAAC;CAAD,CAAC,CAnCgC,MAAM,CAAC,SAAS,GAmChD;;;iBCrCwB,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
},
"OFFSET_X": {
"alias": "OFFSET_X",
"type": "number",
"default": 0
},
"OFFSET_Y": {
"alias": "OFFSET_Y",
"type": "number",
"default": 0
},
"GAME_TIME": {
"alias": "游戏时间",
"type": "number",
"default": 30
},
"GAP": {
"alias": "图片间隙",
"type": "number",
"default": 0
}
},
"assets": [
{
"name": "被遮罩",
"url": "//yun.duiba.com.cn/aurora/assets/c9d66b3e2381fdc7503cdcef9b7173f067a0b96d.png",
"uuid": "8a8e79b6-2c6f-441b-81ae-c441465abfb0",
"ext": ".png"
},
{
"name": "遮罩",
"url": "//yun.duiba.com.cn/aurora/assets/70ade7c1efa699c8662379f406319188fb6aebc5.png",
"uuid": "024d67e9-ed7f-4481-94ca-a15bd5226cad",
"ext": ".png"
},
{
"name":"衣服湿润度",
"url":"//yun.duiba.com.cn/aurora/assets/f59b03b7441b4da17d8e7567b44c6fe92ce9eb50.png",
"uuid":"ed0e8931-2557-4527-bcfc-9071f90d5737",
"ext":".png"
},
{
"name":"背景",
"url":"//yun.duiba.com.cn/aurora/assets/d0e22ae58b6e8519b969ed207197a31820790349.png",
"uuid":"5ab43bdc-a6ce-46fb-99c2-a806f57f7484",
"ext":".png"
},
{
"name":"倒计时",
"url":"//yun.duiba.com.cn/aurora/assets/97e5c35fa0503b5d28168fe7d22fb179f1279e21.png",
"uuid":"b7d2a60a-9e60-4eca-be80-a991abea47c9",
"ext":".png"
},
{
"name":"云1",
"url":"//yun.duiba.com.cn/aurora/assets/429981638472e8f02ce2a780f3b05be72d13b943.png",
"uuid":"1e1a6993-9da0-4813-b1bd-00f2dbae2af2",
"ext":".png"
},
{
"name":"云2",
"url":"//yun.duiba.com.cn/aurora/assets/c900fe3536b2119b1a917540e1aac5380363d9d1.png",
"uuid":"6ed0e2e7-3ba3-4967-8fe0-39667792e343",
"ext":".png"
},
{
"name":"太阳",
"url":"//yun.duiba.com.cn/aurora/assets/f4ad009080bac141589b7f8eb88d6e66da732cd9.png",
"uuid":"0f05aaae-338a-439a-82b0-20efcee5cca4",
"ext":".png"
},
{
"name":"常态1",
"url":"//yun.duiba.com.cn/aurora/assets/3a1e9ec8247078fc92af538ea8ee29c73b532b93.png",
"uuid":"487c1ca7-dea5-4732-b4b6-acb5406ee3a4",
"ext":".png"
},
{
"name":"吃力1",
"url":"//yun.duiba.com.cn/aurora/assets/40f906478c4fe90f9b68392df0031d382502f8d9.png",
"uuid":"b876771a-a5d1-47f4-bd45-5978519c521a",
"ext":".png"
},
{
"name":"沮丧1",
"url":"//yun.duiba.com.cn/aurora/assets/f76eb798d2ccff84f53780c37d802830c5f6071c.png",
"uuid":"ff43517a-27bb-4f73-948c-d7a4fa7b4c69",
"ext":".png"
},
{
"name":"常态2",
"url":"//yun.duiba.com.cn/aurora/assets/875fd6ba38735682fe27d010338277238672f310.png",
"uuid":"4f8d0a7e-9db3-408e-81f2-fdd323ba6094",
"ext":".png"
},
{
"name":"吃力2",
"url":"//yun.duiba.com.cn/aurora/assets/753b58a25ee4b617afe0a14767036b63681f0809.png",
"uuid":"71e07cee-fd6d-40bb-ac0b-5bb28c87276e",
"ext":".png"
},
{
"name":"沮丧2",
"url":"//yun.duiba.com.cn/aurora/assets/17682be2c0e9f299315bf4e17598ea2e3c8e11ce.png",
"uuid":"2cd9f1bb-d0d8-42ea-941b-dcd0428e474d",
"ext":".png"
},
{
"name":"撑伞按钮",
"url":"//yun.duiba.com.cn/aurora/assets/2d15942ed213e1d0ae953925565d80f93cec4701.png",
"uuid":"9e347bef-6e91-4c92-ba5f-f9a52e656207",
"ext":".png"
},
{
"name":"伞",
"url":"//yun.duiba.com.cn/aurora/assets/a4c14c17dc144611164c70f905f1d35a2aa1812f.png",
"uuid":"c7129f77-92a6-479e-9994-7d4b39040a15",
"ext":".png"
},
{
"name":"雨滴",
"url":"//yun.duiba.com.cn/aurora/assets/a1bf1b1622759aabec29e857e325039c147bac54.png",
"uuid":"07f74bf6-416f-445e-98d5-021efe4c9fdc",
"ext":".png"
},
{
"name":"",
"url":"//yun.duiba.com.cn/aurora/assets/1cded0d917c44d22ddce058f239e1cfac1b506c2.png",
"uuid":"57d4067e-c32f-4b12-a8fc-185753726fc6",
"ext":".png"
},
{
"name":"击中",
"url":"//yun.duiba.com.cn/aurora/assets/251402a1991ef00a124ddd91f519a30147285e00.png",
"uuid":"38ec6627-efa8-4f7a-9bdc-3c73cea717f1",
"ext":".png"
},
{
"name":"关闭",
"url":"//yun.duiba.com.cn/aurora/assets/6900f3a3b592c1b9cd3925fb9b66b6ec673a8c43.png",
"uuid":"e4a82aee-4472-4b06-bd75-02fb64f1c8c8",
"ext":".png"
}
],
"events": {
"in": {
"pictures-start": {
"alias": "开始",
"data": {
"picUrl":"图片路径",
"blockUrl":"blockUrl",
"GAME_TIME":"每局的游戏时间",
"MAX_ROW":"行",
"MAX_COL":"列",
"W":"宽",
"H":"高",
"GAP":"图片间隙",
"OFFSET_X":"OFFSET_X",
"OFFSET_Y":"OFFSET_Y"
}
},
"pictures-stop": {
"alias": "停止"
}
},
"out": {
"cloud-time-update": {
"alias": "倒计时更新",
"data": {
"time":"剩余时间"
}
},
"cloud-game-fail": {
"alias": "游戏结束",
"data": {
"reason": "结束原因(1:时间到了)"
}
},
"cloud-game-success": {
"alias": "游戏成功",
"data": {
"time": "游戏消耗时间"
}
}
}
}
}
\ No newline at end of file
import {getTexture} from './utils'
export default class CloudRain extends engine.Container{
clound1:engine.Sprite = new engine.Sprite(getTexture('1e1a6993-9da0-4813-b1bd-00f2dbae2af2'))
clound2:engine.Sprite = new engine.Sprite(getTexture('6ed0e2e7-3ba3-4967-8fe0-39667792e343'))
sun = new engine.Sprite(getTexture("0f05aaae-338a-439a-82b0-20efcee5cca4"));
constructor(){
super()
this.sun.x = 90;
this.sun.y = 120;
this.addChild(this.sun)
this.addChild(this.clound1);
this.addChild(this.clound2);
this.clound1.x = 100;
this.clound1.y = 220;
this.clound2.x = 150;
this.clound2.y = 220;
}
succeed(){
// 380 580
let a = 0
let ld = Date.now();
this.addEventListener(engine.Event.ENTER_FRAME,()=>{
let dt = Date.now() - ld;
a += dt;
if(a>100){
this.clound1.x -= (800 * dt) / 1000;
this.clound2.x += (820*dt)/1000;
if(this.clound1.x <= -380){
this.clound1.x = -380;
}
if(this.clound2.x >= 750){
this.clound2.x = 750;
}
this.sun.y -= (150 * dt) / 1000;
if(this.sun.y <= 60){
this.sun.y = 60;
}
}
ld = Date.now();
})
}
}
\ No newline at end of file
import { getTexture } from "./utils";
export default class GameTest1 extends engine.Container {
constructor() {
super();
this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);
}
rightHand: engine.Sprite;
ambrella: engine.Sprite;
playBtn: engine.Sprite;
human: engine.Sprite;
setup() {
let playBg = new engine.Sprite(getTexture('c9ff7c30-2734-417d-a811-d88b6b7140b8'))
this.addChild(playBg)
this.human = new engine.Sprite(
getTexture("487c1ca7-dea5-4732-b4b6-acb5406ee3a4")
);
this.human.x = 290;
this.human.y = 900;
this.rightHand = new engine.Sprite(
getTexture("c7129f77-92a6-479e-9994-7d4b39040a15")
);
this.rightHand.x = -70;
this.rightHand.y = -65;
this.rightHand.anchorX = 196;
this.rightHand.anchorY = 253;
this.addChild(this.human);
this.human.addChild(this.rightHand);
this.playBtn = new engine.Sprite(
getTexture("9e347bef-6e91-4c92-ba5f-f9a52e656207")
);
this.playBtn.x = 138;
this.playBtn.y = 200;
this.addChild(this.playBtn);
}
dripArray: any[] = [];
clicknum: number = 0;
R: number = 250;
D: number = 340;
angle: number;
con: engine.Sprite = new engine.Sprite();
start() {
const middleX = this.human.x + this.human.width / 2;
const validX1 = this.human.x;
const validX2 = this.human.x + this.human.width;
// setInterval(()=>{
// let drip = new engine.Sprite(getTexture('07f74bf6-416f-445e-98d5-021efe4c9fdc'))
// drip.x = Math.random() * ((this.human.x + 180)) + (this.human.x - 180) ;
// drip.y = Math.random() * (drip.height);
// this.dripArray.push(drip)
// this.addChild(drip);
// },100)
let drip = new engine.Sprite(
getTexture("07f74bf6-416f-445e-98d5-021efe4c9fdc")
);
drip.x = 200;
drip.y = 0;
this.dripArray.push(drip);
this.addChild(drip);
for (let i = 0; i < 1000; i++) {
let y =
-Math.sqrt(
this.R * this.R - (i - middleX - 50) * (i - middleX - 50)
) +
(this.human.y + 180);
let img = new engine.Sprite(
getTexture("e4a82aee-4472-4b06-bd75-02fb64f1c8c8")
);
img.width = 2;
img.height = 2;
img.x = i;
img.y = y;
this.con.addChild(img);
}
this.addChild(this.con);
// 位移
// setInterval(()=>{
// for(let drip of this.dripArray){
// drip.y += 10;
// if(drip.y > this.stage.height){
// this.removeChild(drip);
// let index = this.dripArray.indexOf(drip)
// this.dripArray = this.dripArray.filter((ele,i)=>i != index)
// }
// }
// },100)
let point1 = new engine.Container();
// point1.beginFill(0xff0000);
// point1.drawRect(0,0,10,10);
point1.y = 100;
// point1.endFill();
this.rightHand.addChild(point1);
let point2 = new engine.Container();
// point2.beginFill(0xff0000);
// point2.drawRect(0,0,10,10);
point2.x = 170;
// point2.endFill();
this.rightHand.addChild(point2);
let point3 = new engine.Container();
// point3.beginFill(0xff0000);
// point3.drawRect(0,0,10,10);
point3.x = 330;
point3.y = 100;
// point3.endFill();
this.rightHand.addChild(point3);
let ld = Date.now();
let a = 0;
this.addEventListener(engine.Event.ENTER_FRAME, () => {
let dt = Date.now() - ld;
a += dt;
if (a > 200) {
a = 0;
let drip = new engine.Sprite(
getTexture("07f74bf6-416f-445e-98d5-021efe4c9fdc")
);
drip.x =
Math.random() * (this.human.x + 180) + (this.human.x - 180);
drip.y = Math.random() * drip.height;
this.dripArray.push(drip);
this.addChild(drip);
}
// 位移
for (let drip of this.dripArray) {
drip.y += (300 * dt) / 1000;
if (drip.y > this.stage.height) {
this.removeChild(drip);
let index = this.dripArray.indexOf(drip);
this.dripArray = this.dripArray.filter(
(ele, i) => i != index
);
}
}
let wind = -40;
this.rightHand.rotation += wind / 60;
if (this.rightHand.rotation <= -90) {
this.rightHand.rotation = -90;
} else if (this.rightHand.rotation >= 90) {
this.rightHand.rotation = 90;
}
ld = Date.now();
// return;
// 扇形的角度
this.angle = Math.asin(this.D / 2 / this.R) * 57.18;
// 伞的偏移角度距离水平位置
let validMaxX;
let validMinX;
// 伞的圆函数
let ambrellaFuncY;
this.rightHand.name = 'aaa';
// a.worldMatrix.tx
// point1,2线性方程斜率
let k12 = (point1.worldMatrix.ty - point2.worldMatrix.ty) / ((point1.worldMatrix.tx - point2.worldMatrix.tx))
let k23 = (point2.worldMatrix.ty - point3.worldMatrix.ty) / ((point2.worldMatrix.tx - point3.worldMatrix.tx))
if (this.rightHand.rotation >= 0) {
// 右偏移且伞左端在右边
// if (this.rightHand.rotation - this.angle >= 0) {
// let x =
// this.R *
// Math.sin((this.rightHand.rotation - this.angle) / 180);
// // 伞是否完全在人的右侧 大于人物的一半宽度
// validMaxX = middleX + x;
// // 距离圆最远的垂直切线距离
// let rx = this.R;
// for (let drip of this.dripArray) {
// // 伞的范围内
// if (
// drip.x + drip.width >= validMaxX &&
// drip.x + drip.width <= middleX + this.R
// ) {
// let ambrellaFuncY =
// -Math.sqrt(
// this.R * this.R -
// (drip.x - middleX - 50) *
// (drip.x - middleX - 50)
// ) +
// (this.human.y + 160);
// if (drip.y + drip.height >= ambrellaFuncY) {
// this.removeChild(drip);
// let index = this.dripArray.indexOf(drip);
// this.dripArray = this.dripArray.filter(
// (ele, i) => i != index
// );
// }
// }
// if (x - this.human.width / 2 >= 0) {
// validMaxX = validX2;
// }
// if (
// (drip.x >= validX1 && drip.x <= validMaxX) ||
// (drip.x + drip.width >= validX1 &&
// drip.x + drip.width <= validMaxX)
// ) {
// // 是否发生碰撞
// if (drip.y + drip.height >= this.human.y) {
// this.removeChild(drip);
// let index = this.dripArray.indexOf(drip);
// this.dripArray = this.dripArray.filter(
// (ele, i) => i != index
// );
// // let upset = new engine.Sprite(getTexture('ff43517a-27bb-4f73-948c-d7a4fa7b4c69'))
// // upset.x = 294;
// // upset.y = 900;
// // this.addChild(upset);
// // setTimeout(()=>{
// // this.removeChild(upset)
// // },1000)
// }
// }
// }
let px1 = point1.worldMatrix.tx;
let px2 = point2.worldMatrix.tx;
let px3 = point3.worldMatrix.tx;
let maxX = px1 > px2 ? (px1>px3?px1:(px3)) : (px2>px3?px2:px3);
let minX = px1 > px2 ? (px2>px3?px3:px2) : (px1>px3?px3:(px1));
// let x2 = (middleX + this.R) < maxX ? (middleX+this.R):maxX;
for(let drip of this.dripArray){
// point1,2线性方程
let b12 = point1.worldMatrix.ty - point1.worldMatrix.tx * k12;
let b23 = point2.worldMatrix.ty - point2.worldMatrix.tx * k23;
let y12 = k12 * drip.x + b12;
let y23 = k23 * drip.x + b23;
if(minX >= validX1){
if(drip.x > minX && drip.x < maxX){
// 伞碰撞12
if(drip.x < px2){
if(drip.y >= y12){
this.removeChild(drip);
let index = this.dripArray.indexOf(drip);
this.dripArray = this.dripArray.filter(
(ele, i) => i != index
);
}
}
// 23
if(drip.x >= px2){
if(drip.y >= y23){
this.removeChild(drip);
let index = this.dripArray.indexOf(drip);
this.dripArray = this.dripArray.filter(
(ele, i) => i != index
);
}
}
}
// 碰人
if(drip.x < minX && drip.x >= validX1){
if(drip.y >= this.human.y){
this.removeChild(drip);
let index = this.dripArray.indexOf(drip);
this.dripArray = this.dripArray.filter(
(ele, i) => i != index
);
}
}
}
}
// } else {
// let x =
// this.R *
// Math.sin((this.angle - this.rightHand.rotation) / 180);
// // 右偏移且伞左端在左边
// validMinX = middleX - x;
// // 伞的右端
// let rx =
// this.R *
// Math.sin((this.angle + this.rightHand.rotation) / 180);
// // 伞是否完全包裹人物
// for (let drip of this.dripArray) {
// // 伞的范围内
// if (
// drip.x + drip.width >= validMinX &&
// drip.x + drip.width < middleX + rx
// ) {
// // ambrellaFuncY = Math.sqrt(this.R*this.R - (drip.x-this.rightHand.anchorX-200) * (drip.x-this.rightHand.anchorX-200)) + this.rightHand.anchorY;
// // let r = Math.sqrt((drip.x - middleX-50)*(drip.x - middleX-50) + ((drip.y+drip.height) - (this.human.y + 200)) * ((drip.y+drip.height) - (this.human.y + 200)))
// ambrellaFuncY =
// -Math.sqrt(
// this.R * this.R -
// (drip.x - middleX - 50) *
// (drip.x - middleX - 50)
// ) +
// (this.human.y + 160);
// // let y = Math.sqrt(this.R*this.R - (drip.x-middleX-50)*(drip.x-middleX-50)) + (this.human.y + 200);
// // console.log(ambrellaFuncY,2,y,r)
// if (drip.y + drip.height >= ambrellaFuncY) {
// // if(r <= this.R){
// this.removeChild(drip);
// let index = this.dripArray.indexOf(drip);
// this.dripArray = this.dripArray.filter(
// (ele, i) => i != index
// );
// }
// }
// if (
// (drip.x > validX1 && drip.x < validMinX) ||
// (drip.x + drip.width > validX1 &&
// drip.x + drip.width < validMinX)
// ) {
// // 是否发生碰撞
// if (drip.y + drip.height >= this.human.y) {
// this.removeChild(drip);
// let index = this.dripArray.indexOf(drip);
// this.dripArray = this.dripArray.filter(
// (ele, i) => i != index
// );
// // let upset = new engine.Sprite(getTexture('ff43517a-27bb-4f73-948c-d7a4fa7b4c69'))
// // upset.x = 294;
// // upset.y = 900;
// // this.addChild(upset);
// // setTimeout(()=>{
// // this.removeChild(upset)
// // },1000)
// }
// }
// }
// }
} else {
let px1 = point1.worldMatrix.tx;
let px2 = point2.worldMatrix.tx;
let px3 = point3.worldMatrix.tx;
let maxX = px1 > px2 ? (px1>px3?px1:(px3)) : (px2>px3?px2:px3);
let minX = px1 > px2 ? (px2>px3?px3:px2) : (px1>px3?px3:(px1));
for(let drip of this.dripArray){
// point1,2线性方程
let b12 = point1.worldMatrix.ty - point1.worldMatrix.tx * k12;
let b23 = point2.worldMatrix.ty - point2.worldMatrix.tx * k23;
let y12 = k12 * drip.x + b12;
let y23 = k23 * drip.x + b23;
if(maxX <= validX2){
if(drip.x > minX && drip.x < maxX){
// 伞碰撞23
if(drip.x > px2){
if(drip.y >= y23){
this.removeChild(drip);
let index = this.dripArray.indexOf(drip);
this.dripArray = this.dripArray.filter(
(ele, i) => i != index
);
}
}
// 12
if(drip.x <= px2){
if(drip.y >= y12){
this.removeChild(drip);
let index = this.dripArray.indexOf(drip);
this.dripArray = this.dripArray.filter(
(ele, i) => i != index
);
}
}
}
// 碰人
if(drip.x < px1 && drip.x >= validX1){
if(drip.y >= this.human.y){
this.removeChild(drip);
let index = this.dripArray.indexOf(drip);
this.dripArray = this.dripArray.filter(
(ele, i) => i != index
);
}
}
}
}
// if (-this.rightHand.rotation - this.angle >= 0) {
// let x =
// this.R *
// Math.sin((-this.angle - this.rightHand.rotation) / 180);
// // 左偏且在左边
// validMinX = middleX - x;
// for (let drip of this.dripArray) {
// // 伞的范围内(可能包括人的部分)
// if (
// drip.x + drip.width < validMinX &&
// drip.x + drip.width > middleX - this.R
// ) {
// // ambrellaFuncY = Math.sqrt(this.R*this.R - (drip.x-this.rightHand.anchorX) * (drip.x-this.rightHand.anchorX)) + this.rightHand.anchorY;
// // ambrellaFuncY = Math.sqrt(this.R*this.R - (drip.x-this.rightHand.anchorX-200) * (drip.x-this.rightHand.anchorX-200)) + this.rightHand.anchorY + 500;
// // let r = Math.sqrt((drip.x - middleX-50)*(drip.x - middleX-50) + ((drip.y+drip.height) - (this.human.y + 200)) * ((drip.y+drip.height) - (this.human.y + 200)))
// ambrellaFuncY =
// -Math.sqrt(
// this.R * this.R -
// (drip.x - middleX - 50) *
// (drip.x - middleX - 50)
// ) +
// (this.human.y + 160);
// // let y = Math.sqrt(this.R*this.R - (drip.x-middleX-50)*(drip.x-middleX-50)) + (this.human.y + 200)
// // console.log(ambrellaFuncY,3,y,r)
// // if(r <= this.R){
// if (drip.y + drip.height >= ambrellaFuncY) {
// this.removeChild(drip);
// let index = this.dripArray.indexOf(drip);
// this.dripArray = this.dripArray.filter(
// (ele, i) => i != index
// );
// }
// }
// if (x > this.human.width / 2) {
// validMinX = validX1;
// }
// if (
// (drip.x > validMinX && drip.x < validX2) ||
// (drip.x + drip.width > validMinX &&
// drip.x + drip.width < validX2)
// ) {
// // 淋湿人物范围
// // 人物是否发生碰撞
// if (drip.y + drip.height >= this.human.y) {
// this.removeChild(drip);
// let index = this.dripArray.indexOf(drip);
// this.dripArray = this.dripArray.filter(
// (ele, i) => i != index
// );
// // let upset = new engine.Sprite(getTexture('ff43517a-27bb-4f73-948c-d7a4fa7b4c69'))
// // upset.x = 294;
// // upset.y = 900;
// // this.addChild(upset);
// // setTimeout(()=>{
// // this.removeChild(upset)
// // },1000)
// }
// }
// }
// } else {
// // 左偏移且在右边
// let x =
// this.R *
// Math.sin((this.angle + this.rightHand.rotation) / 180);
// let lx =
// this.R *
// Math.sin((this.angle - this.rightHand.rotation) / 180);
// validMinX = middleX + x;
// for (let drip of this.dripArray) {
// // 雨滴和伞碰撞
// if (
// drip.x + drip.width <= validMinX &&
// drip.x + drip.width > middleX - lx
// ) {
// // ambrellaFuncY = Math.sqrt(this.R*this.R - (drip.x-this.rightHand.anchorX) * (drip.x-this.rightHand.anchorX)) + this.rightHand.anchorY;
// // ambrellaFuncY = Math.sqrt(this.R*this.R - (drip.x-middleX) * (drip.x-middleX)) + (this.human.y );
// // let r = Math.sqrt((drip.x - middleX-50)*(drip.x - middleX-50) + ((drip.y+drip.height) - (this.human.y + 200)) * ((drip.y+drip.height) - (this.human.y + 200)))
// // ambrellaFuncY = Math.sqrt(this.R*this.R - (drip.x-middleX) * (drip.x- middleX)) + (this.human.y);
// let ambrellaFuncY =
// -Math.sqrt(
// this.R * this.R -
// (drip.x - middleX - 50) *
// (drip.x - middleX - 50)
// ) +
// (this.human.y + 160);
// // console.log(ambrellaFuncY,4,y,r)
// // if(r <= this.R){
// if (drip.y + drip.height >= ambrellaFuncY) {
// this.removeChild(drip);
// let index = this.dripArray.indexOf(drip);
// this.dripArray = this.dripArray.filter(
// (ele, i) => i != index
// );
// }
// } else if (
// (drip.x > validMinX && drip.x < validX2) ||
// (drip.x + drip.width > validMinX &&
// drip.x + drip.width < validX2)
// ) {
// // 人物是否发生碰撞
// if (drip.y + drip.height >= this.human.y) {
// this.removeChild(drip);
// let index = this.dripArray.indexOf(drip);
// this.dripArray = this.dripArray.filter(
// (ele, i) => i != index
// );
// // let upset = new engine.Sprite(getTexture('ff43517a-27bb-4f73-948c-d7a4fa7b4c69'))
// // upset.x = 294;
// // upset.y = 900;
// // this.addChild(upset);
// // setTimeout(()=>{
// // this.removeChild(upset)
// // },1000)
// }
// }
// }
// }
}
ld = Date.now();
});
this.playBtn.addEventListener(
engine.MouseEvent.CLICK,
this.onClick,
this
);
this.rightHand.rotation = 0;
}
onClick() {
this.clicknum += 1;
this.rightHand.rotation += 10 * this.clicknum;
this.clicknum = 0;
}
stop() {}
}
\ No newline at end of file
import { getTexture } from "./utils";
import Human from "./Human";
import Moist from "./Moist";
import TimeCounter from "./TimeCounter";
import CloudRain from "./CloudRain";
export default class GameTest extends engine.Container {
constructor() {
super();
this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);
}
rightHand: engine.Sprite;
ambrella: engine.Sprite;
playBtn: engine.Sprite;
human: engine.Sprite;
humanbeing: Human;
moists: Moist;
contain: any;
timeCounter: TimeCounter;
cloudRain: CloudRain;
cloud: CloudRain;
setup() {
let playBg = new engine.Sprite(
getTexture("5ab43bdc-a6ce-46fb-99c2-a806f57f7484")
);
this.addChild(playBg);
// this.human = new engine.Sprite(
// getTexture("487c1ca7-dea5-4732-b4b6-acb5406ee3a4")
// );
// this.human.x = 290;
// this.human.y = 900;
// 人
this.humanbeing = new Human();
this.humanbeing.x = 290;
// this.humanbeing.y = 900;
this.humanbeing.y = 750;
this.addChild(this.humanbeing);
// this.contain = new engine.Sprite()
console.log(
"xxxxxx",
this.stage.width,
this.stage.height,
this.width,
this.height
);
// 手和伞为一个整体
this.rightHand = new engine.Sprite(
getTexture("c7129f77-92a6-479e-9994-7d4b39040a15")
);
this.rightHand.x = -70;
this.rightHand.y = -65;
this.rightHand.anchorX = 196;
this.rightHand.anchorY = 253;
this.humanbeing.addChild(this.rightHand);
// this.addChild(this.human);
// this.human.addChild(this.rightHand);
this.playBtn = new engine.Sprite(
getTexture("9e347bef-6e91-4c92-ba5f-f9a52e656207")
);
this.playBtn.x = 138;
this.playBtn.y = 1150;
this.addChild(this.playBtn);
// 湿润度
this.moists = new Moist();
this.moists.x = 20;
this.moists.y = 450;
this.addChild(this.moists);
// 云
this.cloud = new CloudRain();
this.addChild(this.cloud);
}
dripArray: any[] = [];
clicknum: number = 0;
R: number = 250;
D: number = 340;
angle: number;
con: engine.Sprite = new engine.Sprite();
start() {
const middleX = this.humanbeing.x + this.humanbeing.width / 2;
const validX1 = this.humanbeing.x;
const validX2 = this.humanbeing.x + this.humanbeing.width;
// 弧形参考线
for (let i = 0; i < 1000; i++) {
let y =
-Math.sqrt(
this.R * this.R - (i - middleX - 50) * (i - middleX - 50)
) +
(this.humanbeing.y + 180);
let img = new engine.Sprite(
getTexture("e4a82aee-4472-4b06-bd75-02fb64f1c8c8")
);
img.width = 2;
img.height = 2;
img.x = i;
img.y = y;
this.con.addChild(img);
}
this.addChild(this.con);
// 位移
// setInterval(()=>{
// for(let drip of this.dripArray){
// drip.worldMatrix.ty += 10;
// if(drip.y > this.stage.height){
// this.removeChild(drip);
// let index = this.dripArray.indexOf(drip)
// this.dripArray = this.dripArray.filter((ele,i)=>i != index)
// }
// }
// },100)
let point1 = new engine.Graphics();
point1.beginFill(0xff0000);
point1.drawRect(0, 0, 10, 10);
point1.y = 100;
point1.endFill();
// this.addChild(point1)
this.rightHand.addChild(point1);
let point2 = new engine.Graphics();
point2.beginFill(0xff0000);
point2.drawRect(0, 0, 10, 10);
point2.x = 170;
point2.endFill();
// this.addChild(point2)
this.rightHand.addChild(point2);
let point3 = new engine.Graphics();
point3.beginFill(0xff0000);
point3.drawRect(0, 0, 10, 10);
point3.x = 330;
point3.y = 100;
point3.endFill();
// this.addChild(point3)
this.rightHand.addChild(point3);
//计时器
this.timeCounter = new TimeCounter();
this.addChild(this.timeCounter);
// setInterval(()=>{
// this.timeCounter.time -= 1;
// this.timeCounter.updateTime(this.timeCounter.time);
// if(this.timeCounter.time <= 0){
// console.log('游戏结束!');
// }
// },1000)
let ld = Date.now();
let a = 0;
let b = 0;
let drip = new engine.Sprite(
getTexture("07f74bf6-416f-445e-98d5-021efe4c9fdc")
);
drip.x =
Math.random() * (this.humanbeing.x + 160) +
(this.humanbeing.x - 160);
drip.worldMatrix.ty = Math.random() * 100 + 300;
this.dripArray.push(drip);
this.addChild(drip);
this.addEventListener(engine.Event.ENTER_FRAME, () => {
let dt = Date.now() - ld;
a += dt;
b += dt;
if (a > 200) {
a = 0;
if (this.timeCounter.time > 0) {
let drip = new engine.Sprite(
getTexture("07f74bf6-416f-445e-98d5-021efe4c9fdc")
);
drip.x =
Math.random() * (this.humanbeing.x + 160) +
(this.humanbeing.x - 160);
drip.worldMatrix.ty = Math.random() * 100 + 300;
this.dripArray.push(drip);
this.addChild(drip);
}
// this.cloudRain = new CloudRain();
// let x = Math.random() * (this.humanbeing.x + 160) + (this.humanbeing.x - 160);
// let y = Math.random() * (100) + 200;
// this.cloudRain.setPosition(x,y);
// this.dripArray.push(this.cloudRain);
}
// 位移
for (let drip of this.dripArray) {
drip.y += (300 * dt) / 1000;
if (drip.y > this.stage.height) {
let index = this.dripArray.indexOf(drip);
this.removeChild(drip);
this.dripArray = this.dripArray.filter(
(ele, i) => i != index
);
}
}
//计时器
if (b >= 1000) {
b = 0;
this.timeCounter.time -= 1;
if (this.timeCounter.time <= 0) {
this.timeCounter.time = 0;
}
this.timeCounter.updateTime(this.timeCounter.time);
if (this.timeCounter.time <= 0) {
console.log("游戏成功!");
// 云动画
// 雨水结束
// 太阳出来
this.success();
// this.removeEventListener(engine.Event.END_FRAME,()=>{})
}
}
// for(let cloudrain of this.dripArray){
// cloudrain.drip.y += (300 * dt) / 1000;
// if (cloudrain.drip.y > this.stage.height) {
// this.removeChild(cloudrain);
// let index = this.dripArray.indexOf(cloudrain);
// this.dripArray = this.dripArray.filter(
// (ele, i) => i != index
// );
// }
// }
let wind = -40;
this.rightHand.rotation += wind / 60;
if (this.rightHand.rotation <= -90) {
this.rightHand.rotation = -90;
} else if (this.rightHand.rotation >= 90) {
this.rightHand.rotation = 90;
}
ld = Date.now();
// return;
// 扇形的角度
this.angle = Math.asin(this.D / 2 / this.R) * 57.18;
// 伞的偏移角度距离水平位置
let validMaxX;
let validMinX;
// 伞的圆函数
let ambrellaFuncY;
this.rightHand.name = "aaa";
// a.worldMatrix.tx
// point1,2线性方程斜率
let aa = 0;
if (this.stage.height > 1334) {
aa = 290;
}
let k12 =
(point1.worldMatrix.ty - point2.worldMatrix.ty) /
(point1.worldMatrix.tx - point2.worldMatrix.tx);
let k23 =
(point2.worldMatrix.ty - point3.worldMatrix.ty) /
(point2.worldMatrix.tx - point3.worldMatrix.tx);
let px1 = point1.worldMatrix.tx;
let px2 = point2.worldMatrix.tx;
let px3 = point3.worldMatrix.tx;
let maxX =
px1 >= px2 ? (px1 >= px3 ? px1 : px3) : px2 >= px3 ? px2 : px3;
let minX =
px1 >= px2 ? (px2 >= px3 ? px3 : px2) : px1 >= px3 ? px3 : px1;
// let x2 = (middleX + this.R) < maxX ? (middleX+this.R):maxX;
for (let drip of this.dripArray) {
// point1,2线性方程
let b12 =
point1.worldMatrix.ty -
point1.worldMatrix.tx * k12 - 50;
let b23 =
point2.worldMatrix.ty -
point2.worldMatrix.tx * k23 - 50;
let y12 = k12 * drip.x + b12;
let y23 = k23 * drip.x + b23;
if (drip.x > minX && drip.x < maxX) {
// 伞碰撞12
if (drip.x < px2) {
// if (Math.abs(y12 -drip.worldMatrix.ty) <= 20) {
if (drip.worldMatrix.ty >= y12) {
let index = this.dripArray.indexOf(drip);
this.removeChild(drip);
this.dripArray = this.dripArray.filter(
(ele, i) => i != index
);
}
// }
}
// 23
if (drip.x >= px2) {
// if (Math.abs(y23 -drip.worldMatrix.ty) <= 20) {
if (drip.worldMatrix.ty >= y23) {
let index = this.dripArray.indexOf(drip);
this.removeChild(drip);
this.dripArray = this.dripArray.filter(
(ele, i) => i != index
);
}
// }
}
}
// 碰人
if (
drip.x > this.humanbeing.x &&
drip.x < this.humanbeing.x + this.humanbeing.width
) {
if (drip.y >= this.humanbeing.y) {
this.moists.percent += 0.1;
this.moists.cover(this.moists.percent);
this.moists.updateText(this.moists.percent);
if (this.moists.percent >= 1) {
// 游戏结束
this.moists.stopScale();
console.log("游戏结束!");
// 清除事件
this.stop();
}
this.removeChild(drip);
let face = this.humanbeing.facialChange(2);
face.x = 7;
face.y = 22;
setTimeout(() => {
this.humanbeing.removeFace(face);
}, 1000);
console.log("人");
let index = this.dripArray.indexOf(drip);
this.dripArray = this.dripArray.filter(
(ele, i) => i != index
);
}
}
}
ld = Date.now();
});
this.playBtn.addEventListener(
engine.MouseEvent.CLICK,
this.onClick,
this
);
// this.rightHand.rotation = 0;
}
onClick() {
this.clicknum += 1;
this.rightHand.rotation += 10 * this.clicknum;
this.clicknum = 0;
}
stop() {
// this.removeAllEventListener();
// this.playBtn.removeAllEventListener();
engine.globalEvent.dispatchEvent("cloud-game-fail", { reason: 1 });
}
success() {
this.cloud.succeed();
engine.globalEvent.dispatchEvent("cloud-game-success", {
moist: this.moists.percent,
});
}
}
import { getTexture } from "./utils";
console.log = ()=>{}
export default class GameView extends engine.Container {
constructor() {
super();
this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);
}
rightHand: engine.Sprite;
ambrella: engine.Sprite;
playBtn: engine.Sprite;
human: engine.Sprite;
cir: engine.Shape;
setup() {
// let playBg = new engine.Sprite(getTexture('c9ff7c30-2734-417d-a811-d88b6b7140b8'))
// this.addChild(playBg)
this.human = new engine.Sprite(
getTexture("487c1ca7-dea5-4732-b4b6-acb5406ee3a4")
);
this.human.x = 290;
this.human.y = 900;
this.rightHand = new engine.Sprite(
getTexture("c7129f77-92a6-479e-9994-7d4b39040a15")
);
this.rightHand.x = -70;
this.rightHand.y = -65;
this.rightHand.anchorX = 196;
this.rightHand.anchorY = 253;
this.addChild(this.human);
this.human.addChild(this.rightHand);
this.playBtn = new engine.Sprite(
getTexture("9e347bef-6e91-4c92-ba5f-f9a52e656207")
);
this.playBtn.x = 138;
this.playBtn.y = 200;
this.addChild(this.playBtn);
// 沮丧
// 设置圆
// this.cir = new engine.Shape();
// this.cir.beginFill(0x666666,1);
// this.cir.drawRect(0,0,200,200)
// this.addChild(this.cir)
}
dripArray: any[] = [];
clicknum: number = 0;
R: number = 250;
D: number = 340;
angle: number;
con: engine.Sprite = new engine.Sprite();
// middleX:number = this.human.x + this.human.width/2;
// validX1:number = this.human.x;
// validX2:number = this.human.x + this.human.width;
start() {
const middleX = this.human.x + this.human.width / 2;
const validX1 = this.human.x;
const validX2 = this.human.x + this.human.width;
// setInterval(()=>{
// let drip = new engine.Sprite(getTexture('07f74bf6-416f-445e-98d5-021efe4c9fdc'))
// drip.x = Math.random() * ((this.human.x + 180)) + (this.human.x - 180) ;
// drip.y = Math.random() * (drip.height);
// this.dripArray.push(drip)
// this.addChild(drip);
// },100)
let drip = new engine.Sprite(
getTexture("07f74bf6-416f-445e-98d5-021efe4c9fdc")
);
drip.x = 200;
drip.y = 0;
this.dripArray.push(drip);
this.addChild(drip);
window['a'] = new engine.Graphics();
window['a'].beginFill(0xff0000);
window['a'].drawRect(280,1290,10,10);
window['a'].endFill();
this.addChild(window['a']);
window['b'] = new engine.Graphics();
window['b'].beginFill(0xff0000);
window['b'].drawRect(165,1110,10,10);
window['b'].endFill();
this.addChild(window['b']);
window['c'] = new engine.Graphics();
window['c'].beginFill(0xff0000);
window['c'].drawRect(280,940,10,10);
window['c'].endFill();
this.addChild(window['c']);
for (let i = 0; i < 1000; i++) {
let y =
-Math.sqrt(
this.R * this.R - (i - middleX - 50) * (i - middleX - 50)
) +
(this.human.y + 180);
let img = new engine.Sprite(
getTexture("e4a82aee-4472-4b06-bd75-02fb64f1c8c8")
);
img.width = 2;
img.height = 2;
img.x = i;
img.y = y;
this.con.addChild(img);
}
this.addChild(this.con);
// setInterval(()=>{
// for(let drip of this.dripArray){
// drip.y += 10;
// if(drip.y > this.stage.height){
// this.removeChild(drip);
// let index = this.dripArray.indexOf(drip)
// this.dripArray = this.dripArray.filter((ele,i)=>i != index)
// }
// }
// },100)
let ld = Date.now();
let a = 0;
this.addEventListener(engine.Event.ENTER_FRAME, () => {
let dt = Date.now() - ld;
// a += dt;
// if (a > 100) {
// a = 0;
// let drip = new engine.Sprite(
// getTexture("07f74bf6-416f-445e-98d5-021efe4c9fdc")
// );
// drip.x =
// Math.random() * (this.human.x + 180) + (this.human.x - 180);
// drip.y = Math.random() * drip.height;
// this.dripArray.push(drip);
// this.addChild(drip);
// }
for (let drip of this.dripArray) {
drip.y += (50 * dt) / 1000;
if (drip.y > this.stage.height) {
this.removeChild(drip);
let index = this.dripArray.indexOf(drip);
this.dripArray = this.dripArray.filter(
(ele, i) => i != index
);
}
}
let wind = -40;
let clicknum = this.clicknum || 0;
// let deg = (wind + 10 * clicknum );
this.rightHand.rotation += wind / 60;
// console.log(this.rightHand.rotation);
if (this.rightHand.rotation <= -90) {
this.rightHand.rotation = -90;
} else if (this.rightHand.rotation >= 90) {
this.rightHand.rotation = 90;
}
// 先算点三点最小和最大X
// a.worldMatrix.tx;
this.dripArray.forEach((v:engine.Sprite)=>{
// 看看雨滴的x是不是在
// y
});
ld = Date.now();
return;
// 扇形的角度
this.angle = Math.asin(this.D / 2 / this.R) * 57.18;
// 伞的偏移角度距离水平位置
let validMaxX;
let validMinX;
// 伞的圆函数
let ambrellaFuncY;
if (this.rightHand.rotation >= 0) {
// 伞距离中点偏移的距离
let x2 =
this.R *
Math.sin((this.angle + this.rightHand.rotation) / 180);
// 右偏移且伞左端在右边
if (this.rightHand.rotation - this.angle >= 0) {
let x =
this.R *
Math.sin((this.rightHand.rotation - this.angle) / 180);
// 伞是否完全在人的右侧 大于人物的一半宽度
validMaxX = middleX + x;
// 距离圆最远的垂直切线距离
let rx = this.R;
for (let drip of this.dripArray) {
// 伞的范围内
if (
drip.x + drip.width >= validMaxX &&
drip.x + drip.width <= middleX + this.R
) {
// ambrellaFuncY = Math.sqrt(this.R*this.R - (drip.x-this.rightHand.anchorX) * (drip.x-this.rightHand.anchorX)) + this.rightHand.anchorY;
// let r = Math.sqrt((drip.x - middleX -50)*(drip.x - middleX - 50) + ((drip.y+drip.height) - (this.human.y + 200)) * ((drip.y+drip.height) - (this.human.y + 200)))
// ambrellaFuncY = Math.sqrt(this.R*this.R - (drip.x-middleX) * (drip.x- middleX)) + (this.human.y)
let ambrellaFuncY =
-Math.sqrt(
this.R * this.R -
(drip.x - middleX - 50) *
(drip.x - middleX - 50)
) +
(this.human.y + 160);
// console.log(ambrellaFuncY,1,y,r)
// if(r <= this.R){
if (drip.y + drip.height >= ambrellaFuncY) {
this.removeChild(drip);
let index = this.dripArray.indexOf(drip);
this.dripArray = this.dripArray.filter(
(ele, i) => i != index
);
}
}
if (x - this.human.width / 2 >= 0) {
validMaxX = validX2;
}
if (
(drip.x >= validX1 && drip.x <= validMaxX) ||
(drip.x + drip.width >= validX1 &&
drip.x + drip.width <= validMaxX)
) {
// 是否发生碰撞
if (drip.y + drip.height >= this.human.y) {
this.removeChild(drip);
let index = this.dripArray.indexOf(drip);
this.dripArray = this.dripArray.filter(
(ele, i) => i != index
);
// let upset = new engine.Sprite(getTexture('ff43517a-27bb-4f73-948c-d7a4fa7b4c69'))
// upset.x = 294;
// upset.y = 900;
// this.addChild(upset);
// setTimeout(()=>{
// this.removeChild(upset)
// },1000)
}
}
}
} else {
let x =
this.R *
Math.sin((this.angle - this.rightHand.rotation) / 180);
// 右偏移且伞左端在左边
validMinX = middleX - x;
// 伞的右端
let rx =
this.R *
Math.sin((this.angle + this.rightHand.rotation) / 180);
// 伞是否完全包裹人物
for (let drip of this.dripArray) {
// 伞的范围内
if (
drip.x + drip.width >= validMinX &&
drip.x + drip.width < middleX + rx
) {
// ambrellaFuncY = Math.sqrt(this.R*this.R - (drip.x-this.rightHand.anchorX-200) * (drip.x-this.rightHand.anchorX-200)) + this.rightHand.anchorY;
// let r = Math.sqrt((drip.x - middleX-50)*(drip.x - middleX-50) + ((drip.y+drip.height) - (this.human.y + 200)) * ((drip.y+drip.height) - (this.human.y + 200)))
ambrellaFuncY =
-Math.sqrt(
this.R * this.R -
(drip.x - middleX - 50) *
(drip.x - middleX - 50)
) +
(this.human.y + 160);
// let y = Math.sqrt(this.R*this.R - (drip.x-middleX-50)*(drip.x-middleX-50)) + (this.human.y + 200);
// console.log(ambrellaFuncY,2,y,r)
if (drip.y + drip.height >= ambrellaFuncY) {
// if(r <= this.R){
this.removeChild(drip);
let index = this.dripArray.indexOf(drip);
this.dripArray = this.dripArray.filter(
(ele, i) => i != index
);
}
}
if (
(drip.x > validX1 && drip.x < validMinX) ||
(drip.x + drip.width > validX1 &&
drip.x + drip.width < validMinX)
) {
// 是否发生碰撞
if (drip.y + drip.height >= this.human.y) {
this.removeChild(drip);
let index = this.dripArray.indexOf(drip);
this.dripArray = this.dripArray.filter(
(ele, i) => i != index
);
// let upset = new engine.Sprite(getTexture('ff43517a-27bb-4f73-948c-d7a4fa7b4c69'))
// upset.x = 294;
// upset.y = 900;
// this.addChild(upset);
// setTimeout(()=>{
// this.removeChild(upset)
// },1000)
}
}
}
}
} else {
if (-this.rightHand.rotation - this.angle >= 0) {
let x =
this.R *
Math.sin((-this.angle - this.rightHand.rotation) / 180);
// 左偏且在左边
validMinX = middleX - x;
for (let drip of this.dripArray) {
// 伞的范围内(可能包括人的部分)
if (
drip.x + drip.width < validMinX &&
drip.x + drip.width > middleX - this.R
) {
// ambrellaFuncY = Math.sqrt(this.R*this.R - (drip.x-this.rightHand.anchorX) * (drip.x-this.rightHand.anchorX)) + this.rightHand.anchorY;
// ambrellaFuncY = Math.sqrt(this.R*this.R - (drip.x-this.rightHand.anchorX-200) * (drip.x-this.rightHand.anchorX-200)) + this.rightHand.anchorY + 500;
// let r = Math.sqrt((drip.x - middleX-50)*(drip.x - middleX-50) + ((drip.y+drip.height) - (this.human.y + 200)) * ((drip.y+drip.height) - (this.human.y + 200)))
ambrellaFuncY =
-Math.sqrt(
this.R * this.R -
(drip.x - middleX - 50) *
(drip.x - middleX - 50)
) +
(this.human.y + 160);
// let y = Math.sqrt(this.R*this.R - (drip.x-middleX-50)*(drip.x-middleX-50)) + (this.human.y + 200)
// console.log(ambrellaFuncY,3,y,r)
// if(r <= this.R){
if (drip.y + drip.height >= ambrellaFuncY) {
this.removeChild(drip);
let index = this.dripArray.indexOf(drip);
this.dripArray = this.dripArray.filter(
(ele, i) => i != index
);
}
}
if (x > this.human.width / 2) {
validMinX = validX1;
}
if (
(drip.x > validMinX && drip.x < validX2) ||
(drip.x + drip.width > validMinX &&
drip.x + drip.width < validX2)
) {
// 淋湿人物范围
// 人物是否发生碰撞
if (drip.y + drip.height >= this.human.y) {
this.removeChild(drip);
let index = this.dripArray.indexOf(drip);
this.dripArray = this.dripArray.filter(
(ele, i) => i != index
);
// let upset = new engine.Sprite(getTexture('ff43517a-27bb-4f73-948c-d7a4fa7b4c69'))
// upset.x = 294;
// upset.y = 900;
// this.addChild(upset);
// setTimeout(()=>{
// this.removeChild(upset)
// },1000)
}
}
}
} else {
// 左偏移且在右边
let x =
this.R *
Math.sin((this.angle + this.rightHand.rotation) / 180);
let lx =
this.R *
Math.sin((this.angle - this.rightHand.rotation) / 180);
validMinX = middleX + x;
for (let drip of this.dripArray) {
// 雨滴和伞碰撞
if (
drip.x + drip.width <= validMinX &&
drip.x + drip.width > middleX - lx
) {
// ambrellaFuncY = Math.sqrt(this.R*this.R - (drip.x-this.rightHand.anchorX) * (drip.x-this.rightHand.anchorX)) + this.rightHand.anchorY;
// ambrellaFuncY = Math.sqrt(this.R*this.R - (drip.x-middleX) * (drip.x-middleX)) + (this.human.y );
// let r = Math.sqrt((drip.x - middleX-50)*(drip.x - middleX-50) + ((drip.y+drip.height) - (this.human.y + 200)) * ((drip.y+drip.height) - (this.human.y + 200)))
// ambrellaFuncY = Math.sqrt(this.R*this.R - (drip.x-middleX) * (drip.x- middleX)) + (this.human.y);
let ambrellaFuncY =
-Math.sqrt(
this.R * this.R -
(drip.x - middleX - 50) *
(drip.x - middleX - 50)
) +
(this.human.y + 160);
// console.log(ambrellaFuncY,4,y,r)
// if(r <= this.R){
if (drip.y + drip.height >= ambrellaFuncY) {
this.removeChild(drip);
let index = this.dripArray.indexOf(drip);
this.dripArray = this.dripArray.filter(
(ele, i) => i != index
);
}
} else if (
(drip.x > validMinX && drip.x < validX2) ||
(drip.x + drip.width > validMinX &&
drip.x + drip.width < validX2)
) {
// 人物是否发生碰撞
if (drip.y + drip.height >= this.human.y) {
this.removeChild(drip);
let index = this.dripArray.indexOf(drip);
this.dripArray = this.dripArray.filter(
(ele, i) => i != index
);
// let upset = new engine.Sprite(getTexture('ff43517a-27bb-4f73-948c-d7a4fa7b4c69'))
// upset.x = 294;
// upset.y = 900;
// this.addChild(upset);
// setTimeout(()=>{
// this.removeChild(upset)
// },1000)
}
}
}
}
}
ld = Date.now();
});
this.playBtn.addEventListener(
engine.MouseEvent.CLICK,
this.onClick,
this
);
// engine.Tween.get(this.rightHand)
// .to({
// alpha:1,
// rotation:90
// },1000)
this.rightHand.rotation = 0;
// 点击按钮
//明天:伞两边的距离都要计算,判断还不完全。
// 伞在人物上方时,注意x的偏移量与人物两端的大小比较
}
onClick() {
this.clicknum += 1;
this.rightHand.rotation += 10 * this.clicknum;
this.clicknum = 0;
// setInterval(()=>{
// this.rightHand.rotation += 10*this.clicknum/60;
// },1000/60)
}
stop() {}
}
import GameView from "./GameView";
import GameTest from "./GameTest";
import { injectProps } from "../props";
export class GameWrapper extends engine.Container {
// private _status;
private _gameView: GameView;
private _gameTest: GameTest;
constructor() {
super();
engine.globalEvent.addEventListener('pictures-start', this.start, this);
engine.globalEvent.addEventListener('pictures-stop', this.stop, this);
//创建实例
// let gameView = this._gameView = new GameView();
let gameTest = this._gameTest = new GameTest();
this.addChild(gameTest);
}
start(event: engine.Event) {
injectProps(event.data);
// this._status = 1;
// this._gameView.start();
this._gameTest.start();
}
stop(event: engine.Event) {
// this._gameView.stop();
this._gameTest.stop();
}
}
import {getTexture} from './utils'
export default class Human extends engine.Container{
//常态,吃力,沮丧
humanArray = [
'487c1ca7-dea5-4732-b4b6-acb5406ee3a4',
'71e07cee-fd6d-40bb-ac0b-5bb28c87276e',
'2cd9f1bb-d0d8-42ea-941b-dcd0428e474d'
]
//三张面部表情
human:engine.Sprite = new engine.Sprite(getTexture(this.humanArray[0]))
constructor(){
super();
this.addChild(this.human)
this.width = this.human.width;
this.height = this.human.height;
}
facialChange(num){
let face = new engine.Sprite(getTexture(this.humanArray[num]));
this.human.addChild(face);
return face;
}
removeFace(face){
this.human.removeChild(face);
}
}
\ No newline at end of file
import {getTexture} from './utils'
export default class Moist extends engine.Container{
percent:number
moistBg:engine.Sprite = new engine.Sprite(getTexture('8a8e79b6-2c6f-441b-81ae-c441465abfb0'))
moist:engine.Sprite = new engine.Sprite(getTexture('024d67e9-ed7f-4481-94ca-a15bd5226cad'))
moistCover:any = new engine.Sprite(getTexture('024d67e9-ed7f-4481-94ca-a15bd5226cad'))
txt = new engine.TextInput();
hintpic:engine.Sprite = new engine.Sprite(getTexture('ed0e8931-2557-4527-bcfc-9071f90d5737'))
constructor(){
super();
this.percent = 0;
this.addChild(this.moistBg)
this.moistBg.addChild(this.moist)
this.moist.mask = this.moistCover;
this.txt.text = this.percent*100+'%';
this.txt.size = 30;
this.txt.fillColor = '#7A83C5';
this.addChild(this.txt)
this.txt.x = 0;
this.txt.y = -50;
this.hintpic.x = -10;
this.hintpic.y = 440;
this.addChild(this.hintpic)
}
cover(percent){
this.moistCover.anchorY = 416;
this.moistBg.addChild(this.moistCover)
this.moistCover.scaleY = percent;
}
stopScale(){
this.moistCover.scaleY = 1;
this.txt.text = '100%';
}
updateText(percent){
let a = percent * 100;
if(a <=90){
this.txt.text = a.toPrecision(2)+'%';
}else{
this.txt.text = a.toPrecision(3)+'%';
}
}
}
\ No newline at end of file
import {getTexture} from './utils'
export default class TimeCounter extends engine.Container{
timeCounter:engine.Sprite = new engine.Sprite(getTexture('b7d2a60a-9e60-4eca-be80-a991abea47c9'));
timeText:any;
time:number
constructor(){
super()
this.time = 20
this.addChild(this.timeCounter)
this.timeCounter.x = 256;
this.timeCounter.y = 50;
// 计时文本
this.timeText = new engine.TextInput();
this.timeText.text = this.time +'s';
this.timeText.size = 48;
this.timeText.fillColor = '#7A83C5';
this.timeCounter.addChild(this.timeText);
this.timeText.x = 100;
this.timeText.y = 15;
}
updateTime(time){
this.time = time;
this.timeText.text = this.time + 's'
}
}
\ No newline at end of file
/**
* 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 getIndexFromRC(row,col,maxCol){
let index;
index = row * maxCol + col ;
return index
}
export function getRandomArray(array){
array.sort(function() {
return .5 - Math.random();
});
}
\ No newline at end of file
import {GameWrapper} from "./game/GameWrapper";
import {injectProps, prepareProps} from "./props";
export default function (props) {
prepareProps();
injectProps(props);
let instance = new GameWrapper();
return instance;
}
export let props: any = {};
export function prepareProps() {
let metaProps = getProps();
engine.injectProp(props, metaProps);
}
export function injectProps(p) {
engine.injectProp(props, p);
}
const W = 600
const H = 600
const MAX_ROW = 3;
const MAX_COL = 3;
const GAP = 10;
const w = W / MAX_COL;
const h = H / MAX_ROW;
export default class GameView extends engine.Container{
constructor(){
super()
}
start(){
}
setup(){
}
cutPicture(parent, url, MAX_ROW, MAX_COL){
const sprite = []
for(let row = 0; row < MAX_ROW; row++) {
for(let col = 0; col < MAX_COL; col++) {
// 创建图片子节点
const child = new engine.Sprite.fromImage(url);
sprite.push(child)
child.scaleX =
}
}
}
}
\ No newline at end of file
import {props} from '../props'
import { getTexture } from "./utils";
const W = 600
const H = 600
const MAX_ROW = 3;
const MAX_COL = 3;
const GAP = 10;
const w = W / MAX_COL;
const h = H / MAX_ROW;
export default class GameView extends engine.Container{
constructor(){
super()
this.once(engine.Event.ADDED_TO_STAGE,this.setup,this);
}
start(){
}
pictures:engine.Sprite[]
private picturesWrapper: engine.Sprite;
setup(){
const getSprites = this.cutPicture(this.picturesWrapper,props.picUrl,MAX_ROW,MAX_COL)
this.pictures = getSprites[0];
const parent = new engine.Sprite();
this.picturesWrapper = parent;
this.addChild(parent);
}
// 切图
cutPicture(parent, url, MAX_ROW, MAX_COL){
const sprite = []
const spritePos = []
// 正确的图片顺序
for(let row = 0; row < MAX_ROW; row++) {
for(let col = 0; col < MAX_COL; col++) {
// 创建图片子节点
const child = engine.Sprite.fromImage(url);
sprite.push(child)
child.scaleX = 1 / MAX_COL;
child.scaleY = 1 / MAX_ROW;
parent.addChild(child);
child.x = col * (W / MAX_COL + GAP);
child.y = row * (H / MAX_ROW + GAP);
spritePos.push([child.x,child.y]);
child.addEventListener(engine.Event.COMPLETE, () => {
const uvs = new Float32Array([
col / MAX_COL,
row / MAX_ROW,
(col + 1) / MAX_COL,
row / MAX_ROW,
(col + 1) / MAX_COL,
(row + 1) / MAX_ROW,
col / MAX_COL,
(row + 1) / MAX_ROW,
]);
child.uvs = uvs;
});
}
}
return [sprite,spritePos];
}
// 随机函数
getRandomArray(array){
array.sort(()=>{
return 0.5 - Math.random();
})
}
}
\ No newline at end of file
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;
}
\ No newline at end of file
{
"name": "拼图",
"desc": "拼图模块1.0",
"props": {
"MAX_COL": {
"alias": "图片分成几列",
"type": "number",
"default": 3
},
"MAX_ROW": {
"alias": "图片分成几行",
"type": "number",
"default": 4
},
"W": {
"alias": "图片的宽度",
"type": "number",
"default": 618
},
"H": {
"alias": "图片的高度",
"type": "number",
"default": 827
},
"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": 50
}
},
"assets": [
{
"name": "遮罩",
"url": "//yun.duiba.com.cn/aurora/assets/5b3e30496b2d9fdafb0cf3835fd6704ce10e45b4.png",
"uuid": "888",
"ext": ".png"
}
],
"events": {
"in": {
"pictures-start": {
"alias": "开始",
"data": {
"picUrl":"图片路径",
"blockUrl":"blockUrl"
}
},
"pictures-stop": {
"alias": "停止"
}
},
"out": {
"pictures-time-update": {
"alias": "倒计时更新",
"data": {
"time":"剩余时间"
}
},
"pictures-game-fail": {
"alias": "游戏结束",
"data": {
"reason": "结束原因(1:时间到了)"
}
},
"pictures-game-success": {
"alias": "游戏成功",
"data": {
"time": "游戏消耗时间"
}
}
}
}
}
\ No newline at end of file
export let props: any = {};
export function prepareProps() {
let metaProps = getProps();
engine.injectProp(props, metaProps);
}
export function injectProps(p) {
engine.injectProp(props, p);
}
\ No newline at end of file
(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.pictures = 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
var picMap = {};
var posMap = {};
var qietu = (function (parent, url, MAX_COL, MAX_ROW) {
if (picMap[url]) {
var pics = picMap[url];
for (var _i = 0, pics_1 = pics; _i < pics_1.length; _i++) {
var pic = pics_1[_i];
parent.addChild(pic);
}
return [picMap[url], posMap[url]];
}
var W = props.W;
var H = props.H;
var GAP = props.GAP;
var spr = [];
var pos = [];
var _loop_1 = function (row) {
var _loop_2 = function (col) {
var child = engine.Sprite.fromImage(url);
spr.push(child);
child.scaleX = 1 / MAX_COL;
child.scaleY = 1 / MAX_ROW;
parent.addChild(child);
child.x = col * (W / MAX_COL + GAP);
child.y = row * (H / MAX_ROW + GAP);
pos.push([child.x, child.y]);
child.addEventListener(engine.Event.COMPLETE, function () {
var uvs = new Float32Array([
col / MAX_COL,
row / MAX_ROW,
(col + 1) / MAX_COL,
row / MAX_ROW,
(col + 1) / MAX_COL,
(row + 1) / MAX_ROW,
col / MAX_COL,
(row + 1) / MAX_ROW,
]);
child.uvs = uvs;
});
};
for (var col = 0; col < MAX_COL; col++) {
_loop_2(col);
}
};
for (var row = 0; row < MAX_ROW; row++) {
_loop_1(row);
}
picMap[url] = spr.concat([]);
posMap[url] = pos.concat([]);
return [spr, pos];
});
//# sourceMappingURL=qietu.js.map
function getIndexFromRC(row, col, maxCol) {
var index;
index = row * maxCol + col;
return index;
}
function getRandomArray(array) {
array.sort(function () {
return .5 - Math.random();
});
}
//# sourceMappingURL=utils.js.map
var MAX_COL;
var MAX_ROW;
var W;
var H;
var GAP;
var GAME_TIME;
var w;
var h;
var GameView = (function (_super) {
tslib.__extends(GameView, _super);
function GameView() {
var _this = _super.call(this) || this;
_this._timeCounter = 0;
_this.listenStageOn = 1;
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
return _this;
}
GameView.prototype.start = function () {
var _this = this;
if (!this.guideHole) {
this.guideHole = new engine.Image();
this.guideHole.source = "asset://" + props.blockUrl;
this.guideHole.mouseChildren = this.guideHole.mouseEnabled = false;
}
if (this.pictures) {
for (var _i = 0, _a = this.pictures; _i < _a.length; _i++) {
var pic = _a[_i];
if (pic && pic.parent)
pic.parent.removeChild(pic);
}
}
console.log("on start");
engine.globalEvent.dispatchEvent("pictures-time-update", {
second: this.getSecond(),
});
var result = qietu(this.picturesWrapper, props.picUrl, MAX_COL, MAX_ROW);
this.picturesWrapper.addChild(this.guideHole);
console.log(this.picturesWrapper);
this.pictures = result[0];
this.rightList = this.pictures.concat([]);
var posList = result[1];
getRandomArray(this.pictures);
var i = 0;
var len;
len = this.pictures.length;
for (; i < len; i++) {
this.dragPic = this.pictures[i];
this.pictures[i].addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDown, this);
var _b = posList[i], x = _b[0], y = _b[1];
this.dragPic.x = x;
this.dragPic.y = y;
}
this._timer = setInterval(function () {
_this.onTimer();
}, 10);
};
GameView.prototype.onTimer = function () {
GAME_TIME -= 0.01;
GAME_TIME = this.afterPointTwo(GAME_TIME);
GAME_TIME = GAME_TIME.toFixed(2);
if (GAME_TIME < 10) {
GAME_TIME = "0" + GAME_TIME;
}
console.log(GAME_TIME);
engine.globalEvent.dispatchEvent("pictures-time-update", {
second: this.getSecond(),
});
if (this.getSecond() == 0) {
GAME_TIME = props.GAME_TIME;
this.stop();
engine.globalEvent.dispatchEvent("pictures-game-fail", {
reason: 1,
});
}
};
GameView.prototype.afterPointTwo = function (n) {
var floatN = parseFloat(n);
if (isNaN(floatN)) {
return;
}
floatN = Math.round(floatN * 100) / 100;
return floatN;
};
GameView.prototype.getSecond = function () {
return GAME_TIME;
};
GameView.prototype.stop = function () {
clearInterval(this._timer);
this.stage.removeEventListener(engine.MouseEvent.MOUSE_UP, this.stageOnUp, this);
var len = this.pictures.length;
for (var i = 0; i < len; i++) {
this.pictures[i].removeAllEventListener();
}
};
GameView.prototype.createRects = function () { };
GameView.prototype.setup = function () {
MAX_COL = props.MAX_COL;
MAX_ROW = props.MAX_ROW;
GAME_TIME = props.GAME_TIME;
W = props.W;
H = props.H;
GAP = props.GAP;
w = W / MAX_COL;
h = H / MAX_ROW;
console.log("onSteup", props);
var parent = new engine.Sprite();
this.picturesWrapper = parent;
this.addChild(parent);
};
GameView.prototype.onDown = function (e) {
var stageLeft = (750 - props.W) / 2;
var stageTop = (this.stage.height - props.H) / 2;
this.dragPic = e.target;
this.picturesWrapper.addChild(this.dragPic);
this.localPicX = e.localX / MAX_COL;
this.localPicY = e.localY / MAX_ROW;
this.distanceX = this.dragPic.x;
this.distanceY = this.dragPic.y;
this.indexJ = Math.floor(this.distanceX / (w + GAP));
this.indexI = Math.floor(this.distanceY / (h + GAP));
this.index = this.indexI * MAX_COL + this.indexJ;
this.centerX = Math.floor((e.clientX - stageLeft) / w) * w + w / 2;
this.centerY = Math.floor((e.clientY - stageTop) / h) * h + h / 2;
this.stage.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMove, this);
this.stage.addEventListener(engine.MouseEvent.MOUSE_UP, this.stageOnUp, this);
};
GameView.prototype.stageOnUp = function () {
if (GAME_TIME > 0) {
var stageLeft = (750 - props.W) / 2;
var stageTop = (this.stage.height - props.H) / 2;
this.stage.removeEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMove, this);
this.stage.removeEventListener(engine.MouseEvent.MOUSE_UP, this.stageOnUp, this);
if (this.centerY < stageTop || this.centerX < stageLeft) {
this.dragPic.x = this.distanceX;
this.dragPic.y = this.distanceY;
}
var curJ = Math.floor(this.centerX / (w + GAP));
var curI = Math.floor(this.centerY / (h + GAP));
this.picturesWrapper.addChild(this.guideHole);
if (0 <= curJ && curJ < MAX_COL && 0 <= curI && curI < MAX_ROW) {
var index = getIndexFromRC(curI, curJ, MAX_COL);
var dropPic = this.pictures[index];
var dropPicX = dropPic.x + stageLeft;
var dropPicy = dropPic.y + stageTop;
dropPic.x = this.distanceX;
dropPic.y = this.distanceY;
this.dragPic.x = dropPicX - stageLeft;
this.dragPic.y = dropPicy - stageTop;
var dropPicIndex = this.pictures.indexOf(dropPic);
var dragPicIndex = this.pictures.indexOf(this.dragPic);
this.pictures[dropPicIndex] = this.dragPic;
this.pictures[dragPicIndex] = dropPic;
if (dragPicIndex === dropPicIndex) {
this.dragPic.x = this.distanceX;
this.dragPic.y = this.distanceY;
}
var result = true;
for (var j = 0; j < this.rightList.length; j++) {
if (this.rightList[j] != this.pictures[j]) {
result = false;
break;
}
}
if (result) {
this.onSuccess();
}
}
else {
this.dragPic.x = this.distanceX;
this.dragPic.y = this.distanceY;
}
}
};
GameView.prototype.onSuccess = function () {
console.log("拼图成功!");
engine.globalEvent.dispatchEvent("pictures-game-success", {
time: GAME_TIME,
});
this.stop();
};
GameView.prototype.onMove = function (e) {
this.dragPic.x = e.stageX - this.localPicX - (750 - props.W) / 2;
this.dragPic.y =
e.stageY - this.localPicY - (this.stage.height - props.H) / 2;
this.centerX = this.dragPic.x + w / 2;
this.centerY = this.dragPic.y + h / 2;
};
return GameView;
}(engine.Container));
var GameWrapper = (function (_super) {
tslib.__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('pictures-start', _this.start, _this);
engine.globalEvent.addEventListener('pictures-stop', _this.stop, _this);
var gameView = _this._gameView = new GameView();
_this.addChild(gameView);
return _this;
}
GameWrapper.prototype.start = function (event) {
injectProps(event.data);
this._gameView.start();
};
GameWrapper.prototype.stop = function (event) {
this._gameView.stop();
};
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
"use strict";var tslib=require("tslib"),props={};function prepareProps(){var t=getProps();engine.injectProp(props,t)}function injectProps(t){engine.injectProp(props,t)}var MAX_COL,MAX_ROW,W,H,GAP,GAME_TIME,w,h,picMap={},posMap={},qietu=function(n,r,o,a){if(picMap[r]){for(var t=0,e=picMap[r];t<e.length;t++){var i=e[t];n.addChild(i)}return[picMap[r],posMap[r]]}for(var p=props.W,h=props.H,c=props.GAP,d=[],g=[],s=0;s<a;s++)!function(s){for(var t=0;t<o;t++)!function(e){var i=engine.Sprite.fromImage(r);d.push(i),i.scaleX=1/o,i.scaleY=1/a,n.addChild(i),i.x=e*(p/o+c),i.y=s*(h/a+c),g.push([i.x,i.y]),i.addEventListener(engine.Event.COMPLETE,function(){var t=new Float32Array([e/o,s/a,(e+1)/o,s/a,(e+1)/o,(s+1)/a,e/o,(s+1)/a]);i.uvs=t})}(t)}(s);return picMap[r]=d.concat([]),posMap[r]=g.concat([]),[d,g]};function getIndexFromRC(t,e,i){return t*i+e}function getRandomArray(t){t.sort(function(){return.5-Math.random()})}var GameView=function(e){function t(){var t=e.call(this)||this;return t._timeCounter=0,t.listenStageOn=1,t.once(engine.Event.ADDED_TO_STAGE,t.setup,t),t}return tslib.__extends(t,e),t.prototype.start=function(){var t=this;if(this.guideHole||(this.guideHole=new engine.Image,this.guideHole.source="asset://"+props.blockUrl,this.guideHole.mouseChildren=this.guideHole.mouseEnabled=!1),this.pictures)for(var e=0,i=this.pictures;e<i.length;e++){var s=i[e];s&&s.parent&&s.parent.removeChild(s)}console.log("on start"),engine.globalEvent.dispatchEvent("pictures-time-update",{second:this.getSecond()});var n=qietu(this.picturesWrapper,props.picUrl,MAX_COL,MAX_ROW);this.picturesWrapper.addChild(this.guideHole),console.log(this.picturesWrapper),this.pictures=n[0],this.rightList=this.pictures.concat([]);var r=n[1];getRandomArray(this.pictures);for(var o=0,a=this.pictures.length;o<a;o++){this.dragPic=this.pictures[o],this.pictures[o].addEventListener(engine.MouseEvent.MOUSE_DOWN,this.onDown,this);var p=r[o],h=p[0],c=p[1];this.dragPic.x=h,this.dragPic.y=c}this._timer=setInterval(function(){t.onTimer()},10),this.date=(new Date).getTime()},t.prototype.onTimer=function(){var t=(new Date).getTime(),e=(t-this.date)/1e3;this.date=t,console.log(e,"gap"),(GAME_TIME-=e)<0&&(GAME_TIME=0),(GAME_TIME=(GAME_TIME=this.afterPointTwo(GAME_TIME)).toFixed(2))<10&&(GAME_TIME="0"+GAME_TIME),console.log(GAME_TIME),engine.globalEvent.dispatchEvent("pictures-time-update",{second:this.getSecond()}),0==this.getSecond()&&(this.stop(),engine.globalEvent.dispatchEvent("pictures-game-fail",{reason:1}))},t.prototype.afterPointTwo=function(t){var e=parseFloat(t);if(!isNaN(e))return e=Math.round(100*e)/100},t.prototype.getSecond=function(){return GAME_TIME},t.prototype.stop=function(){GAME_TIME=props.GAME_TIME,clearInterval(this._timer);for(var t=this.pictures.length,e=0;e<t;e++)this.pictures[e].removeAllEventListener();this.stage.removeEventListener(engine.MouseEvent.MOUSE_UP,this.stageOnUp,this)},t.prototype.createRects=function(){},t.prototype.setup=function(){MAX_COL=props.MAX_COL,MAX_ROW=props.MAX_ROW,GAME_TIME=props.GAME_TIME,W=props.W,H=props.H,GAP=props.GAP,w=W/MAX_COL,h=H/MAX_ROW,console.log("onSteup",props);var t=new engine.Sprite;this.picturesWrapper=t,this.addChild(t)},t.prototype.onDown=function(t){var e=(750-props.W)/2,i=(this.stage.height-props.H)/2;this.dragPic=t.target,this.picturesWrapper.addChild(this.dragPic),this.localPicX=t.localX/MAX_COL,this.localPicY=t.localY/MAX_ROW,this.distanceX=this.dragPic.x,this.distanceY=this.dragPic.y,this.indexJ=Math.floor(this.distanceX/(w+GAP)),this.indexI=Math.floor(this.distanceY/(h+GAP)),this.index=this.indexI*MAX_COL+this.indexJ,this.centerX=Math.floor((t.clientX-e)/w)*w+w/2,this.centerY=Math.floor((t.clientY-i)/h)*h+h/2,this.stage.addEventListener(engine.MouseEvent.MOUSE_MOVE,this.onMove,this),this.stage.addEventListener(engine.MouseEvent.MOUSE_UP,this.stageOnUp,this)},t.prototype.stageOnUp=function(t){var e=(750-props.W)/2,i=(this.stage.height-props.H)/2;this.stage.removeEventListener(engine.MouseEvent.MOUSE_MOVE,this.onMove,this),this.stage.removeEventListener(engine.MouseEvent.MOUSE_UP,this.stageOnUp,this),(this.centerY<i||this.centerX<e)&&(this.dragPic.x=this.distanceX,this.dragPic.y=this.distanceY);var s=Math.floor(this.centerX/(w+GAP)),n=Math.floor(this.centerY/(h+GAP));if(this.picturesWrapper.addChild(this.guideHole),0<=s&&s<MAX_COL&&0<=n&&n<MAX_ROW){var r=getIndexFromRC(n,s,MAX_COL),o=this.pictures[r],a=o.x+e,p=o.y+i;o.x=this.distanceX,o.y=this.distanceY,this.dragPic.x=a-e,this.dragPic.y=p-i;var c=this.pictures.indexOf(o),d=this.pictures.indexOf(this.dragPic);this.pictures[c]=this.dragPic,this.pictures[d]=o,d===c&&(this.dragPic.x=this.distanceX,this.dragPic.y=this.distanceY);for(var g=!0,u=0;u<this.rightList.length;u++)if(this.rightList[u]!=this.pictures[u]){g=!1;break}g&&this.onSuccess()}else this.dragPic.x=this.distanceX,this.dragPic.y=this.distanceY},t.prototype.onSuccess=function(){console.log("拼图成功!"),engine.globalEvent.dispatchEvent("pictures-game-success",{time:GAME_TIME}),this.stop()},t.prototype.onMove=function(t){this.dragPic.x=t.stageX-this.localPicX-(750-props.W)/2,this.dragPic.y=t.stageY-this.localPicY-(this.stage.height-props.H)/2,this.centerX=this.dragPic.x+w/2,this.centerY=this.dragPic.y+h/2},t}(engine.Container),GameWrapper=function(i){function t(){var t=i.call(this)||this;engine.globalEvent.addEventListener("pictures-start",t.start,t),engine.globalEvent.addEventListener("pictures-stop",t.stop,t);var e=t._gameView=new GameView;return t.addChild(e),t}return tslib.__extends(t,i),t.prototype.start=function(t){injectProps(t.data),this._gameView.start()},t.prototype.stop=function(t){this._gameView.stop()},t}(engine.Container);function index(t){return prepareProps(),injectProps(t),new GameWrapper}module.exports=index;
{"version":3,"file":"index.js","sources":["src/custom/pictures/src/props.ts","src/custom/pictures/src/game/qietu.ts","src/custom/pictures/src/game/utils.ts","src/custom/pictures/src/game/GameView.ts","src/custom/pictures/src/game/GameWrapper.ts","src/custom/pictures/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","import { props } from \"../props\";\r\nconst urls = [];\r\nconst picMap = {};\r\nconst posMap = {};\r\nexport default (parent, url, MAX_COL, MAX_ROW) => {\r\n if (picMap[url]) {\r\n const pics:any[] = picMap[url];\r\n for (const pic of pics) {\r\n parent.addChild(pic);\r\n }\r\n return [picMap[url], posMap[url]]\r\n }\r\n\r\n const W = props.W;\r\n const H = props.H;\r\n const GAP = props.GAP;\r\n\r\n const spr = [];\r\n const pos = []\r\n\r\n for (let row = 0; row < MAX_ROW; row++) {\r\n for (let col = 0; col < MAX_COL; col++) {\r\n\r\n const child = engine.Sprite.fromImage(url);\r\n spr.push(child);\r\n\r\n child.scaleX = 1 / MAX_COL;\r\n child.scaleY = 1 / MAX_ROW;\r\n parent.addChild(child);\r\n child.x = col * (W / MAX_COL + GAP);\r\n child.y = row * (H / MAX_ROW + GAP);\r\n pos.push([child.x, child.y]);\r\n // child.texture.addEventListener('update', () => {\r\n child.addEventListener(engine.Event.COMPLETE, () => {\r\n const uvs = new Float32Array([\r\n col / MAX_COL,\r\n row / MAX_ROW,\r\n (col + 1) / MAX_COL,\r\n row / MAX_ROW,\r\n (col + 1) / MAX_COL,\r\n (row + 1) / MAX_ROW,\r\n col / MAX_COL,\r\n (row + 1) / MAX_ROW,\r\n ]);\r\n\r\n child.uvs = uvs;\r\n // spr.push(child);\r\n });\r\n }\r\n }\r\n picMap[url] = spr.concat([]);\r\n posMap[url] = pos.concat([]);;\r\n // console.log(spr);\r\n return [spr, pos];\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 getIndexFromRC(row,col,maxCol){\r\n\tlet index;\r\n\tindex = row * maxCol + col ;\r\n\treturn index\r\n}\r\n\r\n\r\n\r\n\r\nexport function getRandomArray(array){\r\n\tarray.sort(function() {\r\n\t\treturn .5 - Math.random();\r\n\t});\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 { getIndexFromRC, getRandomArray, getTexture } from \"./utils\";\r\nimport ObjectPool = engine.ObjectPool;\r\n\r\n// let OFFSET_X;\r\n// let OFFSET_Y;\r\nlet MAX_COL;\r\nlet MAX_ROW;\r\nlet W;\r\nlet H;\r\nlet GAP;\r\nlet GAME_TIME;\r\n// 每张图片宽\r\nlet w;\r\n// 每张图片高\r\nlet h;\r\n\r\nexport default class GameView extends engine.Container {\r\n private _timer;\r\n private _timeCounter = 0;\r\n\r\n start() {\r\n if (!this.guideHole) {\r\n this.guideHole = new engine.Image();\r\n this.guideHole.source = \"asset://\" + props.blockUrl;\r\n this.guideHole.mouseChildren = this.guideHole.mouseEnabled = false;\r\n }\r\n\r\n if (this.pictures) {\r\n for (const pic of this.pictures) {\r\n if (pic && pic.parent) pic.parent.removeChild(pic);\r\n }\r\n }\r\n\r\n console.log(\"on start\");\r\n engine.globalEvent.dispatchEvent(\"pictures-time-update\", {\r\n second: this.getSecond(),\r\n });\r\n\r\n // 图片一维数组\r\n const result = qietu(this.picturesWrapper, props.picUrl, MAX_COL, MAX_ROW);\r\n this.picturesWrapper.addChild(this.guideHole);\r\n\r\n console.log(this.picturesWrapper);\r\n\r\n this.pictures = result[0];\r\n this.rightList = this.pictures.concat([]);\r\n const posList = result[1];\r\n getRandomArray(this.pictures);\r\n\r\n let i = 0;\r\n let len;\r\n len = this.pictures.length;\r\n\r\n for (; i < len; i++) {\r\n this.dragPic = this.pictures[i];\r\n this.pictures[i].addEventListener(\r\n engine.MouseEvent.MOUSE_DOWN,\r\n this.onDown,\r\n this\r\n );\r\n const [x, y] = posList[i];\r\n this.dragPic.x = x;\r\n this.dragPic.y = y;\r\n }\r\n\r\n this._timer = setInterval(() => {\r\n this.onTimer();\r\n }, 10);\r\n }\r\n\r\n onTimer() {\r\n // 以GAME_TIME为标准\r\n GAME_TIME -= 0.01;\r\n GAME_TIME = this.afterPointTwo(GAME_TIME);\r\n GAME_TIME = GAME_TIME.toFixed(2);\r\n if (GAME_TIME < 10) {\r\n GAME_TIME = \"0\" + GAME_TIME;\r\n }\r\n console.log(GAME_TIME);\r\n\r\n engine.globalEvent.dispatchEvent(\"pictures-time-update\", {\r\n second: this.getSecond(),\r\n });\r\n\r\n if (this.getSecond() == 0) {\r\n \r\n GAME_TIME = props.GAME_TIME;\r\n this.stop();\r\n \r\n engine.globalEvent.dispatchEvent(\"pictures-game-fail\", {\r\n reason: 1,\r\n });\r\n }\r\n }\r\n\r\n afterPointTwo(n) {\r\n var floatN = parseFloat(n);\r\n if (isNaN(floatN)) {\r\n return;\r\n }\r\n\r\n floatN = Math.round(floatN * 100) / 100;\r\n\r\n return floatN;\r\n }\r\n\r\n getSecond() {\r\n return GAME_TIME;\r\n }\r\n\r\n stop() {\r\n // GAME_TIME = props.GAME_TIME\r\n clearInterval(this._timer);\r\n this.stage.removeEventListener(\r\n engine.MouseEvent.MOUSE_UP,\r\n this.stageOnUp,\r\n this\r\n );\r\n let len = this.pictures.length;\r\n for (let i = 0; i < len; i++) {\r\n this.pictures[i].removeAllEventListener();\r\n }\r\n // this.dragPic.removeAllEventListener();\r\n \r\n }\r\n\r\n constructor() {\r\n super();\r\n this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);\r\n }\r\n\r\n //当前图片对象\r\n dragPic;\r\n // 鼠标在当前图片上的位置\r\n localPicX;\r\n localPicY;\r\n // 拖动的图片最开始的位置(左上角为准)\r\n distanceX;\r\n distanceY;\r\n // 图片中心的位置\r\n centerX: number;\r\n centerY: number;\r\n\r\n pictures: engine.Sprite[];\r\n\r\n // 点击图片时的一维数组索引\r\n index;\r\n // 计算目标图片行和列的位置\r\n indexI: number;\r\n indexJ: number;\r\n rightList: engine.Sprite[];\r\n\r\n private picturesWrapper: engine.Sprite;\r\n private guideHole: engine.Image;\r\n\r\n createRects() {}\r\n setup() {\r\n MAX_COL = props.MAX_COL;\r\n MAX_ROW = props.MAX_ROW;\r\n GAME_TIME = props.GAME_TIME;\r\n // OFFSET_X = props.OFFSET_X;\r\n // OFFSET_Y = props.OFFSET_Y;\r\n W = props.W;\r\n H = props.H;\r\n GAP = props.GAP;\r\n // 每张图片宽\r\n w = W / MAX_COL;\r\n // 每张图片高\r\n h = H / MAX_ROW;\r\n\r\n console.log(\"onSteup\", props);\r\n\r\n const parent = new engine.Sprite();\r\n this.picturesWrapper = parent;\r\n this.addChild(parent);\r\n\r\n // this.picturesWrapper.x = OFFSET_X;\r\n // this.picturesWrapper.y = OFFSET_Y;\r\n\r\n // 添加按钮\r\n // const btn = new engine.Rect();\r\n // btn.width = 200;\r\n // btn.height = 100;\r\n // btn.stage.top = 1000;\r\n // btn.stage.left = 350;\r\n // btn.fillColor = 'cyan';\r\n // this.addChild(btn)\r\n\r\n // btn.addEventListener(engine.MouseEvent.CLICK,this.onClk,this)\r\n }\r\n\r\n onDown(e: engine.MouseEvent) {\r\n // console.log(e);\r\n\r\n let stageLeft = (750 - props.W) / 2;\r\n let stageTop = (this.stage.height - props.H) / 2;\r\n\r\n // 创建一个图片对象接收当前位置信息\r\n this.dragPic = e.target;\r\n this.picturesWrapper.addChild(this.dragPic);\r\n\r\n // 鼠标的偏移量\r\n this.localPicX = e.localX / MAX_COL;\r\n this.localPicY = e.localY / MAX_ROW;\r\n\r\n // 最开始图片的位置\r\n this.distanceX = this.dragPic.x;\r\n this.distanceY = this.dragPic.y;\r\n\r\n // 最开始点击的图片的索引值\r\n\r\n this.indexJ = Math.floor(this.distanceX / (w + GAP));\r\n this.indexI = Math.floor(this.distanceY / (h + GAP));\r\n this.index = this.indexI * MAX_COL + this.indexJ;\r\n\r\n // this.centerX = Math.floor(e.clientX / w) * w + w / 2;\r\n // this.centerY = Math.floor(e.clientY / h) * h + h / 2;\r\n\r\n this.centerX = Math.floor((e.clientX - stageLeft) / w) * w + w / 2;\r\n this.centerY = Math.floor((e.clientY - stageTop) / h) * h + h / 2;\r\n\r\n this.stage.addEventListener(\r\n engine.MouseEvent.MOUSE_MOVE,\r\n this.onMove,\r\n this\r\n );\r\n this.stage.addEventListener(\r\n engine.MouseEvent.MOUSE_UP,\r\n this.stageOnUp,\r\n this\r\n );\r\n }\r\n\r\n listenStageOn = 1;\r\n /*\r\n stageOnUp(e) {\r\n\r\n let stageLeft = (750 - props.W) / 2\r\n let stageTop = (this.stage.height - props.H) / 2;\r\n\r\n this.stage.removeEventListener(\r\n engine.MouseEvent.MOUSE_MOVE,\r\n this.onMove,\r\n this\r\n );\r\n\r\n this.stage.removeEventListener(\r\n engine.MouseEvent.MOUSE_UP,\r\n this.stageOnUp,\r\n this\r\n );\r\n\r\n // 拖动的图片的中心位置在图片之外,回到原来的位置\r\n if (this.centerY < stageTop || this.centerX < stageLeft) {\r\n this.dragPic.x = this.distanceX ;\r\n this.dragPic.y = this.distanceY ;\r\n }\r\n\r\n // 判断图片是否进入另一张图片的范围内\r\n // 要交换的图片第几行第几列\r\n let curJ = Math.floor(this.centerX / (w + GAP));\r\n let curI = Math.floor(this.centerY / (h + GAP));\r\n\r\n this.picturesWrapper.addChild(this.guideHole);\r\n\r\n\r\n // 点击图片的位置\r\n\r\n if ( 0 <= curJ && curJ < (MAX_COL) && 0 <= curI && curI < (MAX_ROW)) {\r\n\r\n // 获取交互图片的索引值\r\n let index = getIndexFromRC(curI, curJ, MAX_COL);\r\n // console.log(index);\r\n\r\n //要交换的图片\r\n let dropPic = this.pictures[index];\r\n\r\n let dropPicX = dropPic.x + stageLeft;\r\n let dropPicy = dropPic.y + stageTop;\r\n\r\n dropPic.x = this.distanceX;\r\n dropPic.y = this.distanceY;\r\n\r\n this.dragPic.x = dropPicX - stageLeft;\r\n this.dragPic.y = dropPicy - stageTop;\r\n\r\n // 交换之后索引也需要交换\r\n\r\n const dropPicIndex = this.pictures.indexOf(dropPic);\r\n const dragPicIndex = this.pictures.indexOf(this.dragPic);\r\n\r\n this.pictures[dropPicIndex] = this.dragPic;\r\n this.pictures[dragPicIndex] = dropPic;\r\n\r\n // 图片中心还是在原来的位置\r\n if (dragPicIndex === dropPicIndex) {\r\n this.dragPic.x = this.distanceX\r\n this.dragPic.y = this.distanceY\r\n }\r\n\r\n let result = true;\r\n for (let j = 0; j < this.rightList.length; j++) {\r\n if (this.rightList[j] != this.pictures[j]) {\r\n result = false;\r\n break;\r\n }\r\n }\r\n\r\n if (result) {\r\n this.onSuccess();\r\n\r\n }\r\n } else {\r\n this.dragPic.x = this.distanceX\r\n this.dragPic.y = this.distanceY\r\n }\r\n\r\n\r\n }\r\n\r\n */\r\n\r\n stageOnUp() {\r\n if (GAME_TIME > 0) {\r\n let stageLeft = (750 - props.W) / 2;\r\n let stageTop = (this.stage.height - props.H) / 2;\r\n\r\n this.stage.removeEventListener(\r\n engine.MouseEvent.MOUSE_MOVE,\r\n this.onMove,\r\n this\r\n );\r\n\r\n this.stage.removeEventListener(\r\n engine.MouseEvent.MOUSE_UP,\r\n this.stageOnUp,\r\n this\r\n );\r\n\r\n // 拖动的图片的中心位置在图片之外,回到原来的位置\r\n if (this.centerY < stageTop || this.centerX < stageLeft) {\r\n this.dragPic.x = this.distanceX;\r\n this.dragPic.y = this.distanceY;\r\n }\r\n\r\n // 判断图片是否进入另一张图片的范围内\r\n // 要交换的图片第几行第几列\r\n let curJ = Math.floor(this.centerX / (w + GAP));\r\n let curI = Math.floor(this.centerY / (h + GAP));\r\n\r\n this.picturesWrapper.addChild(this.guideHole);\r\n\r\n // 点击图片的位置\r\n\r\n if (0 <= curJ && curJ < MAX_COL && 0 <= curI && curI < MAX_ROW) {\r\n // 获取交互图片的索引值\r\n let index = getIndexFromRC(curI, curJ, MAX_COL);\r\n // console.log(index);\r\n\r\n //要交换的图片\r\n let dropPic = this.pictures[index];\r\n\r\n let dropPicX = dropPic.x + stageLeft;\r\n let dropPicy = dropPic.y + stageTop;\r\n\r\n dropPic.x = this.distanceX;\r\n dropPic.y = this.distanceY;\r\n\r\n this.dragPic.x = dropPicX - stageLeft;\r\n this.dragPic.y = dropPicy - stageTop;\r\n\r\n // 交换之后索引也需要交换\r\n\r\n const dropPicIndex = this.pictures.indexOf(dropPic);\r\n const dragPicIndex = this.pictures.indexOf(this.dragPic);\r\n\r\n this.pictures[dropPicIndex] = this.dragPic;\r\n this.pictures[dragPicIndex] = dropPic;\r\n\r\n // 图片中心还是在原来的位置\r\n if (dragPicIndex === dropPicIndex) {\r\n this.dragPic.x = this.distanceX;\r\n this.dragPic.y = this.distanceY;\r\n }\r\n\r\n let result = true;\r\n for (let j = 0; j < this.rightList.length; j++) {\r\n if (this.rightList[j] != this.pictures[j]) {\r\n result = false;\r\n break;\r\n }\r\n }\r\n\r\n if (result) {\r\n this.onSuccess();\r\n }\r\n } else {\r\n this.dragPic.x = this.distanceX;\r\n this.dragPic.y = this.distanceY;\r\n }\r\n }\r\n }\r\n\r\n private onSuccess() {\r\n console.log(\"拼图成功!\");\r\n engine.globalEvent.dispatchEvent(\"pictures-game-success\", {\r\n time: GAME_TIME,\r\n });\r\n this.stop();\r\n }\r\n\r\n onMove(e: engine.MouseEvent) {\r\n // 当前图片的位置\r\n this.dragPic.x = e.stageX - this.localPicX - (750 - props.W) / 2;\r\n this.dragPic.y =\r\n e.stageY - this.localPicY - (this.stage.height - props.H) / 2;\r\n\r\n // 当前图片的中心位置\r\n this.centerX = this.dragPic.x + w / 2;\r\n this.centerY = this.dragPic.y + h / 2;\r\n }\r\n\r\n // onClk(e){\r\n // // 重置时间\r\n // this._timeCounter = 0;\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\tengine.globalEvent.addEventListener('pictures-start', this.start, this);\r\n\t\tengine.globalEvent.addEventListener('pictures-stop', this.stop, this);\r\n\r\n\t\t//创建实例\r\n\t\tlet gameView = this._gameView = new GameView();\r\n\t\tthis.addChild(gameView);\r\n\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\tstop(event: engine.Event) {\r\n\t\t\r\n\t\tthis._gameView.stop();\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\treturn instance;\r\n}\r\n"],"names":["__extends"],"mappings":";;;;;;CAIO,IAAI,KAAK,GAAQ,EAAE,CAAC;UAEX,YAAY;KAC3B,IAAI,SAAS,GAAG,QAAQ,EAAE,CAAC;KAE3B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;CACrC,CAAC;UAEe,WAAW,CAAC,CAAC;KAC5B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;CAC7B,CAAC;;;CCZD,IAAM,MAAM,GAAG,EAAE,CAAC;CAClB,IAAM,MAAM,GAAG,EAAE,CAAC;AAClB,cAAe,UAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO;KAC3C,IAAI,MAAM,CAAC,GAAG,CAAC,EAAE;SACf,IAAM,IAAI,GAAS,MAAM,CAAC,GAAG,CAAC,CAAC;SAC/B,KAAkB,UAAI,EAAJ,aAAI,EAAJ,kBAAI,EAAJ,IAAI,EAAE;aAAnB,IAAM,GAAG,aAAA;aACZ,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;UACtB;SACD,OAAO,CAAC,MAAM,CAAC,GAAG,C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KAAK,CAAC,CAAC,IAAI,CAAC,CAAC;SAGhE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;SACtC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;MACvC;KAQH,eAAC;CAAD,CAAC,CA5ZqC,MAAM,CAAC,SAAS,GA4ZrD;;CC1aD;KAAiCA,qCAAgB;KAQhD;SAAA,YACC,iBAAO,SASP;SAPA,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,gBAAgB,EAAE,KAAI,CAAC,KAAK,EAAE,KAAI,CAAC,CAAC;SACxE,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,eAAe,EAAE,KAAI,CAAC,IAAI,EAAE,KAAI,CAAC,CAAC;SAGtE,IAAI,QAAQ,GAAG,KAAI,CAAC,SAAS,GAAG,IAAI,QAAQ,EAAE,CAAC;SAC/C,KAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;;MAExB;KAED,2BAAK,GAAL,UAAM,KAAmB;SACxB,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SAIxB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;MACvB;KACD,0BAAI,GAAJ,UAAK,KAAmB;SAEvB,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;MACtB;KACF,kBAAC;CAAD,CAAC,CA/BgC,MAAM,CAAC,SAAS,GA+BhD;;;iBChCwB,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
{"version":3,"file":"index.js","sources":["src/custom/pictures/src/props.ts","src/custom/pictures/src/game/qietu.ts","src/custom/pictures/src/game/utils.ts","src/custom/pictures/src/game/GameView.ts","src/custom/pictures/src/game/GameWrapper.ts","src/custom/pictures/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","import { props } from \"../props\";\r\nconst urls = [];\r\nconst picMap = {};\r\nconst posMap = {};\r\nexport default (parent, url, MAX_COL, MAX_ROW) => {\r\n if (picMap[url]) {\r\n const pics:any[] = picMap[url];\r\n for (const pic of pics) {\r\n parent.addChild(pic);\r\n }\r\n return [picMap[url], posMap[url]]\r\n }\r\n\r\n const W = props.W;\r\n const H = props.H;\r\n const GAP = props.GAP;\r\n\r\n const spr = [];\r\n const pos = []\r\n\r\n for (let row = 0; row < MAX_ROW; row++) {\r\n for (let col = 0; col < MAX_COL; col++) {\r\n\r\n const child = engine.Sprite.fromImage(url);\r\n spr.push(child);\r\n\r\n child.scaleX = 1 / MAX_COL;\r\n child.scaleY = 1 / MAX_ROW;\r\n parent.addChild(child);\r\n child.x = col * (W / MAX_COL + GAP);\r\n child.y = row * (H / MAX_ROW + GAP);\r\n pos.push([child.x, child.y]);\r\n // child.texture.addEventListener('update', () => {\r\n child.addEventListener(engine.Event.COMPLETE, () => {\r\n const uvs = new Float32Array([\r\n col / MAX_COL,\r\n row / MAX_ROW,\r\n (col + 1) / MAX_COL,\r\n row / MAX_ROW,\r\n (col + 1) / MAX_COL,\r\n (row + 1) / MAX_ROW,\r\n col / MAX_COL,\r\n (row + 1) / MAX_ROW,\r\n ]);\r\n\r\n child.uvs = uvs;\r\n // spr.push(child);\r\n });\r\n }\r\n }\r\n picMap[url] = spr.concat([]);\r\n posMap[url] = pos.concat([]);;\r\n // console.log(spr);\r\n return [spr, pos];\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 getIndexFromRC(row,col,maxCol){\r\n\tlet index;\r\n\tindex = row * maxCol + col ;\r\n\treturn index\r\n}\r\n\r\n\r\n\r\n\r\nexport function getRandomArray(array){\r\n\tarray.sort(function() {\r\n\t\treturn .5 - Math.random();\r\n\t});\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 { getIndexFromRC, getRandomArray, getTexture } from \"./utils\";\r\nimport ObjectPool = engine.ObjectPool;\r\n\r\n// let OFFSET_X;\r\n// let OFFSET_Y;\r\nlet MAX_COL;\r\nlet MAX_ROW;\r\nlet W;\r\nlet H;\r\nlet GAP;\r\nlet GAME_TIME;\r\n// 每张图片宽\r\nlet w;\r\n// 每张图片高\r\nlet h;\r\n\r\nexport default class GameView extends engine.Container {\r\n private _timer;\r\n private _timeCounter = 0;\r\n\r\n private date\r\n\r\n start() {\r\n \r\n if (!this.guideHole) {\r\n this.guideHole = new engine.Image();\r\n this.guideHole.source = 'asset://' + props.blockUrl;\r\n this.guideHole.mouseChildren = this.guideHole.mouseEnabled = false;\r\n }\r\n\r\n if (this.pictures) {\r\n for (const pic of this.pictures) {\r\n if (pic && pic.parent)\r\n pic.parent.removeChild(pic);\r\n }\r\n }\r\n\r\n console.log('on start')\r\n engine.globalEvent.dispatchEvent('pictures-time-update', {\r\n second: this.getSecond(),\r\n });\r\n\r\n // 图片一维数组\r\n const result = qietu(this.picturesWrapper, props.picUrl, MAX_COL, MAX_ROW);\r\n this.picturesWrapper.addChild(this.guideHole);\r\n\r\n console.log(this.picturesWrapper)\r\n\r\n this.pictures = result[0];\r\n this.rightList = this.pictures.concat([]);\r\n const posList = result[1];\r\n getRandomArray(this.pictures);\r\n\r\n let i = 0;\r\n let len;\r\n len = this.pictures.length;\r\n\r\n\r\n for (; i < len; i++) {\r\n this.dragPic = this.pictures[i];\r\n this.pictures[i].addEventListener(\r\n engine.MouseEvent.MOUSE_DOWN,\r\n this.onDown,\r\n this\r\n );\r\n const [x, y] = posList[i];\r\n this.dragPic.x = x;\r\n this.dragPic.y = y;\r\n\r\n }\r\n\r\n this._timer = setInterval(() => {\r\n this.onTimer();\r\n }, 10)\r\n\r\n this.date = new Date().getTime();\r\n\r\n }\r\n\r\n onTimer() {\r\n\r\n let date = new Date().getTime();\r\n\r\n let gap = ((date - this.date) / 1000);\r\n this.date = date;\r\n console.log(gap,\"gap\");\r\n\r\n // 以GAME_TIME为标准\r\n GAME_TIME -= gap;\r\n if(GAME_TIME < 0){\r\n GAME_TIME = 0;\r\n }\r\n GAME_TIME = this.afterPointTwo(GAME_TIME);\r\n GAME_TIME = GAME_TIME.toFixed(2)\r\n if (GAME_TIME < 10) {\r\n GAME_TIME = '0' + GAME_TIME\r\n }\r\n console.log(GAME_TIME);\r\n\r\n\r\n engine.globalEvent.dispatchEvent('pictures-time-update', {\r\n second: this.getSecond(),\r\n });\r\n\r\n if (this.getSecond() == 0) {\r\n GAME_TIME = props.GAME_TIME\r\n this.stop();\r\n engine.globalEvent.dispatchEvent('pictures-game-fail', {\r\n reason: 1\r\n });\r\n }\r\n }\r\n\r\n afterPointTwo(n) {\r\n\r\n var floatN = parseFloat(n);\r\n if (isNaN(floatN)) {\r\n return;\r\n }\r\n floatN = Math.round(floatN * 100) / 100;\r\n return floatN;\r\n\r\n }\r\n\r\n getSecond() {\r\n return GAME_TIME\r\n }\r\n\r\n stop() {\r\n \r\n // GAME_TIME = props.GAME_TIME\r\n clearInterval(this._timer);\r\n let len = this.pictures.length;\r\n for(let i=0;i<len;i++){\r\n this.pictures[i].removeAllEventListener();\r\n }\r\n\r\n this.stage.removeEventListener(\r\n engine.MouseEvent.MOUSE_UP,\r\n this.stageOnUp,\r\n this\r\n );\r\n \r\n }\r\n\r\n constructor() {\r\n super();\r\n this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);\r\n }\r\n\r\n //当前图片对象\r\n dragPic;\r\n // 鼠标在当前图片上的位置\r\n localPicX;\r\n localPicY;\r\n // 拖动的图片最开始的位置(左上角为准)\r\n distanceX;\r\n distanceY;\r\n // 图片中心的位置\r\n centerX: number;\r\n centerY: number;\r\n\r\n pictures: engine.Sprite[];\r\n\r\n // 点击图片时的一维数组索引\r\n index;\r\n // 计算目标图片行和列的位置\r\n indexI: number;\r\n indexJ: number;\r\n rightList: engine.Sprite[];\r\n\r\n private picturesWrapper: engine.Sprite;\r\n private guideHole: engine.Image;\r\n\r\n createRects() { }\r\n setup() {\r\n\r\n MAX_COL = props.MAX_COL;\r\n MAX_ROW = props.MAX_ROW;\r\n GAME_TIME = props.GAME_TIME;\r\n // OFFSET_X = props.OFFSET_X;\r\n // OFFSET_Y = props.OFFSET_Y;\r\n W = props.W;\r\n H = props.H;\r\n GAP = props.GAP;\r\n // 每张图片宽\r\n w = W / MAX_COL;\r\n // 每张图片高\r\n h = H / MAX_ROW;\r\n\r\n console.log('onSteup', props);\r\n\r\n const parent = new engine.Sprite();\r\n this.picturesWrapper = parent;\r\n this.addChild(parent);\r\n\r\n // this.picturesWrapper.x = OFFSET_X;\r\n // this.picturesWrapper.y = OFFSET_Y;\r\n\r\n // 添加按钮\r\n // const btn = new engine.Rect();\r\n // btn.width = 200;\r\n // btn.height = 100;\r\n // btn.stage.top = 1000;\r\n // btn.stage.left = 350;\r\n // btn.fillColor = 'cyan';\r\n // this.addChild(btn)\r\n\r\n // btn.addEventListener(engine.MouseEvent.CLICK,this.onClk,this)\r\n\r\n }\r\n\r\n onDown(e: engine.MouseEvent) {\r\n // console.log(e);\r\n\r\n let stageLeft = (750 - props.W) / 2\r\n let stageTop = (this.stage.height - props.H) / 2;\r\n\r\n // 创建一个图片对象接收当前位置信息\r\n this.dragPic = e.target;\r\n this.picturesWrapper.addChild(this.dragPic);\r\n\r\n\r\n // 鼠标的偏移量\r\n this.localPicX = e.localX / MAX_COL;\r\n this.localPicY = e.localY / MAX_ROW;\r\n\r\n // 最开始图片的位置\r\n this.distanceX = this.dragPic.x ;\r\n this.distanceY = this.dragPic.y;\r\n\r\n // 最开始点击的图片的索引值\r\n\r\n this.indexJ = Math.floor((this.distanceX) / (w + GAP));\r\n this.indexI = Math.floor((this.distanceY) / (h + GAP));\r\n this.index = (this.indexI) * MAX_COL + this.indexJ;\r\n\r\n\r\n // this.centerX = Math.floor(e.clientX / w) * w + w / 2;\r\n // this.centerY = Math.floor(e.clientY / h) * h + h / 2;\r\n\r\n this.centerX = Math.floor((e.clientX - stageLeft) / w) * w + w / 2;\r\n this.centerY = Math.floor((e.clientY - stageTop) / h) * h + h / 2;\r\n\r\n this.stage.addEventListener(\r\n engine.MouseEvent.MOUSE_MOVE,\r\n this.onMove,\r\n this\r\n );\r\n this.stage.addEventListener(\r\n engine.MouseEvent.MOUSE_UP,\r\n this.stageOnUp,\r\n this\r\n );\r\n\r\n }\r\n\r\n listenStageOn = 1;\r\n\r\n stageOnUp(e) {\r\n\r\n let stageLeft = (750 - props.W) / 2\r\n let stageTop = (this.stage.height - props.H) / 2;\r\n\r\n this.stage.removeEventListener(\r\n engine.MouseEvent.MOUSE_MOVE,\r\n this.onMove,\r\n this\r\n );\r\n\r\n this.stage.removeEventListener(\r\n engine.MouseEvent.MOUSE_UP,\r\n this.stageOnUp,\r\n this\r\n );\r\n\r\n // 拖动的图片的中心位置在图片之外,回到原来的位置\r\n if (this.centerY < stageTop || this.centerX < stageLeft) {\r\n this.dragPic.x = this.distanceX ;\r\n this.dragPic.y = this.distanceY ;\r\n }\r\n\r\n // 判断图片是否进入另一张图片的范围内\r\n // 要交换的图片第几行第几列\r\n let curJ = Math.floor(this.centerX / (w + GAP));\r\n let curI = Math.floor(this.centerY / (h + GAP));\r\n\r\n this.picturesWrapper.addChild(this.guideHole);\r\n\r\n\r\n // 点击图片的位置\r\n\r\n if ( 0 <= curJ && curJ < (MAX_COL) && 0 <= curI && curI < (MAX_ROW)) {\r\n\r\n // 获取交互图片的索引值\r\n let index = getIndexFromRC(curI, curJ, MAX_COL);\r\n // console.log(index);\r\n\r\n //要交换的图片\r\n let dropPic = this.pictures[index];\r\n\r\n let dropPicX = dropPic.x + stageLeft;\r\n let dropPicy = dropPic.y + stageTop;\r\n\r\n dropPic.x = this.distanceX;\r\n dropPic.y = this.distanceY;\r\n\r\n this.dragPic.x = dropPicX - stageLeft;\r\n this.dragPic.y = dropPicy - stageTop;\r\n\r\n // 交换之后索引也需要交换\r\n\r\n const dropPicIndex = this.pictures.indexOf(dropPic);\r\n const dragPicIndex = this.pictures.indexOf(this.dragPic);\r\n\r\n this.pictures[dropPicIndex] = this.dragPic;\r\n this.pictures[dragPicIndex] = dropPic;\r\n\r\n // 图片中心还是在原来的位置\r\n if (dragPicIndex === dropPicIndex) {\r\n this.dragPic.x = this.distanceX\r\n this.dragPic.y = this.distanceY\r\n }\r\n\r\n let result = true;\r\n for (let j = 0; j < this.rightList.length; j++) {\r\n if (this.rightList[j] != this.pictures[j]) {\r\n result = false;\r\n break;\r\n }\r\n }\r\n\r\n if (result) {\r\n this.onSuccess();\r\n\r\n }\r\n } else {\r\n this.dragPic.x = this.distanceX\r\n this.dragPic.y = this.distanceY\r\n }\r\n\r\n\r\n }\r\n\r\n private onSuccess() {\r\n console.log('拼图成功!');\r\n engine.globalEvent.dispatchEvent('pictures-game-success', { time: GAME_TIME });\r\n this.stop();\r\n\r\n }\r\n\r\n onMove(e: engine.MouseEvent) {\r\n // 当前图片的位置\r\n this.dragPic.x = e.stageX - this.localPicX - (750 - props.W) / 2;\r\n this.dragPic.y = e.stageY - this.localPicY - (this.stage.height - props.H) / 2;\r\n\r\n // 当前图片的中心位置\r\n this.centerX = this.dragPic.x + w / 2;\r\n this.centerY = this.dragPic.y + h / 2;\r\n }\r\n\r\n // onClk(e){\r\n // // 重置时间\r\n // this._timeCounter = 0;\r\n // //重置图片顺序\r\n\r\n\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\tengine.globalEvent.addEventListener('pictures-start', this.start, this);\r\n\t\tengine.globalEvent.addEventListener('pictures-stop', this.stop, this);\r\n\r\n\t\t//创建实例\r\n\t\tlet gameView = this._gameView = new GameView();\r\n\t\tthis.addChild(gameView);\r\n\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\tstop(event: engine.Event) {\r\n\t\t\r\n\t\tthis._gameView.stop();\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\treturn instance;\r\n}\r\n"],"names":["__extends"],"mappings":";;;;;;CAIO,IAAI,KAAK,GAAQ,EAAE,CAAC;UAEX,YAAY;KAC3B,IAAI,SAAS,GAAG,QAAQ,EAAE,CAAC;KAE3B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;CACrC,CAAC;UAEe,WAAW,CAAC,CAAC;KAC5B,MAA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B,CAAC,gBAAgB,EAAE,KAAI,CAAC,KAAK,EAAE,KAAI,CAAC,CAAC;SACxE,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,eAAe,EAAE,KAAI,CAAC,IAAI,EAAE,KAAI,CAAC,CAAC;SAGtE,IAAI,QAAQ,GAAG,KAAI,CAAC,SAAS,GAAG,IAAI,QAAQ,EAAE,CAAC;SAC/C,KAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;;MAExB;KAED,2BAAK,GAAL,UAAM,KAAmB;SACxB,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SAIxB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;MACvB;KACD,0BAAI,GAAJ,UAAK,KAAmB;SAEvB,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;MACtB;KACF,kBAAC;CAAD,CAAC,CA/BgC,MAAM,CAAC,SAAS,GA+BhD;;;iBChCwB,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
......@@ -40,7 +40,7 @@
"GAME_TIME": {
"alias": "游戏时间",
"type": "number",
"default": 5
"default": 10
}
},
......
......@@ -24,6 +24,8 @@ export default class GameView extends engine.Container {
private _timer;
private _timeCounter = 0;
private date
start() {
if (!this.guideHole) {
......@@ -76,19 +78,30 @@ export default class GameView extends engine.Container {
this._timer = setInterval(() => {
this.onTimer();
}, 10)
this.date = new Date().getTime();
}
onTimer() {
let date = new Date().getTime();
let gap = ((date - this.date) / 1000);
this.date = date;
console.log(gap,"gap");
// 以GAME_TIME为标准
GAME_TIME -= 0.01
GAME_TIME -= gap;
if(GAME_TIME < 0){
GAME_TIME = 0;
}
GAME_TIME = this.afterPointTwo(GAME_TIME);
GAME_TIME = GAME_TIME.toFixed(2)
if (GAME_TIME < 10) {
GAME_TIME = '0' + GAME_TIME
}
// console.log(GAME_TIME);
console.log(GAME_TIME);
engine.globalEvent.dispatchEvent('pictures-time-update', {
......@@ -96,7 +109,6 @@ export default class GameView extends engine.Container {
});
if (this.getSecond() == 0) {
GAME_TIME = props.GAME_TIME
this.stop();
engine.globalEvent.dispatchEvent('pictures-game-fail', {
reason: 1
......@@ -110,11 +122,7 @@ export default class GameView extends engine.Container {
if (isNaN(floatN)) {
return;
}
floatN = Math.round(floatN * 100) / 100;
return floatN;
}
......@@ -125,7 +133,7 @@ export default class GameView extends engine.Container {
stop() {
// GAME_TIME = props.GAME_TIME
GAME_TIME = props.GAME_TIME
clearInterval(this._timer);
let len = this.pictures.length;
for(let i=0;i<len;i++){
......
/**
* Created by renjianfeng on 2020-03-13.
*/
const customId = 'playWithPlane';
(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/57725dcf8cb23905afb87f42d7aba2ffa4c8d2d1.png",
blockUrl: "308742a0-0ea2-4610-b34a-a230add82021",
});
// 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.playWithPlane = 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);
}
//# sourceMappingURL=utils.js.map
var Ball = (function (_super) {
tslib.__extends(Ball, _super);
function Ball() {
var _this = _super.call(this) || this;
_this.plane = new engine.Sprite();
_this.addChild(_this.plane);
return _this;
}
Ball.prototype.setPosition = function () { };
Ball.prototype.died = function () { };
return Ball;
}(engine.Container));
//# sourceMappingURL=Ball.js.map
var SmallPlane = (function (_super) {
tslib.__extends(SmallPlane, _super);
function SmallPlane() {
var _this = _super.call(this) || this;
_this._life = 3;
_this.smallPlane = new engine.Sprite(getTexture('57d4067e-c32f-4b12-a8fc-185753726fc6'));
_this.life = 3;
_this.name = "smallBall";
_this.addChild(_this.smallPlane);
return _this;
}
SmallPlane.prototype.setPosition = function () {
this.x = Math.random() * (750 - this.width);
this.y = Math.random() * (this.height);
};
SmallPlane.prototype.died = function () {
};
return SmallPlane;
}(Ball));
//# sourceMappingURL=SmallBall.js.map
var Bullets = (function (_super) {
tslib.__extends(Bullets, _super);
function Bullets(_harm) {
if (_harm === void 0) { _harm = 1; }
var _this = _super.call(this) || this;
_this.bulletPic = new engine.Sprite(getTexture('18852543-1f1d-498b-af64-88cd3b343758'));
_this.bullets = [];
_this.harm = _harm;
_this.addChild(_this.bulletPic);
return _this;
}
Bullets.prototype.addBullet = function (planeModel) {
var bullet = new engine.Sprite(getTexture('18852543-1f1d-498b-af64-88cd3b343758'));
bullet.x = planeModel ? planeModel.x + planeModel.width / 2 - bullet.width / 2 : 375 - bullet.width / 2;
bullet.y = 1150;
return bullet;
};
Bullets.prototype.createBullet = function (planeModel) {
this.x = planeModel.x + planeModel.width / 2 - this.bulletPic.width / 2;
this.y = 1150;
};
Bullets.prototype.addBulletNum = function (w) {
};
return Bullets;
}(engine.Container));
//# sourceMappingURL=Bullets.js.map
var TestView = (function (_super) {
tslib.__extends(TestView, _super);
function TestView() {
var _this = _super.call(this) || this;
_this.planeArray = [
{
type: 'smallBall',
enemyPlane: []
},
{
type: 'middleBall',
enemyPlane: []
},
{
type: 'largeBall',
enemyPlane: []
}
];
_this.bulletArray = [];
_this.score = 0;
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
return _this;
}
TestView.prototype.setup = function () {
this.stageBg = new engine.Sprite(getTexture('308742a0-0ea2-4610-b34a-a230add82021'));
this.addChild(this.stageBg);
this.gameBg = new engine.Sprite(getTexture('76820072-df5a-4ab7-8cb7-10c8cd8605c8'));
this.startBtn = new engine.Sprite(getTexture('855e3d77-ffff-443d-b884-4f67a2ebe458'));
this.startBtn.x = (750 - this.startBtn.width) / 2;
this.startBtn.y = (this.stage.height - this.startBtn.height) / 2 + 300;
this.stageBg.addChild(this.startBtn);
this.startBtn.addEventListener(engine.MouseEvent.CLICK, this.onClick, this);
};
TestView.prototype.start = function () {
var _this = this;
this.planeModel = new engine.Sprite(getTexture('32ec481a-3f75-4c36-95ed-ee97aa936517'));
this.planeModel.x = (750 - this.planeModel.width) / 2;
this.planeModel.y = (this.stage.height - this.planeModel.height);
this.planeModel.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDown, this);
this.gameBg.addChild(this.planeModel);
var boom = new engine.Sprite(getTexture('38ec6627-efa8-4f7a-9bdc-3c73cea717f1'));
setInterval(function () {
var smallBall = new SmallPlane();
smallBall.setPosition();
console.log(_this.planeArray);
for (var _i = 0, _a = _this.planeArray; _i < _a.length; _i++) {
var planearray = _a[_i];
if (planearray.type == smallBall.name) {
console.log(planearray.enemyPlane);
planearray.enemyPlane.push(smallBall);
}
}
_this.gameBg.addChild(smallBall);
}, 500);
setInterval(function () {
for (var _i = 0, _a = _this.planeArray; _i < _a.length; _i++) {
var planearray = _a[_i];
if (planearray.type === 'smallBall') {
var _loop_1 = function (sball) {
console.log(sball);
sball.y += 1;
if (sball.y > _this.stage.height) {
_this.gameBg.removeChild(sball);
var index_1 = planearray.enemyPlane.indexOf(sball);
planearray.enemyPlane = planearray.enemyPlane.filter(function (ele, i) { return i != index_1; });
}
};
for (var _b = 0, _c = planearray.enemyPlane; _b < _c.length; _b++) {
var sball = _c[_b];
_loop_1(sball);
}
}
}
}, 16);
setInterval(function () {
var bullet = new Bullets();
bullet.createBullet(_this.planeModel);
_this.bulletArray.push(bullet);
_this.gameBg.addChild(bullet);
}, 40);
setInterval(function () {
console.log(_this.score);
var _loop_2 = function (bullet) {
bullet.y -= 35;
if (bullet.y < -40) {
_this.gameBg.removeChild(bullet);
var index_2 = _this.bulletArray.indexOf(bullet);
_this.bulletArray = _this.bulletArray.filter(function (ele, i) { return i != index_2; });
}
for (var _i = 0, _a = _this.planeArray; _i < _a.length; _i++) {
var planearray = _a[_i];
if (planearray.type === 'smallBall') {
var _loop_3 = function (splane) {
var y = bullet.y - splane.y;
var bulletRight = bullet.x + bullet.width;
var planeRange = splane.x + splane.width;
if (bulletRight > splane.x && bulletRight < planeRange || bullet.x > splane.x && bullet.x < planeRange) {
if (y <= 0) {
splane.life -= bullet.harm;
_this.score += bullet.harm;
_this.gameBg.removeChild(bullet);
var index_3 = _this.bulletArray.indexOf(bullet);
_this.bulletArray = _this.bulletArray.filter(function (ele, i) { return i != index_3; });
if (splane.life === 0) {
_this.gameBg.removeChild(splane);
var ind_1 = planearray.enemyPlane.indexOf(splane);
planearray.enemyPlane = planearray.enemyPlane.filter(function (ele, i) { return i != ind_1; });
boom.x = splane.x;
boom.y = splane.y;
_this.gameBg.addChild(boom);
setTimeout(function () {
_this.gameBg.removeChild(boom);
}, 1500);
}
}
}
};
for (var _b = 0, _c = planearray.enemyPlane; _b < _c.length; _b++) {
var splane = _c[_b];
_loop_3(splane);
}
}
}
};
for (var _i = 0, _a = _this.bulletArray; _i < _a.length; _i++) {
var bullet = _a[_i];
_loop_2(bullet);
}
}, 16);
};
TestView.prototype.onClick = function () {
this.addChild(this.gameBg);
this.gameBg.addChild(this.planeModel);
};
TestView.prototype.onDown = function (e) {
this.mouseX = e.localX;
this.mouseY = e.localY;
this.stage.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMove, this);
this.planeModel.x = e.stageX - this.mouseX;
this.planeCenterX = this.planeModel.x + this.planeModel.width / 2;
};
TestView.prototype.onMove = function (e) {
this.centerX = this.planeModel.width / 2;
var movedCenter = this.centerX + e.stageX - this.mouseX;
if (movedCenter < 0) {
this.planeModel.x = -this.centerX;
}
else if (movedCenter > 750) {
this.planeModel.x = 750 - this.centerX;
}
else {
this.planeModel.x = e.stageX - this.mouseX;
this.planeCenterX = this.planeModel.x + this.planeModel.width / 2;
}
};
TestView.prototype.stop = function () {
};
return TestView;
}(engine.Container));
var GameWrapper = (function (_super) {
tslib.__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('pictures-start', _this.start, _this);
engine.globalEvent.addEventListener('pictures-stop', _this.stop, _this);
var testView = _this._testView = new TestView();
_this.addChild(testView);
return _this;
}
GameWrapper.prototype.start = function (event) {
injectProps(event.data);
this._testView.start();
};
GameWrapper.prototype.stop = function (event) {
this._testView.stop();
};
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/playWithPlane/src/props.ts","src/custom/playWithPlane/src/game/utils.ts","src/custom/playWithPlane/src/game/Ball.ts","src/custom/playWithPlane/src/game/SmallBall.ts","src/custom/playWithPlane/src/game/Bullets.ts","src/custom/playWithPlane/src/game/TestView.ts","src/custom/playWithPlane/src/game/GameWrapper.ts","src/custom/playWithPlane/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 getIndexFromRC(row,col,maxCol){\r\n\tlet index;\r\n\tindex = row * maxCol + col ;\r\n\treturn index\r\n}\r\n\r\n\r\n\r\n\r\nexport function getRandomArray(array){\r\n\tarray.sort(function() {\r\n\t\treturn .5 - Math.random();\r\n\t});\r\n}","import {getTexture} from './utils'\r\n\r\n\r\nexport default class Ball extends engine.Container{\r\n name:string\r\n // 生命值\r\n life:number;\r\n plane:engine.Sprite = new engine.Sprite()\r\n constructor(){\r\n super();\r\n this.addChild(this.plane)\r\n }\r\n\r\n setPosition(){};\r\n\r\n died(){}\r\n\r\n\r\n}","import Ball from \"./Ball\";\r\nimport { getTexture } from \"./utils\";\r\n\r\n\r\nexport class SmallPlane extends Ball{\r\n _life:number = 3;\r\n smallPlane = new engine.Sprite(getTexture('57d4067e-c32f-4b12-a8fc-185753726fc6'))\r\n constructor(){\r\n super()\r\n this.life = 3;\r\n this.name = \"smallBall\"\r\n this.addChild(this.smallPlane)\r\n\r\n }\r\n\r\n setPosition(){\r\n this.x = Math.random() * (750 - this.width)\r\n this.y = Math.random() * (this.height)\r\n }\r\n\r\n died(){\r\n \r\n }\r\n\r\n\r\n\r\n}","import { getTexture } from \"./utils\"\r\n\r\n\r\nexport class Bullets extends engine.Container{\r\n\r\n harm:number\r\n bulletPic = new engine.Sprite(getTexture('18852543-1f1d-498b-af64-88cd3b343758'))\r\n constructor(_harm = 1){\r\n super()\r\n this.harm = _harm\r\n this.addChild(this.bulletPic)\r\n }\r\n\r\n bullet:engine.Sprite \r\n public bullets:engine.Sprite[] = []\r\n \r\n \r\n addBullet(planeModel?){\r\n let bullet = new engine.Sprite(getTexture('18852543-1f1d-498b-af64-88cd3b343758'))\r\n\r\n bullet.x = planeModel ? planeModel.x + planeModel.width / 2 - bullet.width / 2 : 375 - bullet.width / 2 ;\r\n bullet.y = 1150\r\n\r\n // this.bullets.push(bullet)\r\n return bullet\r\n }\r\n\r\n\r\n // 创建子弹\r\n createBullet(planeModel){\r\n this.x = planeModel.x + planeModel.width / 2 - this.bulletPic.width / 2;\r\n this.y = 1150;\r\n }\r\n\r\n // 达到一定分数增加火力\r\n addBulletNum(w){\r\n\r\n }\r\n \r\n\r\n} ","import {getTexture} from './utils'\r\n\r\nimport { SmallPlane } from './SmallBall'\r\nimport {Bullets} from './Bullets'\r\n\r\nexport default class TestView extends engine.Container{\r\n startBtn:engine.Sprite\r\n stageBg: engine.Sprite;\r\n gameBg: engine.Sprite;\r\n planeModel:engine.Sprite;\r\n\r\n constructor(){\r\n super()\r\n this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);\r\n }\r\n\r\n\r\n setup(){\r\n this.stageBg = new engine.Sprite(getTexture('308742a0-0ea2-4610-b34a-a230add82021'))\r\n this.addChild(this.stageBg)\r\n\r\n this.gameBg = new engine.Sprite(getTexture('76820072-df5a-4ab7-8cb7-10c8cd8605c8'))\r\n\r\n // 开始按钮\r\n this.startBtn = new engine.Sprite(getTexture('855e3d77-ffff-443d-b884-4f67a2ebe458'))\r\n this.startBtn.x = (750 - this.startBtn.width) / 2;\r\n this.startBtn.y = (this.stage.height - this.startBtn.height) / 2 + 300;\r\n this.stageBg.addChild(this.startBtn)\r\n this.startBtn.addEventListener(engine.MouseEvent.CLICK,this.onClick,this)\r\n }\r\n\r\n smallBall:SmallPlane\r\n\r\n planeArray:[\r\n {\r\n type:string,\r\n enemyPlane:Array<any>\r\n },\r\n {\r\n type:string,\r\n enemyPlane:Array<any>\r\n },\r\n {\r\n type:string,\r\n enemyPlane:Array<any>\r\n }\r\n ] = [\r\n {\r\n type:'smallBall',\r\n enemyPlane:[]\r\n },\r\n {\r\n type:'middleBall',\r\n enemyPlane:[]\r\n },\r\n {\r\n type:'largeBall',\r\n enemyPlane:[]\r\n }\r\n ]\r\n\r\n bulletArray:any[] = []\r\n score:number = 0;\r\n start(){\r\n // 炮车\r\n this.planeModel = new engine.Sprite(getTexture('32ec481a-3f75-4c36-95ed-ee97aa936517'))\r\n this.planeModel.x = (750 - this.planeModel.width) / 2;\r\n this.planeModel.y = (this.stage.height - this.planeModel.height)\r\n this.planeModel.addEventListener(engine.MouseEvent.MOUSE_DOWN,this.onDown,this)\r\n\r\n this.gameBg.addChild(this.planeModel)\r\n\r\n let boom = new engine.Sprite(getTexture('38ec6627-efa8-4f7a-9bdc-3c73cea717f1'))\r\n\r\n\r\n //敌机\r\n setInterval(()=>{\r\n let smallBall = new SmallPlane();\r\n smallBall.setPosition();\r\n\r\n console.log(this.planeArray);\r\n for(let planearray of this.planeArray){\r\n if(planearray.type == smallBall.name){\r\n console.log(planearray.enemyPlane)\r\n planearray.enemyPlane.push(smallBall)\r\n }\r\n }\r\n \r\n \r\n this.gameBg.addChild(smallBall)\r\n },500)\r\n\r\n // 敌机移动\r\n setInterval(()=>{\r\n for(let planearray of this.planeArray){\r\n if(planearray.type === 'smallBall'){\r\n for(let sball of planearray.enemyPlane){\r\n console.log(sball)\r\n sball.y += 1;\r\n if(sball.y > this.stage.height){\r\n this.gameBg.removeChild(sball)\r\n let index = planearray.enemyPlane.indexOf(sball)\r\n planearray.enemyPlane = planearray.enemyPlane.filter((ele,i)=>i != index)\r\n }\r\n }\r\n }\r\n }\r\n },16)\r\n\r\n\r\n // my plane\r\n setInterval(()=>{\r\n let bullet = new Bullets();\r\n bullet.createBullet(this.planeModel);\r\n\r\n this.bulletArray.push(bullet)\r\n\r\n this.gameBg.addChild(bullet)\r\n\r\n },40)\r\n\r\n setInterval(()=>{\r\n console.log(this.score);\r\n for(let bullet of this.bulletArray){\r\n\r\n // console.log(bullet,123)\r\n\r\n bullet.y -= 35;\r\n if(bullet.y < -40){\r\n this.gameBg.removeChild(bullet)\r\n let index = this.bulletArray.indexOf(bullet)\r\n this.bulletArray = this.bulletArray.filter((ele,i)=>i != index)\r\n }\r\n\r\n // 击中\r\n for(let planearray of this.planeArray){\r\n if(planearray.type === 'smallBall'){\r\n for(let splane of planearray.enemyPlane){\r\n let y = bullet.y - splane.y;\r\n\r\n let bulletRight = bullet.x + bullet.width;\r\n let planeRange = splane.x + splane.width\r\n if(bulletRight > splane.x && bulletRight < planeRange || bullet.x > splane.x && bullet.x < planeRange){\r\n if(y <= 0){\r\n // 击中敌机\r\n splane.life -= bullet.harm;\r\n this.score += bullet.harm;\r\n \r\n // 子弹移除\r\n this.gameBg.removeChild(bullet);\r\n let index = this.bulletArray.indexOf(bullet);\r\n this.bulletArray = this.bulletArray.filter((ele,i)=>i != index)\r\n\r\n if(splane.life === 0){\r\n this.gameBg.removeChild(splane);\r\n let ind = planearray.enemyPlane.indexOf(splane);\r\n planearray.enemyPlane = planearray.enemyPlane.filter((ele,i)=>i!=ind)\r\n\r\n boom.x = splane.x;\r\n boom.y = splane.y;\r\n this.gameBg.addChild(boom);\r\n setTimeout(() => {\r\n this.gameBg.removeChild(boom);\r\n }, 1500);\r\n }\r\n\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n\r\n },16)\r\n\r\n\r\n\r\n }\r\n\r\n\r\n onClick(){\r\n this.addChild(this.gameBg);\r\n this.gameBg.addChild(this.planeModel)\r\n }\r\n mouseX:number;\r\n mouseY:number;\r\n // 炮车宽度\r\n centerX:number;\r\n planeCenterX:number\r\n\r\n onDown(e:engine.MouseEvent){\r\n this.mouseX = e.localX\r\n this.mouseY = e.localY\r\n this.stage.addEventListener(engine.MouseEvent.MOUSE_MOVE,this.onMove,this)\r\n\r\n this.planeModel.x = e.stageX - this.mouseX;\r\n this.planeCenterX = this.planeModel.x + this.planeModel.width / 2;\r\n }\r\n\r\n onMove(e:engine.MouseEvent){\r\n // 炮车移动范围\r\n this.centerX = this.planeModel.width / 2;\r\n let movedCenter = this.centerX + e.stageX - this.mouseX;\r\n if(movedCenter < 0){\r\n this.planeModel.x = -this.centerX;\r\n } else if(movedCenter >750){\r\n this.planeModel.x = 750 - this.centerX;\r\n } else {\r\n this.planeModel.x = e.stageX - this.mouseX;\r\n this.planeCenterX = this.planeModel.x + this.planeModel.width / 2;\r\n\r\n }\r\n }\r\n\r\n stop(){\r\n\r\n }\r\n\r\n}","import GameView from \"./GameView\";\r\nimport { injectProps } from \"../props\";\r\n\r\nimport TestView from './TestView'\r\n\r\n\r\nexport class GameWrapper extends engine.Container{\r\n\tprivate _gameView:GameView\r\n\t\r\n\tprivate _testView:TestView\r\n\r\n constructor(){\r\n super();\r\n engine.globalEvent.addEventListener('pictures-start', this.start, this);\r\n\t\tengine.globalEvent.addEventListener('pictures-stop', this.stop, this);\r\n\r\n\t\t//创建实例\r\n\t\t// let gameView = this._gameView = new GameView();\r\n\t\t// this.addChild(gameView);\r\n\r\n\t\tlet testView = this._testView = new TestView();\r\n\t\tthis.addChild(testView);\r\n }\r\n\r\n // start(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\t// stop(event: engine.Event) {\r\n\t\t\r\n\t// \tthis._gameView.stop();\r\n\t// }\r\n\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._testView.start();\r\n\t}\r\n\tstop(event: engine.Event) {\r\n\t\t\r\n\t\tthis._testView.stop();\r\n\t}\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\treturn instance;\r\n}\r\n"],"names":["__extends"],"mappings":";;;;;;CAIO,IAAI,KAAK,GAAQ,EAAE,CAAC;UAEX,YAAY;KAC3B,IAAI,SAAS,GAAG,QAAQ,EAAE,CAAC;KAE3B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;CACrC,CAAC;UAEe,WAAW,CAAC,CAAC;KAC5B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;CAC7B,CAAC;;;UCVe,UAAU,CAAC,IAAI;KAC9B,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;CACvD,CAAC;AAED;;CCLA;KAAkCA,8BAAgB;KAK9C;SAAA,YACI,iBAAO,SAEV;SAJD,WAAK,GAAiB,IAAI,MAAM,CAAC,MAAM,EAAE,CAAA;SAGrC,KAAI,CAAC,QAAQ,CAAC,KAAI,CAAC,KAAK,CAAC,CAAA;;MAC5B;KAED,0BAAW,GAAX,eAAe;KAEf,mBAAI,GAAJ,eAAQ;KAGZ,WAAC;CAAD,CAAC,CAfiC,MAAM,CAAC,SAAS,GAejD;;;CCdD;KAAgCA,oCAAI;KAGhC;SAAA,YACI,iBAAO,SAKV;SARD,WAAK,GAAU,CAAC,CAAC;SACjB,gBAAU,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,sCAAsC,CAAC,CAAC,CAAA;SAG9E,KAAI,CAAC,IAAI,GAAG,CAAC,CAAC;SACd,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AI,CAAC,UAAU,CAAC,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,GAAG,CAAC,CAAC;UAErE;MACJ;KAED,uBAAI,GAAJ;MAEC;KAEL,eAAC;CAAD,CAAC,CAtNqC,MAAM,CAAC,SAAS,GAsNrD;;CCrND;KAAiCA,qCAAgB;KAK7C;SAAA,YACI,iBAAO,SAUV;SATG,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,gBAAgB,EAAE,KAAI,CAAC,KAAK,EAAE,KAAI,CAAC,CAAC;SAC9E,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,eAAe,EAAE,KAAI,CAAC,IAAI,EAAE,KAAI,CAAC,CAAC;SAMtE,IAAI,QAAQ,GAAG,KAAI,CAAC,SAAS,GAAG,IAAI,QAAQ,EAAE,CAAC;SAC/C,KAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;;MACrB;KAeJ,2BAAK,GAAL,UAAM,KAAmB;SACxB,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SAIxB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;MACvB;KACD,0BAAI,GAAJ,UAAK,KAAmB;SAEvB,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;MACtB;KACF,kBAAC;CAAD,CAAC,CA1CgC,MAAM,CAAC,SAAS,GA0ChD;;;iBC3CwB,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": 618
},
"H": {
"alias": "图片的高度",
"type": "number",
"default": 827
},
"OFFSET_X": {
"alias": "OFFSET_X",
"type": "number",
"default": 0
},
"OFFSET_Y": {
"alias": "OFFSET_Y",
"type": "number",
"default": 0
},
"GAME_TIME": {
"alias": "游戏时间",
"type": "number",
"default": 30
},
"GAP": {
"alias": "图片间隙",
"type": "number",
"default": 0
}
},
"assets": [
{
"name": "遮罩",
"url": "//yun.duiba.com.cn/aurora/assets/5b3e30496b2d9fdafb0cf3835fd6704ce10e45b4.png",
"uuid": "888",
"ext": ".png"
},
{
"name":"背景",
"url":" //yun.duiba.com.cn/aurora/assets/57725dcf8cb23905afb87f42d7aba2ffa4c8d2d1.png",
"uuid":"308742a0-0ea2-4610-b34a-a230add82021",
"ext":".png"
},
{
"name":"飞机",
"url":"//yun.duiba.com.cn/aurora/assets/1d2ba15cb8baf3e5783a9f865673dcf9a2421f19.png",
"uuid":"32ec481a-3f75-4c36-95ed-ee97aa936517",
"ext":".png"
},
{
"name":"开始按钮",
"url":"//yun.duiba.com.cn/aurora/assets/2bed3a9e3cae15a6332397ca675c5d44849eaac2.png",
"uuid":"855e3d77-ffff-443d-b884-4f67a2ebe458",
"ext":".png"
},
{
"name":"游戏背景",
"url":"//yun.duiba.com.cn/aurora/assets/5f56d60285f0e3b253716bc938a3c28cbb288cdf.png",
"uuid":"76820072-df5a-4ab7-8cb7-10c8cd8605c8",
"ext":".png"
},
{
"name":"子弹",
"url":"//yun.duiba.com.cn/aurora/assets/06b3baba53973c01be8943b7a002e58de3bea7cf.png",
"uuid":"18852543-1f1d-498b-af64-88cd3b343758",
"ext":".png"
},
{
"name":"敌机",
"url":"//yun.duiba.com.cn/aurora/assets/fc3b2a4349b098183b2b20c8a754b8b182d73806.png",
"uuid":"780b6b63-3abd-4246-94ba-2a3fbdb3c5af",
"ext":".png"
},
{
"name":"small敌机",
"url":"//yun.duiba.com.cn/aurora/assets/1cded0d917c44d22ddce058f239e1cfac1b506c2.png",
"uuid":"57d4067e-c32f-4b12-a8fc-185753726fc6",
"ext":".png"
},
{
"name":"击中",
"url":"//yun.duiba.com.cn/aurora/assets/251402a1991ef00a124ddd91f519a30147285e00.png",
"uuid":"38ec6627-efa8-4f7a-9bdc-3c73cea717f1",
"ext":".png"
}
],
"events": {
"in": {
"pictures-start": {
"alias": "开始",
"data": {
"picUrl":"图片路径",
"blockUrl":"blockUrl",
"GAME_TIME":"每局的游戏时间",
"MAX_ROW":"行",
"MAX_COL":"列",
"W":"宽",
"H":"高",
"GAP":"图片间隙",
"OFFSET_X":"OFFSET_X",
"OFFSET_Y":"OFFSET_Y"
}
},
"pictures-stop": {
"alias": "停止"
}
},
"out": {
"pictures-time-update": {
"alias": "倒计时更新",
"data": {
"time":"剩余时间"
}
},
"pictures-game-fail": {
"alias": "游戏结束",
"data": {
"reason": "结束原因(1:时间到了)"
}
},
"pictures-game-success": {
"alias": "游戏成功",
"data": {
"time": "游戏消耗时间"
}
}
}
}
}
\ No newline at end of file
import {getTexture} from './utils'
export default class Ball extends engine.Container{
name:string
// 生命值
life:number;
plane:engine.Sprite = new engine.Sprite()
constructor(){
super();
this.addChild(this.plane)
}
setPosition(){};
died(){}
}
\ No newline at end of file
import { getTexture } from "./utils"
export class Bullets extends engine.Container{
harm:number
bulletPic = new engine.Sprite(getTexture('18852543-1f1d-498b-af64-88cd3b343758'))
constructor(_harm = 1){
super()
this.harm = _harm
this.addChild(this.bulletPic)
}
bullet:engine.Sprite
public bullets:engine.Sprite[] = []
addBullet(planeModel?){
let bullet = new engine.Sprite(getTexture('18852543-1f1d-498b-af64-88cd3b343758'))
bullet.x = planeModel ? planeModel.x + planeModel.width / 2 - bullet.width / 2 : 375 - bullet.width / 2 ;
bullet.y = 1150
// this.bullets.push(bullet)
return bullet
}
// 创建子弹
createBullet(planeModel){
this.x = planeModel.x + planeModel.width / 2 - this.bulletPic.width / 2;
this.y = 1150;
}
// 达到一定分数增加火力
addBulletNum(w){
}
}
\ No newline at end of file
import GameObject from "./GameObject";
export default abstract class GameComponent {
public get enabled(): boolean {
return this._enabled;
}
public set enabled(v: boolean) {
if (v == true && this._enabled == false) {
this.onEnabled();
this._enabled = v;
} else if (v == false && this._enabled == true) {
this.onDisabled();
this._enabled = v;
}
}
private _enabled: boolean = false;
public get owner(): GameObject {
return this._owner;
}
private _owner: GameObject = null;
constructor(owner: GameObject) {
this._owner = owner;
}
protected abstract onEnabled(): void;
protected abstract onDisabled(): void;
}
\ No newline at end of file
import GameComponent from "./GameComponent";
export default class GameObject extends engine.Container {
public name: string = "";
public addComponent<T extends GameComponent>(cls: any): T {
if (this.getComponent(cls) != null) {
console.error("component is existent");
return;
}
let ins = new cls(this);
ins.enabled = true;
this.componentList.push(ins);
return ins;
}
public getComponent<T extends GameComponent>(cls: any): T {
for (let i of this.componentList) {
if (i instanceof cls) {
return i as T;
}
}
return null;
}
public removeComponent(cls: any) {
for (let i of this.componentList) {
if (i instanceof cls) {
i.enabled = false;
this.componentList = this.componentList.filter(e => e != i);
return;
}
}
}
private _anchorOffsetX: number = 0;
public get anchorOffsetX(): number {
return this._anchorOffsetX;
}
public set anchorOffsetX(v: number) {
this._anchorOffsetX = v;
}
private _anchorOffsetY: number = 0;
public get anchorOffsetY(): number {
return this._anchorOffsetY;
}
public set anchorOffsetY(v: number) {
this._anchorOffsetY = v;
}
private componentList: GameComponent[] = [];
constructor() {
super();
// this.addEventListener(engine.Event.REMOVED_FROM_STAGE, this.disableAllComponents, this);
this.mouseEnabled = false;
this.mouseChildren = false;
}
/**销毁时禁用所有组件 */
dispose() {
this.destroy();
this.disableAllComponents();
}
protected disableAllComponents() {
Object.keys(this.componentList).forEach(e => this.componentList[e].enabled = false);
}
protected enableAllComponents() {
Object.keys(this.componentList).forEach(e => this.componentList[e].enabled = true);
}
}
\ No newline at end of file
import {props} from '../props'
import {getTexture,getTextureByName} from './utils'
import {Ball} from './Ball';
import {Bullets} from './Bullets';
export default class GameView extends engine.Container{
startBtn:engine.Sprite
stageBg: engine.Sprite;
planeModel:engine.Sprite;
pictureWrapper: engine.Sprite;
gameBg: engine.Sprite;
bullet: engine.Sprite;
ball:engine.Sprite;
constructor(){
super()
this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);
}
setup(){
this.stageBg = new engine.Sprite(getTexture('308742a0-0ea2-4610-b34a-a230add82021'))
this.addChild(this.stageBg)
this.gameBg = new engine.Sprite(getTexture('76820072-df5a-4ab7-8cb7-10c8cd8605c8'))
this.bullet = new engine.Sprite(getTexture('18852543-1f1d-498b-af64-88cd3b343758'))
// 开始按钮
this.startBtn = new engine.Sprite(getTexture('855e3d77-ffff-443d-b884-4f67a2ebe458'))
this.startBtn.x = (750 - this.startBtn.width) / 2;
this.startBtn.y = (this.stage.height - this.startBtn.height) / 2 + 300;
this.stageBg.addChild(this.startBtn)
this.startBtn.addEventListener(engine.MouseEvent.CLICK,this.onClick,this)
}
mouseX;
mouseY;
planeCenterX;
centerX
ballArray:engine.Sprite[] = []
bulletArray:engine.Sprite[] = []
baller:Ball
bulleter:Bullets
ballerArray:any[] = []
bulletsArray:any[] = []
score:number = 0
start(){
// 炮车
this.planeModel = new engine.Sprite(getTexture('32ec481a-3f75-4c36-95ed-ee97aa936517'))
this.planeModel.x = (750 - this.planeModel.width) / 2;
this.planeModel.y = (this.stage.height - this.planeModel.height)
this.planeModel.addEventListener(engine.MouseEvent.MOUSE_DOWN,this.onDown,this)
// 子弹
// this.bullet.x = 375;
// this.bullet.y = 1150
this.gameBg.addChild(this.planeModel)
let boom = new engine.Sprite(getTexture('38ec6627-efa8-4f7a-9bdc-3c73cea717f1'))
// 计分
// 敌机
setInterval(()=>{
let ball = new engine.Sprite(getTexture('780b6b63-3abd-4246-94ba-2a3fbdb3c5af'));
ball.x = Math.random() * (750 - ball.width ) ;
ball.y = Math.random() * (ball.height);
let life = 5
this.ballerArray.push({ball,life})
this.gameBg.addChild(ball)
},500)
// 敌机移动
// setInterval(()=>{
// let index
// for(let ball of this.ballerArray){
// // ball.x += Math.random() * (40) + (-20);
// ball.y += 1;
// if(ball.y > this.stage.height){
// this.gameBg.removeChild(ball)
// index = this.ballerArray.indexOf(ball)
// this.ballerArray = this.ballerArray.filter((ele,i)=>i != index)
// }
// }
// },16)
// 添加生命值
setInterval(()=>{
let index
for(let ballObj of this.ballerArray){
// ball.x += Math.random() * (40) + (-20);
ballObj.ball.y += 1;
if(ballObj.ball.y > this.stage.height){
this.gameBg.removeChild(ballObj.ball)
index = this.ballerArray.indexOf(ballObj)
this.ballerArray = this.ballerArray.filter((ele,i)=>i != index)
}
}
},16)
// 子弹
setInterval(()=>{
let bullet = new engine.Sprite(getTexture('18852543-1f1d-498b-af64-88cd3b343758'))
bullet.x = this.planeModel ? this.planeModel.x + this.planeModel.width / 2 - bullet.width / 2 : 375 - bullet.width / 2 ;
bullet.y = 1150
let harm = 1;
this.bulletsArray.push({bullet,harm});
this.gameBg.addChild(bullet)
},100)
// 子弹移动
// 计算伤害
// 碰撞
// setInterval(()=>{
// for(let bullet of this.bulletsArray){
// console.log(this.ballerArray)
// console.log(this.bulletsArray)
// console.log("===================");
// bullet.y -= 40;
// if(bullet.y < -40){
// this.gameBg.removeChild(bullet)
// let index = this.bulletsArray.indexOf(bullet)
// this.bulletsArray = this.bulletsArray.filter((ele,i)=>i != index)
// }
// for(let baller of this.ballerArray){
// let y = bullet.y - baller.y;
// let bulletRight = bullet.x + bullet.width;
// if(bulletRight > baller.x && bulletRight < (baller.x + baller.width) || bullet.x > baller.x && bullet.x < (baller.x + baller.width)){
// if(y <= 0){
// // 击中 移除敌机
// this.gameBg.removeChild(bullet)
// let index = this.bulletsArray.indexOf(bullet)
// this.bulletsArray = this.bulletsArray.filter((ele,i)=>i != index)
// boom.x = baller.x;
// boom.y = baller.y;
// this.gameBg.addChild(boom)
// this.gameBg.removeChild(baller)
// let ind = this.ballerArray.indexOf(baller)
// this.ballerArray = this.ballerArray.filter((ele,i)=>i != ind)
// setTimeout(() => {
// this.gameBg.removeChild(boom);
// }, 1500);
// }
// }
// }
// }
// },20)
setInterval(()=>{
for(let bulletObj of this.bulletsArray){
console.log(this.ballerArray)
console.log(this.bulletsArray)
console.log("得分:"+this.score)
console.log("===================");
bulletObj.bullet.y -= 40;
if(bulletObj.bullet.y < -40){
this.gameBg.removeChild(bulletObj.bullet)
let index = this.bulletsArray.indexOf(bulletObj)
this.bulletsArray = this.bulletsArray.filter((ele,i)=>i != index)
}
for(let ballObj of this.ballerArray){
let y = bulletObj.bullet.y - ballObj.ball.y;
let bulletRight = bulletObj.bullet.x + bulletObj.bullet.width;
if(bulletRight > ballObj.ball.x && bulletRight < (ballObj.ball.x + ballObj.ball.width) || bulletObj.bullet.x > ballObj.ball.x && bulletObj.bullet.x < (ballObj.ball.x + ballObj.ball.width)){
if(y <= 0){
// 击中 移除敌机
ballObj.life -= bulletObj.harm;
// 加分
this.score += bulletObj.harm;
// console.log("得分:"+this.score)
//子弹移除
this.gameBg.removeChild(bulletObj.bullet)
let index = this.bulletsArray.indexOf(bulletObj)
this.bulletsArray = this.bulletsArray.filter((ele,i)=>i != index)
if(ballObj.life === 0){
this.gameBg.removeChild(ballObj.ball)
let ind = this.ballerArray.indexOf(ballObj)
this.ballerArray = this.ballerArray.filter((ele,i)=>i != ind)
boom.x = ballObj.ball.x;
boom.y = ballObj.ball.y;
this.gameBg.addChild(boom)
setTimeout(() => {
this.gameBg.removeChild(boom);
}, 1500);
}
}
}
}
}
},20)
}
stop(){}
onDown(e){
this.mouseX = e.localX
this.mouseY = e.localY
this.stage.addEventListener(engine.MouseEvent.MOUSE_MOVE,this.onMove,this)
this.planeModel.x = e.stageX - this.mouseX;
this.planeCenterX = this.planeModel.x + this.planeModel.width / 2;
}
onMove(e:engine.MouseEvent){
// 以图片中心为准
this.centerX = this.planeModel.width / 2;
let movedCenter = this.centerX + e.stageX - this.mouseX;
if(movedCenter < 0){
this.planeModel.x = -this.centerX;
} else if(movedCenter >750){
this.planeModel.x = 750 - this.centerX;
} else {
this.planeModel.x = e.stageX - this.mouseX;
this.planeCenterX = this.planeModel.x + this.planeModel.width / 2;
// console.log(e.stageX,e.stageY)
}
}
onClick(){
this.addChild(this.gameBg);
this.gameBg.addChild(this.planeModel)
}
shoot(w){
setInterval(()=>{
let bullet = new engine.Sprite(getTexture('18852543-1f1d-498b-af64-88cd3b343758'));
bullet.x = this.planeModel.x && this.planeModel.x + this.centerX - this.bullet.width / 2 + w || 375 - this.bullet.width / 2 + w;
bullet.y = 1150
this.gameBg.addChild(bullet)
this.bullet.y = this.bullet.y - 40;
let timeid = setInterval(()=>{
bullet.y = bullet.y - 40;
if(bullet.y < -40){
this.gameBg.removeChild(bullet)
clearInterval(timeid)
}
},1000/60)
},1000/60)
}
// ball:engine.Sprite;
drop(){
let ball = new engine.Sprite(getTexture('780b6b63-3abd-4246-94ba-2a3fbdb3c5af'));
ball.x = Math.random() * (750 - ball.width ) + ball.width;
ball.y = Math.random() * (ball.height)
this.gameBg.addChild(ball)
setInterval(()=>{
ball.y += 1;
if(ball.y > this.stage.height){
this.gameBg.removeChild(ball)
}
},50)
}
}
\ No newline at end of file
import GameView from "./GameView";
import { injectProps } from "../props";
import TestView from './TestView'
export class GameWrapper extends engine.Container{
private _gameView:GameView
private _testView:TestView
constructor(){
super();
engine.globalEvent.addEventListener('pictures-start', this.start, this);
engine.globalEvent.addEventListener('pictures-stop', this.stop, this);
//创建实例
// let gameView = this._gameView = new GameView();
// this.addChild(gameView);
let testView = this._testView = new TestView();
this.addChild(testView);
}
// start(event: engine.Event) {
// injectProps(event.data);
// // this._status = 1;
// this._gameView.start();
// }
// stop(event: engine.Event) {
// this._gameView.stop();
// }
start(event: engine.Event) {
injectProps(event.data);
// this._status = 1;
this._testView.start();
}
stop(event: engine.Event) {
this._testView.stop();
}
}
\ No newline at end of file
import Ball from "./Ball";
import { getTexture } from "./utils";
export class SmallPlane extends Ball{
_life:number = 3;
smallPlane = new engine.Sprite(getTexture('57d4067e-c32f-4b12-a8fc-185753726fc6'))
constructor(){
super()
this.life = 3;
this.name = "smallBall"
this.addChild(this.smallPlane)
}
setPosition(){
this.x = Math.random() * (750 - this.width)
this.y = Math.random() * (this.height)
}
died(){
}
}
\ No newline at end of file
import {getTexture} from './utils'
import { SmallPlane } from './SmallBall'
import {Bullets} from './Bullets'
export default class TestView extends engine.Container{
startBtn:engine.Sprite
stageBg: engine.Sprite;
gameBg: engine.Sprite;
planeModel:engine.Sprite;
constructor(){
super()
this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);
}
setup(){
this.stageBg = new engine.Sprite(getTexture('308742a0-0ea2-4610-b34a-a230add82021'))
this.addChild(this.stageBg)
this.gameBg = new engine.Sprite(getTexture('76820072-df5a-4ab7-8cb7-10c8cd8605c8'))
// 开始按钮
this.startBtn = new engine.Sprite(getTexture('855e3d77-ffff-443d-b884-4f67a2ebe458'))
this.startBtn.x = (750 - this.startBtn.width) / 2;
this.startBtn.y = (this.stage.height - this.startBtn.height) / 2 + 300;
this.stageBg.addChild(this.startBtn)
this.startBtn.addEventListener(engine.MouseEvent.CLICK,this.onClick,this)
}
smallBall:SmallPlane
planeArray:[
{
type:string,
enemyPlane:Array<any>
},
{
type:string,
enemyPlane:Array<any>
},
{
type:string,
enemyPlane:Array<any>
}
] = [
{
type:'smallBall',
enemyPlane:[]
},
{
type:'middleBall',
enemyPlane:[]
},
{
type:'largeBall',
enemyPlane:[]
}
]
bulletArray:any[] = []
score:number = 0;
start(){
// 炮车
this.planeModel = new engine.Sprite(getTexture('32ec481a-3f75-4c36-95ed-ee97aa936517'))
this.planeModel.x = (750 - this.planeModel.width) / 2;
this.planeModel.y = (this.stage.height - this.planeModel.height)
this.planeModel.addEventListener(engine.MouseEvent.MOUSE_DOWN,this.onDown,this)
this.gameBg.addChild(this.planeModel)
let boom = new engine.Sprite(getTexture('38ec6627-efa8-4f7a-9bdc-3c73cea717f1'))
//敌机
setInterval(()=>{
let smallBall = new SmallPlane();
smallBall.setPosition();
console.log(this.planeArray);
for(let planearray of this.planeArray){
if(planearray.type == smallBall.name){
console.log(planearray.enemyPlane)
planearray.enemyPlane.push(smallBall)
}
}
this.gameBg.addChild(smallBall)
},500)
// 敌机移动
setInterval(()=>{
for(let planearray of this.planeArray){
if(planearray.type === 'smallBall'){
for(let sball of planearray.enemyPlane){
console.log(sball)
sball.y += 1;
if(sball.y > this.stage.height){
this.gameBg.removeChild(sball)
let index = planearray.enemyPlane.indexOf(sball)
planearray.enemyPlane = planearray.enemyPlane.filter((ele,i)=>i != index)
}
}
}
}
},16)
// my plane
setInterval(()=>{
let bullet = new Bullets();
bullet.createBullet(this.planeModel);
this.bulletArray.push(bullet)
this.gameBg.addChild(bullet)
},40)
setInterval(()=>{
console.log(this.score);
for(let bullet of this.bulletArray){
// console.log(bullet,123)
bullet.y -= 35;
if(bullet.y < -40){
this.gameBg.removeChild(bullet)
let index = this.bulletArray.indexOf(bullet)
this.bulletArray = this.bulletArray.filter((ele,i)=>i != index)
}
// 击中
for(let planearray of this.planeArray){
if(planearray.type === 'smallBall'){
for(let splane of planearray.enemyPlane){
let y = bullet.y - splane.y;
let bulletRight = bullet.x + bullet.width;
let planeRange = splane.x + splane.width
if(bulletRight > splane.x && bulletRight < planeRange || bullet.x > splane.x && bullet.x < planeRange){
if(y <= 0){
// 击中敌机
splane.life -= bullet.harm;
this.score += bullet.harm;
// 子弹移除
this.gameBg.removeChild(bullet);
let index = this.bulletArray.indexOf(bullet);
this.bulletArray = this.bulletArray.filter((ele,i)=>i != index)
if(splane.life === 0){
this.gameBg.removeChild(splane);
let ind = planearray.enemyPlane.indexOf(splane);
planearray.enemyPlane = planearray.enemyPlane.filter((ele,i)=>i!=ind)
boom.x = splane.x;
boom.y = splane.y;
this.gameBg.addChild(boom);
setTimeout(() => {
this.gameBg.removeChild(boom);
}, 1500);
}
}
}
}
}
}
}
},16)
}
onClick(){
this.addChild(this.gameBg);
this.gameBg.addChild(this.planeModel)
}
mouseX:number;
mouseY:number;
// 炮车宽度
centerX:number;
planeCenterX:number
onDown(e:engine.MouseEvent){
this.mouseX = e.localX
this.mouseY = e.localY
this.stage.addEventListener(engine.MouseEvent.MOUSE_MOVE,this.onMove,this)
this.planeModel.x = e.stageX - this.mouseX;
this.planeCenterX = this.planeModel.x + this.planeModel.width / 2;
}
onMove(e:engine.MouseEvent){
// 炮车移动范围
this.centerX = this.planeModel.width / 2;
let movedCenter = this.centerX + e.stageX - this.mouseX;
if(movedCenter < 0){
this.planeModel.x = -this.centerX;
} else if(movedCenter >750){
this.planeModel.x = 750 - this.centerX;
} else {
this.planeModel.x = e.stageX - this.mouseX;
this.planeCenterX = this.planeModel.x + this.planeModel.width / 2;
}
}
stop(){
}
}
\ No newline at end of file
/**
* 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 getIndexFromRC(row,col,maxCol){
let index;
index = row * maxCol + col ;
return index
}
export function getRandomArray(array){
array.sort(function() {
return .5 - Math.random();
});
}
\ No newline at end of file
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);
}
/**
* Created by renjianfeng on 2020-03-13.
*/
const customId = 'rounds-pic';
(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: "http://yun.duiba.com.cn/aurora/assets/e1593b97c27077b85b92f7eaaeae1ed64a1eb79a.png",
blockUrl: "888",
GAME_TIME:30,
MAX_ROW:4,
MAX_COL:3,
W:618,
H:827,
GAP:0,
OFFSET_X:0,
OFFSET_Y:0
});
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['rounds-pic'] = 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
var qietu = (function (parent, url, MAX_COL, MAX_ROW) {
var W = props.W;
var H = props.H;
var GAP = props.GAP;
var spr = [];
var pos = [];
var _loop_1 = function (row) {
var _loop_2 = function (col) {
var child = new engine.Sprite();
child.scaleX = 1 / MAX_COL;
child.scaleY = 1 / MAX_ROW;
parent.addChild(child);
child.x = col * (W / MAX_COL + GAP);
child.y = row * (H / MAX_ROW + GAP);
pos.push([child.x, child.y]);
spr.push(child);
child.addEventListener(engine.Event.COMPLETE, function () {
var uvs = new Float32Array([
col / MAX_COL,
row / MAX_ROW,
(col + 1) / MAX_COL,
row / MAX_ROW,
(col + 1) / MAX_COL,
(row + 1) / MAX_ROW,
col / MAX_COL,
(row + 1) / MAX_ROW,
]);
child.uvs = uvs;
});
child.texture = engine.Texture.fromImage(url);
};
for (var col = 0; col < MAX_COL; col++) {
_loop_2(col);
}
};
for (var row = 0; row < MAX_ROW; row++) {
_loop_1(row);
}
console.log(spr);
return [spr, pos];
});
//# sourceMappingURL=qietu.js.map
function getIndexFromRC(row, col, maxCol) {
var index;
index = row * maxCol + col;
return index;
}
function getRandomArray(array) {
array.sort(function () {
return 0.5 - Math.random();
});
}
var MAX_COL;
var MAX_ROW;
var W;
var H;
var GAP;
var GAME_TIME;
var w;
var h;
var picUrl;
var GameView = (function (_super) {
tslib.__extends(GameView, _super);
function GameView() {
var _this = _super.call(this) || this;
_this._timeCounter = 0;
_this._result = [];
_this.listenStageOn = 1;
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
return _this;
}
GameView.prototype.start = function () {
var _this = this;
picUrl = props.picUrl;
MAX_COL = props.MAX_COL;
MAX_ROW = props.MAX_ROW;
GAME_TIME = props.GAME_TIME;
W = props.W;
H = props.H;
GAP = props.GAP;
w = W / MAX_COL;
h = H / MAX_ROW;
console.log('on start');
engine.globalEvent.dispatchEvent('pictures-time-update', {
second: this.getSecond(),
});
if (this._result.length !== 0) {
this._result = [];
}
this._result = qietu(this.picturesWrapper, picUrl, MAX_COL, MAX_ROW);
this.pictures = this._result[0];
if (this.rightList !== null) {
this.rightList = [];
}
this.rightList = this.pictures.concat([]);
var posList = this._result[1];
getRandomArray(this.pictures);
var i = 0;
var len;
len = this.pictures.length;
for (; i < len; i++) {
this.dragPic = this.pictures[i];
this.pictures[i].addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDown, this);
var _a = posList[i], x = _a[0], y = _a[1];
this.dragPic.x = x;
this.dragPic.y = y;
}
this._timer = setInterval(function () {
_this.onTimer();
}, 10);
this.date = new Date().getTime();
};
GameView.prototype.onTimer = function () {
var date = new Date().getTime();
var gap = ((date - this.date) / 1000);
this.date = date;
GAME_TIME -= gap;
if (GAME_TIME < 0) {
GAME_TIME = 0;
}
GAME_TIME = this.afterPointTwo(GAME_TIME);
GAME_TIME = GAME_TIME.toFixed(2);
if (GAME_TIME < 10) {
GAME_TIME = '0' + GAME_TIME;
}
engine.globalEvent.dispatchEvent('pictures-time-update', {
second: this.getSecond(),
});
if (this.getSecond() == 0) {
this.stop();
engine.globalEvent.dispatchEvent('pictures-game-fail', {
reason: 1
});
this.stage.removeEventListener(engine.MouseEvent.MOUSE_UP, this.stageOnUp, this);
}
};
GameView.prototype.afterPointTwo = function (n) {
var floatN = parseFloat(n);
if (isNaN(floatN)) {
return;
}
floatN = Math.round(floatN * 100) / 100;
return floatN;
};
GameView.prototype.getSecond = function () {
return GAME_TIME;
};
GameView.prototype.stop = function () {
GAME_TIME = props.GAME_TIME;
clearInterval(this._timer);
var len = this.pictures.length;
for (var i = 0; i < len; i++) {
this.pictures[i].removeAllEventListener();
}
};
GameView.prototype.createRects = function () { };
GameView.prototype.setup = function () {
console.log('onSteup', props);
var parent = new engine.Sprite();
this.picturesWrapper = parent;
this.addChild(parent);
};
GameView.prototype.onDown = function (e) {
var stageLeft = (750 - props.W) / 2;
var stageTop = (this.stage.height - props.H) / 2;
this.dragPic = e.target;
this.picturesWrapper.addChild(this.dragPic);
this.localPicX = e.localX / MAX_COL;
this.localPicY = e.localY / MAX_ROW;
this.distanceX = this.dragPic.x;
this.distanceY = this.dragPic.y;
this.indexJ = Math.floor((this.distanceX) / (w + GAP));
this.indexI = Math.floor((this.distanceY) / (h + GAP));
this.index = (this.indexI) * MAX_COL + this.indexJ;
this.centerX = Math.floor((e.clientX - stageLeft) / w) * w + w / 2;
this.centerY = Math.floor((e.clientY - stageTop) / h) * h + h / 2;
this.stage.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMove, this);
this.stage.addEventListener(engine.MouseEvent.MOUSE_UP, this.stageOnUp, this);
};
GameView.prototype.stageOnUp = function (e) {
var stageLeft = (750 - props.W) / 2;
var stageTop = (this.stage.height - props.H) / 2;
this.stage.removeEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMove, this);
this.stage.removeEventListener(engine.MouseEvent.MOUSE_UP, this.stageOnUp, this);
if (this.centerY < stageTop || this.centerX < stageLeft) {
this.dragPic.x = this.distanceX;
this.dragPic.y = this.distanceY;
}
var curJ = Math.floor(this.centerX / (w + GAP));
var curI = Math.floor(this.centerY / (h + GAP));
if (0 <= curJ && curJ < (MAX_COL) && 0 <= curI && curI < (MAX_ROW)) {
var index = getIndexFromRC(curI, curJ, MAX_COL);
var dropPic = this.pictures[index];
var dropPicX = dropPic.x + stageLeft;
var dropPicy = dropPic.y + stageTop;
dropPic.x = this.distanceX;
dropPic.y = this.distanceY;
this.dragPic.x = dropPicX - stageLeft;
this.dragPic.y = dropPicy - stageTop;
var dropPicIndex = this.pictures.indexOf(dropPic);
var dragPicIndex = this.pictures.indexOf(this.dragPic);
this.pictures[dropPicIndex] = this.dragPic;
this.pictures[dragPicIndex] = dropPic;
if (dragPicIndex === dropPicIndex) {
this.dragPic.x = this.distanceX;
this.dragPic.y = this.distanceY;
}
var result = true;
for (var j = 0; j < this.rightList.length; j++) {
if (this.rightList[j] != this.pictures[j]) {
result = false;
break;
}
}
if (result) {
this.onSuccess();
}
}
else {
this.dragPic.x = this.distanceX;
this.dragPic.y = this.distanceY;
}
};
GameView.prototype.onSuccess = function () {
console.log('拼图成功!');
engine.globalEvent.dispatchEvent('pictures-game-success', { time: GAME_TIME });
this.stop();
props.GAME_TIME *= 0.9;
++props.MAX_ROW;
++props.MAX_COL;
};
GameView.prototype.onMove = function (e) {
this.dragPic.x = e.stageX - this.localPicX - (750 - props.W) / 2;
this.dragPic.y = e.stageY - this.localPicY - (this.stage.height - props.H) / 2;
this.centerX = this.dragPic.x + w / 2;
this.centerY = this.dragPic.y + h / 2;
};
return GameView;
}(engine.Container));
//# sourceMappingURL=GameView.js.map
var GameWrapper = (function (_super) {
tslib.__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('pictures-start', _this.start, _this);
engine.globalEvent.addEventListener('pictures-stop', _this.stop, _this);
var gameView = _this._gameView = new GameView();
_this.addChild(gameView);
return _this;
}
GameWrapper.prototype.start = function (event) {
injectProps(event.data);
this._gameView.start();
};
GameWrapper.prototype.stop = function (event) {
this._gameView.stop();
};
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/rounds-pic/src/props.ts","src/custom/rounds-pic/src/game/qietu.ts","src/custom/rounds-pic/src/game/utils.ts","src/custom/rounds-pic/src/game/GameView.ts","src/custom/rounds-pic/src/game/GameWrapper.ts","src/custom/rounds-pic/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","import { props } from \"../props\";\r\nconst urls = [];\r\nconst picMap = {};\r\nconst posMap = {};\r\nexport default (parent, url, MAX_COL, MAX_ROW) => {\r\n // if (picMap[url]) {\r\n // const pics:any[] = picMap[url];\r\n // for (const pic of pics) {\r\n // parent.addChild(pic);\r\n // }\r\n // return [picMap[url], posMap[url]]\r\n // }\r\n\r\n const W = props.W;\r\n const H = props.H;\r\n const GAP = props.GAP;\r\n\r\n const spr = [];\r\n const pos = []\r\n\r\n for (let row = 0; row < MAX_ROW; row++) {\r\n for (let col = 0; col < MAX_COL; col++) {\r\n\r\n const child = new engine.Sprite(); \r\n // spr.push(child);\r\n\r\n child.scaleX = 1 / MAX_COL;\r\n child.scaleY = 1 / MAX_ROW;\r\n parent.addChild(child);\r\n child.x = col * (W / MAX_COL + GAP);\r\n child.y = row * (H / MAX_ROW + GAP);\r\n pos.push([child.x, child.y]);\r\n spr.push(child);\r\n child.addEventListener(engine.Event.COMPLETE, () => {\r\n const uvs = new Float32Array([\r\n col / MAX_COL,\r\n row / MAX_ROW,\r\n (col + 1) / MAX_COL,\r\n row / MAX_ROW,\r\n (col + 1) / MAX_COL,\r\n (row + 1) / MAX_ROW,\r\n col / MAX_COL,\r\n (row + 1) / MAX_ROW,\r\n ]);\r\n\r\n child.uvs = uvs;\r\n });\r\n\r\n child.texture = engine.Texture.fromImage(url);\r\n }\r\n }\r\n // picMap[url] = spr.concat([]);\r\n // posMap[url] = pos.concat([]);\r\n console.log(spr);\r\n return [spr, pos];\r\n};\r\n","/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\nimport {props} from '../props'\r\nexport function getTexture(uuid) {\r\n return engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n}\r\n\r\nexport function getTextureByName(name) {\r\n return getTexture(engine.getAssetByName(name).uuid);\r\n}\r\n\r\nexport function playSound(name) {\r\n engine.playSound(engine.getAssetByName(name).uuid, { keep: true });\r\n}\r\nexport function createSvga(name, anchorName?) {\r\n let inst = new svga.Svga();\r\n inst.source = \"asset://\" + engine.getAssetByName(name).uuid;\r\n return inst;\r\n}\r\n\r\nexport function getIndexFromRC(row, col, maxCol) {\r\n let index;\r\n index = row * maxCol + col;\r\n return index;\r\n}\r\n\r\nexport function getRandomArray(array) {\r\n array.sort(function () {\r\n return 0.5 - Math.random();\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 { getIndexFromRC, getRandomArray, getTexture } from \"./utils\";\r\nimport ObjectPool = engine.ObjectPool;\r\n\r\n// let OFFSET_X;\r\n// let OFFSET_Y;\r\nlet MAX_COL;\r\nlet MAX_ROW;\r\nlet W;\r\nlet H;\r\nlet GAP;\r\nlet GAME_TIME;\r\n// 每张图片宽\r\nlet w;\r\n// 每张图片高\r\nlet h;\r\n// 图片\r\nlet picUrl\r\n\r\nexport default class GameView extends engine.Container {\r\n private _timer;\r\n private _timeCounter = 0;\r\n private _result = []\r\n private date\r\n\r\n \r\n\r\n start() {\r\n picUrl = props.picUrl;\r\n MAX_COL = props.MAX_COL;\r\n MAX_ROW = props.MAX_ROW;\r\n GAME_TIME = props.GAME_TIME;\r\n // OFFSET_X = props.OFFSET_X;\r\n // OFFSET_Y = props.OFFSET_Y;\r\n W = props.W;\r\n H = props.H;\r\n GAP = props.GAP;\r\n // 每张图片宽\r\n w = W / MAX_COL;\r\n // 每张图片高\r\n h = H / MAX_ROW;\r\n\r\n \r\n // if (!this.guideHole) {\r\n // this.guideHole = new engine.Image();\r\n // this.guideHole.source = 'asset://' + props.blockUrl;\r\n // this.guideHole.mouseChildren = this.guideHole.mouseEnabled = false;\r\n // }\r\n\r\n // if (this.pictures) {\r\n // for (const pic of this.pictures) {\r\n // if (pic && pic.parent)\r\n // pic.parent.removeChild(pic);\r\n // }\r\n // }\r\n\r\n console.log('on start')\r\n engine.globalEvent.dispatchEvent('pictures-time-update', {\r\n second: this.getSecond(),\r\n });\r\n\r\n // 图片一维数组\r\n if(this._result.length !==0){\r\n this._result = []\r\n }\r\n\r\n this._result = qietu(this.picturesWrapper, picUrl, MAX_COL, MAX_ROW);\r\n // this.picturesWrapper.addChild(this.guideHole);\r\n\r\n // console.log(this.picturesWrapper)\r\n\r\n this.pictures = this._result[0];\r\n if(this.rightList !== null){\r\n this.rightList = []\r\n }\r\n this.rightList = this.pictures.concat([]);\r\n const posList = this._result[1];\r\n getRandomArray(this.pictures);\r\n\r\n let i = 0;\r\n let len;\r\n len = this.pictures.length;\r\n\r\n\r\n for (; i < len; i++) {\r\n this.dragPic = this.pictures[i];\r\n this.pictures[i].addEventListener(\r\n engine.MouseEvent.MOUSE_DOWN,\r\n this.onDown,\r\n this\r\n );\r\n const [x, y] = posList[i];\r\n this.dragPic.x = x;\r\n this.dragPic.y = y;\r\n\r\n }\r\n\r\n this._timer = setInterval(() => {\r\n this.onTimer();\r\n }, 10)\r\n\r\n this.date = new Date().getTime();\r\n\r\n }\r\n\r\n onTimer() {\r\n\r\n let date = new Date().getTime();\r\n\r\n let gap = ((date - this.date) / 1000);\r\n this.date = date;\r\n // console.log(gap,\"gap\");\r\n\r\n // 以GAME_TIME为标准\r\n GAME_TIME -= gap;\r\n if(GAME_TIME < 0){\r\n GAME_TIME = 0;\r\n }\r\n GAME_TIME = this.afterPointTwo(GAME_TIME);\r\n GAME_TIME = GAME_TIME.toFixed(2);\r\n if (GAME_TIME < 10) {\r\n GAME_TIME = '0' + GAME_TIME\r\n }\r\n // console.log(GAME_TIME);\r\n\r\n\r\n engine.globalEvent.dispatchEvent('pictures-time-update', {\r\n second: this.getSecond(),\r\n });\r\n\r\n if (this.getSecond() == 0) {\r\n this.stop();\r\n engine.globalEvent.dispatchEvent('pictures-game-fail', {\r\n reason: 1\r\n });\r\n\r\n this.stage.removeEventListener(\r\n engine.MouseEvent.MOUSE_UP,\r\n this.stageOnUp,\r\n this\r\n );\r\n\r\n }\r\n }\r\n\r\n afterPointTwo(n) {\r\n\r\n var floatN = parseFloat(n);\r\n if (isNaN(floatN)) {\r\n return;\r\n }\r\n floatN = Math.round(floatN * 100) / 100;\r\n return floatN;\r\n\r\n }\r\n\r\n getSecond() {\r\n return GAME_TIME\r\n }\r\n\r\n stop() {\r\n \r\n GAME_TIME = props.GAME_TIME\r\n clearInterval(this._timer);\r\n let len = this.pictures.length;\r\n for(let i=0;i<len;i++){\r\n this.pictures[i].removeAllEventListener();\r\n }\r\n }\r\n\r\n constructor() {\r\n super();\r\n this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);\r\n }\r\n\r\n //当前图片对象\r\n dragPic;\r\n // 鼠标在当前图片上的位置\r\n localPicX;\r\n localPicY;\r\n // 拖动的图片最开始的位置(左上角为准)\r\n distanceX;\r\n distanceY;\r\n // 图片中心的位置\r\n centerX: number;\r\n centerY: number;\r\n\r\n pictures: engine.Sprite[];\r\n\r\n // 点击图片时的一维数组索引\r\n index;\r\n // 计算目标图片行和列的位置\r\n indexI: number;\r\n indexJ: number;\r\n rightList: engine.Sprite[];\r\n\r\n private picturesWrapper: engine.Sprite;\r\n private guideHole: engine.Image;\r\n\r\n createRects() { }\r\n setup() {\r\n\r\n \r\n\r\n console.log('onSteup', props);\r\n\r\n const parent = new engine.Sprite();\r\n this.picturesWrapper = parent;\r\n this.addChild(parent);\r\n\r\n // this.picturesWrapper.x = OFFSET_X;\r\n // this.picturesWrapper.y = OFFSET_Y;\r\n\r\n // 添加按钮\r\n // const btn = new engine.Rect();\r\n // btn.width = 200;\r\n // btn.height = 100;\r\n // btn.stage.top = 1000;\r\n // btn.stage.left = 350;\r\n // btn.fillColor = 'cyan';\r\n // this.addChild(btn)\r\n\r\n // btn.addEventListener(engine.MouseEvent.CLICK,this.onClk,this)\r\n\r\n }\r\n\r\n onDown(e: engine.MouseEvent) {\r\n // console.log(e);\r\n\r\n let stageLeft = (750 - props.W) / 2\r\n let stageTop = (this.stage.height - props.H) / 2;\r\n\r\n // 创建一个图片对象接收当前位置信息\r\n this.dragPic = e.target;\r\n this.picturesWrapper.addChild(this.dragPic);\r\n\r\n\r\n // 鼠标的偏移量\r\n this.localPicX = e.localX / MAX_COL;\r\n this.localPicY = e.localY / MAX_ROW;\r\n\r\n // 最开始图片的位置\r\n this.distanceX = this.dragPic.x ;\r\n this.distanceY = this.dragPic.y;\r\n\r\n // 最开始点击的图片的索引值\r\n\r\n this.indexJ = Math.floor((this.distanceX) / (w + GAP));\r\n this.indexI = Math.floor((this.distanceY) / (h + GAP));\r\n this.index = (this.indexI) * MAX_COL + this.indexJ;\r\n\r\n\r\n // this.centerX = Math.floor(e.clientX / w) * w + w / 2;\r\n // this.centerY = Math.floor(e.clientY / h) * h + h / 2;\r\n\r\n this.centerX = Math.floor((e.clientX - stageLeft) / w) * w + w / 2;\r\n this.centerY = Math.floor((e.clientY - stageTop) / h) * h + h / 2;\r\n\r\n this.stage.addEventListener(\r\n engine.MouseEvent.MOUSE_MOVE,\r\n this.onMove,\r\n this\r\n );\r\n this.stage.addEventListener(\r\n engine.MouseEvent.MOUSE_UP,\r\n this.stageOnUp,\r\n this\r\n );\r\n\r\n }\r\n\r\n listenStageOn = 1;\r\n\r\n stageOnUp(e) {\r\n\r\n let stageLeft = (750 - props.W) / 2\r\n let stageTop = (this.stage.height - props.H) / 2;\r\n\r\n this.stage.removeEventListener(\r\n engine.MouseEvent.MOUSE_MOVE,\r\n this.onMove,\r\n this\r\n );\r\n\r\n this.stage.removeEventListener(\r\n engine.MouseEvent.MOUSE_UP,\r\n this.stageOnUp,\r\n this\r\n );\r\n\r\n // 拖动的图片的中心位置在图片之外,回到原来的位置\r\n if (this.centerY < stageTop || this.centerX < stageLeft) {\r\n this.dragPic.x = this.distanceX ;\r\n this.dragPic.y = this.distanceY ;\r\n }\r\n\r\n // 判断图片是否进入另一张图片的范围内\r\n // 要交换的图片第几行第几列\r\n let curJ = Math.floor(this.centerX / (w + GAP));\r\n let curI = Math.floor(this.centerY / (h + GAP));\r\n\r\n // this.picturesWrapper.addChild(this.guideHole);\r\n\r\n\r\n\r\n // 点击图片的位置\r\n\r\n if ( 0 <= curJ && curJ < (MAX_COL) && 0 <= curI && curI < (MAX_ROW)) {\r\n\r\n // 获取交互图片的索引值\r\n let index = getIndexFromRC(curI, curJ, MAX_COL);\r\n // console.log(index);\r\n\r\n //要交换的图片\r\n let dropPic = this.pictures[index];\r\n\r\n let dropPicX = dropPic.x + stageLeft;\r\n let dropPicy = dropPic.y + stageTop;\r\n\r\n dropPic.x = this.distanceX;\r\n dropPic.y = this.distanceY;\r\n\r\n this.dragPic.x = dropPicX - stageLeft;\r\n this.dragPic.y = dropPicy - stageTop;\r\n\r\n // 交换之后索引也需要交换\r\n\r\n const dropPicIndex = this.pictures.indexOf(dropPic);\r\n const dragPicIndex = this.pictures.indexOf(this.dragPic);\r\n\r\n this.pictures[dropPicIndex] = this.dragPic;\r\n this.pictures[dragPicIndex] = dropPic;\r\n\r\n // 图片中心还是在原来的位置\r\n if (dragPicIndex === dropPicIndex) {\r\n this.dragPic.x = this.distanceX\r\n this.dragPic.y = this.distanceY\r\n }\r\n\r\n let result = true;\r\n for (let j = 0; j < this.rightList.length; j++) {\r\n if (this.rightList[j] != this.pictures[j]) {\r\n result = false;\r\n break;\r\n }\r\n }\r\n\r\n if (result) {\r\n this.onSuccess();\r\n\r\n }\r\n } else {\r\n this.dragPic.x = this.distanceX\r\n this.dragPic.y = this.distanceY\r\n }\r\n\r\n }\r\n\r\n private onSuccess() {\r\n console.log('拼图成功!');\r\n engine.globalEvent.dispatchEvent('pictures-game-success', { time: GAME_TIME });\r\n this.stop();\r\n props.GAME_TIME *= 0.9;\r\n ++props.MAX_ROW ;\r\n ++props.MAX_COL ;\r\n\r\n }\r\n\r\n onMove(e: engine.MouseEvent) {\r\n // 当前图片的位置\r\n this.dragPic.x = e.stageX - this.localPicX - (750 - props.W) / 2;\r\n this.dragPic.y = e.stageY - this.localPicY - (this.stage.height - props.H) / 2;\r\n\r\n // 当前图片的中心位置\r\n this.centerX = this.dragPic.x + w / 2;\r\n this.centerY = this.dragPic.y + h / 2;\r\n }\r\n\r\n // onClk(e){\r\n // // 重置时间\r\n // this._timeCounter = 0;\r\n // //重置图片顺序\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\tconstructor() {\r\n\t\tsuper();\r\n\r\n\t\tengine.globalEvent.addEventListener('pictures-start', this.start, this);\r\n\t\tengine.globalEvent.addEventListener('pictures-stop', this.stop, this);\r\n\r\n\t\t//创建实例\r\n\t\tlet gameView = this._gameView = new GameView();\r\n\t\tthis.addChild(gameView);\r\n\r\n\t}\r\n\r\n\tstart(event: engine.Event) {\r\n\t\tinjectProps(event.data);\r\n\r\n\t\t\r\n\t\t// this._status = 1;\r\n\r\n\t\tthis._gameView.start();\r\n\t}\r\n\tstop(event: engine.Event) {\r\n\t\t\r\n\t\tthis._gameView.stop();\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\treturn instance;\r\n}\r\n"],"names":["__extends"],"mappings":";;;;;;CAIO,IAAI,KAAK,GAAQ,EAAE,CAAC;UAEX,YAAY;KAC3B,IAAI,SAAS,GAAG,QAAQ,EAAE,CAAC;KAE3B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;CACrC,CAAC;UAEe,WAAW,CAAC,CAAC;KAC5B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;CAC7B,CAAC;;;ACVD,cAAe,UAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO;KAS3C,IAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;KAClB,IAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;KAClB,IAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC;KAEtB,IAAM,GAAG,GAAG,EAAE,CAAC;KACf,IAAM,GAAG,GAAG,EAAE,CAAA;6BAEL,GAAG;iCACD,GAAG;aAEV,IAAM,KAAK,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;aAGlC,KAAK,CAAC,MAAM,GAAG,CAAC,GAAG,OAAO,CAAC;aAC3B,KAAK,CAAC,MAAM,GAAG,CAAC,GAAG,OAAO,CAAC;aAC3B,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;aACv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/C,KAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;;MAExB;KAED,2BAAK,GAAL,UAAM,KAAmB;SACxB,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SAKxB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;MACvB;KACD,0BAAI,GAAJ,UAAK,KAAmB;SAEvB,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;MACtB;KACF,kBAAC;CAAD,CAAC,CA5BgC,MAAM,CAAC,SAAS,GA4BhD;;;iBC7BwB,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": 618
},
"H": {
"alias": "图片的高度",
"type": "number",
"default": 827
},
"OFFSET_X": {
"alias": "OFFSET_X",
"type": "number",
"default": 0
},
"OFFSET_Y": {
"alias": "OFFSET_Y",
"type": "number",
"default": 0
},
"GAME_TIME": {
"alias": "游戏时间",
"type": "number",
"default": 30
},
"GAP": {
"alias": "图片间隙",
"type": "number",
"default": 0
}
},
"assets": [
{
"name": "遮罩",
"url": "//yun.duiba.com.cn/aurora/assets/5b3e30496b2d9fdafb0cf3835fd6704ce10e45b4.png",
"uuid": "888",
"ext": ".png"
}
],
"events": {
"in": {
"pictures-start": {
"alias": "开始",
"data": {
"picUrl":"图片路径",
"blockUrl":"blockUrl",
"GAME_TIME":"每局的游戏时间",
"MAX_ROW":"行",
"MAX_COL":"列",
"W":"宽",
"H":"高",
"GAP":"图片间隙",
"OFFSET_X":"OFFSET_X",
"OFFSET_Y":"OFFSET_Y"
}
},
"pictures-stop": {
"alias": "停止"
}
},
"out": {
"pictures-time-update": {
"alias": "倒计时更新",
"data": {
"time":"剩余时间"
}
},
"pictures-game-fail": {
"alias": "游戏结束",
"data": {
"reason": "结束原因(1:时间到了)"
}
},
"pictures-game-success": {
"alias": "游戏成功",
"data": {
"time": "游戏消耗时间"
}
}
}
}
}
\ No newline at end of file
/**
* Created by rockyl on 2018/8/16.
*/
import { props } from "../props";
import qietu from "./qietu";
import { getIndexFromRC, getRandomArray, getTexture } from "./utils";
import ObjectPool = engine.ObjectPool;
// let OFFSET_X;
// let OFFSET_Y;
let MAX_COL;
let MAX_ROW;
let W;
let H;
let GAP;
let GAME_TIME;
// 每张图片宽
let w;
// 每张图片高
let h;
// 图片
let picUrl
export default class GameView extends engine.Container {
private _timer;
private _timeCounter = 0;
private _result = []
private date
start() {
picUrl = props.picUrl;
MAX_COL = props.MAX_COL;
MAX_ROW = props.MAX_ROW;
GAME_TIME = props.GAME_TIME;
// OFFSET_X = props.OFFSET_X;
// OFFSET_Y = props.OFFSET_Y;
W = props.W;
H = props.H;
GAP = props.GAP;
// 每张图片宽
w = W / MAX_COL;
// 每张图片高
h = H / MAX_ROW;
// if (!this.guideHole) {
// this.guideHole = new engine.Image();
// this.guideHole.source = 'asset://' + props.blockUrl;
// this.guideHole.mouseChildren = this.guideHole.mouseEnabled = false;
// }
// if (this.pictures) {
// for (const pic of this.pictures) {
// if (pic && pic.parent)
// pic.parent.removeChild(pic);
// }
// }
console.log('on start')
engine.globalEvent.dispatchEvent('pictures-time-update', {
second: this.getSecond(),
});
// 图片一维数组
if(this._result.length !==0){
this._result = []
}
this._result = qietu(this.picturesWrapper, picUrl, MAX_COL, MAX_ROW);
// this.picturesWrapper.addChild(this.guideHole);
// console.log(this.picturesWrapper)
this.pictures = this._result[0];
if(this.rightList !== null){
this.rightList = []
}
this.rightList = this.pictures.concat([]);
const posList = this._result[1];
getRandomArray(this.pictures);
let i = 0;
let len;
len = this.pictures.length;
for (; i < len; i++) {
this.dragPic = this.pictures[i];
this.pictures[i].addEventListener(
engine.MouseEvent.MOUSE_DOWN,
this.onDown,
this
);
const [x, y] = posList[i];
this.dragPic.x = x;
this.dragPic.y = y;
}
this._timer = setInterval(() => {
this.onTimer();
}, 10)
this.date = new Date().getTime();
}
onTimer() {
let date = new Date().getTime();
let gap = ((date - this.date) / 1000);
this.date = date;
// console.log(gap,"gap");
// 以GAME_TIME为标准
GAME_TIME -= gap;
if(GAME_TIME < 0){
GAME_TIME = 0;
}
GAME_TIME = this.afterPointTwo(GAME_TIME);
GAME_TIME = GAME_TIME.toFixed(2);
if (GAME_TIME < 10) {
GAME_TIME = '0' + GAME_TIME
}
// console.log(GAME_TIME);
engine.globalEvent.dispatchEvent('pictures-time-update', {
second: this.getSecond(),
});
if (this.getSecond() == 0) {
this.stop();
engine.globalEvent.dispatchEvent('pictures-game-fail', {
reason: 1
});
this.stage.removeEventListener(
engine.MouseEvent.MOUSE_UP,
this.stageOnUp,
this
);
}
}
afterPointTwo(n) {
var floatN = parseFloat(n);
if (isNaN(floatN)) {
return;
}
floatN = Math.round(floatN * 100) / 100;
return floatN;
}
getSecond() {
return GAME_TIME
}
stop() {
GAME_TIME = props.GAME_TIME
clearInterval(this._timer);
let len = this.pictures.length;
for(let i=0;i<len;i++){
this.pictures[i].removeAllEventListener();
}
}
constructor() {
super();
this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);
}
//当前图片对象
dragPic;
// 鼠标在当前图片上的位置
localPicX;
localPicY;
// 拖动的图片最开始的位置(左上角为准)
distanceX;
distanceY;
// 图片中心的位置
centerX: number;
centerY: number;
pictures: engine.Sprite[];
// 点击图片时的一维数组索引
index;
// 计算目标图片行和列的位置
indexI: number;
indexJ: number;
rightList: engine.Sprite[];
private picturesWrapper: engine.Sprite;
private guideHole: engine.Image;
createRects() { }
setup() {
console.log('onSteup', props);
const parent = new engine.Sprite();
this.picturesWrapper = parent;
this.addChild(parent);
// this.picturesWrapper.x = OFFSET_X;
// this.picturesWrapper.y = OFFSET_Y;
// 添加按钮
// const btn = new engine.Rect();
// btn.width = 200;
// btn.height = 100;
// btn.stage.top = 1000;
// btn.stage.left = 350;
// btn.fillColor = 'cyan';
// this.addChild(btn)
// btn.addEventListener(engine.MouseEvent.CLICK,this.onClk,this)
}
onDown(e: engine.MouseEvent) {
// console.log(e);
let stageLeft = (750 - props.W) / 2
let stageTop = (this.stage.height - props.H) / 2;
// 创建一个图片对象接收当前位置信息
this.dragPic = e.target;
this.picturesWrapper.addChild(this.dragPic);
// 鼠标的偏移量
this.localPicX = e.localX / MAX_COL;
this.localPicY = e.localY / MAX_ROW;
// 最开始图片的位置
this.distanceX = this.dragPic.x ;
this.distanceY = this.dragPic.y;
// 最开始点击的图片的索引值
this.indexJ = Math.floor((this.distanceX) / (w + GAP));
this.indexI = Math.floor((this.distanceY) / (h + GAP));
this.index = (this.indexI) * MAX_COL + this.indexJ;
// this.centerX = Math.floor(e.clientX / w) * w + w / 2;
// this.centerY = Math.floor(e.clientY / h) * h + h / 2;
this.centerX = Math.floor((e.clientX - stageLeft) / w) * w + w / 2;
this.centerY = Math.floor((e.clientY - stageTop) / h) * h + h / 2;
this.stage.addEventListener(
engine.MouseEvent.MOUSE_MOVE,
this.onMove,
this
);
this.stage.addEventListener(
engine.MouseEvent.MOUSE_UP,
this.stageOnUp,
this
);
}
listenStageOn = 1;
stageOnUp(e) {
let stageLeft = (750 - props.W) / 2
let stageTop = (this.stage.height - props.H) / 2;
this.stage.removeEventListener(
engine.MouseEvent.MOUSE_MOVE,
this.onMove,
this
);
this.stage.removeEventListener(
engine.MouseEvent.MOUSE_UP,
this.stageOnUp,
this
);
// 拖动的图片的中心位置在图片之外,回到原来的位置
if (this.centerY < stageTop || this.centerX < stageLeft) {
this.dragPic.x = this.distanceX ;
this.dragPic.y = this.distanceY ;
}
// 判断图片是否进入另一张图片的范围内
// 要交换的图片第几行第几列
let curJ = Math.floor(this.centerX / (w + GAP));
let curI = Math.floor(this.centerY / (h + GAP));
// this.picturesWrapper.addChild(this.guideHole);
// 点击图片的位置
if ( 0 <= curJ && curJ < (MAX_COL) && 0 <= curI && curI < (MAX_ROW)) {
// 获取交互图片的索引值
let index = getIndexFromRC(curI, curJ, MAX_COL);
// console.log(index);
//要交换的图片
let dropPic = this.pictures[index];
let dropPicX = dropPic.x + stageLeft;
let dropPicy = dropPic.y + stageTop;
dropPic.x = this.distanceX;
dropPic.y = this.distanceY;
this.dragPic.x = dropPicX - stageLeft;
this.dragPic.y = dropPicy - stageTop;
// 交换之后索引也需要交换
const dropPicIndex = this.pictures.indexOf(dropPic);
const dragPicIndex = this.pictures.indexOf(this.dragPic);
this.pictures[dropPicIndex] = this.dragPic;
this.pictures[dragPicIndex] = dropPic;
// 图片中心还是在原来的位置
if (dragPicIndex === dropPicIndex) {
this.dragPic.x = this.distanceX
this.dragPic.y = this.distanceY
}
let result = true;
for (let j = 0; j < this.rightList.length; j++) {
if (this.rightList[j] != this.pictures[j]) {
result = false;
break;
}
}
if (result) {
this.onSuccess();
}
} else {
this.dragPic.x = this.distanceX
this.dragPic.y = this.distanceY
}
}
private onSuccess() {
console.log('拼图成功!');
engine.globalEvent.dispatchEvent('pictures-game-success', { time: GAME_TIME });
this.stop();
props.GAME_TIME *= 0.9;
++props.MAX_ROW ;
++props.MAX_COL ;
}
onMove(e: engine.MouseEvent) {
// 当前图片的位置
this.dragPic.x = e.stageX - this.localPicX - (750 - props.W) / 2;
this.dragPic.y = e.stageY - this.localPicY - (this.stage.height - props.H) / 2;
// 当前图片的中心位置
this.centerX = this.dragPic.x + w / 2;
this.centerY = this.dragPic.y + h / 2;
}
// onClk(e){
// // 重置时间
// this._timeCounter = 0;
// //重置图片顺序
// }
}
/**
* 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();
engine.globalEvent.addEventListener('pictures-start', this.start, this);
engine.globalEvent.addEventListener('pictures-stop', this.stop, this);
//创建实例
let gameView = this._gameView = new GameView();
this.addChild(gameView);
}
start(event: engine.Event) {
injectProps(event.data);
// this._status = 1;
this._gameView.start();
}
stop(event: engine.Event) {
this._gameView.stop();
}
}
/**
* Created by rockyl on 2020-02-03.
*/
import {Goods} from "./Goods";
import ObjectPool = engine.ObjectPool;
export const PoolName: string = 'goods';
ObjectPool.registerPool(PoolName, function () {
return new Goods();
}, function (item: Goods, data) {
item.reset();
});
import { props } from "../props";
const urls = [];
const picMap = {};
const posMap = {};
export default (parent, url, MAX_COL, MAX_ROW) => {
// if (picMap[url]) {
// const pics:any[] = picMap[url];
// for (const pic of pics) {
// parent.addChild(pic);
// }
// return [picMap[url], posMap[url]]
// }
const W = props.W;
const H = props.H;
const GAP = props.GAP;
const spr = [];
const pos = []
for (let row = 0; row < MAX_ROW; row++) {
for (let col = 0; col < MAX_COL; col++) {
const child = new engine.Sprite();
// spr.push(child);
child.scaleX = 1 / MAX_COL;
child.scaleY = 1 / MAX_ROW;
parent.addChild(child);
child.x = col * (W / MAX_COL + GAP);
child.y = row * (H / MAX_ROW + GAP);
pos.push([child.x, child.y]);
spr.push(child);
child.addEventListener(engine.Event.COMPLETE, () => {
const uvs = new Float32Array([
col / MAX_COL,
row / MAX_ROW,
(col + 1) / MAX_COL,
row / MAX_ROW,
(col + 1) / MAX_COL,
(row + 1) / MAX_ROW,
col / MAX_COL,
(row + 1) / MAX_ROW,
]);
child.uvs = uvs;
});
child.texture = engine.Texture.fromImage(url);
}
}
// picMap[url] = spr.concat([]);
// posMap[url] = pos.concat([]);
console.log(spr);
return [spr, pos];
};
/**
* Created by rockyl on 2020-01-21.
*/
import {props} from '../props'
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 getIndexFromRC(row, col, maxCol) {
let index;
index = row * maxCol + col;
return index;
}
export function getRandomArray(array) {
array.sort(function () {
return 0.5 - Math.random();
});
}
/**
* 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