Commit 745825d1 authored by rockyl's avatar rockyl

Merge remote-tracking branch 'origin/dev' into dev

parents f49f79b7 c59885af
File added
## 一、工程目录 http://gitlab2.dui88.com/laoqifeng/zeroing-libs
切换`dev`分支,在`dev`分支新增修改
## 二、文件路径及大概用途
- 1、`dist`文件下即为打包后的json用于发布版本使用
- 2、src为代码路径
* 1、`src/custom` 为所有自定义模块的源码,也是新增或修改的代码路径
* 2、`src/custom` 路径下每一个自定义模块单独一个项目名字文件夹
- 3、通用代码脚本
* 1、`meta.json`文件
- 1、`name`为项目名字
- 2、`desc` 为项目描述
- 3、`props` 为配置属性,提供对外可配置内容
- 4、`assets` 为资源加载属性,加载路径需跟`uuid`相匹配,注意对应类型
- 5、`events` 为事件属性,与外界用事件传递消息,注意每个模块的时间名
* 2、`debug文件`
- 1、该文件是本地运行使用文件
- 2、可修改`app.js`文件里的事件名,而去执行对应的模块代码
* 3、`src/custom/src`为每个模块的项目代码
- 1、`index.ts`为初始化脚本可以通用
- 2、`props.ts`为获取meta.json文件中的配置使用,可通用的脚本
- 3、`game`文件为自身项目的逻辑代码
## 三、本地运行
- 1、安装本地启动服务`game-cli` 地址:http://cf.dui88.com/display/dbyw/game-cli
- 2、运行http服务,执行src/custom下对应的自定义模块下的`debug`文件
- 3、`yarn build-custom -s 模块名 -w` 为保存档次代码修改也为打包指令
- 4、执行保存指令后在浏览器刷新图标处右键选择`清空缓存`并硬性重新加载,这样可以 保证运行最新修改的代码(劳工手工传授)
## 四、代码执行过程
- 1、入口为`app.js` 读取meta.json文件下的配置,加载对应资源,添加自定义模块
- 2、配置加载成功后使用引擎api将对应模块添加到显示到显示舞台
- 3、而后执行src/custom/对应模块`/src/index.ts` 初始化项目所需要的东西
- 4、而后执行props.ts获取meta.json中的props配置
- 5、而后创建项目逻辑入口脚本实例(例如GameWrapper)
- 6、而后即为对应模块逻辑代码
File added
{
"name": "娃娃机2",
"desc": "娃娃机通用模块",
"props": {
"single": {
"alias": "是否是单层娃娃",
"type": "boolean",
"default": true
},
"dollNum": {
"alias": "一屏展示娃娃个数(最大为4)",
"type": "number",
"default": 4
},
"frontInitX": {
"alias": "前排最右侧娃娃初始X位置",
"type": "number",
"default": 600
},
"frontInitY": {
"alias": "前排最右侧娃娃初始Y位置",
"type": "number",
"default": 614
},
"backInitX": {
"alias": "后排最右侧娃娃初始X位置",
"type": "number",
"default": 188
},
"backInitY": {
"alias": "后排最右侧娃娃初始Y位置",
"type": "number",
"default": 616
},
"ganziShow": {
"alias": "是否显示杆子",
"type": "boolean",
"default": true
},
"bashouShow": {
"alias": "是否显示把手",
"type": "boolean",
"default": true
},
"gameStageWidth": {
"alias": "游戏场景宽度",
"type": "number",
"default": 611
},
"gameStageHeight": {
"alias": "游戏场景高度",
"type": "number",
"default": 704
},
"frontmargin": {
"alias": "前排娃娃的间距",
"type": "number",
"default": 13
},
"backmargin": {
"alias": "后排娃娃的间距",
"type": "number",
"default": 50
},
"moveSpeed": {
"alias": "娃娃移动的速度",
"type": "number",
"default": 3
},
"bashouMoveDist": {
"alias": "爪子整体左右移动的范围",
"type": "number",
"default": 200
},
"ganMoveEndY": {
"alias": "杆子最后需要移动到的y值位置",
"type": "number",
"default": 620
},
"leftRotation": {
"alias": "左边爪子旋转角度",
"type": "number",
"default": 20
},
"rightRotation": {
"alias": "右边爪子旋转角度",
"type": "number",
"default": -20
},
"prizeBoxInitX": {
"alias": "中奖娃娃的x位置",
"type": "number",
"default": 15
},
"prizeBoxInitY": {
"alias": "中奖娃娃的y位置",
"type": "number",
"default": 48
}
},
"assets": [
{
"name": "游戏背景",
"url": "//yun.duiba.com.cn/aurora/assets/460fd0242aada85de5554391756db6ed2a232a9b.png",
"uuid": "05c378c3-bed0-4d5c-bed8-f05ae7920931",
"ext": ".png"
},
{
"name": "frontbox_0",
"url": "//yun.duiba.com.cn/aurora/assets/fde8c60981791e5136c7914274c2a2d0936626cd.png",
"uuid": "aa30ee7c-a6ad-4e10-9b6a-13b139664ab5",
"ext": ".png"
},
{
"name": "frontbox_1",
"url": "//yun.duiba.com.cn/aurora/assets/befb2c9ddfd8a5c4acd5126b2d793f7c1bcc40f2.png",
"uuid": "4483b626-697a-4aa4-ba57-0c22ddc7c0e6",
"ext": ".png"
},
{
"name": "frontbox_2",
"url": "///yun.duiba.com.cn/aurora/assets/50991e640e6bcc2eee02ba945d48a8430ddd2bee.png",
"uuid": "b70f2980-a2b3-4ef7-b060-b14dc7a8c9c8",
"ext": ".png"
},
{
"name": "frontbox_3",
"url": "//yun.duiba.com.cn/aurora/assets/fde8c60981791e5136c7914274c2a2d0936626cd.png",
"uuid": "aa30ee7c-a6ad-4e10-9b6a-13b139664ab5",
"ext": ".png"
},
{
"name": "backbox_0",
"url": "//yun.duiba.com.cn/aurora/assets/94884eafc876346e283efef2aa29bd6d2c36f627.png",
"uuid": "3f3feb30-6700-4ac7-a14e-6d7e41e8d4e8",
"ext": ".png"
},
{
"name": "backbox_1",
"url": "//yun.duiba.com.cn/aurora/assets/7deaaf45e03a626efbced90e4ad3d22373b01bd3.png",
"uuid": "b1422629-55d2-4b8b-bdd0-1b043f965248",
"ext": ".png"
},
{
"name": "backbox_2",
"url": "//yun.duiba.com.cn/aurora/assets/28a5b5b04c84d6acc86b7efb81dd6d7f717e0cda.png",
"uuid": "708da046-26e1-4ff7-abb6-35bf825a5d5b",
"ext": ".png"
},
{
"name": "backbox_3",
"url": "//yun.duiba.com.cn/aurora/assets/28a5b5b04c84d6acc86b7efb81dd6d7f717e0cda.png",
"uuid": "708da046-26e1-4ff7-abb6-35bf825a5d5b",
"ext": ".png"
},
{
"name": "prizebox_0",
"url": "//yun.duiba.com.cn/aurora/assets/a47f438d016d1b178cdb5241651a78e4ea365e75.png",
"uuid": "c106cd1d-52a0-422a-976c-67151af0b484",
"ext": ".png"
},
{
"name": "prizebox_1",
"url": "//yun.duiba.com.cn/aurora/assets/fd60c2da0ce78f7b7bed0e9c45644882a1a40d90.png",
"uuid": "3ff6fb20-4a2f-4789-998d-6078e3b603ec",
"ext": ".png"
},
{
"name": "prizebox_2",
"url": "//yun.duiba.com.cn/aurora/assets/6211ab330a3768ff0a1920cff0ec41f29fa0903b.png",
"uuid": "04fa3325-87fc-4009-bfba-26a95d92d80c",
"ext": ".png"
},
{
"name": "prizebox_3",
"url": "//yun.duiba.com.cn/aurora/assets/6211ab330a3768ff0a1920cff0ec41f29fa0903b.png",
"uuid": "04fa3325-87fc-4009-bfba-26a95d92d80c",
"ext": ".png"
},
{
"name": "prizebox_4",
"url": "//yun.duiba.com.cn/aurora/assets/6211ab330a3768ff0a1920cff0ec41f29fa0903b.png",
"uuid": "04fa3325-87fc-4009-bfba-26a95d92d80c",
"ext": ".png"
},
{
"name": "前传输带",
"url": "//yun.duiba.com.cn/aurora/assets/7bccbc67b3f896176bed7d21c5f4d4307c3919be.png",
"uuid": "06bd03a4-43c3-49bb-94c5-6ef365f70291",
"ext": ".png"
},
{
"name": "后传输带",
"url": "//yun.duiba.com.cn/aurora/assets/df9b718f80747a1e21349d2b9ac35d5e19a61dad.png",
"uuid": "aa0c6ebc-164f-4767-90ca-a79be4316365",
"ext": ".png"
},
{
"name": "把手杆子",
"url": "//yun.duiba.com.cn/aurora/assets/5a9e4ba7ca6701eae85b6d6dcb0612ecb9a3eff9.png",
"uuid": "f2f1a937-00f4-442f-af4f-0bcb00656e69",
"ext": ".png"
},
{
"name": "把手",
"url": "//yun.duiba.com.cn/aurora/assets/71255a6f3cdf9f66d53589e46d72fcd20fef468d.png",
"uuid": "d9b395b5-4e46-43a5-aa2b-bfdd81c07fa7",
"ext": ".png"
},
{
"name": "伸缩杆",
"url": "//yun.duiba.com.cn/aurora/assets/a9cf8b147c52b7d4247e80e90e098f787808bfa9.png",
"uuid": "fddb4636-9c62-47b2-ba5e-f2cd820dbccc",
"ext": ".png"
},
{
"name": "左爪",
"url": "//yun.duiba.com.cn/aurora/assets/1e8634fd94bda455d11956c2847d3823e80701d3.png",
"uuid": "739014d2-3193-4853-bf8d-349bd3e8d990",
"ext": ".png"
},
{
"name": "右爪",
"url": "//yun.duiba.com.cn/aurora/assets/4bfc510e0d1fa1db77f5effa187294af38b74ff6.png",
"uuid": "4fb43b19-67e9-42cc-b461-35c005c714fb",
"ext": ".png"
},
{
"name": "连接点",
"url": "//yun.duiba.com.cn/aurora/assets/39f39234631f739e70e9ab8b713284379f4016fb.png",
"uuid": "2021124f-ffcb-487f-a24f-a00f3d8aae95",
"ext": ".png"
}
],
"events": {
"in": {
"doll-machine2-game-init": {
"alias": "重置"
},
"doll-machine2-game-start": {
"alias": "开始",
"data": {
"prize": true
}
}
},
"out": {
"doll-machine2-game-end": {
"alias": "重置完毕",
"data": null
}
}
},
"id": "doll-machine-common",
"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['doll-machine-common'] = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n\tvar props = {};\n\tfunction prepareProps() {\n\t var metaProps = getProps();\n\t engine.injectProp(props, metaProps);\n\t}\n\tfunction injectProps(p) {\n\t engine.injectProp(props, p);\n\t}\n\t//# sourceMappingURL=props.js.map\n\n\tfunction getTexture(uuid) {\n\t return engine.Texture.from(getAssetByUUID(uuid).uuid);\n\t}\n\tfunction getTextureByName(name) {\n\t return getTexture(engine.getAssetByName(name).uuid);\n\t}\n\t//# sourceMappingURL=utils.js.map\n\n\tvar FrontBoxs = (function (_super) {\n\t tslib.__extends(FrontBoxs, _super);\n\t function FrontBoxs() {\n\t var _this = _super.call(this) || this;\n\t _this.frontBoxs = [];\n\t return _this;\n\t }\n\t FrontBoxs.prototype.setup = function () {\n\t var initX, initY = 0;\n\t for (var i = 0; i < props.dollNum; i++) {\n\t if (!new engine.Sprite(getTextureByName('frontbox_' + i))) {\n\t return;\n\t }\n\t this.frontBoxs[i] = new engine.Sprite(getTextureByName('frontbox_' + i));\n\t initX = this.frontBoxs[0].x = props.frontInitX;\n\t initY = this.frontBoxs[0].y = props.frontInitY;\n\t this.frontBoxs[i]['npcType'] = 'box' + i;\n\t }\n\t this.frontBoxs[props.dollNum] = new engine.Sprite(getTextureByName('frontbox_0'));\n\t this.frontBoxs[props.dollNum]['npcType'] = 'box' + props.dollNum;\n\t console.log(this.frontBoxs);\n\t for (var i = 0; i < this.frontBoxs.length; i++) {\n\t if (i == 0) {\n\t this.frontBoxs[i].x = initX;\n\t }\n\t else {\n\t this.frontBoxs[i].x = this.frontBoxs[i - 1].x - this.frontBoxs[0].width - props.frontmargin;\n\t }\n\t this.frontBoxs[i].y = initY;\n\t this.addChild(this.frontBoxs[i]);\n\t }\n\t this.addEventListener(engine.Event.ENTER_FRAME, this.frameMove, this);\n\t };\n\t FrontBoxs.prototype.frameMove = function () {\n\t var _this = this;\n\t this.frontBoxs.forEach(function (item, index) {\n\t item.x += props.moveSpeed;\n\t if (item.x <= 0 && !item.visible) {\n\t item.visible = true;\n\t }\n\t if (item.x >= 750) {\n\t var lastitem = _this.frontBoxs.shift();\n\t lastitem.x = _this.frontBoxs[_this.frontBoxs.length - 1].x - _this.frontBoxs[0].width - props.frontmargin;\n\t if (!_this.GameView.getMoveX() && item.x <= 0 && _this.GameView.startstatus) {\n\t _this.GameView.setMoveX((370 - item.x - 13) / props.moveSpeed, item);\n\t _this.hideBox = item;\n\t }\n\t _this.frontBoxs.push(lastitem);\n\t }\n\t });\n\t };\n\t FrontBoxs.prototype.stop = function () {\n\t };\n\t FrontBoxs.prototype.showHidePrizeBox = function (isshow) {\n\t this.hideBox.visible = isshow;\n\t };\n\t return FrontBoxs;\n\t}(engine.Container));\n\t//# sourceMappingURL=frontBox.js.map\n\n\tvar BackBoxs = (function (_super) {\n\t tslib.__extends(BackBoxs, _super);\n\t function BackBoxs() {\n\t var _this = _super.call(this) || this;\n\t _this.backBoxs = [];\n\t return _this;\n\t }\n\t BackBoxs.prototype.setup = function () {\n\t var initX, initY = 0;\n\t for (var i = 0; i < props.dollNum; i++) {\n\t this.backBoxs[i] = new engine.Sprite(getTextureByName('backbox_' + i));\n\t initX = this.backBoxs[0].x = props.backInitX;\n\t initY = this.backBoxs[0].y = props.backInitY;\n\t this.backBoxs[i]['npcType'] = 'box' + i;\n\t }\n\t this.backBoxs[props.dollNum] = new engine.Sprite(getTextureByName('backbox_0'));\n\t this.backBoxs[props.dollNum]['npcType'] = 'box' + props.dollNum;\n\t for (var i = 0; i < this.backBoxs.length; i++) {\n\t if (i == 0) {\n\t this.backBoxs[i].x = initX;\n\t }\n\t else {\n\t this.backBoxs[i].x = this.backBoxs[i - 1].x + this.backBoxs[i].width + props.backmargin;\n\t }\n\t this.backBoxs[i].y = initY;\n\t this.addChild(this.backBoxs[i]);\n\t }\n\t this.addEventListener(engine.Event.ENTER_FRAME, this.frameMove, this);\n\t };\n\t BackBoxs.prototype.frameMove = function () {\n\t var _this = this;\n\t this.backBoxs.forEach(function (item) {\n\t item.x -= props.moveSpeed;\n\t if (item.x <= 0) {\n\t var lastitem = _this.backBoxs.shift();\n\t lastitem.x = _this.backBoxs[_this.backBoxs.length - 1].x + item.width + props.backmargin;\n\t _this.backBoxs.push(lastitem);\n\t }\n\t });\n\t };\n\t return BackBoxs;\n\t}(engine.Container));\n\t//# sourceMappingURL=backBox.js.map\n\n\tvar Zhuazi = (function (_super) {\n\t tslib.__extends(Zhuazi, _super);\n\t function Zhuazi() {\n\t var _this = _super.call(this) || this;\n\t _this.moveArr = [];\n\t _this.prizeBoxs = [];\n\t return _this;\n\t }\n\t Zhuazi.prototype.setup = function () {\n\t this.ganNode = new engine.Container();\n\t this.moveNode = new engine.Container();\n\t this.ganNode.x = 280;\n\t this.ganNode.y = 350;\n\t this.bashouGan = new engine.Sprite(getTextureByName(\"把手杆子\"));\n\t this.bashouGan.x = 60;\n\t this.bashouGan.y = 275;\n\t this.bashou = new engine.Sprite(getTextureByName(\"把手\"));\n\t this.bashou.x = 0;\n\t this.bashou.y = 263;\n\t this.ganzi = new engine.Sprite(getTextureByName(\"伸缩杆\"));\n\t this.ganzi.x = 97;\n\t this.ganzi.y = 290;\n\t this.connect = new engine.Sprite(getTextureByName(\"连接点\"));\n\t this.connect.x = 18;\n\t this.connect.y = -5;\n\t this.left_zhuazi = new engine.Sprite(getTextureByName(\"左爪\"));\n\t this.left_zhuazi.x = -15;\n\t this.left_zhuazi.y = 60;\n\t this.left_zhuazi.anchorX = this.left_zhuazi.width;\n\t this.left_zhuazi.anchorY = 0;\n\t this.right_zhuazi = new engine.Sprite(getTextureByName(\"右爪\"));\n\t this.right_zhuazi.x = 98;\n\t this.right_zhuazi.y = 60;\n\t this.ganNode.addChild(this.left_zhuazi);\n\t this.ganNode.addChild(this.right_zhuazi);\n\t this.ganNode.addChild(this.connect);\n\t this.ganNode.x = 30;\n\t this.zhuaziY = this.ganNode.y;\n\t this.moveNode.addChild(this.ganzi);\n\t this.moveNode.addChild(this.ganNode);\n\t this.moveNode.addChild(this.bashou);\n\t this.moveNode.x = 262;\n\t this.addChild(this.bashouGan);\n\t this.addChild(this.moveNode);\n\t if (!props.ganziShow) {\n\t this.bashouGan.visible = false;\n\t }\n\t if (!props.bashouShow) {\n\t this.bashou.visible = false;\n\t }\n\t this.createPrizeBox();\n\t };\n\t Zhuazi.prototype.createPrizeBox = function () {\n\t var _this = this;\n\t for (var i = 0; i < props.dollNum; i++) {\n\t if (!new engine.Sprite(getTextureByName('prizebox_' + i))) {\n\t return;\n\t }\n\t this.prizeBoxs[i] = new engine.Sprite(getTextureByName('prizebox_' + i));\n\t this.prizeBoxs[i]['npcType'] = 'box' + i;\n\t }\n\t this.prizeBoxs[props.dollNum] = new engine.Sprite(getTextureByName('prizebox_0'));\n\t this.prizeBoxs[props.dollNum]['npcType'] = 'box' + props.dollNum;\n\t this.prizeBoxs.forEach(function (item) {\n\t _this.ganNode.addChild(item);\n\t item.visible = false;\n\t item.x = props.prizeBoxInitX;\n\t item.y = props.prizeBoxInitY;\n\t });\n\t };\n\t Zhuazi.prototype.showPrizeBox = function () {\n\t var _this = this;\n\t this.prizeBoxs.forEach(function (item) {\n\t console.log(_this.GameView.getBox()['npcType']);\n\t if (item['npcType'] === _this.GameView.getBox()['npcType']) {\n\t item.visible = true;\n\t _this.itemShow = item;\n\t }\n\t else {\n\t item.visible = false;\n\t }\n\t });\n\t };\n\t Zhuazi.prototype.move = function () {\n\t var _this = this;\n\t var rndist = Math.random();\n\t var halfWidth = this.bashou.width / 2;\n\t var randomX = rndist * (rndist > 0.5 ? 1 : -1) * props.bashouMoveDist;\n\t console.log(randomX);\n\t engine.Tween.get(this.moveNode).to({ x: 370 + halfWidth - 71 }, 1000).call(function () {\n\t _this.zhangkai();\n\t });\n\t };\n\t Zhuazi.prototype.zhangkai = function () {\n\t var _this = this;\n\t this.left_zhuazi.anchorX = this.left_zhuazi.width;\n\t this.left_zhuazi.anchorY = 0;\n\t engine.Tween.get(this.left_zhuazi, { loop: false }).to({ rotation: props.leftRotation }, 1000);\n\t engine.Tween.get(this.right_zhuazi, { loop: false }).to({ rotation: props.rightRotation }, 1000);\n\t setTimeout(function () {\n\t _this.getLong();\n\t }, 500);\n\t };\n\t Zhuazi.prototype.getLong = function () {\n\t var _this = this;\n\t var droptime = Number((this.GameView.getMoveX() / 60 - 1).toFixed(2)) * 1000;\n\t console.log('dr', droptime);\n\t var times = (props.ganMoveEndY - this.ganzi.y) / this.ganzi.height;\n\t console.log(Number(times.toFixed(2)));\n\t engine.Tween.get(this.ganzi).to({ scaleY: Number(times.toFixed(2)) }, droptime).to({ scaleY: 1 }, droptime);\n\t console.log('node', this.zhuaziY);\n\t engine.Tween.get(this.ganNode).to({ y: props.ganMoveEndY }, droptime).call(function () {\n\t _this.GameView.stopMove();\n\t if (_this.GameView.ifPrize) {\n\t _this.showPrizeBox();\n\t _this.GameView.setVisible(false);\n\t }\n\t }).to({ y: this.zhuaziY }, droptime).call(function () {\n\t if (_this.GameView.ifPrize) {\n\t _this.itemShow.visible = false;\n\t }\n\t engine.globalEvent.dispatchEvent('doll-machine2-game-end');\n\t });\n\t };\n\t Zhuazi.prototype.getReset = function () {\n\t this.left_zhuazi.anchorX = this.left_zhuazi.width;\n\t this.left_zhuazi.anchorY = 0;\n\t engine.Tween.get(this.moveNode, { loop: false }).to({ x: 262 }, 1000);\n\t engine.Tween.get(this.left_zhuazi, { loop: false }).to({ rotation: 0 }, 1000);\n\t engine.Tween.get(this.right_zhuazi, { loop: false }).to({ rotation: 0 }, 1000);\n\t this.GameView.resetMoveX();\n\t };\n\t return Zhuazi;\n\t}(engine.Container));\n\t//# sourceMappingURL=Zhuazi.js.map\n\n\tvar GameView = (function (_super) {\n\t tslib.__extends(GameView, _super);\n\t function GameView() {\n\t var _this = _super.call(this) || this;\n\t _this.startstatus = false;\n\t _this.ifPrize = false;\n\t _this.goodsItems = [];\n\t _this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);\n\t return _this;\n\t }\n\t GameView.prototype.setup = function () {\n\t if (this._hasSetup) {\n\t return;\n\t }\n\t this._hasSetup = true;\n\t var frontBoxs = (this._frontBoxs = new FrontBoxs());\n\t this._frontBoxs.GameView = this;\n\t var backBoxs = (this._backBoxs = new BackBoxs());\n\t this._Zhuazi = new Zhuazi();\n\t this._Zhuazi.GameView = this;\n\t this.frontTransfer = new engine.Container();\n\t this.backTransfer = new engine.Container();\n\t this.frontTransfer.width = 0;\n\t this.frontTransfer.height = 0;\n\t this.frontTransfer.alpha = 1;\n\t this.backTransfer.width = 0;\n\t this.backTransfer.height = 0;\n\t this.backTransfer.alpha = 1;\n\t this.rect = new engine.Rect();\n\t this.rect.width = props.gameStageWidth;\n\t this.rect.height = props.gameStageHeight;\n\t this.rect.x = 65;\n\t this.rect.y = 263;\n\t this.NpcBg = new engine.Container();\n\t this.addChild(this.NpcBg);\n\t this.addChild(this.rect);\n\t this.frontDesk = new engine.Sprite(getTextureByName(\"前传输带\"));\n\t this.frontDesk.x = 60;\n\t this.frontDesk.y = 781;\n\t this.backDesk = new engine.Sprite(getTextureByName(\"后传输带\"));\n\t this.backDesk.x = 60;\n\t this.backDesk.y = 712;\n\t if (props.single) {\n\t this.backDesk.visible = false;\n\t }\n\t this.NpcBg.addChild(this.backDesk);\n\t this.NpcBg.addChild(this.frontDesk);\n\t this.NpcBg.addChild(this.backTransfer);\n\t this.NpcBg.addChild(this.frontTransfer);\n\t this.NpcBg.addChild(this._Zhuazi);\n\t this.NpcBg.mask = this.rect;\n\t this._Zhuazi.setup();\n\t this.backTransfer.addChild(this._backBoxs);\n\t this._backBoxs.setup();\n\t if (props.single) {\n\t this.backTransfer.visible = false;\n\t }\n\t this.frontTransfer.addChild(this._frontBoxs);\n\t this._frontBoxs.setup();\n\t };\n\t GameView.prototype.stopMove = function () {\n\t this._frontBoxs.stop();\n\t };\n\t GameView.prototype.setMoveX = function (x, item) {\n\t this.moveTime = x;\n\t this.prizeBox = item;\n\t this._Zhuazi.move();\n\t };\n\t GameView.prototype.setVisible = function (isshow) {\n\t this._frontBoxs.showHidePrizeBox(isshow);\n\t };\n\t GameView.prototype.getMoveX = function () {\n\t return this.moveTime;\n\t };\n\t GameView.prototype.resetMoveX = function () {\n\t this.moveTime = null;\n\t };\n\t GameView.prototype.getBox = function () {\n\t return this.prizeBox;\n\t };\n\t GameView.prototype.reset = function () {\n\t this.startstatus = false;\n\t this.ifPrize = false;\n\t this._Zhuazi.getReset();\n\t };\n\t GameView.prototype.start = function (type) {\n\t if (type === void 0) { type = null; }\n\t this.speed = 1;\n\t this.gameIng = true;\n\t console.log('执行', type);\n\t this.startstatus = true;\n\t this.ifPrize = type && type.prize || false;\n\t };\n\t GameView.prototype.beginNpc = function () {\n\t var _this = this;\n\t this.timer = setTimeout(function () {\n\t if (_this.gameIng) ;\n\t }, 2000 / this.speed);\n\t };\n\t GameView.prototype.pause = function () {\n\t this.gameIng = false;\n\t };\n\t GameView.prototype.revive = function () {\n\t this.gameIng = true;\n\t };\n\t GameView.prototype.resume = function () {\n\t this.reset();\n\t this.start();\n\t };\n\t return GameView;\n\t}(engine.Container));\n\n\tvar GameWrapper = (function (_super) {\n\t tslib.__extends(GameWrapper, _super);\n\t function GameWrapper() {\n\t var _this = _super.call(this) || this;\n\t engine.globalEvent.addEventListener('doll-machine2-game-init', _this.reset, _this);\n\t engine.globalEvent.addEventListener('doll-machine2-game-start', _this.start, _this);\n\t var gameView = _this._gameView = new GameView();\n\t _this.addChild(gameView);\n\t return _this;\n\t }\n\t GameWrapper.prototype.reset = function (event) {\n\t injectProps(event.data);\n\t this._gameView.visible = true;\n\t this._gameView.reset();\n\t };\n\t GameWrapper.prototype.start = function (event) {\n\t console.log('监听开始');\n\t injectProps(event.data);\n\t this._gameView.start(event.data);\n\t };\n\t GameWrapper.prototype.pause = function () {\n\t this._gameView.pause();\n\t };\n\t GameWrapper.prototype.resume = function () {\n\t this._gameView.resume();\n\t };\n\t GameWrapper.prototype.revive = function () {\n\t this._gameView.revive();\n\t };\n\t GameWrapper.prototype.clear = function () {\n\t this._gameView.visible = false;\n\t };\n\t GameWrapper.prototype.onTap = function (event) {\n\t };\n\t return GameWrapper;\n\t}(engine.Container));\n\t//# sourceMappingURL=GameWrapper.js.map\n\n\tfunction index (props) {\n\t prepareProps();\n\t injectProps(props);\n\t var instance = new GameWrapper();\n\t return instance;\n\t}\n\t//# sourceMappingURL=index.js.map\n\n\treturn index;\n\n})));\n"
}
{
"name": "娃娃机",
"desc": "娃娃机模块",
"props": {
"frontmargin": {
"alias": "前排娃娃的间距",
"type": "number",
"default": 50
},
"backmargin": {
"alias": "后排娃娃的间距",
"type": "number",
"default": 50
},
"moveSpeed": {
"alias": "娃娃移动的速度",
"type": "number",
"default": 3
},
"bashouMoveDist": {
"alias": "爪子整体左右移动的范围",
"type": "number",
"default": 200
},
"ganMoveEndY": {
"alias": "杆子最后需要移动到的y值位置",
"type": "number",
"default": 820
},
"leftRotation": {
"alias": "左边爪子旋转角度",
"type": "number",
"default": 20
},
"rightRotation": {
"alias": "右边爪子旋转角度",
"type": "number",
"default": -20
}
},
"assets": [
{
"name": "游戏背景",
"url": "//yun.duiba.com.cn/aurora/assets/460fd0242aada85de5554391756db6ed2a232a9b.png",
"uuid": "05c378c3-bed0-4d5c-bed8-f05ae7920931",
"ext": ".png"
},
{
"name": "草泥马盒",
"url": "//yun.duiba.com.cn/aurora/assets/fde8c60981791e5136c7914274c2a2d0936626cd.png",
"uuid": "aa30ee7c-a6ad-4e10-9b6a-13b139664ab5",
"ext": ".png"
},
{
"name": "狗盒",
"url": "//yun.duiba.com.cn/aurora/assets/befb2c9ddfd8a5c4acd5126b2d793f7c1bcc40f2.png",
"uuid": "4483b626-697a-4aa4-ba57-0c22ddc7c0e6",
"ext": ".png"
},
{
"name": "猫盒",
"url": "///yun.duiba.com.cn/aurora/assets/50991e640e6bcc2eee02ba945d48a8430ddd2bee.png",
"uuid": "b70f2980-a2b3-4ef7-b060-b14dc7a8c9c8",
"ext": ".png"
},
{
"name": "后草泥马盒",
"url": "//yun.duiba.com.cn/aurora/assets/94884eafc876346e283efef2aa29bd6d2c36f627.png",
"uuid": "3f3feb30-6700-4ac7-a14e-6d7e41e8d4e8",
"ext": ".png"
},
{
"name": "后狗盒",
"url": "//yun.duiba.com.cn/aurora/assets/7deaaf45e03a626efbced90e4ad3d22373b01bd3.png",
"uuid": "b1422629-55d2-4b8b-bdd0-1b043f965248",
"ext": ".png"
},
{
"name": "后猫盒",
"url": "//yun.duiba.com.cn/aurora/assets/28a5b5b04c84d6acc86b7efb81dd6d7f717e0cda.png",
"uuid": "708da046-26e1-4ff7-abb6-35bf825a5d5b",
"ext": ".png"
},
{
"name": "中奖草泥马盒",
"url": "//yun.duiba.com.cn/aurora/assets/a47f438d016d1b178cdb5241651a78e4ea365e75.png",
"uuid": "c106cd1d-52a0-422a-976c-67151af0b484",
"ext": ".png"
},
{
"name": "中奖狗盒",
"url": "//yun.duiba.com.cn/aurora/assets/fd60c2da0ce78f7b7bed0e9c45644882a1a40d90.png",
"uuid": "3ff6fb20-4a2f-4789-998d-6078e3b603ec",
"ext": ".png"
},
{
"name": "中奖猫盒",
"url": "//yun.duiba.com.cn/aurora/assets/6211ab330a3768ff0a1920cff0ec41f29fa0903b.png",
"uuid": "04fa3325-87fc-4009-bfba-26a95d92d80c",
"ext": ".png"
},
{
"name": "前传输带",
"url": "//yun.duiba.com.cn/aurora/assets/7bccbc67b3f896176bed7d21c5f4d4307c3919be.png",
"uuid": "06bd03a4-43c3-49bb-94c5-6ef365f70291",
"ext": ".png"
},
{
"name": "后传输带",
"url": "//yun.duiba.com.cn/aurora/assets/df9b718f80747a1e21349d2b9ac35d5e19a61dad.png",
"uuid": "aa0c6ebc-164f-4767-90ca-a79be4316365",
"ext": ".png"
},
{
"name": "把手杆子",
"url": "//yun.duiba.com.cn/aurora/assets/5a9e4ba7ca6701eae85b6d6dcb0612ecb9a3eff9.png",
"uuid": "f2f1a937-00f4-442f-af4f-0bcb00656e69",
"ext": ".png"
},
{
"name": "把手",
"url": "//yun.duiba.com.cn/aurora/assets/71255a6f3cdf9f66d53589e46d72fcd20fef468d.png",
"uuid": "d9b395b5-4e46-43a5-aa2b-bfdd81c07fa7",
"ext": ".png"
},
{
"name": "伸缩杆",
"url": "//yun.duiba.com.cn/aurora/assets/a9cf8b147c52b7d4247e80e90e098f787808bfa9.png",
"uuid": "fddb4636-9c62-47b2-ba5e-f2cd820dbccc",
"ext": ".png"
},
{
"name": "左爪",
"url": "//yun.duiba.com.cn/aurora/assets/1e8634fd94bda455d11956c2847d3823e80701d3.png",
"uuid": "739014d2-3193-4853-bf8d-349bd3e8d990",
"ext": ".png"
},
{
"name": "右爪",
"url": "//yun.duiba.com.cn/aurora/assets/4bfc510e0d1fa1db77f5effa187294af38b74ff6.png",
"uuid": "4fb43b19-67e9-42cc-b461-35c005c714fb",
"ext": ".png"
},
{
"name": "连接点",
"url": "//yun.duiba.com.cn/aurora/assets/39f39234631f739e70e9ab8b713284379f4016fb.png",
"uuid": "2021124f-ffcb-487f-a24f-a00f3d8aae95",
"ext": ".png"
}
],
"events": {
"in": {
"doll-machine-reset": {
"alias": "重置"
},
"doll-machine-prize": {
"alias": "开始",
"data": {
"prize": true
}
}
},
"out": {
"doll-machine-gameover": {
"alias": "重置完毕",
"data": null
}
}
},
"id": "doll-machine",
"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['doll-machine'] = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n\tfunction getTexture(uuid) {\n\t return engine.Texture.from(getAssetByUUID(uuid).uuid);\n\t}\n\tfunction getTextureByName(name) {\n\t return getTexture(engine.getAssetByName(name).uuid);\n\t}\n\n\tvar Goods = (function (_super) {\n\t tslib.__extends(Goods, _super);\n\t function Goods() {\n\t var _this = _super.call(this) || this;\n\t var body;\n\t body = _this._body = new engine.Rect();\n\t var box1 = new engine.Sprite(getTextureByName(\"草泥马盒\"));\n\t box1[\"npcType\"] = \"box1\";\n\t var box2 = new engine.Sprite(getTextureByName(\"狗盒\"));\n\t box2[\"npcType\"] = \"box2\";\n\t var box3 = new engine.Sprite(getTextureByName(\"猫盒\"));\n\t box3[\"npcType\"] = \"box3\";\n\t box1.visible = false;\n\t box2.visible = false;\n\t box3.visible = false;\n\t body.addChild(box1);\n\t body.addChild(box2);\n\t body.addChild(box3);\n\t _this.addChild(body);\n\t body.width = 0.0001;\n\t body.height = 0.0001;\n\t body.mouseEnabled = false;\n\t return _this;\n\t }\n\t Goods.prototype.getRandomNumberByRange = function (start, end) {\n\t return Math.floor(Math.random() * (end - start) + start);\n\t };\n\t Goods.prototype.reset = function () {\n\t this.visible = true;\n\t this.y = 200;\n\t this.x = 0;\n\t this.rotation = 0;\n\t var random = Math.random();\n\t if (random < 0.3) {\n\t this.showNpc(\"box1\");\n\t }\n\t else if (random < 0.6) {\n\t this.showNpc(\"box2\");\n\t }\n\t else {\n\t this.showNpc(\"box3\");\n\t }\n\t };\n\t Goods.prototype.showNpc = function (type) {\n\t for (var i = 0; i < this._body.children.length; i++) {\n\t this._body.children[i].visible = false;\n\t this._body.children[i].mouseEnabled = false;\n\t }\n\t for (var i = 0; i < this._body.children.length; i++) {\n\t if (this._body.children[i][\"npcType\"] == type) {\n\t this[\"npcType\"] = type;\n\t console.log(type);\n\t this._body.children[i].visible = true;\n\t this._body.children[i].mouseEnabled = false;\n\t }\n\t }\n\t };\n\t Object.defineProperty(Goods.prototype, \"anchorOffsetY\", {\n\t set: function (v) {\n\t this._body.y = v;\n\t },\n\t enumerable: true,\n\t configurable: true\n\t });\n\t return Goods;\n\t}(engine.Container));\n\n\tvar ObjectPool = engine.ObjectPool;\n\tvar PoolName = 'goods';\n\tObjectPool.registerPool(PoolName, function () {\n\t return new Goods();\n\t}, function (item, data) {\n\t item.reset();\n\t});\n\n\tvar props = {};\n\tfunction prepareProps() {\n\t var metaProps = getProps();\n\t engine.injectProp(props, metaProps);\n\t}\n\tfunction injectProps(p) {\n\t engine.injectProp(props, p);\n\t}\n\n\tvar FrontBoxs = (function (_super) {\n\t tslib.__extends(FrontBoxs, _super);\n\t function FrontBoxs() {\n\t var _this = _super.call(this) || this;\n\t _this.frontBoxs = [];\n\t return _this;\n\t }\n\t FrontBoxs.prototype.setup = function () {\n\t var initX, initY = 0;\n\t this.box1 = new engine.Sprite(getTextureByName(\"狗盒\"));\n\t this.box1[\"npcType\"] = \"box1\";\n\t initX = this.box1.x = 435;\n\t initY = this.box1.y = 614;\n\t this.box2 = new engine.Sprite(getTextureByName(\"猫盒\"));\n\t this.box2[\"npcType\"] = \"box2\";\n\t this.box3 = new engine.Sprite(getTextureByName(\"草泥马盒\"));\n\t this.box3[\"npcType\"] = \"box3\";\n\t this.box4 = new engine.Sprite(getTextureByName(\"狗盒\"));\n\t this.box4[\"npcType\"] = \"box4\";\n\t this.box5 = new engine.Sprite(getTextureByName(\"猫盒\"));\n\t this.box5[\"npcType\"] = \"box5\";\n\t this.frontBoxs = [this.box1, this.box2, this.box3, this.box4];\n\t for (var i = 0; i < this.frontBoxs.length; i++) {\n\t if (i == 0) {\n\t this.frontBoxs[i].x = initX;\n\t }\n\t else {\n\t this.frontBoxs[i].x = this.frontBoxs[i - 1].x - this.box1.width - props.frontmargin;\n\t }\n\t this.frontBoxs[i].y = initY;\n\t this.addChild(this.frontBoxs[i]);\n\t }\n\t this.addEventListener(engine.Event.ENTER_FRAME, this.frameMove, this);\n\t };\n\t FrontBoxs.prototype.frameMove = function () {\n\t var _this = this;\n\t this.frontBoxs.forEach(function (item, index) {\n\t item.x += props.moveSpeed;\n\t if (item.x <= 0 && !item.visible) {\n\t item.visible = true;\n\t }\n\t if (item.x >= 750) {\n\t var lastitem = _this.frontBoxs.shift();\n\t lastitem.x = _this.frontBoxs[_this.frontBoxs.length - 1].x - _this.box1.width - props.frontmargin;\n\t if (!_this.GameView.getMoveX() && item.x <= 0 && _this.GameView.startstatus) {\n\t _this.GameView.setMoveX((370 - item.x - 13) / props.moveSpeed, item);\n\t _this.hideBox = item;\n\t }\n\t _this.frontBoxs.push(lastitem);\n\t }\n\t });\n\t };\n\t FrontBoxs.prototype.stop = function () {\n\t };\n\t FrontBoxs.prototype.showHidePrizeBox = function (isshow) {\n\t this.hideBox.visible = isshow;\n\t };\n\t return FrontBoxs;\n\t}(engine.Container));\n\n\tvar BackBoxs = (function (_super) {\n\t tslib.__extends(BackBoxs, _super);\n\t function BackBoxs() {\n\t var _this = _super.call(this) || this;\n\t _this.backBoxs = [];\n\t return _this;\n\t }\n\t BackBoxs.prototype.setup = function () {\n\t var initX, initY = 0;\n\t this.box1 = new engine.Sprite(getTextureByName(\"后狗盒\"));\n\t initX = this.box1.x = 188;\n\t initY = this.box1.y = 616;\n\t this.box2 = new engine.Sprite(getTextureByName(\"后猫盒\"));\n\t this.box3 = new engine.Sprite(getTextureByName(\"后草泥马盒\"));\n\t this.box4 = new engine.Sprite(getTextureByName(\"后狗盒\"));\n\t this.box5 = new engine.Sprite(getTextureByName(\"后猫盒\"));\n\t this.backBoxs = [this.box1, this.box2, this.box3, this.box4, this.box5];\n\t for (var i = 0; i < this.backBoxs.length; i++) {\n\t if (i == 0) {\n\t this.backBoxs[i].x = initX;\n\t }\n\t else {\n\t this.backBoxs[i].x = this.backBoxs[i - 1].x + this.backBoxs[i].width + props.backmargin;\n\t }\n\t this.backBoxs[i].y = initY;\n\t this.addChild(this.backBoxs[i]);\n\t }\n\t this.addEventListener(engine.Event.ENTER_FRAME, this.frameMove, this);\n\t };\n\t BackBoxs.prototype.frameMove = function () {\n\t var _this = this;\n\t this.backBoxs.forEach(function (item) {\n\t item.x -= props.moveSpeed;\n\t if (item.x <= 0) {\n\t var lastitem = _this.backBoxs.shift();\n\t lastitem.x = _this.backBoxs[_this.backBoxs.length - 1].x + item.width + props.backmargin;\n\t _this.backBoxs.push(lastitem);\n\t }\n\t });\n\t };\n\t return BackBoxs;\n\t}(engine.Container));\n\n\tvar Zhuazi = (function (_super) {\n\t tslib.__extends(Zhuazi, _super);\n\t function Zhuazi() {\n\t var _this = _super.call(this) || this;\n\t _this.moveArr = [];\n\t _this.prizeBoxs = [];\n\t return _this;\n\t }\n\t Zhuazi.prototype.setup = function () {\n\t this.ganNode = new engine.Container();\n\t this.moveNode = new engine.Container();\n\t this.ganNode.x = 280;\n\t this.ganNode.y = 350;\n\t this.bashouGan = new engine.Sprite(getTextureByName(\"把手杆子\"));\n\t this.bashouGan.x = 60;\n\t this.bashouGan.y = 275;\n\t this.bashou = new engine.Sprite(getTextureByName(\"把手\"));\n\t this.bashou.x = 0;\n\t this.bashou.y = 263;\n\t this.ganzi = new engine.Sprite(getTextureByName(\"伸缩杆\"));\n\t this.ganzi.x = 97;\n\t this.ganzi.y = 290;\n\t this.connect = new engine.Sprite(getTextureByName(\"连接点\"));\n\t this.connect.x = 18;\n\t this.connect.y = -5;\n\t this.left_zhuazi = new engine.Sprite(getTextureByName(\"左爪\"));\n\t this.left_zhuazi.x = -15;\n\t this.left_zhuazi.y = 60;\n\t this.left_zhuazi.anchorX = this.left_zhuazi.width;\n\t this.left_zhuazi.anchorY = 0;\n\t this.right_zhuazi = new engine.Sprite(getTextureByName(\"右爪\"));\n\t this.right_zhuazi.x = 98;\n\t this.right_zhuazi.y = 60;\n\t this.ganNode.addChild(this.left_zhuazi);\n\t this.ganNode.addChild(this.right_zhuazi);\n\t this.ganNode.addChild(this.connect);\n\t this.ganNode.x = 30;\n\t this.zhuaziY = this.ganNode.y;\n\t this.moveNode.addChild(this.ganzi);\n\t this.moveNode.addChild(this.ganNode);\n\t this.moveNode.addChild(this.bashou);\n\t this.moveNode.x = 262;\n\t this.addChild(this.bashouGan);\n\t this.addChild(this.moveNode);\n\t this.createPrizeBox();\n\t };\n\t Zhuazi.prototype.createPrizeBox = function () {\n\t var _this = this;\n\t this.box1 = new engine.Sprite(getTextureByName(\"中奖狗盒\"));\n\t this.box1[\"npcType\"] = \"box1\";\n\t this.box2 = new engine.Sprite(getTextureByName(\"中奖猫盒\"));\n\t this.box2[\"npcType\"] = \"box2\";\n\t this.box3 = new engine.Sprite(getTextureByName(\"中奖草泥马盒\"));\n\t this.box3[\"npcType\"] = \"box3\";\n\t this.box4 = new engine.Sprite(getTextureByName(\"中奖狗盒\"));\n\t this.box4[\"npcType\"] = \"box4\";\n\t this.box5 = new engine.Sprite(getTextureByName(\"中奖猫盒\"));\n\t this.box5[\"npcType\"] = \"box5\";\n\t this.prizeBoxs = [this.box1, this.box2, this.box3, this.box4, this.box5];\n\t this.prizeBoxs.forEach(function (item) {\n\t _this.ganNode.addChild(item);\n\t item.visible = false;\n\t item.x = 15;\n\t item.y = 48;\n\t });\n\t };\n\t Zhuazi.prototype.showPrizeBox = function () {\n\t var _this = this;\n\t this.prizeBoxs.forEach(function (item) {\n\t console.log(_this.GameView.getBox()['npcType']);\n\t if (item['npcType'] === _this.GameView.getBox()['npcType']) {\n\t item.visible = true;\n\t _this.itemShow = item;\n\t }\n\t else {\n\t item.visible = false;\n\t }\n\t });\n\t };\n\t Zhuazi.prototype.move = function () {\n\t var _this = this;\n\t var rndist = Math.random();\n\t var halfWidth = this.bashou.width / 2;\n\t var randomX = rndist * (rndist > 0.5 ? 1 : -1) * props.bashouMoveDist;\n\t console.log(randomX);\n\t engine.Tween.get(this.moveNode).to({ x: 370 + halfWidth - 71 }, 1000).call(function () {\n\t _this.zhangkai();\n\t });\n\t };\n\t Zhuazi.prototype.zhangkai = function () {\n\t var _this = this;\n\t this.left_zhuazi.anchorX = this.left_zhuazi.width;\n\t this.left_zhuazi.anchorY = 0;\n\t engine.Tween.get(this.left_zhuazi, { loop: false }).to({ rotation: props.leftRotation }, 1000);\n\t engine.Tween.get(this.right_zhuazi, { loop: false }).to({ rotation: props.rightRotation }, 1000);\n\t setTimeout(function () {\n\t _this.getLong();\n\t }, 500);\n\t };\n\t Zhuazi.prototype.getLong = function () {\n\t var _this = this;\n\t var droptime = Number((this.GameView.getMoveX() / 60 - 1).toFixed(2)) * 1000;\n\t console.log('dr', droptime);\n\t var times = (props.ganMoveEndY - this.ganzi.y) / this.ganzi.height;\n\t console.log(Number(times.toFixed(2)));\n\t engine.Tween.get(this.ganzi).to({ scaleY: Number(times.toFixed(2)) }, droptime).to({ scaleY: 1 }, droptime);\n\t console.log('node', this.zhuaziY);\n\t engine.Tween.get(this.ganNode).to({ y: props.ganMoveEndY }, droptime).call(function () {\n\t _this.GameView.stopMove();\n\t if (_this.GameView.ifPrize) {\n\t _this.showPrizeBox();\n\t _this.GameView.setVisible(false);\n\t }\n\t }).to({ y: this.zhuaziY }, droptime).call(function () {\n\t if (_this.GameView.ifPrize) {\n\t _this.itemShow.visible = false;\n\t }\n\t engine.globalEvent.dispatchEvent('doll-machine-gameover');\n\t });\n\t };\n\t Zhuazi.prototype.getReset = function () {\n\t this.left_zhuazi.anchorX = this.left_zhuazi.width;\n\t this.left_zhuazi.anchorY = 0;\n\t engine.Tween.get(this.moveNode, { loop: false }).to({ x: 262 }, 1000);\n\t engine.Tween.get(this.left_zhuazi, { loop: false }).to({ rotation: 0 }, 1000);\n\t engine.Tween.get(this.right_zhuazi, { loop: false }).to({ rotation: 0 }, 1000);\n\t this.GameView.resetMoveX();\n\t };\n\t return Zhuazi;\n\t}(engine.Container));\n\n\tvar ObjectPool$1 = engine.ObjectPool;\n\tvar GameView = (function (_super) {\n\t tslib.__extends(GameView, _super);\n\t function GameView() {\n\t var _this = _super.call(this) || this;\n\t _this.startstatus = false;\n\t _this.ifPrize = false;\n\t _this.goodsItems = [];\n\t _this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);\n\t return _this;\n\t }\n\t GameView.prototype.setup = function () {\n\t if (this._hasSetup) {\n\t return;\n\t }\n\t this._hasSetup = true;\n\t var frontBoxs = (this._frontBoxs = new FrontBoxs());\n\t this._frontBoxs.GameView = this;\n\t var backBoxs = (this._backBoxs = new BackBoxs());\n\t this._Zhuazi = new Zhuazi();\n\t this._Zhuazi.GameView = this;\n\t this.frontTransfer = new engine.Container();\n\t this.backTransfer = new engine.Container();\n\t this.frontTransfer.width = 0;\n\t this.frontTransfer.height = 0;\n\t this.frontTransfer.alpha = 1;\n\t this.backTransfer.width = 0;\n\t this.backTransfer.height = 0;\n\t this.backTransfer.alpha = 1;\n\t this.rect = new engine.Rect();\n\t this.rect.width = 611;\n\t this.rect.height = 704;\n\t this.rect.x = 65;\n\t this.rect.y = 263;\n\t this.NpcBg = new engine.Container();\n\t this.addChild(this.NpcBg);\n\t this.addChild(this.rect);\n\t var gameBg = new engine.Sprite(getTextureByName(\"游戏背景\"));\n\t gameBg.x = 65;\n\t gameBg.y = 263;\n\t this.NpcBg.addChild(gameBg);\n\t this.frontDesk = new engine.Sprite(getTextureByName(\"前传输带\"));\n\t this.frontDesk.x = 60;\n\t this.frontDesk.y = 781;\n\t this.backDesk = new engine.Sprite(getTextureByName(\"后传输带\"));\n\t this.backDesk.x = 60;\n\t this.backDesk.y = 712;\n\t this.NpcBg.addChild(this.backDesk);\n\t this.NpcBg.addChild(this.frontDesk);\n\t this.NpcBg.addChild(this.backTransfer);\n\t this.NpcBg.addChild(this.frontTransfer);\n\t this.NpcBg.addChild(this._Zhuazi);\n\t this.NpcBg.mask = this.rect;\n\t this._Zhuazi.setup();\n\t this.backTransfer.addChild(this._backBoxs);\n\t this._backBoxs.setup();\n\t this.frontTransfer.addChild(this._frontBoxs);\n\t this._frontBoxs.setup();\n\t };\n\t GameView.prototype.stopMove = function () {\n\t this._frontBoxs.stop();\n\t };\n\t GameView.prototype.setMoveX = function (x, item) {\n\t this.moveTime = x;\n\t this.prizeBox = item;\n\t this._Zhuazi.move();\n\t };\n\t GameView.prototype.setVisible = function (isshow) {\n\t this._frontBoxs.showHidePrizeBox(isshow);\n\t };\n\t GameView.prototype.getMoveX = function () {\n\t return this.moveTime;\n\t };\n\t GameView.prototype.resetMoveX = function () {\n\t this.moveTime = null;\n\t };\n\t GameView.prototype.getBox = function () {\n\t return this.prizeBox;\n\t };\n\t GameView.prototype.reset = function () {\n\t this.startstatus = false;\n\t this.ifPrize = false;\n\t this._Zhuazi.getReset();\n\t };\n\t GameView.prototype.start = function (type) {\n\t if (type === void 0) { type = null; }\n\t this.speed = 1;\n\t this.gameIng = true;\n\t console.log('执行', type);\n\t this.startstatus = true;\n\t this.ifPrize = type && type.prize || false;\n\t };\n\t GameView.prototype.beginNpc = function () {\n\t var _this = this;\n\t this.timer = setTimeout(function () {\n\t if (_this.gameIng) ;\n\t }, 2000 / this.speed);\n\t };\n\t GameView.prototype.pause = function () {\n\t this.gameIng = false;\n\t };\n\t GameView.prototype.revive = function () {\n\t this.gameIng = true;\n\t };\n\t GameView.prototype.resume = function () {\n\t this.reset();\n\t this.start();\n\t };\n\t GameView.prototype.initNpc = function () {\n\t this.box1 = new engine.Sprite(getTextureByName(\"草泥马盒\"));\n\t this.box2 = new engine.Sprite(getTextureByName(\"狗盒\"));\n\t this.box3 = new engine.Sprite(getTextureByName(\"猫盒\"));\n\t this.box4 = new engine.Sprite(getTextureByName(\"草泥马盒\"));\n\t this.box5 = new engine.Sprite(getTextureByName(\"猫盒\"));\n\t this.box1.x = 120;\n\t this.box1.y = 434;\n\t this.box2.x = 306;\n\t this.box2.y = 434;\n\t this.box3.x = 487;\n\t this.box3.y = 434;\n\t this.box4.x = 240;\n\t this.box4.scaleX = 0.5;\n\t this.box4.scaleY = 0.5;\n\t this.box4.y = 390;\n\t this.box5.x = 434;\n\t this.box5.y = 390;\n\t this.box5.scaleX = 0.5;\n\t this.box5.scaleY = 0.5;\n\t this.backTransfer.addChild(this.box4);\n\t this.backTransfer.addChild(this.box5);\n\t this.frontTransfer.addChild(this.box1);\n\t this.frontTransfer.addChild(this.box2);\n\t this.frontTransfer.addChild(this.box3);\n\t };\n\t GameView.prototype.died = function () {\n\t this.score = 0;\n\t this.pause();\n\t };\n\t GameView.prototype.removeNpc = function (goods) {\n\t this.NpcBg.removeChild(goods);\n\t ObjectPool$1.recycleObject(PoolName, goods);\n\t goods.removeEventListener(engine.Event.ENTER_FRAME, goods[\"onGoodsEnter\"], this);\n\t var index = this.goodsItems.indexOf(goods);\n\t if (index > -1) {\n\t this.goodsItems.splice(index, 1);\n\t }\n\t };\n\t GameView.prototype.recycleGoods = function () {\n\t clearTimeout(this.timer);\n\t clearInterval(this.countdownTimer);\n\t for (var _i = 0, _a = this.goodsItems; _i < _a.length; _i++) {\n\t var goods = _a[_i];\n\t if (goods) {\n\t this.removeChild(goods);\n\t ObjectPool$1.recycleObject(PoolName, goods);\n\t goods.removeEventListener(engine.Event.ENTER_FRAME, goods[\"onGoodsEnter\"], this);\n\t }\n\t }\n\t this.goodsItems = [];\n\t };\n\t GameView.prototype.hasHit = function (a, b) {\n\t if (Math.abs(a.x + a.width / 2 - (b.x + b.width / 2)) <\n\t a.width / 2 + b.width / 2 &&\n\t Math.abs(a.y + a.height / 2 - (b.y + b.height / 2)) <\n\t a.height / 2 + b.height / 2) {\n\t return true;\n\t }\n\t else {\n\t return false;\n\t }\n\t };\n\t return GameView;\n\t}(engine.Container));\n\n\tvar GameWrapper = (function (_super) {\n\t tslib.__extends(GameWrapper, _super);\n\t function GameWrapper() {\n\t var _this = _super.call(this) || this;\n\t engine.globalEvent.addEventListener('doll-machine-reset', _this.reset, _this);\n\t engine.globalEvent.addEventListener('doll-machine-prize', _this.start, _this);\n\t var gameView = _this._gameView = new GameView();\n\t _this.addChild(gameView);\n\t return _this;\n\t }\n\t GameWrapper.prototype.reset = function (event) {\n\t injectProps(event.data);\n\t this._gameView.visible = true;\n\t this._gameView.reset();\n\t };\n\t GameWrapper.prototype.start = function (event) {\n\t console.log('监听开始');\n\t injectProps(event.data);\n\t this._gameView.start(event.data);\n\t };\n\t GameWrapper.prototype.pause = function () {\n\t this._gameView.pause();\n\t };\n\t GameWrapper.prototype.resume = function () {\n\t this._gameView.resume();\n\t };\n\t GameWrapper.prototype.revive = function () {\n\t this._gameView.revive();\n\t };\n\t GameWrapper.prototype.clear = function () {\n\t this._gameView.visible = false;\n\t };\n\t GameWrapper.prototype.onTap = function (event) {\n\t };\n\t return GameWrapper;\n\t}(engine.Container));\n\n\tfunction index (props) {\n\t prepareProps();\n\t injectProps(props);\n\t var instance = new GameWrapper();\n\t return instance;\n\t}\n\n\treturn index;\n\n})));\n"
}
{
"name": "娃娃机2",
"desc": "娃娃机通用模块",
"props": {
"single": {
"alias": "是否是单层娃娃",
"type": "boolean",
"default": true
},
"dollNum": {
"alias": "一屏展示娃娃个数(最大为4)",
"type": "number",
"default": 4
},
"initOffsetTop": {
"alias": "整体距离上边距",
"type": "number",
"default": 0
},
"initOffsetLeft": {
"alias": "整体距离左边距",
"type": "number",
"default": 60
},
"frontDeskY": {
"alias": "前排传输带Y位置",
"type": "number",
"default": 518
},
"frontInitX": {
"alias": "前排最右侧娃娃初始X位置",
"type": "number",
"default": 600
},
"frontInitY": {
"alias": "前排最右侧娃娃初始Y位置",
"type": "number",
"default": 351
},
"backDeskY": {
"alias": "后排传输带Y位置",
"type": "number",
"default": 449
},
"backInitX": {
"alias": "后排最右侧娃娃初始X位置",
"type": "number",
"default": 188
},
"backInitY": {
"alias": "后排最右侧娃娃初始Y位置",
"type": "number",
"default": 353
},
"ganziShow": {
"alias": "是否显示杆子",
"type": "boolean",
"default": true
},
"bashouShow": {
"alias": "是否显示把手",
"type": "boolean",
"default": true
},
"gameStageWidth": {
"alias": "游戏场景宽度",
"type": "number",
"default": 611
},
"gameStageHeight": {
"alias": "游戏场景高度",
"type": "number",
"default": 704
},
"frontmargin": {
"alias": "前排娃娃的间距",
"type": "number",
"default": 13
},
"backmargin": {
"alias": "后排娃娃的间距",
"type": "number",
"default": 50
},
"moveSpeed": {
"alias": "娃娃移动的速度",
"type": "number",
"default": 3
},
"bashouMoveDist": {
"alias": "爪子整体左右移动的范围",
"type": "number",
"default": 200
},
"ganMoveEndY": {
"alias": "杆子最后需要移动到的y值位置",
"type": "number",
"default": 357
},
"leftRotation": {
"alias": "左边爪子旋转角度",
"type": "number",
"default": 20
},
<<<<<<< HEAD
"leftLocX": {
"alias": "左边爪子X位置",
"type": "number",
"default": -15
},
"leftLocY": {
"alias": "左边爪子Y位置",
"type": "number",
"default": 60
},
=======
>>>>>>> 1666d83127b74014796759c4dd3e87192f4c7e6e
"rightRotation": {
"alias": "右边爪子旋转角度",
"type": "number",
"default": -20
},
<<<<<<< HEAD
"rightLocX": {
"alias": "右边爪子X位置",
"type": "number",
"default": 98
},
"rightLocY": {
"alias": "右边爪子Y位置",
"type": "number",
"default": 60
},
=======
>>>>>>> 1666d83127b74014796759c4dd3e87192f4c7e6e
"prizeBoxInitX": {
"alias": "中奖娃娃的x位置",
"type": "number",
"default": 15
},
"prizeBoxInitY": {
"alias": "中奖娃娃的y位置",
"type": "number",
"default": 48
}
},
"assets": [
{
"name": "游戏背景",
"url": "//yun.duiba.com.cn/aurora/assets/460fd0242aada85de5554391756db6ed2a232a9b.png",
"uuid": "05c378c3-bed0-4d5c-bed8-f05ae7920931",
"ext": ".png"
},
{
"name": "frontbox_0",
"url": "//yun.duiba.com.cn/aurora/assets/fde8c60981791e5136c7914274c2a2d0936626cd.png",
"uuid": "aa30ee7c-a6ad-4e10-9b6a-13b139664ab5",
"ext": ".png"
},
{
"name": "frontbox_1",
"url": "//yun.duiba.com.cn/aurora/assets/befb2c9ddfd8a5c4acd5126b2d793f7c1bcc40f2.png",
"uuid": "4483b626-697a-4aa4-ba57-0c22ddc7c0e6",
"ext": ".png"
},
{
"name": "frontbox_2",
"url": "///yun.duiba.com.cn/aurora/assets/50991e640e6bcc2eee02ba945d48a8430ddd2bee.png",
"uuid": "b70f2980-a2b3-4ef7-b060-b14dc7a8c9c8",
"ext": ".png"
},
{
"name": "frontbox_3",
"url": "//yun.duiba.com.cn/aurora/assets/fde8c60981791e5136c7914274c2a2d0936626cd.png",
"uuid": "aa30ee7c-a6ad-4e10-9b6a-13b139664ab1",
"ext": ".png"
},
{
<<<<<<< HEAD
=======
"name": "frontbox_4",
"url": "//yun.duiba.com.cn/aurora/assets/fde8c60981791e5136c7914274c2a2d0936626cd.png",
"uuid": "aa30ee7c-a6ad-4e10-9b6a-13b139664ab2",
"ext": ".png"
},
{
>>>>>>> 1666d83127b74014796759c4dd3e87192f4c7e6e
"name": "backbox_0",
"url": "//yun.duiba.com.cn/aurora/assets/94884eafc876346e283efef2aa29bd6d2c36f627.png",
"uuid": "3f3feb30-6700-4ac7-a14e-6d7e41e8d4e8",
"ext": ".png"
},
{
"name": "backbox_1",
"url": "//yun.duiba.com.cn/aurora/assets/7deaaf45e03a626efbced90e4ad3d22373b01bd3.png",
"uuid": "b1422629-55d2-4b8b-bdd0-1b043f965248",
"ext": ".png"
},
{
"name": "backbox_2",
"url": "//yun.duiba.com.cn/aurora/assets/28a5b5b04c84d6acc86b7efb81dd6d7f717e0cda.png",
"uuid": "708da046-26e1-4ff7-abb6-35bf825a5d5b",
"ext": ".png"
},
{
"name": "backbox_3",
"url": "//yun.duiba.com.cn/aurora/assets/28a5b5b04c84d6acc86b7efb81dd6d7f717e0cda.png",
"uuid": "708da046-26e1-4ff7-abb6-35bf825a5d51",
"ext": ".png"
},
{
"name": "backbox_4",
"url": "//yun.duiba.com.cn/aurora/assets/28a5b5b04c84d6acc86b7efb81dd6d7f717e0cda.png",
"uuid": "708da046-26e1-4ff7-abb6-35bf825a5d55",
"ext": ".png"
},
{
"name": "prizebox_0",
"url": "//yun.duiba.com.cn/aurora/assets/a47f438d016d1b178cdb5241651a78e4ea365e75.png",
"uuid": "c106cd1d-52a0-422a-976c-67151af0b484",
"ext": ".png"
},
{
"name": "prizebox_1",
"url": "//yun.duiba.com.cn/aurora/assets/fd60c2da0ce78f7b7bed0e9c45644882a1a40d90.png",
"uuid": "3ff6fb20-4a2f-4789-998d-6078e3b603ec",
"ext": ".png"
},
{
"name": "prizebox_2",
"url": "//yun.duiba.com.cn/aurora/assets/6211ab330a3768ff0a1920cff0ec41f29fa0903b.png",
"uuid": "04fa3325-87fc-4009-bfba-26a95d92d80c",
"ext": ".png"
},
{
"name": "prizebox_3",
"url": "//yun.duiba.com.cn/aurora/assets/6211ab330a3768ff0a1920cff0ec41f29fa0903b.png",
"uuid": "04fa3325-87fc-4009-bfba-26a95d92d800",
"ext": ".png"
},
{
"name": "prizebox_4",
"url": "//yun.duiba.com.cn/aurora/assets/6211ab330a3768ff0a1920cff0ec41f29fa0903b.png",
"uuid": "04fa3325-87fc-4009-bfba-26a95d92d80a",
"ext": ".png"
},
{
"name": "前传输带",
"url": "//yun.duiba.com.cn/aurora/assets/7bccbc67b3f896176bed7d21c5f4d4307c3919be.png",
"uuid": "06bd03a4-43c3-49bb-94c5-6ef365f70291",
"ext": ".png"
},
{
"name": "后传输带",
"url": "//yun.duiba.com.cn/aurora/assets/df9b718f80747a1e21349d2b9ac35d5e19a61dad.png",
"uuid": "aa0c6ebc-164f-4767-90ca-a79be4316365",
"ext": ".png"
},
{
"name": "把手杆子",
"url": "//yun.duiba.com.cn/aurora/assets/5a9e4ba7ca6701eae85b6d6dcb0612ecb9a3eff9.png",
"uuid": "f2f1a937-00f4-442f-af4f-0bcb00656e69",
"ext": ".png"
},
{
"name": "把手",
"url": "//yun.duiba.com.cn/aurora/assets/71255a6f3cdf9f66d53589e46d72fcd20fef468d.png",
"uuid": "d9b395b5-4e46-43a5-aa2b-bfdd81c07fa7",
"ext": ".png"
},
{
"name": "伸缩杆",
"url": "//yun.duiba.com.cn/aurora/assets/a9cf8b147c52b7d4247e80e90e098f787808bfa9.png",
"uuid": "fddb4636-9c62-47b2-ba5e-f2cd820dbccc",
"ext": ".png"
},
{
"name": "左爪",
"url": "//yun.duiba.com.cn/aurora/assets/1e8634fd94bda455d11956c2847d3823e80701d3.png",
"uuid": "739014d2-3193-4853-bf8d-349bd3e8d990",
"ext": ".png"
},
{
"name": "右爪",
"url": "//yun.duiba.com.cn/aurora/assets/4bfc510e0d1fa1db77f5effa187294af38b74ff6.png",
"uuid": "4fb43b19-67e9-42cc-b461-35c005c714fb",
"ext": ".png"
},
{
"name": "连接点",
"url": "//yun.duiba.com.cn/aurora/assets/39f39234631f739e70e9ab8b713284379f4016fb.png",
"uuid": "2021124f-ffcb-487f-a24f-a00f3d8aae95",
"ext": ".png"
}
],
"events": {
"in": {
"doll-machine2-game-init": {
"alias": "重置"
},
"doll-machine2-game-start": {
"alias": "开始",
"data": {
"prize": true
}
}
},
"out": {
"doll-machine2-game-end": {
"alias": "重置完毕",
"data": null
}
}
},
"id": "doll-machine2",
<<<<<<< HEAD
"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['doll-machine2'] = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n\tvar props = {};\n\tfunction prepareProps() {\n\t var metaProps = getProps();\n\t engine.injectProp(props, metaProps);\n\t}\n\tfunction injectProps(p) {\n\t engine.injectProp(props, p);\n\t}\n\t//# sourceMappingURL=props.js.map\n\n\tfunction getTexture(uuid) {\n\t return engine.Texture.from(getAssetByUUID(uuid).uuid);\n\t}\n\tfunction getTextureByName(name) {\n\t return getTexture(engine.getAssetByName(name).uuid);\n\t}\n\t//# sourceMappingURL=utils.js.map\n\n\tvar FrontBoxs = (function (_super) {\n\t tslib.__extends(FrontBoxs, _super);\n\t function FrontBoxs() {\n\t var _this = _super.call(this) || this;\n\t _this.frontBoxs = [];\n\t return _this;\n\t }\n\t FrontBoxs.prototype.setup = function () {\n\t var initX, initY = 0;\n\t for (var i = 0; i < props.dollNum; i++) {\n\t if (!new engine.Sprite(getTextureByName('frontbox_' + i))) {\n\t return;\n\t }\n\t this.frontBoxs[i] = new engine.Sprite(getTextureByName('frontbox_' + i));\n\t initX = this.frontBoxs[0].x = props.frontInitX;\n\t initY = this.frontBoxs[0].y = props.frontInitY;\n\t this.frontBoxs[i]['npcType'] = 'box' + i;\n\t }\n\t this.frontBoxs[props.dollNum] = new engine.Sprite(getTextureByName('frontbox_0'));\n\t this.frontBoxs[props.dollNum]['npcType'] = 'box' + props.dollNum;\n\t console.log(this.frontBoxs);\n\t for (var i = 0; i < this.frontBoxs.length; i++) {\n\t if (i == 0) {\n\t this.frontBoxs[i].x = initX;\n\t }\n\t else {\n\t this.frontBoxs[i].x = this.frontBoxs[i - 1].x - this.frontBoxs[0].width - props.frontmargin;\n\t }\n\t console.log(this.frontBoxs[i].x);\n\t this.frontBoxs[i].y = initY;\n\t this.addChild(this.frontBoxs[i]);\n\t console.log('aaa', this.frontBoxs[i].x);\n\t }\n\t this.addEventListener(engine.Event.ENTER_FRAME, this.frameMove, this);\n\t };\n\t FrontBoxs.prototype.frameMove = function () {\n\t var _this = this;\n\t this.frontBoxs.forEach(function (item, index) {\n\t item.x += props.moveSpeed;\n\t if (item.x <= 0 && !item.visible) {\n\t item.visible = true;\n\t }\n\t if (item.x >= 750) {\n\t var tmpIndex = 0;\n\t if (index <= 0) {\n\t tmpIndex = _this.frontBoxs.length - 1;\n\t }\n\t else {\n\t tmpIndex = index - 1;\n\t }\n\t item.x = _this.frontBoxs[tmpIndex].x - _this.frontBoxs[0].width - props.frontmargin;\n\t if (!_this.GameView.getMoveX() && item.x <= 0 && _this.GameView.startstatus) {\n\t _this.GameView.setMoveX((370 - item.x - 13) / props.moveSpeed, item);\n\t _this.hideBox = item;\n\t }\n\t }\n\t });\n\t };\n\t FrontBoxs.prototype.stop = function () {\n\t };\n\t FrontBoxs.prototype.showHidePrizeBox = function (isshow) {\n\t this.hideBox.visible = isshow;\n\t };\n\t return FrontBoxs;\n\t}(engine.Container));\n\t//# sourceMappingURL=frontBox.js.map\n\n\tvar BackBoxs = (function (_super) {\n\t tslib.__extends(BackBoxs, _super);\n\t function BackBoxs() {\n\t var _this = _super.call(this) || this;\n\t _this.backBoxs = [];\n\t return _this;\n\t }\n\t BackBoxs.prototype.setup = function () {\n\t var initX, initY = 0;\n\t for (var i = 0; i < props.dollNum; i++) {\n\t this.backBoxs[i] = new engine.Sprite(getTextureByName('backbox_' + i));\n\t initX = this.backBoxs[0].x = props.backInitX;\n\t initY = this.backBoxs[0].y = props.backInitY - props.initOffsetTop;\n\t this.backBoxs[i]['npcType'] = 'box' + i;\n\t }\n\t this.backBoxs[props.dollNum] = new engine.Sprite(getTextureByName('backbox_0'));\n\t this.backBoxs[props.dollNum]['npcType'] = 'box' + props.dollNum;\n\t for (var i = 0; i < this.backBoxs.length; i++) {\n\t if (i == 0) {\n\t this.backBoxs[i].x = initX;\n\t }\n\t else {\n\t this.backBoxs[i].x = this.backBoxs[i - 1].x + this.backBoxs[i].width + props.backmargin;\n\t }\n\t this.backBoxs[i].y = initY;\n\t this.addChild(this.backBoxs[i]);\n\t }\n\t this.addEventListener(engine.Event.ENTER_FRAME, this.frameMove, this);\n\t };\n\t BackBoxs.prototype.frameMove = function () {\n\t var _this = this;\n\t this.backBoxs.forEach(function (item) {\n\t item.x -= props.moveSpeed;\n\t if (item.x <= 0) {\n\t var lastitem = _this.backBoxs.shift();\n\t lastitem.x = _this.backBoxs[_this.backBoxs.length - 1].x + item.width + props.backmargin;\n\t _this.backBoxs.push(lastitem);\n\t }\n\t });\n\t };\n\t return BackBoxs;\n\t}(engine.Container));\n\t//# sourceMappingURL=backBox.js.map\n\n\tvar Zhuazi = (function (_super) {\n\t tslib.__extends(Zhuazi, _super);\n\t function Zhuazi() {\n\t var _this = _super.call(this) || this;\n\t _this.moveArr = [];\n\t _this.prizeBoxs = [];\n\t return _this;\n\t }\n\t Zhuazi.prototype.setup = function () {\n\t this.ganNode = new engine.Container();\n\t this.moveNode = new engine.Container();\n\t this.ganNode.x = 280;\n\t this.ganNode.y = 350;\n\t this.bashouGan = new engine.Sprite(getTextureByName(\"把手杆子\"));\n\t this.bashouGan.x = 60;\n\t this.bashouGan.y = 12;\n\t this.bashou = new engine.Sprite(getTextureByName(\"把手\"));\n\t this.bashou.x = 0;\n\t this.bashou.y = 0;\n\t this.ganzi = new engine.Sprite(getTextureByName(\"伸缩杆\"));\n\t this.ganzi.x = 97;\n\t this.ganzi.y = 27;\n\t this.connect = new engine.Sprite(getTextureByName(\"连接点\"));\n\t this.connect.x = 18;\n\t this.connect.y = -5;\n\t this.left_zhuazi = new engine.Sprite(getTextureByName(\"左爪\"));\n\t this.left_zhuazi.x = props.leftLocX;\n\t this.left_zhuazi.y = props.leftLocY;\n\t this.left_zhuazi.anchorX = this.left_zhuazi.width;\n\t this.left_zhuazi.anchorY = 0;\n\t this.right_zhuazi = new engine.Sprite(getTextureByName(\"右爪\"));\n\t this.right_zhuazi.x = props.rightLocX;\n\t this.right_zhuazi.y = props.rightLocY;\n\t this.ganNode.addChild(this.left_zhuazi);\n\t this.ganNode.addChild(this.right_zhuazi);\n\t this.ganNode.addChild(this.connect);\n\t this.ganNode.x = 30;\n\t this.ganNode.y = this.ganNode.y - 263;\n\t this.zhuaziY = this.ganNode.y;\n\t this.moveNode.addChild(this.ganzi);\n\t this.moveNode.addChild(this.ganNode);\n\t this.moveNode.addChild(this.bashou);\n\t this.moveNode.x = 262;\n\t this.bashouGan.y = this.bashouGan.y;\n\t this.moveNode.y = this.moveNode.y;\n\t this.addChild(this.bashouGan);\n\t this.addChild(this.moveNode);\n\t if (!props.ganziShow) {\n\t this.bashouGan.visible = false;\n\t }\n\t if (!props.bashouShow) {\n\t this.bashou.visible = false;\n\t }\n\t this.createPrizeBox();\n\t };\n\t Zhuazi.prototype.createPrizeBox = function () {\n\t var _this = this;\n\t for (var i = 0; i < props.dollNum; i++) {\n\t if (!new engine.Sprite(getTextureByName('prizebox_' + i))) {\n\t return;\n\t }\n\t this.prizeBoxs[i] = new engine.Sprite(getTextureByName('prizebox_' + i));\n\t this.prizeBoxs[i]['npcType'] = 'box' + i;\n\t }\n\t this.prizeBoxs[props.dollNum] = new engine.Sprite(getTextureByName('prizebox_0'));\n\t this.prizeBoxs[props.dollNum]['npcType'] = 'box' + props.dollNum;\n\t this.prizeBoxs.forEach(function (item) {\n\t _this.ganNode.addChild(item);\n\t item.visible = false;\n\t item.x = props.prizeBoxInitX;\n\t item.y = props.prizeBoxInitY;\n\t });\n\t };\n\t Zhuazi.prototype.showPrizeBox = function () {\n\t var _this = this;\n\t this.prizeBoxs.forEach(function (item) {\n\t console.log(_this.GameView.getBox()['npcType']);\n\t if (item['npcType'] === _this.GameView.getBox()['npcType']) {\n\t item.visible = true;\n\t _this.itemShow = item;\n\t }\n\t else {\n\t item.visible = false;\n\t }\n\t });\n\t };\n\t Zhuazi.prototype.move = function () {\n\t var _this = this;\n\t var rndist = Math.random();\n\t var halfWidth = this.bashou.width / 2;\n\t var randomX = rndist * (rndist > 0.5 ? 1 : -1) * props.bashouMoveDist;\n\t console.log(randomX);\n\t engine.Tween.get(this.moveNode).to({ x: 370 + halfWidth - 71 }, 1000).call(function () {\n\t _this.zhangkai();\n\t });\n\t };\n\t Zhuazi.prototype.zhangkai = function () {\n\t var _this = this;\n\t this.left_zhuazi.anchorX = this.left_zhuazi.width;\n\t this.left_zhuazi.anchorY = 0;\n\t engine.Tween.get(this.left_zhuazi, { loop: false }).to({ rotation: props.leftRotation }, 1000);\n\t engine.Tween.get(this.right_zhuazi, { loop: false }).to({ rotation: props.rightRotation }, 1000);\n\t setTimeout(function () {\n\t _this.getLong();\n\t }, 500);\n\t };\n\t Zhuazi.prototype.getLong = function () {\n\t var _this = this;\n\t var droptime = Number((this.GameView.getMoveX() / 60 - 1).toFixed(2)) * 1000 - 130;\n\t console.log('dr', droptime);\n\t var times = (props.ganMoveEndY - this.ganzi.y) / this.ganzi.height;\n\t console.log(Number(times.toFixed(2)));\n\t engine.Tween.get(this.ganzi).to({ scaleY: Number(times.toFixed(2)) }, droptime).to({ scaleY: 1 }, droptime);\n\t console.log('node', this.zhuaziY);\n\t engine.Tween.get(this.ganNode).to({ y: props.ganMoveEndY }, droptime).call(function () {\n\t _this.GameView.stopMove();\n\t if (_this.GameView.ifPrize) {\n\t _this.showPrizeBox();\n\t _this.GameView.setVisible(false);\n\t }\n\t }).to({ y: this.zhuaziY }, droptime).call(function () {\n\t if (_this.GameView.ifPrize) {\n\t _this.itemShow.visible = false;\n\t }\n\t engine.globalEvent.dispatchEvent('doll-machine2-game-end');\n\t });\n\t };\n\t Zhuazi.prototype.getReset = function () {\n\t this.left_zhuazi.anchorX = this.left_zhuazi.width;\n\t this.left_zhuazi.anchorY = 0;\n\t engine.Tween.get(this.moveNode, { loop: false }).to({ x: 262 }, 1000);\n\t engine.Tween.get(this.left_zhuazi, { loop: false }).to({ rotation: 0 }, 1000);\n\t engine.Tween.get(this.right_zhuazi, { loop: false }).to({ rotation: 0 }, 1000);\n\t this.GameView.resetMoveX();\n\t };\n\t return Zhuazi;\n\t}(engine.Container));\n\t//# sourceMappingURL=Zhuazi.js.map\n\n\tvar GameView = (function (_super) {\n\t tslib.__extends(GameView, _super);\n\t function GameView() {\n\t var _this = _super.call(this) || this;\n\t _this.startstatus = false;\n\t _this.ifPrize = false;\n\t _this.goodsItems = [];\n\t _this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);\n\t return _this;\n\t }\n\t GameView.prototype.setup = function () {\n\t var _this = this;\n\t if (this._hasSetup) {\n\t return;\n\t }\n\t this._hasSetup = true;\n\t var frontBoxs = (this._frontBoxs = new FrontBoxs());\n\t this._frontBoxs.GameView = this;\n\t var backBoxs = (this._backBoxs = new BackBoxs());\n\t this._Zhuazi = new Zhuazi();\n\t this._Zhuazi.GameView = this;\n\t this.frontTransfer = new engine.Container();\n\t this.backTransfer = new engine.Container();\n\t this.frontTransfer.width = 0;\n\t this.frontTransfer.height = 0;\n\t this.frontTransfer.alpha = 1;\n\t this.backTransfer.width = 0;\n\t this.backTransfer.height = 0;\n\t this.backTransfer.alpha = 1;\n\t this.rect = new engine.Rect();\n\t this.rect.width = props.gameStageWidth;\n\t this.rect.height = props.gameStageHeight;\n\t this.rect.x = 65;\n\t this.rect.y = 0;\n\t this.NpcBg = new engine.Container();\n\t this.NpcBg.x = 0;\n\t this.NpcBg.y = 0;\n\t this.addChild(this.NpcBg);\n\t this.addChild(this.rect);\n\t this.frontDesk = new engine.Sprite(getTextureByName(\"前传输带\"));\n\t this.frontDesk.x = props.initOffsetLeft;\n\t this.frontDesk.y = props.frontDeskY - props.initOffsetTop;\n\t this.backDesk = new engine.Sprite(getTextureByName(\"后传输带\"));\n\t this.backDesk.x = props.initOffsetLeft;\n\t this.backDesk.y = props.backDeskY - props.initOffsetTop;\n\t if (props.single) {\n\t this.backDesk.visible = false;\n\t }\n\t var pcarr = [this.backDesk, this.frontDesk, this.backTransfer, this.frontTransfer, this._Zhuazi];\n\t pcarr.forEach(function (item) {\n\t _this.NpcBg.addChild(item);\n\t });\n\t this.NpcBg.mask = this.rect;\n\t this._Zhuazi.setup();\n\t this.backTransfer.addChild(this._backBoxs);\n\t this._backBoxs.setup();\n\t if (props.single) {\n\t this.backTransfer.visible = false;\n\t }\n\t this.frontTransfer.addChild(this._frontBoxs);\n\t this._frontBoxs.setup();\n\t };\n\t GameView.prototype.stopMove = function () {\n\t this._frontBoxs.stop();\n\t };\n\t GameView.prototype.setMoveX = function (x, item) {\n\t this.moveTime = x;\n\t this.prizeBox = item;\n\t this._Zhuazi.move();\n\t };\n\t GameView.prototype.setVisible = function (isshow) {\n\t this._frontBoxs.showHidePrizeBox(isshow);\n\t };\n\t GameView.prototype.getMoveX = function () {\n\t return this.moveTime;\n\t };\n\t GameView.prototype.resetMoveX = function () {\n\t this.moveTime = null;\n\t };\n\t GameView.prototype.getBox = function () {\n\t return this.prizeBox;\n\t };\n\t GameView.prototype.reset = function () {\n\t this.startstatus = false;\n\t this.ifPrize = false;\n\t this._Zhuazi.getReset();\n\t };\n\t GameView.prototype.start = function (type) {\n\t if (type === void 0) { type = null; }\n\t this.speed = 1;\n\t this.gameIng = true;\n\t console.log('执行', type);\n\t this.startstatus = true;\n\t this.ifPrize = type && type.prize || false;\n\t };\n\t GameView.prototype.beginNpc = function () {\n\t var _this = this;\n\t this.timer = setTimeout(function () {\n\t if (_this.gameIng) ;\n\t }, 2000 / this.speed);\n\t };\n\t GameView.prototype.pause = function () {\n\t this.gameIng = false;\n\t };\n\t GameView.prototype.revive = function () {\n\t this.gameIng = true;\n\t };\n\t GameView.prototype.resume = function () {\n\t this.reset();\n\t this.start();\n\t };\n\t return GameView;\n\t}(engine.Container));\n\n\tvar GameWrapper = (function (_super) {\n\t tslib.__extends(GameWrapper, _super);\n\t function GameWrapper() {\n\t var _this = _super.call(this) || this;\n\t engine.globalEvent.addEventListener('doll-machine2-game-init', _this.reset, _this);\n\t engine.globalEvent.addEventListener('doll-machine2-game-start', _this.start, _this);\n\t var gameView = _this._gameView = new GameView();\n\t _this.addChild(gameView);\n\t return _this;\n\t }\n\t GameWrapper.prototype.reset = function (event) {\n\t injectProps(event.data);\n\t this._gameView.visible = true;\n\t this._gameView.reset();\n\t };\n\t GameWrapper.prototype.start = function (event) {\n\t console.log('监听开始');\n\t injectProps(event.data);\n\t this._gameView.start(event.data);\n\t };\n\t GameWrapper.prototype.pause = function () {\n\t this._gameView.pause();\n\t };\n\t GameWrapper.prototype.resume = function () {\n\t this._gameView.resume();\n\t };\n\t GameWrapper.prototype.revive = function () {\n\t this._gameView.revive();\n\t };\n\t GameWrapper.prototype.clear = function () {\n\t this._gameView.visible = false;\n\t };\n\t GameWrapper.prototype.onTap = function (event) {\n\t };\n\t return GameWrapper;\n\t}(engine.Container));\n\t//# sourceMappingURL=GameWrapper.js.map\n\n\tfunction index (props) {\n\t prepareProps();\n\t injectProps(props);\n\t var instance = new GameWrapper();\n\t return instance;\n\t}\n\t//# sourceMappingURL=index.js.map\n\n\treturn index;\n\n})));\n"
=======
"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['doll-machine2'] = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n\tvar props = {};\r\n\tfunction prepareProps() {\r\n\t var metaProps = getProps();\r\n\t engine.injectProp(props, metaProps);\r\n\t}\r\n\tfunction injectProps(p) {\r\n\t engine.injectProp(props, p);\r\n\t}\r\n\t//# sourceMappingURL=props.js.map\n\n\tfunction getTexture(uuid) {\r\n\t return engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n\t}\r\n\tfunction getTextureByName(name) {\r\n\t return getTexture(engine.getAssetByName(name).uuid);\r\n\t}\r\n\t//# sourceMappingURL=utils.js.map\n\n\tvar FrontBoxs = (function (_super) {\r\n\t tslib.__extends(FrontBoxs, _super);\r\n\t function FrontBoxs() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.frontBoxs = [];\r\n\t return _this;\r\n\t }\r\n\t FrontBoxs.prototype.setup = function () {\r\n\t var initX, initY = 0;\r\n\t for (var i = 0; i < +props.dollNum + 1; i++) {\r\n\t if (!new engine.Sprite(getTextureByName('frontbox_' + i))) {\r\n\t return;\r\n\t }\r\n\t this.frontBoxs[i] = new engine.Sprite(getTextureByName('frontbox_' + i));\r\n\t initX = this.frontBoxs[0].x = props.frontInitX;\r\n\t initY = this.frontBoxs[0].y = props.frontInitY;\r\n\t this.frontBoxs[i]['npcType'] = 'box' + i;\r\n\t }\r\n\t for (var i = 0; i < this.frontBoxs.length; i++) {\r\n\t if (i == 0) {\r\n\t this.frontBoxs[i].x = initX;\r\n\t }\r\n\t else {\r\n\t this.frontBoxs[i].x = this.frontBoxs[i - 1].x - this.frontBoxs[0].width - props.frontmargin;\r\n\t }\r\n\t console.log(this.frontBoxs[i].x);\r\n\t this.frontBoxs[i].y = initY;\r\n\t this.addChild(this.frontBoxs[i]);\r\n\t console.log('aaa', this.frontBoxs[i].x);\r\n\t }\r\n\t this.addEventListener(engine.Event.ENTER_FRAME, this.frameMove, this);\r\n\t };\r\n\t FrontBoxs.prototype.frameMove = function () {\r\n\t var _this = this;\r\n\t this.frontBoxs.forEach(function (item, index) {\r\n\t item.x += props.moveSpeed;\r\n\t if (item.x <= 0 && !item.visible) {\r\n\t item.visible = true;\r\n\t }\r\n\t if (item.x >= 750) {\r\n\t var tmpIndex = 0;\r\n\t if (index <= 0) {\r\n\t tmpIndex = _this.frontBoxs.length - 1;\r\n\t }\r\n\t else {\r\n\t tmpIndex = index - 1;\r\n\t }\r\n\t item.x = _this.frontBoxs[tmpIndex].x - _this.frontBoxs[0].width - props.frontmargin;\r\n\t if (!_this.GameView.getMoveX() && item.x <= 0 && _this.GameView.startstatus) {\r\n\t _this.GameView.setMoveX((370 - item.x) / props.moveSpeed, item);\r\n\t _this.hideBox = item;\r\n\t }\r\n\t }\r\n\t });\r\n\t };\r\n\t FrontBoxs.prototype.stop = function () {\r\n\t };\r\n\t FrontBoxs.prototype.showHidePrizeBox = function (isshow) {\r\n\t this.hideBox.visible = isshow;\r\n\t };\r\n\t return FrontBoxs;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=frontBox.js.map\n\n\tvar BackBoxs = (function (_super) {\r\n\t tslib.__extends(BackBoxs, _super);\r\n\t function BackBoxs() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.backBoxs = [];\r\n\t return _this;\r\n\t }\r\n\t BackBoxs.prototype.setup = function () {\r\n\t var initX, initY = 0;\r\n\t for (var i = 0; i < props.dollNum; i++) {\r\n\t this.backBoxs[i] = new engine.Sprite(getTextureByName('backbox_' + i));\r\n\t initX = this.backBoxs[0].x = props.backInitX;\r\n\t initY = this.backBoxs[0].y = props.backInitY - props.initOffsetTop;\r\n\t this.backBoxs[i]['npcType'] = 'box' + i;\r\n\t }\r\n\t this.backBoxs[props.dollNum] = new engine.Sprite(getTextureByName('backbox_0'));\r\n\t this.backBoxs[props.dollNum]['npcType'] = 'box' + props.dollNum;\r\n\t for (var i = 0; i < this.backBoxs.length; i++) {\r\n\t if (i == 0) {\r\n\t this.backBoxs[i].x = initX;\r\n\t }\r\n\t else {\r\n\t this.backBoxs[i].x = this.backBoxs[i - 1].x + this.backBoxs[i].width + props.backmargin;\r\n\t }\r\n\t this.backBoxs[i].y = initY;\r\n\t this.addChild(this.backBoxs[i]);\r\n\t }\r\n\t this.addEventListener(engine.Event.ENTER_FRAME, this.frameMove, this);\r\n\t };\r\n\t BackBoxs.prototype.frameMove = function () {\r\n\t var _this = this;\r\n\t this.backBoxs.forEach(function (item) {\r\n\t item.x -= props.moveSpeed;\r\n\t if (item.x <= 0) {\r\n\t var lastitem = _this.backBoxs.shift();\r\n\t lastitem.x = _this.backBoxs[_this.backBoxs.length - 1].x + item.width + props.backmargin;\r\n\t _this.backBoxs.push(lastitem);\r\n\t }\r\n\t });\r\n\t };\r\n\t return BackBoxs;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=backBox.js.map\n\n\tvar Zhuazi = (function (_super) {\r\n\t tslib.__extends(Zhuazi, _super);\r\n\t function Zhuazi() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.moveArr = [];\r\n\t _this.prizeBoxs = [];\r\n\t return _this;\r\n\t }\r\n\t Zhuazi.prototype.setup = function () {\r\n\t this.ganNode = new engine.Container();\r\n\t this.moveNode = new engine.Container();\r\n\t this.ganNode.x = 280;\r\n\t this.ganNode.y = 350;\r\n\t this.bashouGan = new engine.Sprite(getTextureByName(\"把手杆子\"));\r\n\t this.bashouGan.x = 60;\r\n\t this.bashouGan.y = 12;\r\n\t this.bashou = new engine.Sprite(getTextureByName(\"把手\"));\r\n\t this.bashou.x = 0;\r\n\t this.bashou.y = 0;\r\n\t this.ganzi = new engine.Sprite(getTextureByName(\"伸缩杆\"));\r\n\t this.ganzi.x = 97;\r\n\t this.ganzi.y = 27;\r\n\t this.connect = new engine.Sprite(getTextureByName(\"连接点\"));\r\n\t this.connect.x = 18;\r\n\t this.connect.y = -5;\r\n\t this.left_zhuazi = new engine.Sprite(getTextureByName(\"左爪\"));\r\n\t this.left_zhuazi.x = -15;\r\n\t this.left_zhuazi.y = 60;\r\n\t this.left_zhuazi.anchorX = this.left_zhuazi.width;\r\n\t this.left_zhuazi.anchorY = 0;\r\n\t this.right_zhuazi = new engine.Sprite(getTextureByName(\"右爪\"));\r\n\t this.right_zhuazi.x = 98;\r\n\t this.right_zhuazi.y = 60;\r\n\t this.ganNode.addChild(this.left_zhuazi);\r\n\t this.ganNode.addChild(this.right_zhuazi);\r\n\t this.ganNode.addChild(this.connect);\r\n\t this.ganNode.x = 30;\r\n\t this.ganNode.y = this.ganNode.y - 263;\r\n\t this.zhuaziY = this.ganNode.y;\r\n\t this.moveNode.addChild(this.ganzi);\r\n\t this.moveNode.addChild(this.ganNode);\r\n\t this.moveNode.addChild(this.bashou);\r\n\t this.moveNode.x = 262;\r\n\t this.bashouGan.y = this.bashouGan.y;\r\n\t this.moveNode.y = this.moveNode.y;\r\n\t this.addChild(this.bashouGan);\r\n\t this.addChild(this.moveNode);\r\n\t if (!props.ganziShow) {\r\n\t this.bashouGan.visible = false;\r\n\t }\r\n\t if (!props.bashouShow) {\r\n\t this.bashou.visible = false;\r\n\t }\r\n\t this.createPrizeBox();\r\n\t };\r\n\t Zhuazi.prototype.createPrizeBox = function () {\r\n\t var _this = this;\r\n\t for (var i = 0; i < props.dollNum; i++) {\r\n\t if (!new engine.Sprite(getTextureByName('prizebox_' + i))) {\r\n\t return;\r\n\t }\r\n\t this.prizeBoxs[i] = new engine.Sprite(getTextureByName('prizebox_' + i));\r\n\t this.prizeBoxs[i]['npcType'] = 'box' + i;\r\n\t }\r\n\t this.prizeBoxs[props.dollNum] = new engine.Sprite(getTextureByName('prizebox_0'));\r\n\t this.prizeBoxs[props.dollNum]['npcType'] = 'box' + props.dollNum;\r\n\t this.prizeBoxs.forEach(function (item) {\r\n\t _this.ganNode.addChild(item);\r\n\t item.visible = false;\r\n\t item.x = props.prizeBoxInitX;\r\n\t item.y = props.prizeBoxInitY;\r\n\t });\r\n\t };\r\n\t Zhuazi.prototype.showPrizeBox = function () {\r\n\t var _this = this;\r\n\t this.prizeBoxs.forEach(function (item) {\r\n\t console.log(_this.GameView.getBox()['npcType']);\r\n\t if (item['npcType'] === _this.GameView.getBox()['npcType']) {\r\n\t item.visible = true;\r\n\t _this.itemShow = item;\r\n\t }\r\n\t else {\r\n\t item.visible = false;\r\n\t }\r\n\t });\r\n\t };\r\n\t Zhuazi.prototype.move = function () {\r\n\t var _this = this;\r\n\t var rndist = Math.random();\r\n\t var halfWidth = this.bashou.width / 2;\r\n\t var randomX = rndist * (rndist > 0.5 ? 1 : -1) * props.bashouMoveDist;\r\n\t console.log(randomX);\r\n\t engine.Tween.get(this.moveNode).to({ x: 370 + halfWidth - 71 }, 1000).call(function () {\r\n\t _this.zhangkai();\r\n\t });\r\n\t };\r\n\t Zhuazi.prototype.zhangkai = function () {\r\n\t var _this = this;\r\n\t this.left_zhuazi.anchorX = this.left_zhuazi.width;\r\n\t this.left_zhuazi.anchorY = 0;\r\n\t engine.Tween.get(this.left_zhuazi, { loop: false }).to({ rotation: props.leftRotation }, 1000);\r\n\t engine.Tween.get(this.right_zhuazi, { loop: false }).to({ rotation: props.rightRotation }, 1000);\r\n\t setTimeout(function () {\r\n\t _this.getLong();\r\n\t }, 500);\r\n\t };\r\n\t Zhuazi.prototype.getLong = function () {\r\n\t var _this = this;\r\n\t var droptime = Number((this.GameView.getMoveX() / 60 - 1).toFixed(2)) * 1000 - 130;\r\n\t console.log('dr', droptime);\r\n\t var times = (props.ganMoveEndY - this.ganzi.y) / this.ganzi.height;\r\n\t console.log(Number(times.toFixed(2)));\r\n\t engine.Tween.get(this.ganzi).to({ scaleY: Number(times.toFixed(2)) }, droptime).to({ scaleY: 1 }, droptime);\r\n\t console.log('node', this.zhuaziY);\r\n\t engine.Tween.get(this.ganNode).to({ y: props.ganMoveEndY }, droptime).call(function () {\r\n\t _this.GameView.stopMove();\r\n\t if (_this.GameView.ifPrize) {\r\n\t _this.showPrizeBox();\r\n\t _this.GameView.setVisible(false);\r\n\t }\r\n\t }).to({ y: this.zhuaziY }, droptime).call(function () {\r\n\t if (_this.GameView.ifPrize) {\r\n\t _this.itemShow.visible = false;\r\n\t }\r\n\t engine.globalEvent.dispatchEvent('doll-machine2-game-end');\r\n\t });\r\n\t };\r\n\t Zhuazi.prototype.getReset = function () {\r\n\t this.left_zhuazi.anchorX = this.left_zhuazi.width;\r\n\t this.left_zhuazi.anchorY = 0;\r\n\t engine.Tween.get(this.moveNode, { loop: false }).to({ x: 262 }, 1000);\r\n\t engine.Tween.get(this.left_zhuazi, { loop: false }).to({ rotation: 0 }, 1000);\r\n\t engine.Tween.get(this.right_zhuazi, { loop: false }).to({ rotation: 0 }, 1000);\r\n\t this.GameView.resetMoveX();\r\n\t };\r\n\t return Zhuazi;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=Zhuazi.js.map\n\n\tvar GameView = (function (_super) {\r\n\t tslib.__extends(GameView, _super);\r\n\t function GameView() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.startstatus = true;\r\n\t _this.ifPrize = true;\r\n\t _this.goodsItems = [];\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.setup = function () {\r\n\t var _this = this;\r\n\t if (this._hasSetup) {\r\n\t return;\r\n\t }\r\n\t this._hasSetup = true;\r\n\t var frontBoxs = (this._frontBoxs = new FrontBoxs());\r\n\t this._frontBoxs.GameView = this;\r\n\t var backBoxs = (this._backBoxs = new BackBoxs());\r\n\t this._Zhuazi = new Zhuazi();\r\n\t this._Zhuazi.GameView = this;\r\n\t this.frontTransfer = new engine.Container();\r\n\t this.backTransfer = new engine.Container();\r\n\t this.frontTransfer.width = 0;\r\n\t this.frontTransfer.height = 0;\r\n\t this.frontTransfer.alpha = 1;\r\n\t this.backTransfer.width = 0;\r\n\t this.backTransfer.height = 0;\r\n\t this.backTransfer.alpha = 1;\r\n\t this.rect = new engine.Rect();\r\n\t this.rect.width = props.gameStageWidth;\r\n\t this.rect.height = props.gameStageHeight;\r\n\t this.rect.x = 65;\r\n\t this.rect.y = 0;\r\n\t this.NpcBg = new engine.Container();\r\n\t this.NpcBg.x = 0;\r\n\t this.NpcBg.y = 0;\r\n\t this.addChild(this.NpcBg);\r\n\t this.addChild(this.rect);\r\n\t this.frontDesk = new engine.Sprite(getTextureByName(\"前传输带\"));\r\n\t this.frontDesk.x = props.initOffsetLeft;\r\n\t this.frontDesk.y = props.frontDeskY - props.initOffsetTop;\r\n\t this.backDesk = new engine.Sprite(getTextureByName(\"后传输带\"));\r\n\t this.backDesk.x = props.initOffsetLeft;\r\n\t this.backDesk.y = props.backDeskY - props.initOffsetTop;\r\n\t if (props.single) {\r\n\t this.backDesk.visible = false;\r\n\t }\r\n\t var pcarr = [this.backDesk, this.frontDesk, this.backTransfer, this.frontTransfer, this._Zhuazi];\r\n\t pcarr.forEach(function (item) {\r\n\t _this.NpcBg.addChild(item);\r\n\t });\r\n\t this.NpcBg.mask = this.rect;\r\n\t this._Zhuazi.setup();\r\n\t this.backTransfer.addChild(this._backBoxs);\r\n\t this._backBoxs.setup();\r\n\t if (props.single) {\r\n\t this.backTransfer.visible = false;\r\n\t }\r\n\t this.frontTransfer.addChild(this._frontBoxs);\r\n\t this._frontBoxs.setup();\r\n\t };\r\n\t GameView.prototype.stopMove = function () {\r\n\t this._frontBoxs.stop();\r\n\t };\r\n\t GameView.prototype.setMoveX = function (x, item) {\r\n\t this.moveTime = x;\r\n\t this.prizeBox = item;\r\n\t this._Zhuazi.move();\r\n\t };\r\n\t GameView.prototype.setVisible = function (isshow) {\r\n\t this._frontBoxs.showHidePrizeBox(isshow);\r\n\t };\r\n\t GameView.prototype.getMoveX = function () {\r\n\t return this.moveTime;\r\n\t };\r\n\t GameView.prototype.resetMoveX = function () {\r\n\t this.moveTime = null;\r\n\t };\r\n\t GameView.prototype.getBox = function () {\r\n\t return this.prizeBox;\r\n\t };\r\n\t GameView.prototype.reset = function () {\r\n\t this.startstatus = false;\r\n\t this.ifPrize = false;\r\n\t this._Zhuazi.getReset();\r\n\t };\r\n\t GameView.prototype.start = function (type) {\r\n\t if (type === void 0) { type = null; }\r\n\t this.speed = 1;\r\n\t this.gameIng = true;\r\n\t console.log('执行', type);\r\n\t this.startstatus = true;\r\n\t this.ifPrize = type && type.prize || false;\r\n\t };\r\n\t GameView.prototype.beginNpc = function () {\r\n\t var _this = this;\r\n\t this.timer = setTimeout(function () {\r\n\t if (_this.gameIng) ;\r\n\t }, 2000 / this.speed);\r\n\t };\r\n\t GameView.prototype.pause = function () {\r\n\t this.gameIng = false;\r\n\t };\r\n\t GameView.prototype.revive = function () {\r\n\t this.gameIng = true;\r\n\t };\r\n\t GameView.prototype.resume = function () {\r\n\t this.reset();\r\n\t this.start();\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('doll-machine2-game-init', _this.reset, _this);\r\n\t engine.globalEvent.addEventListener('doll-machine2-game-start', _this.start, _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.reset = function (event) {\r\n\t injectProps(event.data);\r\n\t this._gameView.visible = true;\r\n\t this._gameView.reset();\r\n\t };\r\n\t GameWrapper.prototype.start = function (event) {\r\n\t console.log('监听开始');\r\n\t injectProps(event.data);\r\n\t this._gameView.start(event.data);\r\n\t };\r\n\t GameWrapper.prototype.pause = function () {\r\n\t this._gameView.pause();\r\n\t };\r\n\t GameWrapper.prototype.resume = function () {\r\n\t this._gameView.resume();\r\n\t };\r\n\t GameWrapper.prototype.revive = function () {\r\n\t this._gameView.revive();\r\n\t };\r\n\t GameWrapper.prototype.clear = function () {\r\n\t this._gameView.visible = false;\r\n\t };\r\n\t GameWrapper.prototype.onTap = function (event) {\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"
>>>>>>> 1666d83127b74014796759c4dd3e87192f4c7e6e
}
{
"name": "度小宝出游记",
"desc": "度小宝出游记模块",
"props": {
"guideText1": {
"alias": "引导1的文本",
"type": "string",
"default": "长按屏幕\n杆子变长即可通过"
},
"guideText2": {
"alias": "引导2的文本",
"type": "string",
"default": "当度小宝获得金币时积分+5"
},
"pierMinDistance": {
"alias": "障碍物最小间距",
"type": "number",
"default": 350
},
"pierMaxDistance": {
"alias": "障碍物最大间距",
"type": "number",
"default": 500
},
"frontBGMoveSpeed": {
"alias": "前背影移动速度",
"type": "number",
"default": 0.5
},
"afterBGMoveSpeed": {
"alias": "后背影移动速度",
"type": "number",
"default": 0.2
},
"reward": {
"alias": "出现金币的概率(0-1区间 1为必出现 0为必不出现)",
"type": "number",
"default": 0
},
"pierCount": {
"alias": "一屏中最多出现的桥墩数量(最好默认为2)",
"type": "number",
"default": 2
},
"pierMoveTime": {
"alias": "一个周期内桥墩移动的总时长(毫秒)",
"type": "number",
"default": 1000
},
"strutUpSpeed": {
"alias": "撑杆上升速度(每帧上升增量,一秒60帧)",
"type": "number",
"default": 10
},
"strutWidth": {
"alias": "撑杆宽度",
"type": "number",
"default": 5
},
"strutColor": {
"alias": "撑杆颜色",
"type": "string",
"default": "#000000"
},
"strutRotationSpeed": {
"alias": "撑杆旋转总时长(毫秒)",
"type": "number",
"default": 300
},
"playerMoveSpeed": {
"alias": "人物移动总时长(毫秒)",
"type": "number",
"default": 1200
},
"singleScore": {
"alias": "每个桥墩分数",
"type": "number",
"default": 5
},
"goldScore": {
"alias": "每个金币分数",
"type": "number",
"default": 5
},
"bgFristScore": {
"alias": "第一张图的分数区间最大值(超过此值就更换第二张背景图)",
"type": "number",
"default": 30
},
"bgSecondScore": {
"alias": "第二张图的分数区间最大值(超过此值就更换第三张背景图)",
"type": "number",
"default": 80
}
},
"assets": [
{
"name": "hhl_after",
"url": "//yun.duiba.com.cn/aurora/assets/88252cca633a2f6d5c863d1678cb3d92c4e0e2a2.png",
"uuid": "76e73c53-d727-4746-b86e-92997af58c7f",
"ext": ".png"
},
{
"name": "hhl_front",
"url": "//yun.duiba.com.cn/aurora/assets/5c5a2581c91346de4d9fe66782aa8687cc9135e5.png",
"uuid": "848e2fdf-dcf0-44e2-b269-fdf0e2f84710",
"ext": ".png"
},
{
"name": "pier",
"url": "//yun.duiba.com.cn/aurora/assets/faf5cf941f1c3118bcf087352b812c2fb65ae992.png",
"uuid": "d784fe9f-5d1d-4522-ab4b-d6875a3da33f",
"ext": ".png"
},
{
"name": "gold",
"url": "//yun.duiba.com.cn/aurora/assets/ae210ad26cee13f8fb6e69be62f7f5498be50a5b.png",
"uuid": "7f4e19f2-c80f-4a65-bec2-1f3c3dc6d210",
"ext": ".png"
},
{
"name": "hb_after",
"url": "//yun.duiba.com.cn/aurora/assets/aaa76c50cfb00c602cc393df658670e1465a9b4e.png",
"uuid": "48a6636c-e04a-4836-8ae1-ed84db74c4f6",
"ext": ".png"
},
{
"name": "hb_front",
"url": "//yun.duiba.com.cn/aurora/assets/40d1dccd9d0c1dc1f4354d62e7c0b2eaab88457f.png",
"uuid": "b77802ea-7ee7-444e-aa11-72f85990f0c7",
"ext": ".png"
},
{
"name": "wh_after",
"url": "//yun.duiba.com.cn/aurora/assets/4e4f0adbca2b1d1e131271cc1ceddd97c3529f8b.png",
"uuid": "5efd9347-5e0d-4876-a483-7c22f3fdc3fb",
"ext": ".png"
},
{
"name": "wh_front",
"url": "//yun.duiba.com.cn/aurora/assets/b68ed0e4f49ac03736d80365e2ab66614ae97894.png",
"uuid": "8683ad45-3e7e-4944-ade0-eb4d5e48839f",
"ext": ".png"
},
{
"name": "walk",
"url": "//yun.duiba.com.cn/aurora/assets/a4ab1e1a2b49d140db4a0806562098a8b1619b06.svga",
"uuid": "10cd1fdd-4fd8-43cf-a1c7-6ff5846d8a91",
"ext": ".svga"
},
{
"name": "scoreBg",
"url": "//yun.duiba.com.cn/aurora/assets/1a61bd62c82c2ba872443fb14e0f5304d7aee224.png",
"uuid": "fb7f0d1a-c548-43ae-a86e-46ba98155813",
"ext": ".png"
},
{
"name": "scoreHint",
"url": "//yun.duiba.com.cn/aurora/assets/6bb8c64878288b074f840ea74f2956d0d0c65125.png",
"uuid": "0ab7dc8d-1388-4679-8637-54d6f3cd3a28",
"ext": ".png"
},
{
"name": "guide",
"url": "//yun.duiba.com.cn/aurora/assets/75cc4ea91654fd1e9900d071cac5ca5296b1bd19.png",
"uuid": "e904cd4e-cd87-421e-8292-25137299236e",
"ext": ".png"
},
{
"name": "guideHand",
"url": "//yun.duiba.com.cn/aurora/assets/4f014befa3c812e6882d578a6867afd3d05d7fe3.png",
"uuid": "fb1c2ead-dda8-495d-a846-7e4a26289d01",
"ext": ".png"
},
{
"name": "know",
"url": "//yun.duiba.com.cn/aurora/assets/3e695571aebebba6add5aae3d743fbd16b8ee915.png",
"uuid": "4999d4c5-507e-4ae9-8310-b90bf017a74f",
"ext": ".png"
}
],
"events": {
"in": {
"dxbcyj-game-start": {
"alias": "开始",
"data": {}
}
},
"out": {
"dxbcyj-game-result": {
"alias": "游戏结束",
"data": {}
}
}
},
"id": "dxbcyj-game",
"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['dxbcyj-game'] = 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}\n\n\tvar ObjectPool = engine.ObjectPool;\r\n\tvar Road = (function (_super) {\r\n\t tslib.__extends(Road, _super);\r\n\t function Road() {\r\n\t return _super !== null && _super.apply(this, arguments) || this;\r\n\t }\r\n\t Road.prototype.setup = function () {\r\n\t this.lastPos = 0;\r\n\t this.addPier();\r\n\t };\r\n\t Road.prototype.getFristPier = function () {\r\n\t return this.getChildAt(0).width;\r\n\t };\r\n\t Road.prototype.getDistance = function () {\r\n\t var distance = [];\r\n\t var pier1 = this.getChildAt(0);\r\n\t var pier2 = this.getChildAt(1);\r\n\t distance.push(pier2.x - pier1.x);\r\n\t distance.push(pier2.width);\r\n\t return distance;\r\n\t };\r\n\t Road.prototype.addPier = function () {\r\n\t while (this.children.length < props.pierCount + 1) {\r\n\t var childrenNum = this.children.length;\r\n\t var randomPos = this.makeRandomFloat(props.pierMaxDistance, props.pierMinDistance);\r\n\t var pier = ObjectPool.getObject('pier');\r\n\t this.addChild(pier);\r\n\t if (childrenNum == 0) {\r\n\t pier.x = 0;\r\n\t }\r\n\t else {\r\n\t pier.x = this.lastPos + randomPos;\r\n\t }\r\n\t this.lastPos = pier.x;\r\n\t }\r\n\t };\r\n\t Road.prototype.moveAddPier = function () {\r\n\t var randomPos = this.makeRandomFloat(props.pierMaxDistance, props.pierMinDistance);\r\n\t var pier = ObjectPool.getObject('pier');\r\n\t var lastChild = this.getChildAt(this.children.length - 1);\r\n\t pier.x = lastChild.x + randomPos;\r\n\t this.addChild(pier);\r\n\t };\r\n\t Road.prototype.makeRandomFloat = function (max, min) {\r\n\t if (min === void 0) { min = 0; }\r\n\t return Math.random() * (max - min) + min;\r\n\t };\r\n\t Road.prototype.setViewport = function () {\r\n\t var _this = this;\r\n\t var tmpMovepos = this.getMovePos();\r\n\t this.children.forEach(function (item, index) {\r\n\t _this.playTween(item, index, tmpMovepos);\r\n\t });\r\n\t };\r\n\t Road.prototype.getMovePos = function () {\r\n\t var movePos = this.getChildAt(1);\r\n\t return movePos.x;\r\n\t };\r\n\t Road.prototype.playTween = function (item, index, tmpMovepos) {\r\n\t var _this = this;\r\n\t engine.Tween.get(item, { loop: false })\r\n\t .to({ x: item.x - tmpMovepos }, props.pierMoveTime)\r\n\t .call(function () {\r\n\t if (_this.getChildIndex(item) == 0) {\r\n\t engine.Tween.removeTweens(item);\r\n\t _this.removeChild(item);\r\n\t ObjectPool.recycleObject('pier', item);\r\n\t }\r\n\t if (index == 0) {\r\n\t _this.moveAddPier();\r\n\t }\r\n\t });\r\n\t };\r\n\t Road.prototype.getStartGold = function (index, isClose) {\r\n\t if (isClose === void 0) { isClose = true; }\r\n\t var tmpNode = this.getChildAt(index);\r\n\t var haveGold = tmpNode.haveGold;\r\n\t if (haveGold && isClose) {\r\n\t tmpNode.closeGold();\r\n\t }\r\n\t return haveGold;\r\n\t };\r\n\t Road.prototype.setGuide = function () {\r\n\t var tmpNode = this.getChildAt(1);\r\n\t if (!tmpNode.haveGold) {\r\n\t tmpNode.children.forEach(function (item) {\r\n\t if (item.name == 'gold') {\r\n\t item.visible = true;\r\n\t }\r\n\t });\r\n\t tmpNode.haveGold = true;\r\n\t }\r\n\t };\r\n\t return Road;\r\n\t}(engine.Container));\n\n\tfunction getTexture(uuid) {\r\n\t return engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n\t}\r\n\tfunction getTextureByName(name) {\r\n\t return getTexture(engine.getAssetByName(name).uuid);\r\n\t}\r\n\tfunction getStage() {\r\n\t return engine.gameStage.stage;\r\n\t}\r\n\tfunction createSvga(name) {\r\n\t var inst = new svga.Svga();\r\n\t inst.source = engine.getAssetByName(name).uuid;\r\n\t return inst;\r\n\t}\n\n\tvar GuideLayer = (function (_super) {\r\n\t tslib.__extends(GuideLayer, _super);\r\n\t function GuideLayer() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this._canClear = [];\r\n\t _this.setup();\r\n\t return _this;\r\n\t }\r\n\t GuideLayer.prototype.setup = function () {\r\n\t };\r\n\t GuideLayer.prototype.show = function (id, options, callback) {\r\n\t this.visible = true;\r\n\t this._callBack = callback ? callback : null;\r\n\t if (!this.guideMask) {\r\n\t this._options = options;\r\n\t var _a = this.stage, width = _a.width, height = _a.height;\r\n\t var guideMask = this.guideMask = new engine.Container();\r\n\t var guideHole = this._guideHole = new engine.Image(getTextureByName('guide'));\r\n\t guideHole.x = options.x;\r\n\t guideHole.y = options.y;\r\n\t guideHole.width = 250;\r\n\t guideHole.height = 250;\r\n\t guideHole.name = 'guideHole';\r\n\t guideMask.addChild(guideHole);\r\n\t this.createRect(guideMask, 0, 0, width, guideHole.y);\r\n\t this.createRect(guideMask, 0, guideHole.y, guideHole.x, guideHole.height);\r\n\t this.createRect(guideMask, guideHole.x + guideHole.width, guideHole.y, width - guideHole.x - guideHole.width, guideHole.height);\r\n\t this.createRect(guideMask, 0, guideHole.y + guideHole.height, width, height - guideHole.y - guideHole.height);\r\n\t this.guideStep(id);\r\n\t var label = this.label = new engine.Label();\r\n\t label.fillColor = 'white';\r\n\t label.size = 30;\r\n\t label.text = options.guideText;\r\n\t label.x = (width - label.width) / 2;\r\n\t label.y = guideHole.y + guideHole.height + 50;\r\n\t label.textAlign = engine.TEXT_ALIGN.CENTER;\r\n\t label.name = 'labHint';\r\n\t guideMask.addChild(label);\r\n\t this.addChild(guideMask);\r\n\t }\r\n\t this.once(engine.MouseEvent.CLICK, function () {\r\n\t this.removeChild(this.guideMask);\r\n\t this.guideMask = null;\r\n\t if (this._callBack) {\r\n\t this._callBack();\r\n\t }\r\n\t }, this);\r\n\t };\r\n\t GuideLayer.prototype.createRect = function (container, x, y, width, height) {\r\n\t var rect = new engine.Rect();\r\n\t rect.x = x;\r\n\t rect.y = y;\r\n\t rect.width = width;\r\n\t rect.height = height;\r\n\t rect.fillColor = 'black';\r\n\t rect.alpha = 0.7;\r\n\t container.addChild(rect);\r\n\t };\r\n\t GuideLayer.prototype.guideStep = function (id) {\r\n\t if (id == 1) {\r\n\t var guideHand = new engine.Image(getTextureByName('guideHand'));\r\n\t guideHand.x = this._options.x + 300;\r\n\t guideHand.y = this._options.y + 100;\r\n\t this.guideMask.addChild(guideHand);\r\n\t var rect = new engine.Rect();\r\n\t rect.x = this._options.x + 200;\r\n\t rect.y = this._options.y - 15;\r\n\t rect.width = props.strutWidth;\r\n\t rect.height = 200;\r\n\t rect.fillColor = props.strutColor;\r\n\t this.guideMask.addChild(rect);\r\n\t this._canClear.push(guideHand);\r\n\t this._canClear.push(rect);\r\n\t }\r\n\t if (id == 2) {\r\n\t var know = new engine.Image(getTextureByName('know'));\r\n\t know.x = (this.stage.width - know.width) / 2;\r\n\t know.y = this._options.y + 400;\r\n\t this.guideMask.addChild(know);\r\n\t this._canClear.push(know);\r\n\t }\r\n\t };\r\n\t return GuideLayer;\r\n\t}(engine.Container));\n\n\tvar LoopComponent = (function (_super) {\r\n\t tslib.__extends(LoopComponent, _super);\r\n\t function LoopComponent() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.onceInfo = { width: 0, height: 0, count: 0 };\r\n\t _this.loopInfo = { width: 0, height: 0, count: 0 };\r\n\t _this.parts = [];\r\n\t return _this;\r\n\t }\r\n\t LoopComponent.prototype.setup = function (parts, info) {\r\n\t var _this = this;\r\n\t parts.forEach(function (item, index) {\r\n\t var part;\r\n\t if (typeof item == 'string') {\r\n\t part = new engine.Sprite(getTextureByName(item));\r\n\t }\r\n\t else if (item instanceof engine.Texture) {\r\n\t part = new engine.Sprite(item);\r\n\t }\r\n\t else {\r\n\t part = item;\r\n\t }\r\n\t _this.addChild(part);\r\n\t _this.parts.push(part);\r\n\t if (index == 0) {\r\n\t info.width = part.width;\r\n\t info.height = part.height;\r\n\t }\r\n\t });\r\n\t info.count = parts.length;\r\n\t this.setViewport(0, 0);\r\n\t };\r\n\t LoopComponent.prototype.changeBg = function (changName) {\r\n\t this.parts.forEach(function (item, index) {\r\n\t item.texture = getTextureByName(changName);\r\n\t });\r\n\t };\r\n\t LoopComponent.prototype.setupLoop = function (resArr) {\r\n\t this.setup(resArr, this.loopInfo);\r\n\t };\r\n\t LoopComponent.prototype.setViewport = function (x, y) {\r\n\t if (y === void 0) { y = 0; }\r\n\t var sizeField = y == 0 ? 'width' : 'height';\r\n\t var posField = y == 0 ? 'x' : 'y';\r\n\t var pos = y == 0 ? x : y;\r\n\t var index;\r\n\t var onceSize = this.onceInfo[sizeField];\r\n\t var onceCount = this.onceInfo.count;\r\n\t var loopCount = this.loopInfo.count;\r\n\t var loopSize = this.loopInfo[sizeField];\r\n\t index = onceSize == 0 ? -1 : Math.floor(pos / onceSize);\r\n\t if (index < 0 || index >= onceCount) {\r\n\t var loopIndex = Math.floor((pos - onceCount * onceSize) / this.loopInfo[sizeField]);\r\n\t index = onceCount + loopIndex;\r\n\t }\r\n\t var formerIndex = index < onceCount ? index : (index) % loopCount + onceCount;\r\n\t var latterIndex = index < onceCount ? index + 1 : (index - onceCount + 1) % loopCount + onceCount;\r\n\t var former = this.parts[formerIndex];\r\n\t var latter = this.parts[latterIndex];\r\n\t if (!former || !latter) {\r\n\t console.log(formerIndex, latterIndex);\r\n\t }\r\n\t former[posField] = -(pos - loopSize * (index < onceCount ? index : index - onceCount) - (index < onceCount ? 0 : onceCount * onceSize));\r\n\t latter[posField] = former.x + (index < onceCount ? onceSize : loopSize);\r\n\t };\r\n\t return LoopComponent;\r\n\t}(engine.Container));\n\n\tvar Background = (function (_super) {\r\n\t tslib.__extends(Background, _super);\r\n\t function Background() {\r\n\t var _this = _super !== null && _super.apply(this, arguments) || this;\r\n\t _this.partResHHL = ['hhl_after', 'hhl_front'];\r\n\t _this.partResHB = ['hb_after', 'hb_front'];\r\n\t _this.partResWH = ['wh_after', 'wh_front'];\r\n\t _this.speeds = [];\r\n\t _this.resArray = [];\r\n\t _this.frameMovePos = 0;\r\n\t return _this;\r\n\t }\r\n\t Background.prototype.initBg = function () {\r\n\t this.sumMovePos = 0;\r\n\t this.speeds.push(props.afterBGMoveSpeed);\r\n\t this.speeds.push(props.frontBGMoveSpeed);\r\n\t var bottomBg = new engine.Rect();\r\n\t bottomBg.x = 0;\r\n\t bottomBg.y = 0;\r\n\t bottomBg.width = getStage().width;\r\n\t bottomBg.height = 0;\r\n\t bottomBg.fillColor = 0x75c9f5;\r\n\t this.addChild(bottomBg);\r\n\t this.resArray.push(this.partResHHL);\r\n\t this.resArray.push(this.partResHB);\r\n\t this.resArray.push(this.partResWH);\r\n\t this._bgIndex = 0;\r\n\t var parts = [];\r\n\t for (var i = 0; i < 2; i++) {\r\n\t var part = new LoopComponent();\r\n\t part.setupLoop([\r\n\t this.resArray[0][i],\r\n\t this.resArray[0][i],\r\n\t ]);\r\n\t parts.push(part);\r\n\t this.addChild(part);\r\n\t }\r\n\t parts[1].y = 200;\r\n\t };\r\n\t Background.prototype.setViewport = function (pos) {\r\n\t this.needFrameSum = (props.pierMoveTime / 1000) * 60;\r\n\t this.frameMovePos = pos / this.needFrameSum;\r\n\t this.frameIndex = 0;\r\n\t this.addEventListener(engine.Event.ENTER_FRAME, this.frameBack, this);\r\n\t };\r\n\t Background.prototype.frameBack = function () {\r\n\t if (this.frameIndex < this.needFrameSum) {\r\n\t for (var i = 0; i < 2; i++) {\r\n\t var part = this.getChildAt(i + 1);\r\n\t var speed = this.speeds[i];\r\n\t var tmpPos = ((this.frameMovePos * this.frameIndex) + this.sumMovePos) * speed;\r\n\t part.setViewport(tmpPos);\r\n\t }\r\n\t this.frameIndex++;\r\n\t }\r\n\t else {\r\n\t this.sumMovePos += this.frameMovePos * this.needFrameSum;\r\n\t this.frameIndex = 0;\r\n\t this.removeEventListener(engine.Event.ENTER_FRAME, this.frameBack, this);\r\n\t }\r\n\t };\r\n\t Background.prototype.changeBg = function (index) {\r\n\t for (var i = 0; i < 2; i++) {\r\n\t var part = this.getChildAt(i + 1);\r\n\t part.changeBg(this.resArray[index][i]);\r\n\t if (i == 1 && index == 1) {\r\n\t part.y = 400;\r\n\t }\r\n\t if (i == 1 && index == 2) {\r\n\t part.y = 250;\r\n\t }\r\n\t }\r\n\t this._bgIndex = index;\r\n\t };\r\n\t Background.prototype.getBgIndex = function () {\r\n\t return this._bgIndex;\r\n\t };\r\n\t return Background;\r\n\t}(engine.Container));\n\n\tvar Pier = (function (_super) {\r\n\t tslib.__extends(Pier, _super);\r\n\t function Pier() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.bmp = new engine.Sprite();\r\n\t _this.addChild(_this.bmp);\r\n\t return _this;\r\n\t }\r\n\t Pier.prototype.init = function () {\r\n\t var bmp = this.bmp;\r\n\t bmp.alpha = 1;\r\n\t bmp.texture = getTextureByName('pier');\r\n\t bmp.x = 0;\r\n\t bmp.y = bmp.height;\r\n\t if (this.children.length < 2) {\r\n\t var gold = new engine.Sprite();\r\n\t gold.texture = getTextureByName('gold');\r\n\t gold.name = 'gold';\r\n\t this.addChild(gold);\r\n\t }\r\n\t this.setGoldPosX(bmp);\r\n\t this.setShowGold();\r\n\t };\r\n\t Pier.prototype.setShowGold = function () {\r\n\t var nodeGold = this.getChildByName('gold');\r\n\t var randomWard = Math.random();\r\n\t nodeGold.alpha = 1;\r\n\t var isShow = randomWard < props.reward ? true : false;\r\n\t nodeGold.visible = isShow;\r\n\t this.haveGold = isShow;\r\n\t };\r\n\t Pier.prototype.setGoldPosX = function (bmp) {\r\n\t var nodeGold = this.getChildByName('gold');\r\n\t var pos = bmp.width / 2 - nodeGold.width / 2;\r\n\t nodeGold.x = pos;\r\n\t nodeGold.y = bmp.height - nodeGold.height - 50;\r\n\t nodeGold.visible = false;\r\n\t };\r\n\t Pier.prototype.closeGold = function () {\r\n\t var _this = this;\r\n\t this.children.forEach(function (item) {\r\n\t if (item.name == 'gold') {\r\n\t item.anchorX = item.width / 2;\r\n\t item.anchorY = item.height / 2;\r\n\t engine.Tween.get(item, { loop: false })\r\n\t .to({ scaleX: 2.5, scaleY: 2.5 }, 200, engine.Ease.cubicOut)\r\n\t .to({ scaleX: 1, scaleY: 1, alpha: 0 }, 200, engine.Ease.cubicIn)\r\n\t .call(function () {\r\n\t item.visible = false;\r\n\t _this.haveGold = false;\r\n\t });\r\n\t }\r\n\t });\r\n\t };\r\n\t return Pier;\r\n\t}(engine.Container));\n\n\tvar Player = (function (_super) {\r\n\t tslib.__extends(Player, _super);\r\n\t function Player() {\r\n\t return _super !== null && _super.apply(this, arguments) || this;\r\n\t }\r\n\t Player.prototype.initPlayer = function (pierWidth) {\r\n\t this._container = new engine.Container();\r\n\t this.addChild(this._container);\r\n\t this.playerNode = createSvga('walk');\r\n\t this._container.addChild(this.playerNode);\r\n\t this.playerNode.y = 675;\r\n\t this.playerNode.x = pierWidth / 2 - 80;\r\n\t this.playerNode.play();\r\n\t };\r\n\t Player.prototype.setViewport = function (pos, callBack, pierWidth) {\r\n\t var tmpPos = 0;\r\n\t var isSuccess = false;\r\n\t if (!pierWidth) {\r\n\t tmpPos = pos;\r\n\t isSuccess = true;\r\n\t }\r\n\t else {\r\n\t tmpPos = pierWidth - this.playerNode.x + pos - 60;\r\n\t }\r\n\t this.playGoTween(tmpPos, callBack, isSuccess);\r\n\t };\r\n\t Player.prototype.playGoTween = function (pos, callBack, isSuccess) {\r\n\t var _this = this;\r\n\t engine.Tween.get(this._container, { loop: false })\r\n\t .to({ x: pos }, props.playerMoveSpeed)\r\n\t .call(function () {\r\n\t engine.Tween.removeTweens(_this._container);\r\n\t if (isSuccess) {\r\n\t if (callBack) {\r\n\t callBack();\r\n\t }\r\n\t }\r\n\t else {\r\n\t _this.playDropTween(callBack);\r\n\t }\r\n\t });\r\n\t };\r\n\t Player.prototype.playDropTween = function (callBack) {\r\n\t var _this = this;\r\n\t engine.Tween.get(this._container, { loop: false })\r\n\t .to({ y: 2000 }, 1000)\r\n\t .call(function () {\r\n\t engine.Tween.removeTweens(_this._container);\r\n\t if (callBack) {\r\n\t callBack();\r\n\t }\r\n\t });\r\n\t };\r\n\t Player.prototype.setBackViewport = function (callBack) {\r\n\t var _this = this;\r\n\t engine.Tween.get(this._container, { loop: false })\r\n\t .to({ x: 0 }, props.pierMoveTime)\r\n\t .call(function () {\r\n\t engine.Tween.removeTweens(_this._container);\r\n\t if (callBack) {\r\n\t callBack();\r\n\t }\r\n\t });\r\n\t };\r\n\t return Player;\r\n\t}(engine.Container));\n\n\tvar Strut = (function (_super) {\r\n\t tslib.__extends(Strut, _super);\r\n\t function Strut() {\r\n\t return _super !== null && _super.apply(this, arguments) || this;\r\n\t }\r\n\t Strut.prototype.init = function () {\r\n\t this._strut = new engine.Rect();\r\n\t this.addChild(this._strut);\r\n\t this._strut.width = props.strutWidth;\r\n\t this._strut.y = 833;\r\n\t this._strut.fillColor = props.strutColor;\r\n\t this._strut.rotation = 180;\r\n\t };\r\n\t Strut.prototype.onMouseDown = function (pierWidth, distance, callBack) {\r\n\t this._strut.x = pierWidth - 60;\r\n\t this._distance = distance;\r\n\t this._callBack = callBack;\r\n\t this._strut.visible = true;\r\n\t this.addEventListener(engine.Event.ENTER_FRAME, this.frameStrut, this);\r\n\t };\r\n\t Strut.prototype.onMouseUp = function () {\r\n\t var _this = this;\r\n\t this.removeEventListener(engine.Event.ENTER_FRAME, this.frameStrut, this);\r\n\t setTimeout(function () {\r\n\t _this.strutRotation();\r\n\t }, 200);\r\n\t };\r\n\t Strut.prototype.strutRotation = function () {\r\n\t var _this = this;\r\n\t engine.Tween.get(this._strut, { loop: false })\r\n\t .to({ rotation: 270 }, props.strutRotationSpeed)\r\n\t .call(function () {\r\n\t _this.judgeResult();\r\n\t engine.Tween.removeTweens(_this._strut);\r\n\t });\r\n\t };\r\n\t Strut.prototype.judgeResult = function () {\r\n\t var isSuccess = false;\r\n\t if (this._distance[0] - this._distance[1] + 100 <= this._strut.height && this._strut.height <= this._distance[0] + 20) {\r\n\t isSuccess = true;\r\n\t }\r\n\t if (this._callBack) {\r\n\t this._callBack(isSuccess);\r\n\t }\r\n\t };\r\n\t Strut.prototype.frameStrut = function () {\r\n\t if (this._strut.height < 1000) {\r\n\t this._strut.height += props.strutUpSpeed;\r\n\t }\r\n\t };\r\n\t Strut.prototype.rest = function () {\r\n\t this._strut.width = props.strutWidth;\r\n\t this._strut.y = 833;\r\n\t this._strut.fillColor = props.strutColor;\r\n\t this._strut.rotation = 180;\r\n\t this._strut.height = 0;\r\n\t this._strut.visible = false;\r\n\t };\r\n\t Strut.prototype.getStrutHeight = function () {\r\n\t var distance = this._strut.height > 1000 ? 1000 : this._strut.height;\r\n\t return distance;\r\n\t };\r\n\t return Strut;\r\n\t}(engine.Container));\n\n\tvar ScoreLabel = (function (_super) {\r\n\t tslib.__extends(ScoreLabel, _super);\r\n\t function ScoreLabel() {\r\n\t return _super !== null && _super.apply(this, arguments) || this;\r\n\t }\r\n\t ScoreLabel.prototype.updateScore = function (score, animation) {\r\n\t if (animation === void 0) { animation = true; }\r\n\t this._value = score;\r\n\t if (animation && this._tmp) {\r\n\t this.animationUpdate();\r\n\t }\r\n\t else {\r\n\t this.updateLocal(score);\r\n\t }\r\n\t };\r\n\t ScoreLabel.prototype.animationUpdate = function () {\r\n\t var _this = this;\r\n\t var tmpInterval = setInterval(function () {\r\n\t _this._tmp += 1;\r\n\t if (_this._tmp <= _this._value) {\r\n\t _this.text = _this._tmp;\r\n\t }\r\n\t else {\r\n\t _this._tmp = _this._value;\r\n\t clearInterval(tmpInterval);\r\n\t }\r\n\t }, 50);\r\n\t };\r\n\t ScoreLabel.prototype.updateLocal = function (v) {\r\n\t this._tmp = v;\r\n\t this.text = v;\r\n\t };\r\n\t return ScoreLabel;\r\n\t}(engine.Label));\n\n\tvar ObjectPool$1 = engine.ObjectPool;\r\n\tvar PoolName = 'pier';\r\n\tObjectPool$1.registerPool(PoolName, function () {\r\n\t return new Pier();\r\n\t}, function (item, data) {\r\n\t item.init();\r\n\t});\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.moveX = 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 GameView.prototype.setup = function () {\r\n\t if (this._hasSetup) {\r\n\t return;\r\n\t }\r\n\t this._hasSetup = true;\r\n\t this._backgroud = new Background();\r\n\t this.addChild(this._backgroud);\r\n\t this._backgroud.initBg();\r\n\t var road = this._road = new Road();\r\n\t this.addChild(road);\r\n\t road.setup();\r\n\t var pierWidth = this._road.getFristPier();\r\n\t var player = this._player = new Player();\r\n\t this.addChild(player);\r\n\t player.initPlayer(pierWidth);\r\n\t var strut = this._strut = new Strut();\r\n\t this.addChild(strut);\r\n\t strut.init();\r\n\t this._scoreContainer = new engine.Container();\r\n\t this.addChild(this._scoreContainer);\r\n\t this.initLabScore();\r\n\t };\r\n\t GameView.prototype.start = function (guide) {\r\n\t return tslib.__awaiter(this, void 0, void 0, function () {\r\n\t var initScore;\r\n\t return tslib.__generator(this, function (_a) {\r\n\t this._isTouchLayer = true;\r\n\t this._sumScore = 0;\r\n\t this._isMouseDown = false;\r\n\t this._guide = guide;\r\n\t initScore = this._road.getStartGold(0) ? props.goldScore : 0;\r\n\t this.updateScore(initScore);\r\n\t if (this._guide == '1') {\r\n\t this.setGuide();\r\n\t }\r\n\t else {\r\n\t this.initTouch();\r\n\t this.registerEvent();\r\n\t }\r\n\t return [2];\r\n\t });\r\n\t });\r\n\t };\r\n\t GameView.prototype.setGuide = function () {\r\n\t var _this = this;\r\n\t this._road.setGuide();\r\n\t var guideLayer = this.guideLayer = new GuideLayer();\r\n\t this.addChild(guideLayer);\r\n\t this.guideLayer.show(1, { x: 20, y: 650, guideText: props.guideText1 }, function () {\r\n\t var posX = _this._road.getMovePos();\r\n\t _this.guideLayer.show(2, { x: posX + 20, y: 620, guideText: props.guideText2 }, function () {\r\n\t _this.initTouch();\r\n\t _this.registerEvent();\r\n\t });\r\n\t });\r\n\t };\r\n\t GameView.prototype.initLabScore = function () {\r\n\t var scoreBg = new engine.Sprite(getTextureByName('scoreBg'));\r\n\t scoreBg.x = getStage().width / 2 - scoreBg.width / 2;\r\n\t scoreBg.y = 80;\r\n\t var scoreHint = new engine.Sprite(getTextureByName('scoreHint'));\r\n\t scoreHint.x = getStage().width / 2 - scoreHint.width / 2;\r\n\t scoreHint.y = 40;\r\n\t this._scoreContainer.addChild(scoreHint);\r\n\t this.labScore = new ScoreLabel();\r\n\t this.labScore.fillColor = 0xff7646;\r\n\t this.labScore.size = 70;\r\n\t this.labScore.width = getStage().width;\r\n\t this.labScore.height = scoreBg.height;\r\n\t this.labScore.textAlign = engine.TEXT_ALIGN.CENTER;\r\n\t this.labScore.x = 0;\r\n\t this.labScore.y = scoreBg.y + 10;\r\n\t this._scoreContainer.addChild(this.labScore);\r\n\t };\r\n\t GameView.prototype.registerEvent = function () {\r\n\t this._touchLayer.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onMouseDown, this);\r\n\t this._touchLayer.addEventListener(engine.MouseEvent.MOUSE_UP, this.onMouseUp, this);\r\n\t };\r\n\t GameView.prototype.removeListener = function () {\r\n\t this._touchLayer.removeEventListener(engine.MouseEvent.MOUSE_DOWN, this.onMouseDown, this);\r\n\t this._touchLayer.removeEventListener(engine.MouseEvent.MOUSE_UP, this.onMouseUp, this);\r\n\t };\r\n\t GameView.prototype.initTouch = function () {\r\n\t this._touchLayer = new engine.Rect();\r\n\t this.addChild(this._touchLayer);\r\n\t this._touchLayer.width = getStage().width;\r\n\t this._touchLayer.height = getStage().height;\r\n\t this._touchLayer.x = 0;\r\n\t this._touchLayer.y = 0;\r\n\t this._touchLayer.alpha = 0;\r\n\t };\r\n\t GameView.prototype.setScoreShow = function () {\r\n\t };\r\n\t GameView.prototype.onMouseDown = function () {\r\n\t if (this._isTouchLayer) {\r\n\t this._isMouseDown = true;\r\n\t this._strut.onMouseDown(this._road.getFristPier(), this._road.getDistance(), this.goCallBcak.bind(this));\r\n\t }\r\n\t };\r\n\t GameView.prototype.onMouseUp = function () {\r\n\t if (this._isTouchLayer && this._isMouseDown) {\r\n\t this._strut.onMouseUp();\r\n\t this._isMouseDown = false;\r\n\t this._isTouchLayer = false;\r\n\t }\r\n\t };\r\n\t GameView.prototype.goCallBcak = function (isSuccess) {\r\n\t var _this = this;\r\n\t if (isSuccess) {\r\n\t console.log('成功了');\r\n\t var movePos = this._road.getMovePos();\r\n\t if (this._road.getStartGold(1, false)) {\r\n\t this.updateScore(props.singleScore + props.goldScore);\r\n\t }\r\n\t else {\r\n\t this.updateScore(props.singleScore);\r\n\t }\r\n\t this._player.setViewport(movePos, this.complete.bind(this));\r\n\t }\r\n\t else {\r\n\t console.log('失败了');\r\n\t this._player.setViewport(this._strut.getStrutHeight(), function () {\r\n\t console.log('掉下去了');\r\n\t engine.globalEvent.dispatchEvent('dxbcyj-game-result', { score: _this._sumScore });\r\n\t }, this._road.getFristPier());\r\n\t }\r\n\t };\r\n\t GameView.prototype.complete = function () {\r\n\t var _this = this;\r\n\t this._road.getStartGold(1);\r\n\t var movePos = this._road.getMovePos();\r\n\t this._road.setViewport();\r\n\t this._backgroud.setViewport(movePos);\r\n\t this._player.setBackViewport(function () {\r\n\t _this._isTouchLayer = true;\r\n\t });\r\n\t this.closeStrut();\r\n\t };\r\n\t GameView.prototype.closeStrut = function () {\r\n\t this._strut.rest();\r\n\t };\r\n\t GameView.prototype.updateScore = function (score) {\r\n\t this._sumScore += score;\r\n\t if (0 <= this._sumScore && this._sumScore <= props.bgFristScore) {\r\n\t this.changeBg(0);\r\n\t }\r\n\t else if (props.bgFristScore < this._sumScore && this._sumScore <= props.bgSecondScore) {\r\n\t this.changeBg(1);\r\n\t }\r\n\t else {\r\n\t this.changeBg(2);\r\n\t }\r\n\t this.labScore.updateScore(this._sumScore);\r\n\t };\r\n\t GameView.prototype.getScore = function () {\r\n\t return this._sumScore;\r\n\t };\r\n\t GameView.prototype.changeBg = function (index) {\r\n\t if (this._backgroud.getBgIndex() != index) {\r\n\t this._backgroud.changeBg(index);\r\n\t }\r\n\t };\r\n\t return GameView;\r\n\t}(engine.Container));\n\n\tvar GameWrapper = (function (_super) {\r\n\t tslib.__extends(GameWrapper, _super);\r\n\t function GameWrapper() {\r\n\t var _this = _super.call(this) || this;\r\n\t engine.globalEvent.addEventListener('dxbcyj-game-start', _this.start, _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 this._gameView.start(event.data.guide);\r\n\t };\r\n\t return GameWrapper;\r\n\t}(engine.Container));\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}\n\n\treturn index;\n\n})));\n"
}
{
"name": "拆礼盒",
"desc": "拆礼盒模块",
"props": {
"initX": {
"alias": "游戏场景初始X位置",
"type": "number",
"default": 0
},
"initY": {
"alias": "游戏场景初始Y位置",
"type": "number",
"default": 0
},
"gameStageWidth": {
"alias": "游戏场景宽度",
"type": "number",
"default": 534
},
"gameStageHeight": {
"alias": "游戏场景高度",
"type": "number",
"default": 408
}
},
"assets": [
{
"name": "底座",
"url": "//yun.duiba.com.cn/aurora/assets/d6ed718f0d236febaa4d1331950e5a190f225cb5.png",
"uuid": "7a0f8b48-449c-46d9-bd80-64455a30e641",
"ext": ".png"
},
{
"name": "点缀",
"url": "//yun.duiba.com.cn/aurora/assets/e08f680bbd26c4dcc47fd67ee2e145c46d6fcd1a.png",
"uuid": "c7426dc4-d631-4947-accc-015666277208",
"ext": ".png"
},
{
"name": "初始礼盒",
"url": "//yun.duiba.com.cn/aurora/assets/b9bb4e52c3734025fc96a92cb574c92209927b61.svga",
"uuid": "947cb448-1992-49f1-a9ed-e359b944953a",
"ext": ".svga"
},
{
"name": "拆礼盒",
"url": "//yun.duiba.com.cn/aurora/assets/8e86f8696710de414f0f36dc330db6e4bd0683d6.svga",
"uuid": "d9222991-064c-4816-85ee-6964ba78fbd0",
"ext": ".svga"
}
],
"events": {
"in": {
"open-gift-game-init": {
"alias": "重置"
},
"open-gift-game-start": {
"alias": "开始",
"data": {
"prize": true
}
}
},
"out": {
"open-gift-game-end": {
"alias": "动画完毕",
"data": null
}
}
},
"id": "open-gift",
"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['open-gift'] = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n\tvar props = {};\n\tfunction prepareProps() {\n\t var metaProps = getProps();\n\t engine.injectProp(props, metaProps);\n\t}\n\tfunction injectProps(p) {\n\t engine.injectProp(props, p);\n\t}\n\t//# sourceMappingURL=props.js.map\n\n\tfunction getTexture(uuid) {\n\t return engine.Texture.from(getAssetByUUID(uuid).uuid);\n\t}\n\tfunction getTextureByName(name) {\n\t return getTexture(engine.getAssetByName(name).uuid);\n\t}\n\tfunction createSvga(name, anchorName) {\n\t var inst = new svga.Svga();\n\t inst.source = 'asset://' + engine.getAssetByName(name).uuid;\n\t return inst;\n\t}\n\t//# sourceMappingURL=utils.js.map\n\n\tvar GameView = (function (_super) {\n\t tslib.__extends(GameView, _super);\n\t function GameView() {\n\t var _this = _super.call(this) || this;\n\t _this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);\n\t return _this;\n\t }\n\t GameView.prototype.setup = function () {\n\t if (this._hasSetup) {\n\t return;\n\t }\n\t this._hasSetup = true;\n\t this.NpcBg = new engine.Container();\n\t this.NpcBg.x = props.initX;\n\t this.NpcBg.y = props.initY;\n\t this.addChild(this.NpcBg);\n\t this.bottomCircle = new engine.Sprite(getTextureByName('底座'));\n\t this.bottomCircle.x = 17;\n\t this.bottomCircle.y = 305;\n\t this.loveDot = new engine.Sprite(getTextureByName('点缀'));\n\t this.loveDot.x = 0;\n\t this.loveDot.y = 6;\n\t this.giftboxSvga = createSvga('初始礼盒');\n\t this.giftboxSvga.x = 105;\n\t this.giftboxSvga.y = 37;\n\t this.giftAfterSvga = createSvga(\"拆礼盒\");\n\t this.giftAfterSvga.x = 105;\n\t this.giftAfterSvga.y = 0;\n\t this.giftAfterSvga.visible = false;\n\t this.NpcBg.addChild(this.bottomCircle);\n\t this.NpcBg.addChild(this.giftboxSvga);\n\t this.NpcBg.addChild(this.giftAfterSvga);\n\t this.NpcBg.addChild(this.loveDot);\n\t this.giftboxSvga.play(false, true);\n\t };\n\t GameView.prototype.reset = function () {\n\t this.giftboxSvga.visible = true;\n\t this.giftAfterSvga.visible = false;\n\t };\n\t GameView.prototype.start = function () {\n\t this.giftAfterSvga.visible = true;\n\t this.giftboxSvga.visible = false;\n\t this.giftAfterSvga.play(false, false);\n\t this.giftAfterSvga.once(engine.Event.END_FRAME, function () {\n\t engine.globalEvent.dispatchEvent('open-gift-game-end');\n\t }, this);\n\t };\n\t GameView.prototype.resume = function () {\n\t this.reset();\n\t this.start();\n\t };\n\t return GameView;\n\t}(engine.Container));\n\n\tvar GameWrapper = (function (_super) {\n\t tslib.__extends(GameWrapper, _super);\n\t function GameWrapper() {\n\t var _this = _super.call(this) || this;\n\t engine.globalEvent.addEventListener('open-gift-game-init', _this.reset, _this);\n\t engine.globalEvent.addEventListener('open-gift-game-start', _this.start, _this);\n\t var gameView = _this._gameView = new GameView();\n\t _this.addChild(gameView);\n\t return _this;\n\t }\n\t GameWrapper.prototype.reset = function (event) {\n\t injectProps(event.data);\n\t this._gameView.visible = true;\n\t this._gameView.reset();\n\t };\n\t GameWrapper.prototype.start = function (event) {\n\t console.log('监听开始');\n\t injectProps(event.data);\n\t this._gameView.start();\n\t };\n\t GameWrapper.prototype.clear = function () {\n\t this._gameView.visible = false;\n\t };\n\t return GameWrapper;\n\t}(engine.Container));\n\t//# sourceMappingURL=GameWrapper.js.map\n\n\tfunction index (props) {\n\t prepareProps();\n\t injectProps(props);\n\t var instance = new GameWrapper();\n\t return instance;\n\t}\n\t//# sourceMappingURL=index.js.map\n\n\treturn index;\n\n})));\n"
}
{
"name": "猫步前行",
"desc": "猫步前行模块",
"props": {
"blockMinDistance": {
"alias": "障碍物最小间距",
"type": "number",
"default": 150
},
"blockMaxDistance": {
"alias": "障碍物最大间距",
"type": "number",
"default": 350
},
"maxScore": {
"alias": "最大分数",
"type": "number",
"default": 100
},
"scoreTimes": {
"alias": "时间倍率",
"type": "number",
"default": 1
},
"showScore": {
"alias": "是否显示分数",
"type": "boolean",
"default": true
}
},
"assets": [
{
"name": "bg_far",
"url": "//yun.duiba.com.cn/aurora/assets/88b99a184b1d91ec207c3899da4e33d204d85849.jpg",
"uuid": "755ce179-ea64-4723-b86f-d75fec134578",
"ext": ".jpg"
},
{
"name": "bg_mid",
"url": "//yun.duiba.com.cn/aurora/assets/8422a19eddca5948b779efe47248db8a742f5714.png",
"uuid": "41c5721d-cb13-4f31-9dce-29c3ff115897",
"ext": ".png"
},
{
"name": "bg_near",
"url": "//yun.duiba.com.cn/aurora/assets/30653d0b47998d7413c5d767dcff605a4174cedd.jpg",
"uuid": "bab097bf-c891-4bda-9c2f-5ee752480841",
"ext": ".jpg"
},
{
"name": "moon",
"url": "//yun.duiba.com.cn/aurora/assets/0361ea50ed4716a99f8a76581edc7223d21bd62a.png",
"uuid": "97d31833-f9f0-4eb0-ab01-d9c8576e0f02",
"ext": ".png"
},
{
"name": "block_0",
"url": "//yun.duiba.com.cn/aurora/assets/e01d62022b585d5255b54f0dad936da4463118d3.png",
"uuid": "0feae6ef-3b0d-484c-be13-2fc10627e2fe",
"ext": ".png"
},
{
"name": "block_1",
"url": "//yun.duiba.com.cn/aurora/assets/5a70669941b6d0f503e8e9aa76e68f95d599ec99.png",
"uuid": "c5e5a381-bbe4-4dc1-8818-f089bb6f9c61",
"ext": ".png"
},
{
"name": "block_2",
"url": "//yun.duiba.com.cn/aurora/assets/24c974c21131b590891c6fb7ec72b9539a864588.png",
"uuid": "585ea53f-fdf3-463f-917e-d6b8cd96c499",
"ext": ".png"
},
{
"name": "block_3",
"url": "//yun.duiba.com.cn/aurora/assets/c2412641cd12f00b033cca5f2dafee7470559b60.png",
"uuid": "74f67ccc-95ec-4580-886d-0b4e187d0774",
"ext": ".png"
},
{
"name": "block_4",
"url": "//yun.duiba.com.cn/aurora/assets/9dbf27eed32fdbfce72eabd0c04aed1e3f42fe22.png",
"uuid": "a169afaa-08fd-4c5a-925b-be382f4ec9dc",
"ext": ".png"
},
{
"name": "flag_record",
"url": "//yun.duiba.com.cn/aurora/assets/53a59eb76dfb45099da4f240b86d15828749f0e8.png",
"uuid": "8c9f66a6-9748-455d-83c6-5ce6a55fbed2",
"ext": ".png"
},
{
"name": "dust_0",
"url": "//yun.duiba.com.cn/aurora/assets/b6719afed81d25b73cb112019d723134ca13df7c.png",
"uuid": "d2a3e515-f4c3-4090-9ec2-10937c5b2cbe",
"ext": ".png"
},
{
"name": "dust_1",
"url": "//yun.duiba.com.cn/aurora/assets/8be3c18b1c1119f6e40b9155aad8b26061cb47b3.png",
"uuid": "fe3b9f95-3df2-4026-9497-67dad642136e",
"ext": ".png"
},
{
"name": "dust_2",
"url": "//yun.duiba.com.cn/aurora/assets/3e98b389b933baa5f50bf2e8d342e000ce575fb7.png",
"uuid": "a07f4696-a682-4729-91e4-02f7141a49c8",
"ext": ".png"
},
{
"name": "dust_3",
"url": "//yun.duiba.com.cn/aurora/assets/0ad9f8a2b2d567d6452903023f7c549fd870d075.png",
"uuid": "3a0254c7-3b74-43a9-9abd-7637fc283dd5",
"ext": ".png"
},
{
"name": "dust_4",
"url": "//yun.duiba.com.cn/aurora/assets/8180658a2ac225d899794c4251b870688dcd1859.png",
"uuid": "0026bd07-8e2a-41d0-8953-1de2f99d7661",
"ext": ".png"
},
{
"name": "dust_5",
"url": "//yun.duiba.com.cn/aurora/assets/db20fa6912a19d65bc958d31f09c0757cf9b806c.png",
"uuid": "761f766b-15b2-4334-a920-1c8de8e25cd0",
"ext": ".png"
},
{
"name": "dust_6",
"url": "//yun.duiba.com.cn/aurora/assets/4ddbc7683055eaa1550ffc753c919fcbd649e08b.png",
"uuid": "36b1721f-659c-4b97-8468-604ea33e27a5",
"ext": ".png"
},
{
"name": "dust_7",
"url": "//yun.duiba.com.cn/aurora/assets/384b4da951496703bf95f007ffcad02203973cc5.png",
"uuid": "5359045c-9e8a-4324-bf15-df793559bfaa",
"ext": ".png"
},
{
"name": "dust_8",
"url": "//yun.duiba.com.cn/aurora/assets/5a0674b72b1932581ce09f993141ecc2ac86e9be.png",
"uuid": "04e0b191-393b-4705-9594-0af37e0e869b",
"ext": ".png"
},
{
"name": "dust_9",
"url": "//yun.duiba.com.cn/aurora/assets/faa629cb99a8c6996919f7c979c111373f0b8920.png",
"uuid": "ca81348a-1a4b-49d9-9e0a-0e19b5d2c887",
"ext": ".png"
},
{
"name": "dust_10",
"url": "//yun.duiba.com.cn/aurora/assets/ea6d57192dc436a50e934548cba53885bcfe5b26.png",
"uuid": "3b57c024-0272-4d4e-a857-16e31ec26c2d",
"ext": ".png"
},
{
"name": "dust_11",
"url": "//yun.duiba.com.cn/aurora/assets/b8bacf81393af61e42fc298e11f27eab4b946881.png",
"uuid": "d751c409-14fb-444e-b352-63244868c43a",
"ext": ".png"
},
{
"name": "menu_block_10",
"url": "//yun.duiba.com.cn/aurora/assets/995c15e67de28088ccc6a5cabf270f8e8ef22415.png",
"uuid": "5b6845de-bd5e-4bfa-b4a4-d2b8f6166ad6",
"ext": ".png"
},
{
"name": "body_normal_body",
"url": "//yun.duiba.com.cn/aurora/assets/2a19cc08e72d78d0287ce30c7dfb4b695371c8ba.png",
"uuid": "20f22f45-d558-4332-a0d5-212ae1a256e5",
"ext": ".png"
},
{
"name": "body_normal_foot",
"url": "//yun.duiba.com.cn/aurora/assets/27716e26f91252735ba1e071f0ced93b9aee4182.png",
"uuid": "34cf1f23-e70c-4c19-9e37-2de4de693fcf",
"ext": ".png"
},
{
"name": "body_normal_lower_left_arm",
"url": "//yun.duiba.com.cn/aurora/assets/4197679b407e24e892f7749488f1b8062d712a35.png",
"uuid": "b62a99b0-bff3-4b44-97bd-fe606502d3e7",
"ext": ".png"
},
{
"name": "body_normal_lower_left_leg",
"url": "//yun.duiba.com.cn/aurora/assets/4abc68dea6205eb070460b31dc289144509cfadd.png",
"uuid": "dceb7805-b91b-44c9-b9d8-eea72565810f",
"ext": ".png"
},
{
"name": "body_normal_lower_right_arm",
"url": "//yun.duiba.com.cn/aurora/assets/4f3a8fb6f567b1d0c425673a6790585fae3372ee.png",
"uuid": "dd3b9db5-14d5-4d8f-831e-d6f854ef97d0",
"ext": ".png"
},
{
"name": "body_normal_lower_right_leg",
"url": "//yun.duiba.com.cn/aurora/assets/0e05af056b9df883e3a281322c16a95e24f2ee51.png",
"uuid": "b6524f1f-8d94-435e-84c9-b9bb7c691119",
"ext": ".png"
},
{
"name": "body_normal_upper_left_arm",
"url": "//yun.duiba.com.cn/aurora/assets/67da6919e38eddf06d8f61ea77a8ca4f264cfe8a.png",
"uuid": "40b913a7-fe43-479d-b796-1bc337ab2f4a",
"ext": ".png"
},
{
"name": "body_normal_upper_left_leg",
"url": "//yun.duiba.com.cn/aurora/assets/2f3b13a48a873161a0d620f761efc830ec3da9e1.png",
"uuid": "e98509e0-704e-4ac3-9770-3bffd7ee0ef4",
"ext": ".png"
},
{
"name": "body_normal_upper_right_arm",
"url": "//yun.duiba.com.cn/aurora/assets/8587e14a8b7d2e57f8b93f8e558d511a5d5e0b54.png",
"uuid": "c58ce0c9-1540-4595-b22a-64f6e48d913a",
"ext": ".png"
},
{
"name": "body_normal_upper_right_leg",
"url": "//yun.duiba.com.cn/aurora/assets/a459a6ea09d0b69b5f85df504df34457b1ec8760.png",
"uuid": "fe81c45d-a4ea-4f11-aa0c-5afa5c1a24dc",
"ext": ".png"
},
{
"name": "head_0",
"url": "//yun.duiba.com.cn/aurora/assets/54f4cabcad3c0d297c1786ea74529cce274bfdce.png",
"uuid": "88bdda7e-9af3-4e98-ae7f-da4d53ab42d2",
"ext": ".png"
},
{
"name": "head_1",
"url": "//yun.duiba.com.cn/aurora/assets/abfe9be652673e7c0bc761b36775e6b3d0c66aff.png",
"uuid": "e7beb90a-13d2-4504-a88b-5aa6c53f5c9b",
"ext": ".png"
},
{
"name": "head_2",
"url": "//yun.duiba.com.cn/aurora/assets/5ea8fe57ab6d1ff0a796431550b49bce3ddd41d2.png",
"uuid": "4975457c-12c2-49c2-893d-fdf40c1fef94",
"ext": ".png"
},
{
"name": "head_3",
"url": "//yun.duiba.com.cn/aurora/assets/0f0850f184c6ca6f7e7add61d43b8adf16dd43f4.png",
"uuid": "47db2073-4f14-43ee-afca-1e98188cd169",
"ext": ".png"
},
{
"name": "head_4",
"url": "//yun.duiba.com.cn/aurora/assets/426a5773e6781c3f287bb0a01561014848055602.png",
"uuid": "7d7dea57-26ee-488e-b928-78c0e4f21baf",
"ext": ".png"
},
{
"name": "head_bird",
"url": "//yun.duiba.com.cn/aurora/assets/022f41d77464df1edeca7fcc4c235ec8c8081743.png",
"uuid": "4d8b2438-0d62-47fd-9971-7766e63a9283",
"ext": ".png"
},
{
"name": "head_heart",
"url": "//yun.duiba.com.cn/aurora/assets/29f401553ae6a1cac70e3eb9f2ced4af4563e6d9.png",
"uuid": "b7918a78-18ee-4a98-8fd2-c5ea1d74f80b",
"ext": ".png"
},
{
"name": "head_smoke",
"url": "//yun.duiba.com.cn/aurora/assets/562d44364589ea6cd6354d15a7ad5e19bf9229e2.png",
"uuid": "8921ea9f-f618-45d2-b2ce-99540a9455f4",
"ext": ".png"
},
{
"name": "dialog_0",
"url": "//yun.duiba.com.cn/aurora/assets/f742f6a3ecd6664059e37aa6ae901b059a6da2b0.png",
"uuid": "5f6ef454-634e-4663-8591-de8a383f629e",
"ext": ".png"
},
{
"name": "dialog_1",
"url": "//yun.duiba.com.cn/aurora/assets/ca5d41083614b91f0a3b0d140ec247f4c7121f1d.png",
"uuid": "c64a2e5a-197c-486a-8d7a-245cf3f3d0c9",
"ext": ".png"
},
{
"name": "body_gray_body",
"url": "//yun.duiba.com.cn/aurora/assets/1a68b3195fd3568d9b31e3ff87a3721c321a0d74.png",
"uuid": "1ad192ec-0412-4120-af19-015134a5dbf1",
"ext": ".png"
},
{
"name": "body_gray_foot",
"url": "//yun.duiba.com.cn/aurora/assets/c4c3584c49d77878fd76b357d9b11aac9a1377e8.png",
"uuid": "2af600c6-4bfb-4870-89b5-27d1cb25088d",
"ext": ".png"
},
{
"name": "body_gray_lower_left_arm",
"url": "//yun.duiba.com.cn/aurora/assets/f188548ec71fc93b62c39d53d374c518b97c4f33.png",
"uuid": "c591459e-781f-4114-b020-66678eb572fe",
"ext": ".png"
},
{
"name": "body_gray_lower_left_leg",
"url": "//yun.duiba.com.cn/aurora/assets/fb085cf0df30bbaa4f615a438a1099fcf8c9e301.png",
"uuid": "1c2153bb-3639-4d89-8cf3-0a88656bf23a",
"ext": ".png"
},
{
"name": "body_gray_lower_right_arm",
"url": "//yun.duiba.com.cn/aurora/assets/4af5042462d46a168704614cd3a4f3b171fc15a3.png",
"uuid": "7c838ff5-d21f-4f10-9967-1d361c6755e0",
"ext": ".png"
},
{
"name": "body_gray_lower_right_leg",
"url": "//yun.duiba.com.cn/aurora/assets/da576541165b14d775f115db3c280737ee9ecf0a.png",
"uuid": "71bf4fb3-6ca0-4738-85f0-4662ea99aa05",
"ext": ".png"
},
{
"name": "body_gray_upper_left_arm",
"url": "//yun.duiba.com.cn/aurora/assets/6680f484a38c27f88978c08c868f400ba9649402.png",
"uuid": "109aedfe-5b12-43ec-b6c8-272f0ad68454",
"ext": ".png"
},
{
"name": "body_gray_upper_left_leg",
"url": "//yun.duiba.com.cn/aurora/assets/29037e47c3d44e656dcb89cca718e91f9689324d.png",
"uuid": "6f8ac4a2-323e-4c8f-98b0-a85ea1c6f3e1",
"ext": ".png"
},
{
"name": "body_gray_upper_right_arm",
"url": "//yun.duiba.com.cn/aurora/assets/ac396f21c9a494e5ed6a5c57417674bd5504ef71.png",
"uuid": "842bd78c-93bb-4500-9445-a55bfe00ae30",
"ext": ".png"
},
{
"name": "body_gray_upper_right_leg",
"url": "//yun.duiba.com.cn/aurora/assets/44ec8f17ec1470d13e78c132e6c5f790d59c93ae.png",
"uuid": "3cc57fd8-bf90-42e9-9149-3b7f5e6bceda",
"ext": ".png"
}
],
"events": {
"in": {
"walking-cat-start": {
"alias": "开始"
},
"walking-cat-revive": {
"alias": "复活"
}
},
"out": {
"walking-cat-game-end": {
"alias": "游戏结束",
"data": {}
},
"walking-cat-game-changScore": {
"alias": "游戏分数改变",
"data": {}
}
}
},
"id": "walking-cat",
"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['walking-cat'] = 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\tfunction getTextureByName(name) {\r\n\t return getTexture(engine.getAssetByName(name).uuid);\r\n\t}\r\n\tfunction getStage() {\r\n\t return engine.gameStage.stage;\r\n\t}\r\n\tfunction getfactor() {\r\n\t return 10;\r\n\t}\r\n\t//# sourceMappingURL=utils.js.map\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 ScoreLabel = (function (_super) {\r\n\t tslib.__extends(ScoreLabel, _super);\r\n\t function ScoreLabel() {\r\n\t return _super !== null && _super.apply(this, arguments) || this;\r\n\t }\r\n\t ScoreLabel.prototype.updateScore = function (score, formatFun, animation) {\r\n\t if (formatFun === void 0) { formatFun = null; }\r\n\t if (animation === void 0) { animation = true; }\r\n\t this.formatFun = formatFun;\r\n\t this._value = score;\r\n\t if (animation) {\r\n\t engine.Tween.get(this, null, null, true)\r\n\t .to({ temp: score }, 300);\r\n\t }\r\n\t else {\r\n\t this.updateLocal(score);\r\n\t }\r\n\t };\r\n\t Object.defineProperty(ScoreLabel.prototype, \"score\", {\r\n\t get: function () {\r\n\t return this._value;\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t Object.defineProperty(ScoreLabel.prototype, \"temp\", {\r\n\t get: function () {\r\n\t return this._temp;\r\n\t },\r\n\t set: function (v) {\r\n\t this._temp = v;\r\n\t this.updateLocal(v);\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t ScoreLabel.prototype.updateLocal = function (v) {\r\n\t this.text = this.formatFun && this.formatFun(v) || v;\r\n\t };\r\n\t return ScoreLabel;\r\n\t}(engine.Label));\r\n\t//# sourceMappingURL=ScoreLabel.js.map\n\n\tvar PlayGame = (function (_super) {\r\n\t tslib.__extends(PlayGame, _super);\r\n\t function PlayGame() {\r\n\t var _this = _super !== null && _super.apply(this, arguments) || this;\r\n\t _this.addlabelScore = null;\r\n\t _this.formatScore = function (s) {\r\n\t var t = (Math.ceil(s * 10) / 10).toString();\r\n\t t += t.indexOf('.') < 0 ? '.0' : '';\r\n\t return t;\r\n\t };\r\n\t return _this;\r\n\t }\r\n\t Object.defineProperty(PlayGame, \"instance\", {\r\n\t get: function () {\r\n\t if (this._instance == undefined) {\r\n\t this._instance = new PlayGame();\r\n\t }\r\n\t return this._instance;\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t PlayGame.prototype.start = function (revive) {\r\n\t if (revive === void 0) { revive = false; }\r\n\t if (!revive) {\r\n\t this.normalScore = 0;\r\n\t this.rewardScore = 0;\r\n\t this.lastDialogTs = 0;\r\n\t this.initTouch();\r\n\t this.initLabScore();\r\n\t this.initAddlabel();\r\n\t this.initDialog();\r\n\t }\r\n\t this.registerEvent();\r\n\t };\r\n\t PlayGame.prototype.registerEvent = function () {\r\n\t this.touchLayer.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onMouseDown, this);\r\n\t this.touchLayer.addEventListener(engine.MouseEvent.MOUSE_UP, this.onMouseUp, this);\r\n\t this.GameView.addEventListener(engine.Event.COMPLETE, this.onGameComplete, this);\r\n\t this.GameView.addEventListener('scoreChange', this.onScoreChange, this);\r\n\t };\r\n\t PlayGame.prototype.initTouch = function () {\r\n\t this.touchLayer = new engine.Rect();\r\n\t this.addChild(this.touchLayer);\r\n\t this.touchLayer.width = getStage().width;\r\n\t this.touchLayer.height = getStage().height;\r\n\t this.touchLayer.x = 0;\r\n\t this.touchLayer.y = 0;\r\n\t this.touchLayer.alpha = 0;\r\n\t };\r\n\t PlayGame.prototype.removeListener = function () {\r\n\t this.touchLayer.removeEventListener(engine.MouseEvent.MOUSE_DOWN, this.onMouseDown, this);\r\n\t this.touchLayer.removeEventListener(engine.MouseEvent.MOUSE_UP, this.onMouseUp, this);\r\n\t this.GameView.removeEventListener(engine.Event.COMPLETE, this.onGameComplete, this);\r\n\t this.GameView.removeEventListener('scoreChange', this.onScoreChange, this);\r\n\t };\r\n\t PlayGame.prototype.initLabScore = function () {\r\n\t this.labScore = new ScoreLabel();\r\n\t this.labScore.visible = props.showScore;\r\n\t this.labScore.updateScore(0, this.formatScore, false);\r\n\t this.labScore.fillColor = 'yellow';\r\n\t this.labScore.size = 46;\r\n\t this.labScore.x = 610;\r\n\t engine.Tween.get(this.labScore, { loop: false })\r\n\t .set({ y: -100 })\r\n\t .wait(300)\r\n\t .to({ y: 40 }, 200, engine.Ease.backOut);\r\n\t this.addChild(this.labScore);\r\n\t };\r\n\t PlayGame.prototype.initAddlabel = function () {\r\n\t this.addlabelScore = new engine.Label();\r\n\t this.addlabelScore.fillColor = 'yellow';\r\n\t this.addlabelScore.size = 40;\r\n\t this.addlabelScore.text = '';\r\n\t this.addlabelScore.x = 378;\r\n\t this.addlabelScore.y = 582;\r\n\t this.addlabelScore.visible = false;\r\n\t this.addChild(this.addlabelScore);\r\n\t };\r\n\t PlayGame.prototype.initDialog = function () {\r\n\t this.dialog = new engine.Image();\r\n\t this.dialog.x = 390;\r\n\t this.dialog.y = 323;\r\n\t this.addChild(this.dialog);\r\n\t };\r\n\t PlayGame.prototype.onMouseDown = function () {\r\n\t this.GameView.down();\r\n\t };\r\n\t PlayGame.prototype.onMouseUp = function () {\r\n\t this.GameView.up();\r\n\t };\r\n\t PlayGame.prototype.onGameComplete = function () {\r\n\t console.log('死亡');\r\n\t this.removeListener();\r\n\t var score = this.getScore();\r\n\t engine.globalEvent.dispatchEvent('walking-cat-game-end', { score: score });\r\n\t };\r\n\t PlayGame.prototype.getScore = function (round) {\r\n\t if (round === void 0) { round = false; }\r\n\t var score = (this.normalScore + this.rewardScore) / 10;\r\n\t score *= (props.scoreTimes || 1);\r\n\t if (round) {\r\n\t return Math.round(score);\r\n\t }\r\n\t return score;\r\n\t };\r\n\t PlayGame.prototype.onScoreChange = function (event) {\r\n\t var _a = event.data, score = _a.score, passType = _a.passType, rewardScore = _a.rewardScore;\r\n\t var scoreAdd;\r\n\t if (rewardScore) {\r\n\t this.rewardScore += rewardScore;\r\n\t scoreAdd = rewardScore;\r\n\t }\r\n\t else {\r\n\t scoreAdd = score - this.normalScore;\r\n\t this.normalScore = score;\r\n\t }\r\n\t var curScore = this.getScore();\r\n\t this.labScore.updateScore(curScore, this.formatScore);\r\n\t if (passType > 0 && passType <= 4) {\r\n\t var now = Date.now();\r\n\t if (now - this.lastDialogTs > 15000) {\r\n\t this.play(1);\r\n\t this.lastDialogTs = now;\r\n\t }\r\n\t }\r\n\t else if (passType == 10) {\r\n\t this.play(0);\r\n\t this.lastDialogTs = Date.now();\r\n\t this.GameView.setWitchFace('happy');\r\n\t }\r\n\t if (scoreAdd > 0) {\r\n\t var labScoreAdd_1 = this.addlabelScore;\r\n\t labScoreAdd_1.visible = props.showScore;\r\n\t labScoreAdd_1.alpha = 0;\r\n\t labScoreAdd_1.verticalCenter = 0;\r\n\t labScoreAdd_1.text = '+' + (scoreAdd / 10 * (props.scoreTimes || 1));\r\n\t engine.Tween.get(labScoreAdd_1, null, null, true)\r\n\t .to({ verticalCenter: -50, alpha: 1, }, 200, engine.Ease.cubicIn)\r\n\t .wait(300)\r\n\t .to({ verticalCenter: -100, alpha: 0, }, 100, engine.Ease.cubicOut)\r\n\t .call(function () {\r\n\t labScoreAdd_1.visible = false;\r\n\t }, this);\r\n\t }\r\n\t engine.globalEvent.dispatchEvent('walking-cat-game-changScore', { score: curScore });\r\n\t };\r\n\t PlayGame.prototype.play = function (id) {\r\n\t var img = this.dialog;\r\n\t img.texture = getTextureByName('dialog_' + id);\r\n\t img.scaleX = img.scaleY = 0;\r\n\t img.alpha = 1;\r\n\t img.visible = true;\r\n\t engine.Tween.get(img, null, null, true)\r\n\t .to({\r\n\t scaleX: 1, scaleY: 1\r\n\t }, 500, engine.Ease.backOut)\r\n\t .wait(500)\r\n\t .to({\r\n\t alpha: 0,\r\n\t }, 300)\r\n\t .call(function () {\r\n\t img.visible = false;\r\n\t });\r\n\t };\r\n\t PlayGame.prototype.revive = function () {\r\n\t this.GameView.reset(true);\r\n\t this.GameView.start(true);\r\n\t };\r\n\t return PlayGame;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=PlayGame.js.map\n\n\tvar LoopComponent = (function (_super) {\r\n\t tslib.__extends(LoopComponent, _super);\r\n\t function LoopComponent() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.onceInfo = { width: 0, height: 0, count: 0 };\r\n\t _this.loopInfo = { width: 0, height: 0, count: 0 };\r\n\t _this.parts = [];\r\n\t return _this;\r\n\t }\r\n\t LoopComponent.prototype.setup = function (parts, info) {\r\n\t var _this = this;\r\n\t parts.forEach(function (item, index) {\r\n\t var part;\r\n\t if (typeof item == 'string') {\r\n\t part = new engine.Sprite(getTextureByName(item));\r\n\t }\r\n\t else if (item instanceof engine.Texture) {\r\n\t part = new engine.Sprite(item);\r\n\t }\r\n\t else {\r\n\t part = item;\r\n\t }\r\n\t _this.addChild(part);\r\n\t _this.parts.push(part);\r\n\t if (index == 0) {\r\n\t info.width = part.width;\r\n\t info.height = part.height;\r\n\t }\r\n\t });\r\n\t info.count = parts.length;\r\n\t this.setViewport(0, 0);\r\n\t };\r\n\t LoopComponent.prototype.setupOnce = function (resArr) {\r\n\t this.setup(resArr, this.onceInfo);\r\n\t };\r\n\t LoopComponent.prototype.setupLoop = function (resArr) {\r\n\t this.setup(resArr, this.loopInfo);\r\n\t };\r\n\t LoopComponent.prototype.setViewport = function (x, y) {\r\n\t if (y === void 0) { y = 0; }\r\n\t var sizeField = y == 0 ? 'width' : 'height';\r\n\t var posField = y == 0 ? 'x' : 'y';\r\n\t var pos = y == 0 ? x : y;\r\n\t var index;\r\n\t var onceSize = this.onceInfo[sizeField];\r\n\t var onceCount = this.onceInfo.count;\r\n\t var loopCount = this.loopInfo.count;\r\n\t var loopSize = this.loopInfo[sizeField];\r\n\t index = onceSize == 0 ? -1 : Math.floor(pos / onceSize);\r\n\t if (index < 0 || index >= onceCount) {\r\n\t var loopIndex = Math.floor((pos - onceCount * onceSize) / this.loopInfo[sizeField]);\r\n\t index = onceCount + loopIndex;\r\n\t }\r\n\t var formerIndex = index < onceCount ? index : (index) % loopCount + onceCount;\r\n\t var latterIndex = index < onceCount ? index + 1 : (index - onceCount + 1) % loopCount + onceCount;\r\n\t var former = this.parts[formerIndex];\r\n\t var latter = this.parts[latterIndex];\r\n\t if (!former || !latter) {\r\n\t console.log(formerIndex, latterIndex);\r\n\t }\r\n\t former[posField] = -(pos - loopSize * (index < onceCount ? index : index - onceCount) - (index < onceCount ? 0 : onceCount * onceSize));\r\n\t latter[posField] = former.x + (index < onceCount ? onceSize : loopSize);\r\n\t };\r\n\t return LoopComponent;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=LoopComponent.js.map\n\n\tvar Background = (function (_super) {\r\n\t tslib.__extends(Background, _super);\r\n\t function Background() {\r\n\t var _this = _super !== null && _super.apply(this, arguments) || this;\r\n\t _this.partRes = ['bg_far', 'bg_mid', 'bg_near'];\r\n\t _this.speeds = [0.05, 0.5, 1];\r\n\t return _this;\r\n\t }\r\n\t Background.prototype.setup = function () {\r\n\t var bottomBg = new engine.Rect();\r\n\t bottomBg.x = 0;\r\n\t bottomBg.y = 0;\r\n\t bottomBg.width = getStage().width;\r\n\t bottomBg.height = 0;\r\n\t bottomBg.fillColor = 0x75c9f5;\r\n\t this.addChild(bottomBg);\r\n\t var parts = [];\r\n\t for (var i = 0; i < 3; i++) {\r\n\t var part = new LoopComponent();\r\n\t part.setupLoop([\r\n\t this.partRes[i],\r\n\t this.partRes[i],\r\n\t ]);\r\n\t parts.push(part);\r\n\t this.addChild(part);\r\n\t }\r\n\t var height = getStage().height;\r\n\t parts[0].y = (height - parts[0].height) / 2 - 400;\r\n\t parts[1].y = (height - parts[1].height) / 2 - 120;\r\n\t parts[2].y = (height - parts[2].height) / 2 + 300;\r\n\t bottomBg.y = parts[2].y;\r\n\t bottomBg.height = height - parts[2].y;\r\n\t var moon = new engine.Sprite(getTextureByName('moon'));\r\n\t moon.x = 100;\r\n\t moon.y = 100;\r\n\t this.addChild(moon);\r\n\t };\r\n\t Background.prototype.setViewport = function (pos) {\r\n\t for (var i = 0; i < 3; i++) {\r\n\t var part = this.getChildAt(i + 1);\r\n\t var speed = this.speeds[i];\r\n\t part.setViewport(pos * speed);\r\n\t }\r\n\t };\r\n\t Background.prototype.reset = function (revive) {\r\n\t };\r\n\t return Background;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=Background.js.map\n\n\tvar localWave = (function () {\r\n\t function localWave() {\r\n\t this._oldProperties = {};\r\n\t this._t = 0;\r\n\t }\r\n\t localWave.prototype.init = function (target, duration, calProps, loop, autoPlay, reverse, delay, offset) {\r\n\t if (calProps === void 0) { calProps = null; }\r\n\t if (loop === void 0) { loop = 0; }\r\n\t if (autoPlay === void 0) { autoPlay = true; }\r\n\t if (reverse === void 0) { reverse = false; }\r\n\t if (delay === void 0) { delay = 0; }\r\n\t if (offset === void 0) { offset = 0; }\r\n\t this.target = target;\r\n\t this._calProps = calProps ? calProps : localWave.round;\r\n\t this.duration = duration;\r\n\t this.loop = loop;\r\n\t this.reverse = reverse;\r\n\t this.delay = delay;\r\n\t this.offset = offset;\r\n\t this.updateRegisterPos();\r\n\t if (autoPlay) {\r\n\t this.play();\r\n\t }\r\n\t };\r\n\t localWave.prototype.updateRegisterPos = function () {\r\n\t this._oldProperties.x = this.target.x;\r\n\t this._oldProperties.y = this.target.y;\r\n\t this._oldProperties.scaleX = this.target.scaleX;\r\n\t this._oldProperties.scaleY = this.target.scaleY;\r\n\t this._oldProperties.skewX = this.target.skewX;\r\n\t this._oldProperties.skewY = this.target.skewY;\r\n\t this._oldProperties.rotation = this.target.rotation;\r\n\t this._oldProperties.alpha = this.target.alpha;\r\n\t };\r\n\t localWave.prototype.play = function () {\r\n\t if (this._tween) {\r\n\t return this._tween;\r\n\t }\r\n\t this._count = 0;\r\n\t return this._playStep();\r\n\t };\r\n\t localWave.prototype._playStep = function () {\r\n\t if (this.loop > 0 && this._count >= this.loop) {\r\n\t this.stop();\r\n\t return;\r\n\t }\r\n\t this._count++;\r\n\t this.t = this.reverse ? Math.PI * 2 : 0;\r\n\t this._tween = engine.Tween.get(this);\r\n\t this._tween.wait(this.delay).to({ t: this.reverse ? 0 : Math.PI * 2 }, this.duration).call(this._playStep, this);\r\n\t return this._tween;\r\n\t };\r\n\t Object.defineProperty(localWave.prototype, \"t\", {\r\n\t get: function () {\r\n\t return this._t;\r\n\t },\r\n\t set: function (value) {\r\n\t if (!this.target.stage) {\r\n\t return;\r\n\t }\r\n\t this._t = value;\r\n\t var props = this._calProps.call(this, this._t + this.offset);\r\n\t if (props.hasOwnProperty('x')) {\r\n\t this.target.x = (props.x || 0) + this._oldProperties.x;\r\n\t }\r\n\t if (props.hasOwnProperty('y')) {\r\n\t this.target.y = (props.y || 0) + this._oldProperties.y;\r\n\t }\r\n\t if (props.hasOwnProperty('sx')) {\r\n\t this.target.scaleX = props.sx;\r\n\t }\r\n\t if (props.hasOwnProperty('sy')) {\r\n\t this.target.scaleY = props.sy;\r\n\t }\r\n\t if (props.hasOwnProperty('skewX')) {\r\n\t this.target.skewX = props.skewX;\r\n\t }\r\n\t if (props.hasOwnProperty('skewY')) {\r\n\t this.target.skewY = props.skewY;\r\n\t }\r\n\t if (props.hasOwnProperty('r')) {\r\n\t this.target.rotation = props.r;\r\n\t }\r\n\t if (props.hasOwnProperty('alpha')) {\r\n\t this.target.alpha = props.alpha;\r\n\t }\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t localWave.prototype.stop = function (recovery, animation, duration) {\r\n\t if (recovery === void 0) { recovery = false; }\r\n\t if (duration === void 0) { duration = 1000; }\r\n\t if (!this._tween) {\r\n\t return;\r\n\t }\r\n\t engine.Tween.removeTweens(this);\r\n\t if (recovery) {\r\n\t engine.Tween.get(this.target).to(this._oldProperties, duration);\r\n\t }\r\n\t this._tween = null;\r\n\t };\r\n\t Object.defineProperty(localWave.prototype, \"playing\", {\r\n\t get: function () {\r\n\t return this._tween != null;\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t localWave.round = function (h, t) {\r\n\t return { x: Math.cos(t) * h, y: Math.sin(t) * h };\r\n\t };\r\n\t localWave.cos = function (h, t) {\r\n\t return { x: Math.cos(t) * h, y: 0 };\r\n\t };\r\n\t localWave.sin = function (h, t) {\r\n\t h = h || 1;\r\n\t return { x: 0, y: Math.sin(t) * h };\r\n\t };\r\n\t localWave.rotate = function (t) {\r\n\t return { r: 360 * t / Math.PI / 2 };\r\n\t };\r\n\t localWave.shake = function (angle, count, t) {\r\n\t return { r: Math.sin(t * count) * angle };\r\n\t };\r\n\t localWave.breath = function (scale, t) {\r\n\t return { sx: Math.sin(t) * scale + 1, sy: -Math.sin(t + Math.PI / 4) * scale + 1 };\r\n\t };\r\n\t localWave.zoom = function (scale, t) {\r\n\t scale = scale || 0.1;\r\n\t return { sx: Math.sin(t) * scale + 1, sy: Math.sin(t) * scale + 1 };\r\n\t };\r\n\t localWave.fade = function (base, t) {\r\n\t return { alpha: (Math.sin(t) + 1) * 0.5 + base };\r\n\t };\r\n\t return localWave;\r\n\t}());\r\n\t//# sourceMappingURL=localWave.js.map\n\n\tvar Block = (function (_super) {\r\n\t tslib.__extends(Block, _super);\r\n\t function Block() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.bmp = new engine.Sprite();\r\n\t _this.addChild(_this.bmp = new engine.Sprite());\r\n\t return _this;\r\n\t }\r\n\t Block.prototype.reset = function (_a) {\r\n\t var type = _a.type;\r\n\t this.type = type;\r\n\t var bmp = this.bmp;\r\n\t bmp.alpha = 1;\r\n\t bmp.texture = this.getBlock();\r\n\t var _b = Block.configs[type], width = _b.width, off = _b.off;\r\n\t bmp.x = -(off + width / 2);\r\n\t bmp.y = -(bmp.height / 2);\r\n\t };\r\n\t Block.prototype.getBlock = function () {\r\n\t return getTextureByName('block_' + this.type);\r\n\t };\r\n\t Block.prototype.playEffect = function () {\r\n\t };\r\n\t Block.prototype.playFadeOut = function () {\r\n\t return this.getTweenPromise(engine.Tween.get(this.bmp)\r\n\t .to({ alpha: 0 }, 100)\r\n\t .to({ alpha: 1 }, 100)\r\n\t .to({ alpha: 0 }, 100));\r\n\t };\r\n\t Block.prototype.onEffectComplete = function (event) {\r\n\t this.effectResolve && this.effectResolve();\r\n\t this.effectResolve = null;\r\n\t };\r\n\t Block.prototype.getTweenPromise = function (tween) {\r\n\t return new Promise(function (resolve) {\r\n\t tween.call(resolve);\r\n\t });\r\n\t };\r\n\t Block.configs = [\r\n\t { ratio: 0.6, width: 15, off: 32, effect: '', effect_offset: { x: 0, y: 0 } },\r\n\t { ratio: 0.1, width: 10, off: 18, effect: '', effect_offset: { x: 0, y: 0 } },\r\n\t { ratio: 0.15, width: 30, off: 32, effect: '', effect_offset: { x: 0, y: 0 } },\r\n\t { ratio: 0.1, width: 86, off: 28, effect: '', effect_offset: { x: 0, y: 0 } },\r\n\t { ratio: 0.5, width: 70, off: 20, effect: '', effect_offset: { x: 0, y: -20 } },\r\n\t { ratio: 0, width: 0, off: 0, effect: '', effect_offset: { x: 0, y: 0 } },\r\n\t { ratio: 0, width: 0, off: 0, effect: '', effect_offset: { x: 0, y: 0 } },\r\n\t { ratio: 0, width: 0, off: 0, effect: '', effect_offset: { x: 0, y: 0 } },\r\n\t { ratio: 0, width: 0, off: 0, effect: '', effect_offset: { x: 0, y: 0 } },\r\n\t { ratio: 0, width: 0, off: 0, effect: '', effect_offset: { x: 0, y: 0 } },\r\n\t { ratio: 0, width: 123, off: 23, effect: '', effect_offset: { x: 0, y: 0 } },\r\n\t ];\r\n\t return Block;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=Block.js.map\n\n\tvar ObjectPool = engine.ObjectPool;\r\n\tvar Road = (function (_super) {\r\n\t tslib.__extends(Road, _super);\r\n\t function Road() {\r\n\t var _this = _super !== null && _super.apply(this, arguments) || this;\r\n\t _this.dustIndex = 0;\r\n\t _this.index = 0;\r\n\t _this.minDistance = parseInt(props.blockMinDistance) || 100;\r\n\t _this.maxDistance = parseInt(props.blockMaxDistance) || 300;\r\n\t _this.basePos = getStage().width / 2 - 100;\r\n\t _this.padding = 500;\r\n\t return _this;\r\n\t }\r\n\t Road.prototype.preSetup = function () {\r\n\t this.addChild(this.container = new engine.Container());\r\n\t var flag = this.flag = new engine.Sprite(getTextureByName('flag_record'));\r\n\t this.anchorRate(flag, 0.5, 1);\r\n\t flag.y = -230;\r\n\t flag.x = this.transScoreToFlagPos();\r\n\t flag.visible = flag.x > 0;\r\n\t this.addChild(flag);\r\n\t };\r\n\t Road.prototype.setup = function () {\r\n\t this.dustNode = new engine.Container();\r\n\t this.dustSprite = new engine.Sprite();\r\n\t this.dustSprite.visible = false;\r\n\t this.dustNode.y = -1000;\r\n\t this.dustNode.x = -450;\r\n\t this.dustNode.addChild(this.dustSprite);\r\n\t this.addChild(this.dustNode);\r\n\t var reward = this.reward = new engine.Sprite();\r\n\t reward.visible = false;\r\n\t reward.y = -500;\r\n\t this.addChild(reward);\r\n\t this.aniReward = new localWave();\r\n\t this.aniReward.init(reward, 2000, localWave.sin.bind(null, 10));\r\n\t };\r\n\t Road.prototype.start = function (revive) {\r\n\t if (revive === void 0) { revive = false; }\r\n\t if (revive) ;\r\n\t else {\r\n\t this.rewardIndex = 0;\r\n\t this.showReward();\r\n\t }\r\n\t };\r\n\t Road.prototype.reset = function (revive) {\r\n\t if (revive === void 0) { revive = false; }\r\n\t if (!revive) {\r\n\t this.index = 0;\r\n\t this.lastPos = 0;\r\n\t this.clear();\r\n\t this.fill();\r\n\t this.flag.x = this.transScoreToFlagPos();\r\n\t this.flag.visible = this.flag.x > 0;\r\n\t }\r\n\t };\r\n\t Road.prototype.anchorRate = function (target, rx, ry, width, height, resetPos) {\r\n\t if (width === void 0) { width = 0; }\r\n\t if (height === void 0) { height = 0; }\r\n\t if (resetPos === void 0) { resetPos = true; }\r\n\t if (width == 0) {\r\n\t width = target.width;\r\n\t }\r\n\t if (height == 0) {\r\n\t height = target.height;\r\n\t }\r\n\t if (resetPos) {\r\n\t if (rx == 0) {\r\n\t target.x -= target.anchorOffsetX;\r\n\t }\r\n\t if (ry == 0) {\r\n\t target.y -= target.anchorOffsetY;\r\n\t }\r\n\t }\r\n\t target.anchorOffsetX = width * rx;\r\n\t target.anchorOffsetY = height * ry;\r\n\t if (resetPos) {\r\n\t if (rx > 0) {\r\n\t target.x += target.anchorOffsetX;\r\n\t }\r\n\t if (ry > 0) {\r\n\t target.y += target.anchorOffsetY;\r\n\t }\r\n\t }\r\n\t };\r\n\t Road.prototype.transScoreToFlagPos = function () {\r\n\t return -1;\r\n\t };\r\n\t Road.prototype.clear = function () {\r\n\t while (this.container.children.length > 0) {\r\n\t this.removeBlockAt(0);\r\n\t }\r\n\t };\r\n\t Road.prototype.addBlock = function () {\r\n\t var type = 0, v;\r\n\t if (this.index > 10) {\r\n\t do {\r\n\t var rv = Math.random();\r\n\t v = 0;\r\n\t for (var i = 0; i < 5; i++) {\r\n\t v += Block.configs[i].ratio;\r\n\t if (rv < v) {\r\n\t type = i;\r\n\t break;\r\n\t }\r\n\t }\r\n\t } while (this.lastBlockType == type);\r\n\t this.lastBlockType = type;\r\n\t }\r\n\t var block = ObjectPool.getObject('block', { type: type });\r\n\t var width = Block.configs[type].width;\r\n\t var distance = this.index == 0 ?\r\n\t this.maxDistance :\r\n\t this.makeRandomFloat(this.maxDistance, this.minDistance);\r\n\t var pos = this.lastPos + distance;\r\n\t block.x = pos;\r\n\t this.container.addChild(block);\r\n\t this.lastPos = pos + width;\r\n\t this.index++;\r\n\t };\r\n\t Road.prototype.removeBlockAt = function (index) {\r\n\t var block = this.container.removeChildAt(index);\r\n\t ObjectPool.recycleObject('block', block);\r\n\t };\r\n\t Road.prototype.removeBlock = function (block) {\r\n\t this.container.removeChild(block);\r\n\t ObjectPool.recycleObject('block', block);\r\n\t };\r\n\t Road.prototype.fill = function () {\r\n\t if (isNaN(this.lastPos)) {\r\n\t return;\r\n\t }\r\n\t while (true) {\r\n\t if (this.lastPos + this.x > getStage().width + this.padding) {\r\n\t break;\r\n\t }\r\n\t this.addBlock();\r\n\t }\r\n\t };\r\n\t Road.prototype.makeRandomFloat = function (max, min) {\r\n\t if (min === void 0) { min = 0; }\r\n\t return Math.random() * (max - min) + min;\r\n\t };\r\n\t Road.prototype.setViewport = function (pos) {\r\n\t this.x = this.basePos - pos;\r\n\t while (this.container.children.length > 0) {\r\n\t if (this.container.getChildAt(0).x >= pos - this.padding) {\r\n\t break;\r\n\t }\r\n\t this.removeBlockAt(0);\r\n\t }\r\n\t this.fill();\r\n\t };\r\n\t Road.prototype.showReward = function (type) {\r\n\t this.rewardIndex++;\r\n\t var pos = this.rewardIndex * getStage().width * 3;\r\n\t var reward = this.reward;\r\n\t reward.visible = true;\r\n\t reward.alpha = 1;\r\n\t reward.texture = getTextureByName('menu_block_10');\r\n\t reward.x = pos;\r\n\t this.aniReward.updateRegisterPos();\r\n\t };\r\n\t Road.prototype.hideReward = function () {\r\n\t var _this = this;\r\n\t var reward = this.reward;\r\n\t this.tweenReward = engine.Tween.get(reward)\r\n\t .to({ alpha: 0 }, 200)\r\n\t .call(function () {\r\n\t _this.tweenReward = null;\r\n\t _this.showReward();\r\n\t });\r\n\t };\r\n\t Road.prototype.hitReward = function (pos) {\r\n\t if (this.reward.visible && pos >= this.reward.x && !this.tweenReward) {\r\n\t this.hideReward();\r\n\t return true;\r\n\t }\r\n\t };\r\n\t Road.prototype.playDust = function (pos) {\r\n\t this.dustSprite.x = pos;\r\n\t this.dustSprite.visible = true;\r\n\t this.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);\r\n\t };\r\n\t Road.prototype.onEnterFrame = function () {\r\n\t if (this.dustIndex < 12) {\r\n\t this.dustSprite.texture = getTextureByName('dust_' + this.dustIndex);\r\n\t this.dustIndex++;\r\n\t }\r\n\t else {\r\n\t this.dustIndex = 0;\r\n\t this.dustSprite.visible = false;\r\n\t this.removeEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);\r\n\t }\r\n\t };\r\n\t Road.prototype.hitBlock = function (pos) {\r\n\t var _this = this;\r\n\t var target, lastTarget;\r\n\t var foot = { a: pos - 84 / 2, b: pos + 84 / 2 };\r\n\t this.container.children.some(function (block, i) {\r\n\t var width = Block.configs[block.type].width;\r\n\t var line = { a: block.x - width / 2, b: block.x + width / 2 };\r\n\t if (_this.lineHitTest(foot, line)) {\r\n\t target = block;\r\n\t return true;\r\n\t }\r\n\t });\r\n\t if (!target) {\r\n\t for (var i = this.container.children.length; i > 0; i--) {\r\n\t var block = this.container.getChildAt(i - 1);\r\n\t if (block.x < pos) {\r\n\t lastTarget = block;\r\n\t break;\r\n\t }\r\n\t }\r\n\t }\r\n\t return {\r\n\t target: target,\r\n\t lastTarget: lastTarget,\r\n\t };\r\n\t };\r\n\t Road.prototype.lineHitTest = function (l0, l1) {\r\n\t return l0.a < l1.b && l0.b > l1.a;\r\n\t };\r\n\t return Road;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=Road.js.map\n\n\tvar factor = 10;\r\n\tvar Head = (function (_super) {\r\n\t tslib.__extends(Head, _super);\r\n\t function Head() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.imgFace = new engine.Sprite(getTextureByName('head_0'));\r\n\t _this.addChild(_this.imgFace);\r\n\t _this.imgFace.anchorTexture.set(107 / _this.imgFace.width, 155 / _this.imgFace.height);\r\n\t _this.imgFace.y = 65;\r\n\t _this._headType = '';\r\n\t return _this;\r\n\t }\r\n\t Head.prototype.localUpdate = function (x, y, rotation, sleeping) {\r\n\t this.x = x;\r\n\t this.y = y;\r\n\t this.rotation = rotation;\r\n\t };\r\n\t Object.defineProperty(Head.prototype, \"fWidth\", {\r\n\t get: function () {\r\n\t return this.width / factor;\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t Object.defineProperty(Head.prototype, \"fHeight\", {\r\n\t get: function () {\r\n\t return this.height / factor;\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t Head.prototype.switchFace = function (type, playAni) {\r\n\t if (type == this._headType) {\r\n\t return;\r\n\t }\r\n\t var headName = '';\r\n\t if (type == 'normal') {\r\n\t headName = 'head_0';\r\n\t }\r\n\t else if (type == 'happy') {\r\n\t headName = 'head_1';\r\n\t }\r\n\t else if (type == 1 || type == 0 || type == 2) {\r\n\t headName = 'head_2';\r\n\t }\r\n\t else if (type == 3) {\r\n\t headName = 'head_3';\r\n\t }\r\n\t else if (type == 4) {\r\n\t headName = 'head_4';\r\n\t }\r\n\t this._headType = type;\r\n\t this.imgFace.texture = getTextureByName(headName);\r\n\t };\r\n\t return Head;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=Head.js.map\n\n\tvar PlayerPart = (function (_super) {\r\n\t tslib.__extends(PlayerPart, _super);\r\n\t function PlayerPart(name) {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.changeRes(name);\r\n\t return _this;\r\n\t }\r\n\t PlayerPart.prototype.changeRes = function (name) {\r\n\t this.name = name;\r\n\t this.texture = getTextureByName('body_normal_' + name);\r\n\t };\r\n\t PlayerPart.prototype.setSkin = function (name) {\r\n\t this.texture = getTextureByName('body_' + name + '_' + this.name);\r\n\t };\r\n\t PlayerPart.prototype.localUpdate = function (x, y, rotation, sleeping) {\r\n\t this.x = x;\r\n\t this.y = y;\r\n\t this.rotation = rotation;\r\n\t };\r\n\t Object.defineProperty(PlayerPart.prototype, \"fSize\", {\r\n\t get: function () {\r\n\t return { width: this.fWidth, height: this.fHeight };\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t Object.defineProperty(PlayerPart.prototype, \"fWidth\", {\r\n\t get: function () {\r\n\t return this.width / getfactor();\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t Object.defineProperty(PlayerPart.prototype, \"fHeight\", {\r\n\t get: function () {\r\n\t return this.height / getfactor();\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t PlayerPart.prototype.reset = function () {\r\n\t };\r\n\t return PlayerPart;\r\n\t}(engine.Sprite));\r\n\t//# sourceMappingURL=PlayerPart.js.map\n\n\tvar PlayerStat;\r\n\t(function (PlayerStat) {\r\n\t PlayerStat[PlayerStat[\"RELEASE\"] = 0] = \"RELEASE\";\r\n\t PlayerStat[PlayerStat[\"RISING\"] = 1] = \"RISING\";\r\n\t PlayerStat[PlayerStat[\"FALL\"] = 2] = \"FALL\";\r\n\t})(PlayerStat || (PlayerStat = {}));\r\n\tvar Player = (function (_super) {\r\n\t tslib.__extends(Player, _super);\r\n\t function Player() {\r\n\t var _this = _super !== null && _super.apply(this, arguments) || this;\r\n\t _this.partMass = 0.1;\r\n\t _this.footMass = 0.1;\r\n\t _this.shouldersDistance = 50 / getfactor();\r\n\t _this.speed = 30;\r\n\t _this.skin = '';\r\n\t _this.originPos = {};\r\n\t _this.safePos = 0;\r\n\t _this.onPostStep = function (e) {\r\n\t var side = _this.currentSide;\r\n\t var footHang = _this.foots[_this.currentSide];\r\n\t var footFall = _this.foots[_this.anotherSide];\r\n\t switch (_this.state) {\r\n\t case PlayerStat.FALL:\r\n\t break;\r\n\t case PlayerStat.RISING:\r\n\t var footOffset = footHang.position[0] - footFall.position[0];\r\n\t var speed = _this.speed;\r\n\t _this.upperLegs[side].angularVelocity = 10;\r\n\t _this.upperLegs[side].velocity = [\r\n\t footOffset < 0 ? speed - 10 : speed,\r\n\t 0\r\n\t ];\r\n\t _this.lowerLegs[side].velocity = [\r\n\t footOffset < 0 ? speed - 10 : speed,\r\n\t footOffset < 0 ? 3 : 2\r\n\t ];\r\n\t _this.head.velocity = [speed * 0.5, 20];\r\n\t _this.dispatchEvent('move', {\r\n\t pos: (_this.leftFoot.position[0] + _this.rightFoot.position[0]) / 2 * getfactor(),\r\n\t bodyPos: _this.body.position[0] * getfactor(),\r\n\t }, true);\r\n\t if (footOffset > 50) {\r\n\t _this.up();\r\n\t }\r\n\t break;\r\n\t case PlayerStat.RELEASE:\r\n\t _this.head.velocity = [0, 30];\r\n\t break;\r\n\t }\r\n\t };\r\n\t _this.onFootDown = function () {\r\n\t var pos = _this.foots[_this.currentSide].position[0] * getfactor();\r\n\t var mileage = Math.max(_this.foots[0].position[0], _this.foots[1].position[0]) * getfactor();\r\n\t _this.safePos = _this.foots[_this.currentSide].position[0];\r\n\t _this.dispatchEvent('foot_down', {\r\n\t mileage: mileage,\r\n\t pos: pos,\r\n\t }, true);\r\n\t };\r\n\t return _this;\r\n\t }\r\n\t Player.prototype.setup = function (options) {\r\n\t var collisionGroup = options.collisionGroup, collisionMask = options.collisionMask, world = options.world, ground = options.ground;\r\n\t this.world = world;\r\n\t world.on('postStep', this.onPostStep);\r\n\t var bodyPartShapes = [];\r\n\t var leftFootDisplay = this.createDisplay('foot');\r\n\t var lowerLeftLegDisplay = this.createDisplay('lower_left_leg');\r\n\t var upperLeftLegDisplay = this.createDisplay('upper_left_leg');\r\n\t var rightFootDisplay = this.createDisplay('foot');\r\n\t var lowerRightLegDisplay = this.createDisplay('lower_right_leg');\r\n\t var upperRightLegDisplay = this.createDisplay('upper_right_leg');\r\n\t var bodyDisplay = this.createDisplay('body', { x: 50, y: 0 });\r\n\t var headDisplay = new Head();\r\n\t var upperLeftArmDisplay = this.createDisplay('upper_left_arm');\r\n\t var lowerLeftArmDisplay = this.createDisplay('lower_left_arm', { x: -20, y: 0 });\r\n\t var upperRightArmDisplay = this.createDisplay('upper_right_arm');\r\n\t var lowerRightArmDisplay = this.createDisplay('lower_right_arm', { x: -39, y: 0 });\r\n\t var leftFootShape = new p2.Box(leftFootDisplay.fSize);\r\n\t bodyPartShapes.push(leftFootShape);\r\n\t this.originPos['leftFoot'] = [\r\n\t -this.shouldersDistance / 2,\r\n\t leftFootDisplay.fHeight / 2\r\n\t ];\r\n\t var leftFoot = this.leftFoot = new p2.Body({\r\n\t allowSleep: false,\r\n\t mass: this.footMass,\r\n\t position: this.originPos['leftFoot'],\r\n\t });\r\n\t leftFoot.displays = [leftFootDisplay];\r\n\t leftFoot.addShape(leftFootShape);\r\n\t var lowerLeftLegShape = new p2.Box(lowerLeftLegDisplay.fSize);\r\n\t bodyPartShapes.push(lowerLeftLegShape);\r\n\t this.originPos['lowerLeftLeg'] = [\r\n\t -this.shouldersDistance / 2,\r\n\t leftFoot.position[1] + lowerLeftLegDisplay.fHeight / 2 + 5 / getfactor()\r\n\t ];\r\n\t var lowerLeftLeg = this.lowerLeftLeg = new p2.Body({\r\n\t allowSleep: false,\r\n\t mass: this.partMass,\r\n\t position: this.originPos['lowerLeftLeg'],\r\n\t });\r\n\t lowerLeftLeg.displays = [lowerLeftLegDisplay];\r\n\t lowerLeftLeg.addShape(lowerLeftLegShape);\r\n\t var leftAnkleJoint = new p2.RevoluteConstraint(lowerLeftLeg, leftFoot, {\r\n\t localPivotA: [0, -lowerLeftLegDisplay.fHeight / 2 + 5 / getfactor()],\r\n\t localPivotB: [-leftFootDisplay.fWidth / 2 + 18 / getfactor(), 0],\r\n\t });\r\n\t leftAnkleJoint.setLimits(-Math.PI / 3, Math.PI / 3);\r\n\t var leftFootGroundCons = this.leftFootGroundCons = new p2.RevoluteConstraint(leftFoot, ground, {\r\n\t localPivotA: [0, -leftFootDisplay.fHeight / 2],\r\n\t localPivotB: [leftFoot.position[0], 0],\r\n\t });\r\n\t leftFootGroundCons.setLimits(0, 0);\r\n\t var upperLeftLegShape = new p2.Box(upperLeftLegDisplay.fSize);\r\n\t bodyPartShapes.push(upperLeftLegShape);\r\n\t this.originPos['upperLeftLeg'] = [\r\n\t -this.shouldersDistance / 2,\r\n\t lowerLeftLeg.position[1] + lowerLeftLegDisplay.fHeight / 2 + upperLeftLegDisplay.fHeight / 2 - 40 / getfactor()\r\n\t ];\r\n\t var upperLeftLeg = this.upperLeftLeg = new p2.Body({\r\n\t allowSleep: false,\r\n\t mass: this.partMass,\r\n\t position: this.originPos['upperLeftLeg'],\r\n\t });\r\n\t upperLeftLeg.displays = [upperLeftLegDisplay];\r\n\t upperLeftLeg.addShape(upperLeftLegShape);\r\n\t var leftKneeJoint = new p2.RevoluteConstraint(upperLeftLeg, lowerLeftLeg, {\r\n\t localPivotA: [0, -upperLeftLegDisplay.fHeight / 2 + 20 / getfactor()],\r\n\t localPivotB: [0, lowerLeftLegDisplay.fHeight / 2 - 20 / getfactor()],\r\n\t });\r\n\t leftKneeJoint.setLimits(-Math.PI, 0);\r\n\t var rightFootShape = new p2.Box(rightFootDisplay.fSize);\r\n\t bodyPartShapes.push(rightFootShape);\r\n\t this.originPos['rightFoot'] = [\r\n\t this.shouldersDistance / 2,\r\n\t rightFootDisplay.fHeight / 2\r\n\t ];\r\n\t var rightFoot = this.rightFoot = new p2.Body({\r\n\t allowSleep: false,\r\n\t mass: this.footMass,\r\n\t position: this.originPos['rightFoot'],\r\n\t });\r\n\t rightFoot.displays = [rightFootDisplay];\r\n\t rightFoot.addShape(rightFootShape);\r\n\t var lowerRightLegShape = new p2.Box(lowerRightLegDisplay.fSize);\r\n\t bodyPartShapes.push(lowerRightLegShape);\r\n\t this.originPos['lowerRightLeg'] = [\r\n\t this.shouldersDistance / 2,\r\n\t rightFoot.position[1] + lowerRightLegDisplay.fHeight / 2 + 5 / getfactor()\r\n\t ];\r\n\t var lowerRightLeg = this.lowerRightLeg = new p2.Body({\r\n\t allowSleep: false,\r\n\t mass: this.partMass,\r\n\t position: this.originPos['lowerRightLeg'],\r\n\t });\r\n\t lowerRightLeg.displays = [lowerRightLegDisplay];\r\n\t lowerRightLeg.addShape(lowerRightLegShape);\r\n\t var rightAnkleJoint = new p2.RevoluteConstraint(lowerRightLeg, rightFoot, {\r\n\t localPivotA: [0, -lowerRightLegDisplay.fHeight / 2 + 5 / getfactor()],\r\n\t localPivotB: [-rightFootDisplay.fWidth / 2 + 18 / getfactor(), 0],\r\n\t });\r\n\t rightAnkleJoint.setLimits(-Math.PI / 3, Math.PI / 3);\r\n\t var rightFootGroundCons = this.rightFootGroundCons = new p2.RevoluteConstraint(rightFoot, ground, {\r\n\t localPivotA: [0, -rightFootDisplay.fHeight / 2],\r\n\t localPivotB: [rightFoot.position[0], 0],\r\n\t });\r\n\t rightFootGroundCons.setLimits(0, 0);\r\n\t var upperRightLegShape = new p2.Box(upperRightLegDisplay.fSize);\r\n\t bodyPartShapes.push(upperRightLegShape);\r\n\t this.originPos['upperRightLeg'] = [\r\n\t this.shouldersDistance / 2,\r\n\t lowerRightLeg.position[1] + lowerRightLegDisplay.fHeight / 2 + upperRightLegDisplay.fHeight / 2 - 40 / getfactor()\r\n\t ];\r\n\t var upperRightLeg = this.upperRightLeg = new p2.Body({\r\n\t allowSleep: false,\r\n\t mass: this.partMass,\r\n\t position: this.originPos['upperRightLeg'],\r\n\t });\r\n\t upperRightLeg.displays = [upperRightLegDisplay];\r\n\t upperRightLeg.addShape(upperRightLegShape);\r\n\t var rightKneeJoint = new p2.RevoluteConstraint(upperRightLeg, lowerRightLeg, {\r\n\t localPivotA: [0, -upperRightLegDisplay.fHeight / 2 + 20 / getfactor()],\r\n\t localPivotB: [0, lowerRightLegDisplay.fHeight / 2 - 20 / getfactor()],\r\n\t });\r\n\t rightKneeJoint.setLimits(-Math.PI, 0);\r\n\t var bodyWidth = 120 / getfactor();\r\n\t var bodyHeight = 250 / getfactor();\r\n\t var bodyShape = new p2.Box({ width: bodyWidth, height: bodyHeight });\r\n\t bodyPartShapes.push(bodyShape);\r\n\t this.originPos['body'] = [\r\n\t 0,\r\n\t upperRightLeg.position[1] + upperRightLegDisplay.fHeight / 2 + bodyHeight / 2 - 60 / getfactor()\r\n\t ];\r\n\t var body = this.body = new p2.Body({\r\n\t allowSleep: false,\r\n\t mass: this.partMass,\r\n\t position: this.originPos['body'],\r\n\t });\r\n\t body.displays = [bodyDisplay];\r\n\t body.addShape(bodyShape);\r\n\t var leftHipJoint = new p2.RevoluteConstraint(body, upperLeftLeg, {\r\n\t localPivotA: [-20 / getfactor(), -bodyHeight / 2 + 30 / getfactor()],\r\n\t localPivotB: [0, upperLeftLegDisplay.fHeight / 2 - 30 / getfactor()],\r\n\t });\r\n\t leftHipJoint.setLimits(-Math.PI / 6 * 2, Math.PI / 6 * 2);\r\n\t var rightHipJoint = new p2.RevoluteConstraint(body, upperRightLeg, {\r\n\t localPivotA: [-20 / getfactor(), -bodyHeight / 2 + 30 / getfactor()],\r\n\t localPivotB: [0, upperRightLegDisplay.fHeight / 2 - 30 / getfactor()],\r\n\t });\r\n\t rightHipJoint.setLimits(-Math.PI / 6 * 2, Math.PI / 6 * 2);\r\n\t var headShape = new p2.Circle({ radius: 85 / getfactor() });\r\n\t bodyPartShapes.push(headShape);\r\n\t this.originPos['head'] = [\r\n\t 0,\r\n\t body.position[1] + bodyHeight / 2 + 85 / getfactor()\r\n\t ];\r\n\t var head = this.head = new p2.Body({\r\n\t allowSleep: false,\r\n\t mass: this.partMass,\r\n\t position: this.originPos['head'],\r\n\t });\r\n\t head.addShape(headShape);\r\n\t head.displays = [headDisplay];\r\n\t var headJoint = new p2.RevoluteConstraint(body, head, {\r\n\t localPivotA: [0, bodyHeight / 2 - 10 / getfactor()],\r\n\t localPivotB: [0, (-85 + 10) / getfactor()],\r\n\t });\r\n\t headJoint.setLimits(-Math.PI / 6 * 2, Math.PI / 6 * 2);\r\n\t var upperLeftArmShape = new p2.Box(upperLeftArmDisplay.fSize);\r\n\t bodyPartShapes.push(upperLeftArmShape);\r\n\t this.originPos['upperLeftArm'] = [\r\n\t -this.shouldersDistance / 2 - 10 / getfactor(),\r\n\t body.position[1] + bodyHeight / 2 - upperLeftArmDisplay.fHeight / 2\r\n\t ];\r\n\t var upperLeftArm = this.upperLeftArm = new p2.Body({\r\n\t allowSleep: false,\r\n\t mass: this.partMass,\r\n\t position: this.originPos['upperLeftArm'],\r\n\t });\r\n\t upperLeftArm.displays = [upperLeftArmDisplay];\r\n\t upperLeftArm.addShape(upperLeftArmShape);\r\n\t var leftShoulderJoint = new p2.RevoluteConstraint(body, upperLeftArm, {\r\n\t localPivotA: [-this.shouldersDistance / 2 + 10 / getfactor(), bodyHeight / 2],\r\n\t localPivotB: [0, upperLeftArmDisplay.fHeight / 2],\r\n\t });\r\n\t leftShoulderJoint.setLimits(-Math.PI / 2, 0);\r\n\t var width = 50 / getfactor();\r\n\t var lowerLeftArmShape = new p2.Box({ width: width, height: lowerLeftArmDisplay.fHeight });\r\n\t bodyPartShapes.push(lowerLeftArmShape);\r\n\t this.originPos['lowerLeftArm'] = [\r\n\t -this.shouldersDistance / 2 - 10 / getfactor() + 10 / getfactor(),\r\n\t upperLeftArm.position[1] - upperLeftArmDisplay.fHeight / 2 - lowerLeftArmDisplay.fHeight / 2 + 20 / getfactor()\r\n\t ];\r\n\t var lowerLeftArm = this.lowerLeftArm = new p2.Body({\r\n\t allowSleep: false,\r\n\t mass: this.partMass,\r\n\t position: this.originPos['lowerLeftArm'],\r\n\t });\r\n\t lowerLeftArm.displays = [lowerLeftArmDisplay];\r\n\t lowerLeftArm.addShape(lowerLeftArmShape);\r\n\t var leftElbowJoint = new p2.RevoluteConstraint(upperLeftArm, lowerLeftArm, {\r\n\t localPivotA: [0, -upperLeftArmDisplay.fHeight / 2 + 10 / getfactor()],\r\n\t localPivotB: [-10 / getfactor(), lowerLeftLegDisplay.fHeight / 2 - 10 / getfactor()],\r\n\t });\r\n\t leftElbowJoint.setLimits(0, Math.PI * 2 / 3);\r\n\t var upperRightArmShape = new p2.Box(upperRightArmDisplay.fSize);\r\n\t bodyPartShapes.push(upperRightArmShape);\r\n\t this.originPos['upperRightArm'] = [\r\n\t this.shouldersDistance / 2,\r\n\t body.position[1] + bodyHeight / 2 - upperRightArmDisplay.fHeight / 2\r\n\t ];\r\n\t var upperRightArm = this.upperRightArm = new p2.Body({\r\n\t allowSleep: false,\r\n\t mass: this.partMass,\r\n\t position: this.originPos['upperRightArm'],\r\n\t });\r\n\t upperRightArm.displays = [upperRightArmDisplay];\r\n\t upperRightArm.addShape(upperRightArmShape);\r\n\t var rightShoulderJoint = new p2.RevoluteConstraint(body, upperRightArm, {\r\n\t localPivotA: [this.shouldersDistance / 2 + 10 / getfactor(), bodyHeight / 2],\r\n\t localPivotB: [0, upperRightArmDisplay.fHeight / 2],\r\n\t });\r\n\t rightShoulderJoint.setLimits(-Math.PI / 2, 0);\r\n\t var width = 30 / getfactor();\r\n\t var lowerRightArmShape = new p2.Box({ width: width, height: lowerRightArmDisplay.fHeight });\r\n\t bodyPartShapes.push(lowerRightArmShape);\r\n\t this.originPos['lowerRightArm'] = [\r\n\t this.shouldersDistance / 2,\r\n\t upperRightArm.position[1] - upperRightArmDisplay.fHeight / 2 - lowerRightArmDisplay.fHeight / 2 + 40 / getfactor()\r\n\t ];\r\n\t var lowerRightArm = this.lowerRightArm = new p2.Body({\r\n\t allowSleep: false,\r\n\t mass: this.partMass,\r\n\t position: this.originPos['lowerRightArm'],\r\n\t });\r\n\t lowerRightArm.displays = [lowerRightArmDisplay];\r\n\t lowerRightArm.addShape(lowerRightArmShape);\r\n\t var rightElbowJoint = new p2.RevoluteConstraint(upperRightArm, lowerRightArm, {\r\n\t localPivotA: [0, -upperRightArmDisplay.fHeight / 2 + 20 / getfactor()],\r\n\t localPivotB: [0, lowerRightLegDisplay.fHeight / 2 - 20 / getfactor()],\r\n\t });\r\n\t rightElbowJoint.setLimits(0, Math.PI * 2 / 3);\r\n\t var bodies = [\r\n\t lowerRightArm, upperRightArm,\r\n\t lowerRightLeg, upperRightLeg, rightFoot,\r\n\t body,\r\n\t lowerLeftLeg, upperLeftLeg, leftFoot,\r\n\t lowerLeftArm, upperLeftArm,\r\n\t head,\r\n\t ];\r\n\t bodies.forEach(function (body) {\r\n\t world.addBody(body);\r\n\t });\r\n\t var joints = [\r\n\t leftAnkleJoint,\r\n\t leftKneeJoint,\r\n\t rightAnkleJoint,\r\n\t rightKneeJoint,\r\n\t headJoint,\r\n\t leftHipJoint,\r\n\t rightHipJoint,\r\n\t leftShoulderJoint,\r\n\t leftElbowJoint,\r\n\t rightShoulderJoint,\r\n\t rightElbowJoint,\r\n\t leftFootGroundCons,\r\n\t rightFootGroundCons,\r\n\t ];\r\n\t joints.forEach(function (joint) {\r\n\t world.addConstraint(joint);\r\n\t });\r\n\t for (var i = 0; i < bodyPartShapes.length; i++) {\r\n\t var s = bodyPartShapes[i];\r\n\t s.collisionGroup = collisionGroup;\r\n\t s.collisionMask = collisionMask;\r\n\t }\r\n\t this.foots = [leftFoot, rightFoot];\r\n\t this.lowerLegs = [lowerLeftLeg, lowerRightLeg];\r\n\t this.upperLegs = [upperLeftLeg, upperRightLeg];\r\n\t this.footGroundCons = [leftFootGroundCons, rightFootGroundCons];\r\n\t };\r\n\t Player.prototype.reset = function (revive) {\r\n\t var _this = this;\r\n\t if (revive === void 0) { revive = false; }\r\n\t if (revive) ;\r\n\t else {\r\n\t this.step = -1;\r\n\t this.safePos = 0;\r\n\t [\r\n\t 'lowerLeftLeg',\r\n\t 'upperLeftLeg',\r\n\t 'lowerRightLeg',\r\n\t 'upperRightLeg',\r\n\t 'body',\r\n\t 'head',\r\n\t 'upperLeftArm',\r\n\t 'lowerLeftArm',\r\n\t 'upperRightArm',\r\n\t 'lowerRightArm',\r\n\t ].forEach(function (partName) {\r\n\t var part = _this[partName];\r\n\t part.position[0] = _this.safePos + _this.originPos[partName][0];\r\n\t });\r\n\t }\r\n\t for (var i = 0; i < 2; i++) {\r\n\t var cons = this.footGroundCons[i];\r\n\t cons.pivotB[0] = this.foots[i].position[0] = this.safePos + (i == 0 ? -1 : 1) * this.shouldersDistance / 2;\r\n\t if (this.state == PlayerStat.FALL) {\r\n\t this.world.addConstraint(cons);\r\n\t }\r\n\t }\r\n\t this.switchFace('normal', false);\r\n\t this.setSkin('normal');\r\n\t this.state = PlayerStat.RELEASE;\r\n\t };\r\n\t Player.prototype.createDisplay = function (resName, offset) {\r\n\t if (offset === void 0) { offset = null; }\r\n\t var bmp = new PlayerPart(resName);\r\n\t var anchorX = bmp.width / 2 + (offset ? offset.x : 0);\r\n\t var anchorY = bmp.height / 2 + (offset ? offset.y : 0);\r\n\t bmp.anchorTexture.set(anchorX / bmp.width, anchorY / bmp.height);\r\n\t return bmp;\r\n\t };\r\n\t Object.defineProperty(Player.prototype, \"currentSide\", {\r\n\t get: function () {\r\n\t return this.step % 2;\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t Object.defineProperty(Player.prototype, \"anotherSide\", {\r\n\t get: function () {\r\n\t return (this.step + 1) % 2;\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t Player.prototype.down = function () {\r\n\t if (this.state == PlayerStat.RISING) {\r\n\t return;\r\n\t }\r\n\t this.step++;\r\n\t var cons = this.footGroundCons[this.currentSide];\r\n\t this.world.removeConstraint(cons);\r\n\t this.state = PlayerStat.RISING;\r\n\t };\r\n\t Player.prototype.up = function () {\r\n\t if (this.state == PlayerStat.RELEASE) {\r\n\t return;\r\n\t }\r\n\t var side = this.currentSide;\r\n\t this.foots[side].velocity = [0, 0];\r\n\t this.body.velocity = [0, 0];\r\n\t var currentFoot = this.foots[side];\r\n\t var cons = this.footGroundCons[side];\r\n\t cons.pivotB[0] = currentFoot.position[0];\r\n\t this.world.addConstraint(cons);\r\n\t this.state = PlayerStat.RELEASE;\r\n\t setTimeout(this.onFootDown, 200);\r\n\t };\r\n\t Player.prototype.fall = function () {\r\n\t this.body.velocity = [0, -30];\r\n\t this.head.velocity = [-50, -50];\r\n\t this.world.removeConstraint(this.footGroundCons[0]);\r\n\t this.world.removeConstraint(this.footGroundCons[1]);\r\n\t this.foots[this.currentSide].velocity[0] = 60;\r\n\t this.foots[this.anotherSide].velocity[0] = 70;\r\n\t this.state = PlayerStat.FALL;\r\n\t };\r\n\t Player.prototype.switchFace = function (type, playAni) {\r\n\t if (playAni === void 0) { playAni = true; }\r\n\t var headDisplay = this.head.displays[0];\r\n\t headDisplay.switchFace(type, playAni);\r\n\t };\r\n\t Player.prototype.setSkin = function (name) {\r\n\t var _this = this;\r\n\t if (this.skin == name) {\r\n\t return;\r\n\t }\r\n\t this.skin = name;\r\n\t [\r\n\t 'leftFoot',\r\n\t 'lowerLeftLeg',\r\n\t 'upperLeftLeg',\r\n\t 'rightFoot',\r\n\t 'lowerRightLeg',\r\n\t 'upperRightLeg',\r\n\t 'body',\r\n\t 'upperLeftArm',\r\n\t 'lowerLeftArm',\r\n\t 'upperRightArm',\r\n\t 'lowerRightArm',\r\n\t ].forEach(function (partName) {\r\n\t var part = _this[partName];\r\n\t part.displays[0].setSkin(name);\r\n\t });\r\n\t };\r\n\t Player.prototype.fade = function (alpha, animation) {\r\n\t var _this = this;\r\n\t if (animation === void 0) { animation = true; }\r\n\t [\r\n\t 'leftFoot',\r\n\t 'lowerLeftLeg',\r\n\t 'upperLeftLeg',\r\n\t 'rightFoot',\r\n\t 'lowerRightLeg',\r\n\t 'upperRightLeg',\r\n\t 'body',\r\n\t 'head',\r\n\t 'upperLeftArm',\r\n\t 'lowerLeftArm',\r\n\t 'upperRightArm',\r\n\t 'lowerRightArm',\r\n\t ].forEach(function (partName) {\r\n\t var display = _this[partName].displays[0];\r\n\t if (animation) {\r\n\t engine.Tween.get(display, null, null, true)\r\n\t .to({ alpha: alpha }, 200);\r\n\t }\r\n\t else {\r\n\t display.alpha = alpha;\r\n\t }\r\n\t });\r\n\t };\r\n\t return Player;\r\n\t}(engine.EventDispatcher));\r\n\t//# sourceMappingURL=Player.js.map\n\n\tvar ObjectPool$1 = engine.ObjectPool;\r\n\tvar PoolName = 'block';\r\n\tObjectPool$1.registerPool(PoolName, function () {\r\n\t return new Block();\r\n\t}, function (item, data) {\r\n\t item.reset(data);\r\n\t});\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.offset = { x: -100, y: 320 };\r\n\t _this.worldFPS = 60;\r\n\t _this._viewport = {\r\n\t x: 0,\r\n\t y: 0,\r\n\t };\r\n\t return _this;\r\n\t }\r\n\t Object.defineProperty(GameView, \"instance\", {\r\n\t get: function () {\r\n\t if (this._instance == undefined) {\r\n\t this._instance = new GameView();\r\n\t }\r\n\t return this._instance;\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t GameView.prototype.eventStart = function () {\r\n\t var _this = this;\r\n\t if (this.hasPreSetup) {\r\n\t return;\r\n\t }\r\n\t this.hasPreSetup = true;\r\n\t var background = this.background = new Background();\r\n\t background.setup();\r\n\t this.addChild(background);\r\n\t var road = this.road = new Road();\r\n\t road.y = getStage().height / 2 + 310;\r\n\t this.addChild(road);\r\n\t this.road.preSetup();\r\n\t this.setupWorld();\r\n\t this.player.fade(0, false);\r\n\t this.viewport = 0;\r\n\t this.startWorld();\r\n\t this.reset();\r\n\t this.setup();\r\n\t var playHint = new engine.Label();\r\n\t playHint.fillColor = 'block';\r\n\t playHint.size = 30;\r\n\t playHint.text = '注意不要踩到线和陷阱哦,后果很严重哦~';\r\n\t playHint.x = (getStage().width - playHint.width) / 2;\r\n\t playHint.y = getStage().height / 2 + 500;\r\n\t this.addChild(playHint);\r\n\t this.playGame = new PlayGame();\r\n\t setTimeout(function () {\r\n\t _this.playGame.GameView = _this;\r\n\t _this.addChild(_this.playGame);\r\n\t _this.start();\r\n\t }, 500);\r\n\t };\r\n\t GameView.prototype.setup = function () {\r\n\t if (this.hasSetup) {\r\n\t return;\r\n\t }\r\n\t this.hasSetup = true;\r\n\t this.road.setup();\r\n\t };\r\n\t GameView.prototype.setupWorld = function () {\r\n\t var OTHER = Math.pow(2, 1), BODYPARTS = Math.pow(2, 2), GROUND = Math.pow(2, 3);\r\n\t var world = this.world = new p2.World({});\r\n\t world.sleepMode = p2.World.BODY_SLEEPING;\r\n\t var planeShape = new p2.Plane();\r\n\t var ground = new p2.Body({\r\n\t position: [0, 0],\r\n\t });\r\n\t ground.addShape(planeShape);\r\n\t planeShape.collisionGroup = GROUND;\r\n\t planeShape.collisionMask = BODYPARTS | OTHER;\r\n\t world.addBody(ground);\r\n\t var player = this.player = new Player();\r\n\t player.setup({\r\n\t collisionGroup: BODYPARTS,\r\n\t collisionMask: GROUND | OTHER,\r\n\t world: world,\r\n\t ground: ground,\r\n\t });\r\n\t player.addEventListener('move', this.onMove, this);\r\n\t player.addEventListener('foot_down', this.onFootDown, this);\r\n\t };\r\n\t GameView.prototype.onTicker = function (dt) {\r\n\t var world = this.world;\r\n\t this.world.step(this.worldFPS / 1000);\r\n\t var l = world.bodies.length;\r\n\t for (var i = 0; i < l; i++) {\r\n\t var body = world.bodies[i];\r\n\t var display = body.displays ? body.displays[0] : null;\r\n\t if (display) {\r\n\t if (!this.contains(display)) {\r\n\t this.addChild(display);\r\n\t }\r\n\t display.localUpdate(body.position[0] * getfactor() + getStage().width / 2 + this.offset.x - this.viewport, getStage().height / 2 - body.position[1] * getfactor() + this.offset.y, 360 - (body.angle + body.shapes[0].angle) * 180 / Math.PI, body.sleepState == p2.Body.SLEEPING);\r\n\t }\r\n\t }\r\n\t return false;\r\n\t };\r\n\t GameView.prototype.reset = function (revive) {\r\n\t if (revive === void 0) { revive = false; }\r\n\t this.background.reset(revive);\r\n\t this.road.reset(revive);\r\n\t this.player.reset(revive);\r\n\t this.player.fade(0);\r\n\t this.viewport = revive ? this.revivePos : 0;\r\n\t };\r\n\t GameView.prototype.start = function (revive) {\r\n\t if (revive === void 0) { revive = false; }\r\n\t this.road.start(revive);\r\n\t this.player.fade(1);\r\n\t this.playGame.start(revive);\r\n\t };\r\n\t GameView.prototype.startWorld = function () {\r\n\t if (this.playing) {\r\n\t return;\r\n\t }\r\n\t this.playing = true;\r\n\t engine.gameStage.addEventListener(engine.Event.ENTER_FRAME, this.onTicker, this);\r\n\t };\r\n\t GameView.prototype.stopWorld = function () {\r\n\t if (!this.playing) {\r\n\t return;\r\n\t }\r\n\t this.playing = false;\r\n\t engine.gameStage.removeEventListener(engine.Event.ENTER_FRAME, this.onTicker, this);\r\n\t };\r\n\t Object.defineProperty(GameView.prototype, \"viewport\", {\r\n\t get: function () {\r\n\t return this._viewport.x;\r\n\t },\r\n\t set: function (v) {\r\n\t this._viewport.x = v;\r\n\t this.updateViewport();\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t GameView.prototype.updateViewport = function () {\r\n\t var _a = this._viewport, x = _a.x, y = _a.y;\r\n\t var pos = Math.max(0, x);\r\n\t this.background.setViewport(pos);\r\n\t this.road.setViewport(pos);\r\n\t };\r\n\t GameView.prototype.onMove = function (event) {\r\n\t var _a = event.data, pos = _a.pos, bodyPos = _a.bodyPos;\r\n\t this.viewport = pos;\r\n\t if (this.road.hitReward(bodyPos)) {\r\n\t this.dispatchEvent('scoreChange', {\r\n\t rewardScore: 100,\r\n\t passType: 10,\r\n\t }, true);\r\n\t }\r\n\t };\r\n\t GameView.prototype.down = function () {\r\n\t if (this.lock) {\r\n\t return;\r\n\t }\r\n\t this.player.down();\r\n\t };\r\n\t GameView.prototype.up = function () {\r\n\t if (this.lock) {\r\n\t return;\r\n\t }\r\n\t this.player.up();\r\n\t };\r\n\t GameView.prototype.onFootDown = function (event) {\r\n\t var _a = event.data, mileage = _a.mileage, pos = _a.pos;\r\n\t this.revivePos = pos;\r\n\t var _b = this.road.hitBlock(pos), target = _b.target, lastTarget = _b.lastTarget;\r\n\t this.road.playDust(pos);\r\n\t if (target) {\r\n\t this.lock = true;\r\n\t this.stopWorld();\r\n\t this.dispatchEvent(engine.Event.COMPLETE, null, true);\r\n\t target.playFadeOut();\r\n\t target.playEffect();\r\n\t if (target.type == 4) {\r\n\t this.player.setSkin('gray');\r\n\t }\r\n\t this.road.removeBlock(target);\r\n\t this.player.switchFace(target.type);\r\n\t if (target.type == 0) {\r\n\t this.player.fall();\r\n\t }\r\n\t this.lock = false;\r\n\t this.startWorld();\r\n\t }\r\n\t else {\r\n\t this.player.switchFace('normal');\r\n\t var score = Math.floor(mileage / 50 * 5);\r\n\t this.dispatchEvent('scoreChange', {\r\n\t score: score,\r\n\t passType: lastTarget ? lastTarget.type : -1,\r\n\t }, true);\r\n\t }\r\n\t };\r\n\t GameView.prototype.setWitchFace = function (type) {\r\n\t this.player.switchFace(type);\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('walking-cat-start', _this.start, _this);\r\n\t engine.globalEvent.addEventListener('walking-cat-revive', _this.revive, _this);\r\n\t engine.globalEvent.addEventListener('walking-cat-showScore', _this.revive, _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.eventStart();\r\n\t };\r\n\t GameWrapper.prototype.revive = function () {\r\n\t console.log('复活');\r\n\t this._gameView.reset(true);\r\n\t this._gameView.start(true);\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"
}
...@@ -407,6 +407,8 @@ var GameView = (function (_super) { ...@@ -407,6 +407,8 @@ var GameView = (function (_super) {
GameView.prototype.playShake = function () { GameView.prototype.playShake = function () {
var _this = this; var _this = this;
var _a = this.frontContainer, x = _a.x, y = _a.y; var _a = this.frontContainer, x = _a.x, y = _a.y;
let a = '';
a.substr
return new Promise(function (resolve) { return new Promise(function (resolve) {
var shakeOffset = 7; var shakeOffset = 7;
var duration = 30; var duration = 30;
......
/**
* Created by renjianfeng on 2020-03-13.
*/
const customId = "doll-machine";
(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,
}
}],
}, null, function () {
setTimeout(() => {
engine.addCustomModule(customId, engine.gameStage.sceneContainer.getChildAt(0));
}, 100);
setTimeout(() => {
engine.globalEvent.dispatchEvent('food-fell-reset', {
"goodsProbability": [0.8,0.1,0.1],
"countDown": 30,
"acceleratedSpeed":0.1
});
engine.globalEvent.dispatchEvent('food-fell-start');
}, 500);
});
engine.globalEvent.addEventListener('food-fell-time-update', (e) => {
console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('food-fell-score-update', (e) => {
console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('food-fell-game-over', (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: red;
}
</style>
</head>
<body>
<div id="game-container" style="line-height:0;font-size:0"></div>
<script crossorigin="anonymous" src="//yun.duiba.com.cn/editor/zeroing/libs/engine.50cdcef6ebe4e8c0fbc624f9d4fbf225102c5750.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/50a7212a113175fa18c866b005d98f07c558dc77.png",
"uuid": "66f23d13-82a5-4cec-9496-301ec240d087",
"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['doll-machine'] = factory(global.tslib));
}(this, (function (tslib) { 'use strict';
function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
var Goods = (function (_super) {
tslib.__extends(Goods, _super);
function Goods() {
var _this = _super.call(this) || this;
var body;
body = _this._body = new engine.Rect();
var box1 = new engine.Sprite(getTextureByName("草泥马盒"));
box1["npcType"] = "box1";
var box2 = new engine.Sprite(getTextureByName("狗盒"));
box2["npcType"] = "box2";
var box3 = new engine.Sprite(getTextureByName("猫盒"));
box3["npcType"] = "box3";
box1.visible = false;
box2.visible = false;
box3.visible = false;
body.addChild(box1);
body.addChild(box2);
body.addChild(box3);
_this.addChild(body);
body.width = 0.0001;
body.height = 0.0001;
body.mouseEnabled = false;
return _this;
}
Goods.prototype.getRandomNumberByRange = function (start, end) {
return Math.floor(Math.random() * (end - start) + start);
};
Goods.prototype.reset = function () {
this.visible = true;
this.y = 200;
this.x = 0;
this.rotation = 0;
var random = Math.random();
if (random < 0.3) {
this.showNpc("box1");
}
else if (random < 0.6) {
this.showNpc("box2");
}
else {
this.showNpc("box3");
}
};
Goods.prototype.showNpc = function (type) {
for (var i = 0; i < this._body.children.length; i++) {
this._body.children[i].visible = false;
this._body.children[i].mouseEnabled = false;
}
for (var i = 0; i < this._body.children.length; i++) {
if (this._body.children[i]["npcType"] == type) {
this["npcType"] = type;
console.log(type);
this._body.children[i].visible = true;
this._body.children[i].mouseEnabled = false;
}
}
};
Object.defineProperty(Goods.prototype, "anchorOffsetY", {
set: function (v) {
this._body.y = v;
},
enumerable: true,
configurable: true
});
return Goods;
}(engine.Container));
var ObjectPool = engine.ObjectPool;
var PoolName = 'goods';
ObjectPool.registerPool(PoolName, function () {
return new Goods();
}, function (item, data) {
item.reset();
});
var props = {};
function prepareProps() {
var metaProps = getProps();
engine.injectProp(props, metaProps);
}
function injectProps(p) {
engine.injectProp(props, p);
}
var FrontBoxs = (function (_super) {
tslib.__extends(FrontBoxs, _super);
function FrontBoxs() {
var _this = _super.call(this) || this;
_this.frontBoxs = [];
return _this;
}
FrontBoxs.prototype.setup = function () {
var initX, initY = 0;
this.box1 = new engine.Sprite(getTextureByName("狗盒"));
this.box1["npcType"] = "box1";
initX = this.box1.x = 435;
initY = this.box1.y = 614;
this.box2 = new engine.Sprite(getTextureByName("猫盒"));
this.box2["npcType"] = "box2";
this.box3 = new engine.Sprite(getTextureByName("草泥马盒"));
this.box3["npcType"] = "box3";
this.box4 = new engine.Sprite(getTextureByName("狗盒"));
this.box4["npcType"] = "box4";
this.box5 = new engine.Sprite(getTextureByName("猫盒"));
this.box5["npcType"] = "box5";
this.frontBoxs = [this.box1, this.box2, this.box3, this.box4];
for (var i = 0; i < this.frontBoxs.length; i++) {
if (i == 0) {
this.frontBoxs[i].x = initX;
}
else {
this.frontBoxs[i].x = this.frontBoxs[i - 1].x - this.box1.width - props.frontmargin;
}
this.frontBoxs[i].y = initY;
this.addChild(this.frontBoxs[i]);
}
this.addEventListener(engine.Event.ENTER_FRAME, this.frameMove, this);
};
FrontBoxs.prototype.frameMove = function () {
var _this = this;
this.frontBoxs.forEach(function (item, index) {
item.x += props.moveSpeed;
if (item.x <= 0 && !item.visible) {
item.visible = true;
}
if (item.x >= 750) {
var lastitem = _this.frontBoxs.shift();
lastitem.x = _this.frontBoxs[_this.frontBoxs.length - 1].x - _this.box1.width - props.frontmargin;
if (!_this.GameView.getMoveX() && item.x <= 0 && _this.GameView.startstatus) {
_this.GameView.setMoveX((370 - item.x - 13) / props.moveSpeed, item);
_this.hideBox = item;
}
_this.frontBoxs.push(lastitem);
}
});
};
FrontBoxs.prototype.stop = function () {
};
FrontBoxs.prototype.showHidePrizeBox = function (isshow) {
this.hideBox.visible = isshow;
};
return FrontBoxs;
}(engine.Container));
var BackBoxs = (function (_super) {
tslib.__extends(BackBoxs, _super);
function BackBoxs() {
var _this = _super.call(this) || this;
_this.backBoxs = [];
return _this;
}
BackBoxs.prototype.setup = function () {
var initX, initY = 0;
this.box1 = new engine.Sprite(getTextureByName("后狗盒"));
initX = this.box1.x = 188;
initY = this.box1.y = 616;
this.box2 = new engine.Sprite(getTextureByName("后猫盒"));
this.box3 = new engine.Sprite(getTextureByName("后草泥马盒"));
this.box4 = new engine.Sprite(getTextureByName("后狗盒"));
this.box5 = new engine.Sprite(getTextureByName("后猫盒"));
this.backBoxs = [this.box1, this.box2, this.box3, this.box4, this.box5];
for (var i = 0; i < this.backBoxs.length; i++) {
if (i == 0) {
this.backBoxs[i].x = initX;
}
else {
this.backBoxs[i].x = this.backBoxs[i - 1].x + this.backBoxs[i].width + props.backmargin;
}
this.backBoxs[i].y = initY;
this.addChild(this.backBoxs[i]);
}
this.addEventListener(engine.Event.ENTER_FRAME, this.frameMove, this);
};
BackBoxs.prototype.frameMove = function () {
var _this = this;
this.backBoxs.forEach(function (item) {
item.x -= props.moveSpeed;
if (item.x <= 0) {
var lastitem = _this.backBoxs.shift();
lastitem.x = _this.backBoxs[_this.backBoxs.length - 1].x + item.width + props.backmargin;
_this.backBoxs.push(lastitem);
}
});
};
return BackBoxs;
}(engine.Container));
var Zhuazi = (function (_super) {
tslib.__extends(Zhuazi, _super);
function Zhuazi() {
var _this = _super.call(this) || this;
_this.moveArr = [];
_this.prizeBoxs = [];
return _this;
}
Zhuazi.prototype.setup = function () {
this.ganNode = new engine.Container();
this.moveNode = new engine.Container();
this.ganNode.x = 280;
this.ganNode.y = 350;
this.bashouGan = new engine.Sprite(getTextureByName("把手杆子"));
this.bashouGan.x = 60;
this.bashouGan.y = 275;
this.bashou = new engine.Sprite(getTextureByName("把手"));
this.bashou.x = 0;
this.bashou.y = 263;
this.ganzi = new engine.Sprite(getTextureByName("伸缩杆"));
this.ganzi.x = 97;
this.ganzi.y = 290;
this.connect = new engine.Sprite(getTextureByName("连接点"));
this.connect.x = 18;
this.connect.y = -5;
this.left_zhuazi = new engine.Sprite(getTextureByName("左爪"));
this.left_zhuazi.x = -15;
this.left_zhuazi.y = 60;
this.left_zhuazi.anchorX = this.left_zhuazi.width;
this.left_zhuazi.anchorY = 0;
this.right_zhuazi = new engine.Sprite(getTextureByName("右爪"));
this.right_zhuazi.x = 98;
this.right_zhuazi.y = 60;
this.ganNode.addChild(this.left_zhuazi);
this.ganNode.addChild(this.right_zhuazi);
this.ganNode.addChild(this.connect);
this.ganNode.x = 30;
this.zhuaziY = this.ganNode.y;
this.moveNode.addChild(this.ganzi);
this.moveNode.addChild(this.ganNode);
this.moveNode.addChild(this.bashou);
this.moveNode.x = 262;
this.addChild(this.bashouGan);
this.addChild(this.moveNode);
this.createPrizeBox();
};
Zhuazi.prototype.createPrizeBox = function () {
var _this = this;
this.box1 = new engine.Sprite(getTextureByName("中奖狗盒"));
this.box1["npcType"] = "box1";
this.box2 = new engine.Sprite(getTextureByName("中奖猫盒"));
this.box2["npcType"] = "box2";
this.box3 = new engine.Sprite(getTextureByName("中奖草泥马盒"));
this.box3["npcType"] = "box3";
this.box4 = new engine.Sprite(getTextureByName("中奖狗盒"));
this.box4["npcType"] = "box4";
this.box5 = new engine.Sprite(getTextureByName("中奖猫盒"));
this.box5["npcType"] = "box5";
this.prizeBoxs = [this.box1, this.box2, this.box3, this.box4, this.box5];
this.prizeBoxs.forEach(function (item) {
_this.ganNode.addChild(item);
item.visible = false;
item.x = 15;
item.y = 48;
});
};
Zhuazi.prototype.showPrizeBox = function () {
var _this = this;
this.prizeBoxs.forEach(function (item) {
console.log(_this.GameView.getBox()['npcType']);
if (item['npcType'] === _this.GameView.getBox()['npcType']) {
item.visible = true;
_this.itemShow = item;
}
else {
item.visible = false;
}
});
};
Zhuazi.prototype.move = function () {
var _this = this;
var rndist = Math.random();
var halfWidth = this.bashou.width / 2;
var randomX = rndist * (rndist > 0.5 ? 1 : -1) * props.bashouMoveDist;
console.log(randomX);
engine.Tween.get(this.moveNode).to({ x: 370 + halfWidth - 71 }, 1000).call(function () {
_this.zhangkai();
});
};
Zhuazi.prototype.zhangkai = function () {
var _this = this;
this.left_zhuazi.anchorX = this.left_zhuazi.width;
this.left_zhuazi.anchorY = 0;
engine.Tween.get(this.left_zhuazi, { loop: false }).to({ rotation: props.leftRotation }, 1000);
engine.Tween.get(this.right_zhuazi, { loop: false }).to({ rotation: props.rightRotation }, 1000);
setTimeout(function () {
_this.getLong();
}, 500);
};
Zhuazi.prototype.getLong = function () {
var _this = this;
var droptime = Number((this.GameView.getMoveX() / 60 - 1).toFixed(2)) * 1000;
console.log('dr', droptime);
var times = (props.ganMoveEndY - this.ganzi.y) / this.ganzi.height;
console.log(Number(times.toFixed(2)));
engine.Tween.get(this.ganzi).to({ scaleY: Number(times.toFixed(2)) }, droptime).to({ scaleY: 1 }, droptime);
console.log('node', this.zhuaziY);
engine.Tween.get(this.ganNode).to({ y: props.ganMoveEndY }, droptime).call(function () {
_this.GameView.stopMove();
if (_this.GameView.ifPrize) {
_this.showPrizeBox();
_this.GameView.setVisible(false);
}
}).to({ y: this.zhuaziY }, droptime).call(function () {
if (_this.GameView.ifPrize) {
_this.itemShow.visible = false;
}
engine.globalEvent.dispatchEvent('doll-machine-gameover');
});
};
Zhuazi.prototype.getReset = function () {
this.left_zhuazi.anchorX = this.left_zhuazi.width;
this.left_zhuazi.anchorY = 0;
engine.Tween.get(this.moveNode, { loop: false }).to({ x: 262 }, 1000);
engine.Tween.get(this.left_zhuazi, { loop: false }).to({ rotation: 0 }, 1000);
engine.Tween.get(this.right_zhuazi, { loop: false }).to({ rotation: 0 }, 1000);
this.GameView.resetMoveX();
};
return Zhuazi;
}(engine.Container));
var ObjectPool$1 = engine.ObjectPool;
var GameView = (function (_super) {
tslib.__extends(GameView, _super);
function GameView() {
var _this = _super.call(this) || this;
_this.startstatus = false;
_this.ifPrize = false;
_this.goodsItems = [];
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
return _this;
}
GameView.prototype.setup = function () {
if (this._hasSetup) {
return;
}
this._hasSetup = true;
var frontBoxs = (this._frontBoxs = new FrontBoxs());
this._frontBoxs.GameView = this;
var backBoxs = (this._backBoxs = new BackBoxs());
this._Zhuazi = new Zhuazi();
this._Zhuazi.GameView = this;
this.frontTransfer = new engine.Container();
this.backTransfer = new engine.Container();
this.frontTransfer.width = 0;
this.frontTransfer.height = 0;
this.frontTransfer.alpha = 1;
this.backTransfer.width = 0;
this.backTransfer.height = 0;
this.backTransfer.alpha = 1;
this.rect = new engine.Rect();
this.rect.width = 611;
this.rect.height = 704;
this.rect.x = 65;
this.rect.y = 263;
this.NpcBg = new engine.Container();
this.addChild(this.NpcBg);
this.addChild(this.rect);
var gameBg = new engine.Sprite(getTextureByName("游戏背景"));
gameBg.x = 65;
gameBg.y = 263;
this.NpcBg.addChild(gameBg);
this.frontDesk = new engine.Sprite(getTextureByName("前传输带"));
this.frontDesk.x = 60;
this.frontDesk.y = 781;
this.backDesk = new engine.Sprite(getTextureByName("后传输带"));
this.backDesk.x = 60;
this.backDesk.y = 712;
this.NpcBg.addChild(this.backDesk);
this.NpcBg.addChild(this.frontDesk);
this.NpcBg.addChild(this.backTransfer);
this.NpcBg.addChild(this.frontTransfer);
this.NpcBg.addChild(this._Zhuazi);
this.NpcBg.mask = this.rect;
this._Zhuazi.setup();
this.backTransfer.addChild(this._backBoxs);
this._backBoxs.setup();
this.frontTransfer.addChild(this._frontBoxs);
this._frontBoxs.setup();
};
GameView.prototype.stopMove = function () {
this._frontBoxs.stop();
};
GameView.prototype.setMoveX = function (x, item) {
this.moveTime = x;
this.prizeBox = item;
this._Zhuazi.move();
};
GameView.prototype.setVisible = function (isshow) {
this._frontBoxs.showHidePrizeBox(isshow);
};
GameView.prototype.getMoveX = function () {
return this.moveTime;
};
GameView.prototype.resetMoveX = function () {
this.moveTime = null;
};
GameView.prototype.getBox = function () {
return this.prizeBox;
};
GameView.prototype.reset = function () {
this.startstatus = false;
this.ifPrize = false;
this._Zhuazi.getReset();
};
GameView.prototype.start = function (type) {
if (type === void 0) { type = null; }
this.speed = 1;
this.gameIng = true;
console.log('执行', type);
this.startstatus = true;
this.ifPrize = type && type.prize || false;
};
GameView.prototype.beginNpc = function () {
var _this = this;
this.timer = setTimeout(function () {
if (_this.gameIng) ;
}, 2000 / this.speed);
};
GameView.prototype.pause = function () {
this.gameIng = false;
};
GameView.prototype.revive = function () {
this.gameIng = true;
};
GameView.prototype.resume = function () {
this.reset();
this.start();
};
GameView.prototype.initNpc = function () {
this.box1 = new engine.Sprite(getTextureByName("草泥马盒"));
this.box2 = new engine.Sprite(getTextureByName("狗盒"));
this.box3 = new engine.Sprite(getTextureByName("猫盒"));
this.box4 = new engine.Sprite(getTextureByName("草泥马盒"));
this.box5 = new engine.Sprite(getTextureByName("猫盒"));
this.box1.x = 120;
this.box1.y = 434;
this.box2.x = 306;
this.box2.y = 434;
this.box3.x = 487;
this.box3.y = 434;
this.box4.x = 240;
this.box4.scaleX = 0.5;
this.box4.scaleY = 0.5;
this.box4.y = 390;
this.box5.x = 434;
this.box5.y = 390;
this.box5.scaleX = 0.5;
this.box5.scaleY = 0.5;
this.backTransfer.addChild(this.box4);
this.backTransfer.addChild(this.box5);
this.frontTransfer.addChild(this.box1);
this.frontTransfer.addChild(this.box2);
this.frontTransfer.addChild(this.box3);
};
GameView.prototype.died = function () {
this.score = 0;
this.pause();
};
GameView.prototype.removeNpc = function (goods) {
this.NpcBg.removeChild(goods);
ObjectPool$1.recycleObject(PoolName, goods);
goods.removeEventListener(engine.Event.ENTER_FRAME, goods["onGoodsEnter"], this);
var index = this.goodsItems.indexOf(goods);
if (index > -1) {
this.goodsItems.splice(index, 1);
}
};
GameView.prototype.recycleGoods = function () {
clearTimeout(this.timer);
clearInterval(this.countdownTimer);
for (var _i = 0, _a = this.goodsItems; _i < _a.length; _i++) {
var goods = _a[_i];
if (goods) {
this.removeChild(goods);
ObjectPool$1.recycleObject(PoolName, goods);
goods.removeEventListener(engine.Event.ENTER_FRAME, goods["onGoodsEnter"], this);
}
}
this.goodsItems = [];
};
GameView.prototype.hasHit = function (a, b) {
if (Math.abs(a.x + a.width / 2 - (b.x + b.width / 2)) <
a.width / 2 + b.width / 2 &&
Math.abs(a.y + a.height / 2 - (b.y + b.height / 2)) <
a.height / 2 + b.height / 2) {
return true;
}
else {
return false;
}
};
return GameView;
}(engine.Container));
var GameWrapper = (function (_super) {
tslib.__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('doll-machine-reset', _this.reset, _this);
engine.globalEvent.addEventListener('doll-machine-prize', _this.start, _this);
var gameView = _this._gameView = new GameView();
_this.addChild(gameView);
return _this;
}
GameWrapper.prototype.reset = function (event) {
injectProps(event.data);
this._gameView.visible = true;
this._gameView.reset();
};
GameWrapper.prototype.start = function (event) {
console.log('监听开始');
injectProps(event.data);
this._gameView.start(event.data);
};
GameWrapper.prototype.pause = function () {
this._gameView.pause();
};
GameWrapper.prototype.resume = function () {
this._gameView.resume();
};
GameWrapper.prototype.revive = function () {
this._gameView.revive();
};
GameWrapper.prototype.clear = function () {
this._gameView.visible = false;
};
GameWrapper.prototype.onTap = function (event) {
};
return GameWrapper;
}(engine.Container));
function index (props) {
prepareProps();
injectProps(props);
var instance = new GameWrapper();
return instance;
}
return index;
})));
//# sourceMappingURL=main.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sources":["src/custom/doll-machine/src/game/utils.ts","src/custom/doll-machine/src/game/Goods.ts","src/custom/doll-machine/src/game/object-pool-init.ts","src/custom/doll-machine/src/props.ts","src/custom/doll-machine/src/game/frontBox.ts","src/custom/doll-machine/src/game/backBox.ts","src/custom/doll-machine/src/game/Zhuazi.ts","src/custom/doll-machine/src/game/GameView.ts","src/custom/doll-machine/src/game/GameWrapper.ts","src/custom/doll-machine/src/index.ts"],"sourcesContent":["/**\n * Created by rockyl on 2020-01-21.\n */\n\nexport function getTexture(uuid) {\n\treturn engine.Texture.from(getAssetByUUID(uuid).uuid);\n}\n\nexport function getTextureByName(name) {\n\treturn getTexture(engine.getAssetByName(name).uuid);\n}\n\nexport function playSound(name) {\n\tengine.playSound(engine.getAssetByName(name).uuid, {keep: true});\n}\nexport function createSvga(name, anchorName?) {\n\tlet inst = new svga.Svga();\n\tinst.source = 'asset://' + engine.getAssetByName(name).uuid;\n\treturn inst;\n}","/**\n * Created by rockyl on 2020-02-02.\n *\n * 掉落物品\n */\nimport { getTextureByName } from \"./utils\";\nimport { props } from \"../props\";\n\nexport class Goods extends engine.Container {\n private _body: engine.Rect;\n private _toY;\n\n constructor() {\n super();\n\n let body;\n body = this._body = new engine.Rect();\n\n // let rain = new engine.Sprite(getTextureByName('雨滴'));\n // rain[\"npcType\"]=\"rain\"\n // let stone = new engine.Sprite(getTextureByName('石块'));\n // stone[\"npcType\"]=\"stone\"\n // let boom = new engine.Sprite(getTextureByName('炸弹'));\n // boom[\"npcType\"]=\"boom\"\n\n let box1 = new engine.Sprite(getTextureByName(\"草泥马盒\"));\n box1[\"npcType\"] = \"box1\";\n let box2 = new engine.Sprite(getTextureByName(\"狗盒\"));\n box2[\"npcType\"] = \"box2\";\n let box3 = new engine.Sprite(getTextureByName(\"猫盒\"));\n box3[\"npcType\"] = \"box3\";\n\n // rain.visible=false;\n // stone.visible=false;\n // boom.visible=false;\n // body.addChild(rain)\n // body.addChild(stone)\n // body.addChild(boom)\n\n box1.visible = false;\n box2.visible = false;\n box3.visible = false;\n body.addChild(box1);\n body.addChild(box2);\n body.addChild(box3);\n\n this.addChild(body);\n body.width = 0.0001;\n body.height = 0.0001;\n body.mouseEnabled = false;\n }\n\n getRandomNumberByRange(start, end) {\n return Math.floor(Math.random() * (end - start) + start);\n }\n\n // reset() {\n // \tthis.visible = true;\n // \tthis.rotation = 0;\n // \tthis.anchorOffsetY = 0;\n // \tthis.y = 0;\n // \tthis.x = (750-120)*Math.random()+30;\n // \tthis.rotation = 0;\n // \tlet random=Math.random()\n\n // \tif(random<props.goodsProbability[0]){\n // \t\tthis.showNpc(\"box1\")\n // \t}else if(random>=props.goodsProbability[0]&&random<=(props.goodsProbability[0]+props.goodsProbability[1])){\n // \t\tthis.showNpc(\"box2\")\n // \t}else if(random>(props.goodsProbability[0]+props.goodsProbability[1])){\n // \t\tthis.showNpc(\"box3\")\n // \t}\n // }\n\n reset() {\n this.visible = true;\n this.y = 200;\n this.x = 0;\n this.rotation = 0;\n let random = Math.random();\n if (random < 0.3) {\n this.showNpc(\"box1\");\n } else if (random < 0.6) {\n this.showNpc(\"box2\");\n } else {\n this.showNpc(\"box3\");\n }\n // this.showNpc(\"box1\");\n // this.showNpc(\"box2\");\n // this.showNpc(\"box3\");\n }\n\n showNpc(type) {\n for (let i = 0; i < this._body.children.length; i++) {\n this._body.children[i].visible = false;\n this._body.children[i].mouseEnabled = false;\n }\n for (let i = 0; i < this._body.children.length; i++) {\n if (this._body.children[i][\"npcType\"] == type) {\n this[\"npcType\"] = type;\n console.log(type);\n\n this._body.children[i].visible = true;\n this._body.children[i].mouseEnabled = false;\n }\n }\n }\n\n set anchorOffsetY(v) {\n this._body.y = v;\n }\n}\n","/**\n * Created by rockyl on 2020-02-03.\n */\n\nimport {Goods} from \"./Goods\";\nimport ObjectPool = engine.ObjectPool;\n\nexport const PoolName: string = 'goods';\n\nObjectPool.registerPool(PoolName, function () {\n\treturn new Goods();\n}, function (item: Goods, data) {\n\titem.reset();\n});\n","/**\n * Created by rockyl on 2020-01-21.\n */\n\nexport let props: any = {};\n\nexport function prepareProps() {\n\tlet metaProps = getProps();\n\n\tengine.injectProp(props, metaProps);\n}\n\nexport function injectProps(p) {\n\tengine.injectProp(props, p);\n}\n","import { getTextureByName } from \"./utils\";\nimport GameView from './GameView';\nimport { props } from \"../props\";\nexport class FrontBoxs extends engine.Container {\n //盒子1\n private box1: engine.Container;\n //盒子2\n private box2: engine.Container;\n //盒子3 \n private box3: engine.Container;\n //盒子4\n private box4: engine.Container;\n //盒子5\n private box5: engine.Container;\n // 需隐藏的盒子\n private hideBox: engine.Container;\n private frontBoxs=[];\n public GameView: GameView;\n constructor() {\n super();\n }\n setup() {\n let initX , initY = 0;\n this.box1 = new engine.Sprite(getTextureByName(\"狗盒\"));\n this.box1[\"npcType\"] = \"box1\";\n initX = this.box1.x = 435;\n initY = this.box1.y = 614;\n\n this.box2 = new engine.Sprite(getTextureByName(\"猫盒\"));\n this.box2[\"npcType\"] = \"box2\";\n this.box3 = new engine.Sprite(getTextureByName(\"草泥马盒\"));\n this.box3[\"npcType\"] = \"box3\";\n this.box4 = new engine.Sprite(getTextureByName(\"狗盒\"));\n this.box4[\"npcType\"] = \"box4\";\n this.box5 = new engine.Sprite(getTextureByName(\"猫盒\"));\n this.box5[\"npcType\"] = \"box5\";\n this.frontBoxs = [this.box1, this.box2, this.box3, this.box4];\n for(let i = 0; i < this.frontBoxs.length; i++) {\n if(i == 0) {\n this.frontBoxs[i].x = initX ;\n } else {\n this.frontBoxs[i].x = this.frontBoxs[i - 1].x - this.box1.width - props.frontmargin;\n }\n \n this.frontBoxs[i].y = initY;\n this.addChild(this.frontBoxs[i]);\n }\n this.addEventListener(engine.Event.ENTER_FRAME, this.frameMove, this);\n }\n frameMove() {\n this.frontBoxs.forEach((item, index) => {\n item.x += props.moveSpeed;\n if(item.x <=0 && !item.visible) {\n item.visible = true;\n }\n if(item.x >= 750) {\n let lastitem = this.frontBoxs.shift();\n lastitem.x = this.frontBoxs[this.frontBoxs.length - 1].x - this.box1.width - props.frontmargin;\n \n if (!this.GameView.getMoveX() && item.x <= 0 && this.GameView.startstatus) {\n this.GameView.setMoveX((370 - item.x - 13) / props.moveSpeed, item);\n this.hideBox = item;\n }\n this.frontBoxs.push(lastitem);\n }\n })\n }\n stop() {\n // this.removeEventListener(engine.Event.ENTER_FRAME, this.frameMove, this);\n }\n showHidePrizeBox(isshow) {\n this.hideBox.visible = isshow\n }\n}","import { getTextureByName } from \"./utils\";\nimport { props } from \"../props\";\nexport class BackBoxs extends engine.Container {\n //盒子1\n private box1: engine.Container;\n //盒子2\n private box2: engine.Container;\n //盒子3\n private box3: engine.Container;\n //盒子4\n private box4: engine.Container;\n //盒子5\n private box5: engine.Container;\n private backBoxs=[];\n constructor() {\n super();\n }\n setup() {\n let initX , initY = 0;\n this.box1 = new engine.Sprite(getTextureByName(\"后狗盒\"));\n initX = this.box1.x = 188;\n initY = this.box1.y = 616;\n\n this.box2 = new engine.Sprite(getTextureByName(\"后猫盒\"));\n this.box3 = new engine.Sprite(getTextureByName(\"后草泥马盒\"));\n this.box4 = new engine.Sprite(getTextureByName(\"后狗盒\"));\n this.box5 = new engine.Sprite(getTextureByName(\"后猫盒\"));\n this.backBoxs = [this.box1, this.box2, this.box3, this.box4, this.box5];\n for (let i = 0; i < this.backBoxs.length; i++) {\n // this.backBoxs[i].scaleX = 0.5;\n // this.backBoxs[i].scaleY = 0.5;\n if(i == 0) {\n this.backBoxs[i].x = initX;\n } else {\n this.backBoxs[i].x = this.backBoxs[i - 1].x + this.backBoxs[i].width + props.backmargin;\n }\n this.backBoxs[i].y = initY;\n \n this.addChild(this.backBoxs[i]);\n }\n this.addEventListener(engine.Event.ENTER_FRAME, this.frameMove, this);\n }\n frameMove() {\n this.backBoxs.forEach((item) => {\n item.x -= props.moveSpeed;\n if (item.x <= 0) {\n let lastitem = this.backBoxs.shift();\n lastitem.x = this.backBoxs[this.backBoxs.length - 1].x + item.width + props.backmargin;\n this.backBoxs.push(lastitem);\n }\n })\n }\n}","import { getTextureByName } from \"./utils\";\nimport { props } from \"../props\";\nimport GameView from './GameView';\nexport class Zhuazi extends engine.Container {\n private bashouGan: engine.Sprite;\n private bashou: engine.Sprite;\n private ganzi: engine.Sprite;\n private left_zhuazi: engine.Sprite;\n private right_zhuazi: engine.Sprite;\n private connect: engine.Sprite;\n private ganNode: engine.Container;\n private moveNode: engine.Container;\n private moveArr = [];\n private zhuaziY;\n //盒子1\n private box1: engine.Container;\n //盒子2\n private box2: engine.Container;\n //盒子3\n private box3: engine.Container;\n //盒子4\n private box4: engine.Container;\n //盒子5\n private box5: engine.Container;\n private itemShow: engine.Container;\n private prizeBoxs = [];\n public GameView: GameView;\n constructor() {\n super();\n }\n setup() {\n this.ganNode = new engine.Container();\n this.moveNode = new engine.Container();\n this.ganNode.x = 280;\n this.ganNode.y = 350;\n this.bashouGan = new engine.Sprite(getTextureByName(\"把手杆子\"));\n this.bashouGan.x = 60;\n this.bashouGan.y = 275;\n this.bashou = new engine.Sprite(getTextureByName(\"把手\"));\n this.bashou.x = 0;\n this.bashou.y = 263;\n this.ganzi = new engine.Sprite(getTextureByName(\"伸缩杆\"));\n this.ganzi.x = 97;\n this.ganzi.y = 290;\n this.connect = new engine.Sprite(getTextureByName(\"连接点\"));\n this.connect.x = 18;\n this.connect.y = -5;\n this.left_zhuazi = new engine.Sprite(getTextureByName(\"左爪\"));\n this.left_zhuazi.x = -15;\n this.left_zhuazi.y = 60;\n this.left_zhuazi.anchorX = this.left_zhuazi.width;\n this.left_zhuazi.anchorY = 0;\n this.right_zhuazi = new engine.Sprite(getTextureByName(\"右爪\"));\n this.right_zhuazi.x = 98;\n this.right_zhuazi.y = 60;\n this.ganNode.addChild(this.left_zhuazi);\n this.ganNode.addChild(this.right_zhuazi);\n this.ganNode.addChild(this.connect);\n this.ganNode.x = 30;\n this.zhuaziY = this.ganNode.y;\n this.moveNode.addChild(this.ganzi);\n this.moveNode.addChild(this.ganNode);\n this.moveNode.addChild(this.bashou);\n this.moveNode.x = 262;\n // this.moveNode.\n // this.moveArr = [this.bashou, this.ganzi, this.ganNode];\n this.addChild(this.bashouGan);\n // this.addChild(this.ganzi);\n // this.addChild(this.bashou);\n // this.addChild(this.ganNode);\n this.addChild(this.moveNode);\n this.createPrizeBox();\n // setTimeout(() => {\n // this.move();\n // }, 2000)\n \n }\n createPrizeBox() {\n this.box1 = new engine.Sprite(getTextureByName(\"中奖狗盒\"));\n this.box1[\"npcType\"] = \"box1\";\n this.box2 = new engine.Sprite(getTextureByName(\"中奖猫盒\"));\n this.box2[\"npcType\"] = \"box2\";\n this.box3 = new engine.Sprite(getTextureByName(\"中奖草泥马盒\"));\n this.box3[\"npcType\"] = \"box3\";\n this.box4 = new engine.Sprite(getTextureByName(\"中奖狗盒\"));\n this.box4[\"npcType\"] = \"box4\";\n this.box5 = new engine.Sprite(getTextureByName(\"中奖猫盒\"));\n this.box5[\"npcType\"] = \"box5\";\n this.prizeBoxs = [this.box1, this.box2, this.box3, this.box4, this.box5];\n this.prizeBoxs.forEach(item => {\n this.ganNode.addChild(item);\n item.visible = false;\n item.x = 15;\n item.y = 48;\n })\n }\n showPrizeBox() {\n this.prizeBoxs.forEach(item => {\n console.log(this.GameView.getBox()['npcType']);\n if (item['npcType'] === this.GameView.getBox()['npcType']) {\n item.visible = true;\n this.itemShow = item;\n } else {\n item.visible = false;\n }\n })\n \n }\n move() {\n let rndist = Math.random();\n let halfWidth = this.bashou.width / 2;\n let randomX = rndist * (rndist > 0.5 ? 1 : -1) * props.bashouMoveDist;\n console.log(randomX);\n engine.Tween.get(this.moveNode).to({ x: 370 + halfWidth - 71}, 1000).call(() => {\n this.zhangkai();\n });\n }\n zhangkai() {\n this.left_zhuazi.anchorX = this.left_zhuazi.width;\n this.left_zhuazi.anchorY = 0;\n engine.Tween.get(this.left_zhuazi, { loop: false }).to({ rotation: props.leftRotation}, 1000);\n engine.Tween.get(this.right_zhuazi, { loop: false }).to({ rotation: props.rightRotation }, 1000);\n setTimeout(() => {\n this.getLong();\n }, 500);\n }\n getLong() {\n let droptime = Number((this.GameView.getMoveX() / 60 - 1).toFixed(2)) * 1000;\n console.log('dr', droptime);\n let times = (props.ganMoveEndY - this.ganzi.y ) / this.ganzi.height;\n console.log(Number(times.toFixed(2)) );\n engine.Tween.get(this.ganzi).to({ scaleY: Number(times.toFixed(2)) }, droptime).to({ scaleY: 1 }, droptime)\n console.log('node', this.zhuaziY);\n engine.Tween.get(this.ganNode).to({ y: props.ganMoveEndY }, droptime).call(() => {\n this.GameView.stopMove();\n if (this.GameView.ifPrize) {\n this.showPrizeBox();\n this.GameView.setVisible(false);\n }\n }).to({ y: this.zhuaziY }, droptime).call(() => {\n // this.getReset();\n if (this.GameView.ifPrize) {\n this.itemShow.visible = false;\n }\n engine.globalEvent.dispatchEvent('doll-machine-gameover');\n })\n }\n getReset() {\n // if (this.GameView.ifPrize) {\n // this.itemShow.visible = false;\n // }\n this.left_zhuazi.anchorX = this.left_zhuazi.width;\n this.left_zhuazi.anchorY = 0;\n engine.Tween.get(this.moveNode, {loop: false}).to({x: 262}, 1000);\n engine.Tween.get(this.left_zhuazi, { loop: false }).to({ rotation: 0 }, 1000);\n engine.Tween.get(this.right_zhuazi, { loop: false }).to({ rotation: 0 }, 1000);\n this.GameView.resetMoveX();\n }\n}","/**\n * Created by rockyl on 2018/8/16.\n */\n\nimport { props } from \"../props\";\nimport { playSound, createSvga } from \"./utils\";\nimport ObjectPool = engine.ObjectPool;\nimport { getTextureByName } from \"./utils\";\nimport { Goods } from \"./Goods\";\nimport { PoolName } from \"./object-pool-init\";\nimport { FrontBoxs } from \"./frontBox\";\nimport { BackBoxs } from \"./backBox\";\nimport { Zhuazi } from './Zhuazi';\n\nexport default class GameView extends engine.Container {\n private _hasSetup;\n\n //触摸层\n private rectBg: engine.Rect;\n //npc层\n private NpcBg: engine.Container;\n //盒子1\n private box1: engine.Container;\n //盒子2\n private box2: engine.Container;\n //盒子3\n private box3: engine.Container;\n //盒子4\n private box4: engine.Container;\n //盒子5\n private box5: engine.Container;\n //前传输区域\n private frontTransfer: engine.Container;\n //后传输区域\n private backTransfer: engine.Container;\n //前台板\n private frontDesk: engine.Sprite;\n //后台板\n private backDesk: engine.Sprite;\n private _frontBoxs: FrontBoxs;\n\tprivate _backBoxs: BackBoxs;\n\tprivate _Zhuazi: Zhuazi;\n\tprivate prizeBox: engine.Container;\n\tprivate rect;\n //当前分数\n\tprivate score;\n\t\n\t//中奖盒子移动距离\n\tprivate moveTime;\n\n //游戏状态\n private gameIng;\n //是否已获取位移值\n public startstatus=false;\n //是否中奖\n public ifPrize=false;\n //npc出身计时器\n private timer;\n //倒计时计时器\n private countdownTimer: any;\n //倒计时\n private countdown: number;\n\n //当前速度\n private speed: number;\n\n // 当前场景上面的物品\n private goodsItems = [];\n\n private _goods: Goods;\n\n constructor() {\n super();\n this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);\n }\n\n // private waterSvga;\n // private boomSvga;\n // private playerSvga;\n\n setup() {\n if (this._hasSetup) {\n return;\n }\n\n this._hasSetup = true;\n\t\tconst frontBoxs = (this._frontBoxs = new FrontBoxs());\n\t\tthis._frontBoxs.GameView = this;\n\t\tconst backBoxs = (this._backBoxs = new BackBoxs());\n\t\tthis._Zhuazi = new Zhuazi();\n\t\tthis._Zhuazi.GameView = this;\n this.frontTransfer = new engine.Container();\n this.backTransfer = new engine.Container();\n this.frontTransfer.width = 0;\n this.frontTransfer.height = 0;\n this.frontTransfer.alpha = 1;\n // this.frontTransfer.x = 0;\n // this.frontTransfer.y = 434;\n\n this.backTransfer.width = 0;\n this.backTransfer.height = 0;\n this.backTransfer.alpha = 1;\n // this.backTransfer.x = 0;\n // this.backTransfer.y = 390;\n\t\tthis.rect = new engine.Rect();\n\t\t// this.rect.width = 608;\n\t\tthis.rect.width = 611;\n\t\tthis.rect.height = 704;\n\t\tthis.rect.x = 65;\n\t\tthis.rect.y = 263;\n this.NpcBg = new engine.Container();\n\t\tthis.addChild(this.NpcBg);\n\t\tthis.addChild(this.rect);\n\t\t\n\t\t\n\t\t\n\t\tlet gameBg = new engine.Sprite(getTextureByName(\"游戏背景\"));\n\t\tgameBg.x = 65;\n\t\tgameBg.y = 263;\n\t\tthis.NpcBg.addChild(gameBg);\n\t\t\n this.frontDesk = new engine.Sprite(getTextureByName(\"前传输带\"));\n this.frontDesk.x = 60;\n this.frontDesk.y = 781;\n\n this.backDesk = new engine.Sprite(getTextureByName(\"后传输带\"));\n this.backDesk.x = 60;\n this.backDesk.y = 712;\n\n this.NpcBg.addChild(this.backDesk);\n this.NpcBg.addChild(this.frontDesk);\n this.NpcBg.addChild(this.backTransfer);\n\t\tthis.NpcBg.addChild(this.frontTransfer);\n\t\tthis.NpcBg.addChild(this._Zhuazi);\n\n\t\tthis.NpcBg.mask = this.rect;\n\t\tthis._Zhuazi.setup();\n\t\t\n\t\t// this._Zhuazi.move();\n\t\tthis.backTransfer.addChild(this._backBoxs);\n\t\tthis._backBoxs.setup();\n\t\tthis.frontTransfer.addChild(this._frontBoxs);\n\t\tthis._frontBoxs.setup();\n\n //\tthis.player.fillColor=\"rgba(0, 0, 0,1)\"\n //console.log(this.player.fillColor)\n\n // this.rectBg = new engine.Rect();\n // this.rectBg.alpha = 0;\n // this.rectBg.width = 750;\n // this.rectBg.height = 1624;\n // this.addChild(this.rectBg);\n\t}\n\t/**\n\t * \n\t * @param 暂停move\n\t */\n\tstopMove() {\n\t\tthis._frontBoxs.stop();\n\t}\n\t/**\n\t * 赋值x距离值\n\t */\n\tsetMoveX(x, item) {\n\t\tthis.moveTime = x;\n this.prizeBox = item;\n\t\tthis._Zhuazi.move();\n }\n\t/**\n\t * 显示隐藏盒子\n\t */\n\tsetVisible(isshow) {\n\t\tthis._frontBoxs.showHidePrizeBox(isshow);\n\t}\n\t/**\n\t * 获取中奖盒子移动的距离\n\t */\n\tgetMoveX() {\n\t\treturn this.moveTime;\n }\n /**\n * 重置moveTime\n */\n resetMoveX() {\n this.moveTime = null;\n }\n\t/**\n\t * 获取中奖盒子\n\t */\n\tgetBox() {\n\t\treturn this.prizeBox;\n\t}\n /**\n * 重置场景\n */\n reset() {\n this.startstatus = false;\n this.ifPrize = false;\n\t\tthis._Zhuazi.getReset();\n }\n\n /**\n * 开始\n */\n start(type=null) {\n this.speed = 1;\n this.gameIng = true;\n console.log('执行', type);\n this.startstatus = true;\n this.ifPrize = type && type.prize || false;\n // this.creatNpc()\n // this.beginNpc();\n // this.countdown = props.countDown;\n\n // this.countdownTimer = setInterval(() => {\n // if (this.gameIng) {\n // if (this.countdown > 0) {\n // engine.globalEvent.dispatchEvent(\"food-fell-time-update\", {\n // time: this.countdown\n // });\n // this.countdown -= 1;\n // } else {\n // engine.globalEvent.dispatchEvent(\"food-fell-game-over\", {\n // score: this.score,\n // reason: 1\n // });\n // this.died();\n // }\n // }\n // }, 1000);\n }\n\n /**\n * npc开始掉落\n */\n beginNpc() {\n this.timer = setTimeout(() => {\n if (this.gameIng) {\n // this.speed += props.acceleratedSpeed;\n // this.creatNpc()\n }\n //递归执行\n // this.beginNpc();\n }, 2000 / this.speed);\n }\n\n /**\n * 暂停\n */\n pause() {\n this.gameIng = false;\n }\n\n /**\n * 恢复\n */\n revive() {\n this.gameIng = true;\n }\n\n /**\n * 重新开始\n */\n resume() {\n this.reset();\n this.start();\n }\n\n /**\n * 初始化盒子位置\n */\n initNpc() {\n this.box1 = new engine.Sprite(getTextureByName(\"草泥马盒\"));\n this.box2 = new engine.Sprite(getTextureByName(\"狗盒\"));\n this.box3 = new engine.Sprite(getTextureByName(\"猫盒\"));\n this.box4 = new engine.Sprite(getTextureByName(\"草泥马盒\"));\n this.box5 = new engine.Sprite(getTextureByName(\"猫盒\"));\n this.box1.x = 120;\n this.box1.y = 434;\n this.box2.x = 306;\n this.box2.y = 434;\n this.box3.x = 487;\n this.box3.y = 434;\n this.box4.x = 240;\n this.box4.scaleX = 0.5;\n this.box4.scaleY = 0.5;\n this.box4.y = 390;\n this.box5.x = 434;\n this.box5.y = 390;\n this.box5.scaleX = 0.5;\n this.box5.scaleY = 0.5;\n this.backTransfer.addChild(this.box4);\n this.backTransfer.addChild(this.box5);\n this.frontTransfer.addChild(this.box1);\n this.frontTransfer.addChild(this.box2);\n this.frontTransfer.addChild(this.box3);\n }\n\n /**\n * 创建NPC\n */\n // private creatNpc() {\n // // this.initNpc();\n // let goods = (this._goods = <Goods>ObjectPool.getObject(PoolName));\n // console.log(goods);\n // this.goodsItems.push(goods);\n // this.NpcBg.addChild(goods);\n // goods.addEventListener(\n // engine.Event.ENTER_FRAME,\n // (goods[\"onGoodsEnter\"] = () => {\n // if (goods.y > 1624) {\n // this.removeNpc(goods);\n // } else {\n // if (this.gameIng) {\n // //速度叠加\n // // goods.y += (4 * this.speed)\n // goods.x += 2 * this.speed;\n // //如果玩家和物品发生碰撞\n // if (this.hasHit(this.player, goods)) {\n // if (goods[\"npcType\"] == \"rain\") {\n // console.log(\"碰到雨滴\");\n // this.score += props.rainScore;\n // this.waterSvga.visible = true;\n // this.waterSvga.play(false, false);\n // this.waterSvga.once(\n // engine.Event.END_FRAME,\n // () => {\n // this.waterSvga.visible = false;\n // },\n // this\n // );\n // } else if (goods[\"npcType\"] == \"stone\") {\n // console.log(\"碰到石头\");\n // this.score += props.stoneScore;\n // } else if (goods[\"npcType\"] == \"boom\") {\n // console.log(\"碰到炸弹\");\n // this.boomSvga.visible = true;\n // this.boomSvga.play(false, false);\n // this.boomSvga.once(\n // engine.Event.END_FRAME,\n // () => {\n // this.boomSvga.visible = false;\n // },\n // this\n // );\n // engine.globalEvent.dispatchEvent(\"food-fell-game-over\", {\n // score: this.score,\n // reason: 2\n // });\n // this.died();\n // }\n // engine.globalEvent.dispatchEvent(\"food-fell-score-update\", {\n // score: this.score\n // });\n // this.removeNpc(goods);\n // }\n // }\n // }\n // }),\n // this\n // );\n // }\n\n /**\n * 玩家死亡\n */\n private died() {\n this.score = 0;\n this.pause();\n }\n\n /**\n * 回收指定物品\n * @param goods 物品\n */\n private removeNpc(goods) {\n this.NpcBg.removeChild(goods);\n ObjectPool.recycleObject(PoolName, goods);\n goods.removeEventListener(\n engine.Event.ENTER_FRAME,\n goods[\"onGoodsEnter\"],\n this\n );\n let index = this.goodsItems.indexOf(goods);\n if (index > -1) {\n this.goodsItems.splice(index, 1);\n }\n }\n\n /**\n * 回收对象\n */\n private recycleGoods() {\n clearTimeout(this.timer);\n clearInterval(this.countdownTimer);\n for (let goods of this.goodsItems) {\n if (goods) {\n this.removeChild(goods);\n ObjectPool.recycleObject(PoolName, goods);\n goods.removeEventListener(\n engine.Event.ENTER_FRAME,\n goods[\"onGoodsEnter\"],\n this\n );\n }\n }\n this.goodsItems = [];\n }\n\n\n /**\n * 碰撞检测\n * @param a a盒子\n * @param b b盒子\n */\n private hasHit(a, b) {\n if (\n Math.abs(a.x + a.width / 2 - (b.x + b.width / 2)) <\n a.width / 2 + b.width / 2 &&\n Math.abs(a.y + a.height / 2 - (b.y + b.height / 2)) <\n a.height / 2 + b.height / 2\n ) {\n return true;\n } else {\n return false;\n }\n }\n}\n","/**\n * Created by rockyl on 2020-01-09.\n */\n\nimport GameView from \"./GameView\";\nimport {injectProps} from \"../props\";\n\n\nexport class GameWrapper extends engine.Container {\n\tprivate _status;\n\tprivate _gameView: GameView;\n\n\n\n\n\n\tconstructor() {\n\t\tsuper();\n\t\tengine.globalEvent.addEventListener('doll-machine-reset', this.reset, this);\n\t\tengine.globalEvent.addEventListener('doll-machine-prize', this.start, this);\n\t\t// engine.globalEvent.addEventListener('food-fell-start', this.start, this);\n\t\t// engine.globalEvent.addEventListener('food-fell-pause', this.pause, this);\n\t\t// engine.globalEvent.addEventListener('food-fell-resume', this.resume, this);\n\t\t// engine.globalEvent.addEventListener('food-fell-revive', this.revive, this);\n\t\t// engine.globalEvent.addEventListener('food-fell-clear', this.clear, this);\n\n\t\t// this.addEventListener(engine.MouseEvent.CLICK, this.onTap, this);\n\n\t\tlet gameView = this._gameView = new GameView();\n\t\tthis.addChild(gameView);\n\t\t// gameView.reset();\n\t\t// gameView.start()\n\t}\n\n\treset(event: engine.Event) {\t\t\n\t\tinjectProps(event.data);\n\t\tthis._gameView.visible = true;\n\t\tthis._gameView.reset();\n\t}\n\n\tstart(event: engine.Event) {\n\t\tconsole.log('监听开始');\n\t\tinjectProps(event.data);\n\t\t// this._status = 1;\n\t\tthis._gameView.start(event.data);\n\t}\n\n\tpause() {\n\t\tthis._gameView.pause();\n\t}\n\n\tresume() {\n\t\tthis._gameView.resume();\n\t}\n\n\trevive() {\n\t\tthis._gameView.revive();\n\t}\n\n\tclear() {\n\t\tthis._gameView.visible = false;\n\t}\n\n\tprivate onTap(event) {\n\t//\tthis._gameView.tap(event);\n\t}\n}\n","/**\n * Created by rockyl on 2019-11-20.\n */\n\nimport {GameWrapper} from \"./game/GameWrapper\";\nimport {injectProps, prepareProps} from \"./props\";\n\nexport default function (props) {\n\tprepareProps();\n\tinjectProps(props);\n\n\tlet instance = new GameWrapper();\n\treturn instance;\n}\n"],"names":["__extends","ObjectPool"],"mappings":";;;;;;UAIgB,UAAU,CAAC,IAAI;KAC9B,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;CACvD,CAAC;UAEe,gBAAgB,CAAC,IAAI;KACpC,OAAO,UAAU,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;CACrD;;CCFA;KAA2BA,+BAAgB;KAIzC;SAAA,YACE,iBAAO,SAqCR;SAnCC,IAAI,IAAI,CAAC;SACT,IAAI,GAAG,KAAI,CAAC,KAAK,GAAG,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;SAStC,IAAI,IAAI,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC;SACvD,IAAI,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC;SACzB,IAAI,IAAI,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC;SACrD,IAAI,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC;SACzB,IAAI,IAAI,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC;SACrD,IAAI,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC;SASzB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;SACrB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;SACrB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;SACrB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;SACpB,IAAI,CAAC,QAAQ,CAAC,IAAI,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B;KACF,kBAAC;CAAD,CAAC,CA1DgC,MAAM,CAAC,SAAS,GA0DhD;;iBC3DwB,KAAK;KAC7B,YAAY,EAAE,CAAC;KACf,WAAW,CAAC,KAAK,CAAC,CAAC;KAEnB,IAAI,QAAQ,GAAG,IAAI,WAAW,EAAE,CAAC;KACjC,OAAO,QAAQ,CAAC;CACjB,CAAC;;;;;;;;"}
\ No newline at end of file
/**
* Created by rockyl on 2020-01-21.
*/
let customModuleProps = {
};
{
"name": "娃娃机",
"desc": "娃娃机模块",
"props": {
"frontmargin": {
"alias": "前排娃娃的间距",
"type": "number",
"default": 50
},
"backmargin": {
"alias": "后排娃娃的间距",
"type": "number",
"default": 50
},
"moveSpeed": {
"alias": "娃娃移动的速度",
"type": "number",
"default": 3
},
"bashouMoveDist": {
"alias": "爪子整体左右移动的范围",
"type": "number",
"default": 200
},
"ganMoveEndY": {
"alias": "杆子最后需要移动到的y值位置",
"type": "number",
"default": 820
},
"leftRotation": {
"alias": "左边爪子旋转角度",
"type": "number",
"default": 20
},
"rightRotation": {
"alias": "右边爪子旋转角度",
"type": "number",
"default": -20
}
},
"assets": [
{
"name": "游戏背景",
"url": "//yun.duiba.com.cn/aurora/assets/460fd0242aada85de5554391756db6ed2a232a9b.png",
"uuid": "05c378c3-bed0-4d5c-bed8-f05ae7920931",
"ext": ".png"
},
{
"name": "草泥马盒",
"url": "//yun.duiba.com.cn/aurora/assets/fde8c60981791e5136c7914274c2a2d0936626cd.png",
"uuid": "aa30ee7c-a6ad-4e10-9b6a-13b139664ab5",
"ext": ".png"
},
{
"name": "狗盒",
"url": "//yun.duiba.com.cn/aurora/assets/befb2c9ddfd8a5c4acd5126b2d793f7c1bcc40f2.png",
"uuid": "4483b626-697a-4aa4-ba57-0c22ddc7c0e6",
"ext": ".png"
},
{
"name": "猫盒",
"url": "///yun.duiba.com.cn/aurora/assets/50991e640e6bcc2eee02ba945d48a8430ddd2bee.png",
"uuid": "b70f2980-a2b3-4ef7-b060-b14dc7a8c9c8",
"ext": ".png"
},
{
"name": "后草泥马盒",
"url": "//yun.duiba.com.cn/aurora/assets/94884eafc876346e283efef2aa29bd6d2c36f627.png",
"uuid": "3f3feb30-6700-4ac7-a14e-6d7e41e8d4e8",
"ext": ".png"
},
{
"name": "后狗盒",
"url": "//yun.duiba.com.cn/aurora/assets/7deaaf45e03a626efbced90e4ad3d22373b01bd3.png",
"uuid": "b1422629-55d2-4b8b-bdd0-1b043f965248",
"ext": ".png"
},
{
"name": "后猫盒",
"url": "//yun.duiba.com.cn/aurora/assets/28a5b5b04c84d6acc86b7efb81dd6d7f717e0cda.png",
"uuid": "708da046-26e1-4ff7-abb6-35bf825a5d5b",
"ext": ".png"
},
{
"name": "中奖草泥马盒",
"url": "//yun.duiba.com.cn/aurora/assets/a47f438d016d1b178cdb5241651a78e4ea365e75.png",
"uuid": "c106cd1d-52a0-422a-976c-67151af0b484",
"ext": ".png"
},
{
"name": "中奖狗盒",
"url": "//yun.duiba.com.cn/aurora/assets/fd60c2da0ce78f7b7bed0e9c45644882a1a40d90.png",
"uuid": "3ff6fb20-4a2f-4789-998d-6078e3b603ec",
"ext": ".png"
},
{
"name": "中奖猫盒",
"url": "//yun.duiba.com.cn/aurora/assets/6211ab330a3768ff0a1920cff0ec41f29fa0903b.png",
"uuid": "04fa3325-87fc-4009-bfba-26a95d92d80c",
"ext": ".png"
},
{
"name": "前传输带",
"url": "//yun.duiba.com.cn/aurora/assets/7bccbc67b3f896176bed7d21c5f4d4307c3919be.png",
"uuid": "06bd03a4-43c3-49bb-94c5-6ef365f70291",
"ext": ".png"
},
{
"name": "后传输带",
"url": "//yun.duiba.com.cn/aurora/assets/df9b718f80747a1e21349d2b9ac35d5e19a61dad.png",
"uuid": "aa0c6ebc-164f-4767-90ca-a79be4316365",
"ext": ".png"
},
{
"name": "把手杆子",
"url": "//yun.duiba.com.cn/aurora/assets/5a9e4ba7ca6701eae85b6d6dcb0612ecb9a3eff9.png",
"uuid": "f2f1a937-00f4-442f-af4f-0bcb00656e69",
"ext": ".png"
},
{
"name": "把手",
"url": "//yun.duiba.com.cn/aurora/assets/71255a6f3cdf9f66d53589e46d72fcd20fef468d.png",
"uuid": "d9b395b5-4e46-43a5-aa2b-bfdd81c07fa7",
"ext": ".png"
},
{
"name": "伸缩杆",
"url": "//yun.duiba.com.cn/aurora/assets/a9cf8b147c52b7d4247e80e90e098f787808bfa9.png",
"uuid": "fddb4636-9c62-47b2-ba5e-f2cd820dbccc",
"ext": ".png"
},
{
"name": "左爪",
"url": "//yun.duiba.com.cn/aurora/assets/1e8634fd94bda455d11956c2847d3823e80701d3.png",
"uuid": "739014d2-3193-4853-bf8d-349bd3e8d990",
"ext": ".png"
},
{
"name": "右爪",
"url": "//yun.duiba.com.cn/aurora/assets/4bfc510e0d1fa1db77f5effa187294af38b74ff6.png",
"uuid": "4fb43b19-67e9-42cc-b461-35c005c714fb",
"ext": ".png"
},
{
"name": "连接点",
"url": "//yun.duiba.com.cn/aurora/assets/39f39234631f739e70e9ab8b713284379f4016fb.png",
"uuid": "2021124f-ffcb-487f-a24f-a00f3d8aae95",
"ext": ".png"
}
],
"events": {
"in": {
"doll-machine-reset": {
"alias": "重置"
},
"doll-machine-prize": {
"alias": "开始",
"data": {
"prize": true
}
}
},
"out": {
"doll-machine-gameover": {
"alias": "重置完毕",
"data": null
}
}
}
}
/**
* Created by rockyl on 2018/8/16.
*/
import { props } from "../props";
import { playSound, createSvga } from "./utils";
import ObjectPool = engine.ObjectPool;
import { getTextureByName } from "./utils";
import { Goods } from "./Goods";
import { PoolName } from "./object-pool-init";
import { FrontBoxs } from "./frontBox";
import { BackBoxs } from "./backBox";
import { Zhuazi } from './Zhuazi';
export default class GameView extends engine.Container {
private _hasSetup;
//触摸层
private rectBg: engine.Rect;
//npc层
private NpcBg: engine.Container;
//盒子1
private box1: engine.Container;
//盒子2
private box2: engine.Container;
//盒子3
private box3: engine.Container;
//盒子4
private box4: engine.Container;
//盒子5
private box5: engine.Container;
//前传输区域
private frontTransfer: engine.Container;
//后传输区域
private backTransfer: engine.Container;
//前台板
private frontDesk: engine.Sprite;
//后台板
private backDesk: engine.Sprite;
private _frontBoxs: FrontBoxs;
private _backBoxs: BackBoxs;
private _Zhuazi: Zhuazi;
private prizeBox: engine.Container;
private rect;
//当前分数
private score;
//中奖盒子移动距离
private moveTime;
//游戏状态
private gameIng;
//是否已获取位移值
public startstatus=false;
//是否中奖
public ifPrize=false;
//npc出身计时器
private timer;
//倒计时计时器
private countdownTimer: any;
//倒计时
private countdown: number;
//当前速度
private speed: number;
// 当前场景上面的物品
private goodsItems = [];
private _goods: Goods;
constructor() {
super();
this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);
}
// private waterSvga;
// private boomSvga;
// private playerSvga;
setup() {
if (this._hasSetup) {
return;
}
this._hasSetup = true;
const frontBoxs = (this._frontBoxs = new FrontBoxs());
this._frontBoxs.GameView = this;
const backBoxs = (this._backBoxs = new BackBoxs());
this._Zhuazi = new Zhuazi();
this._Zhuazi.GameView = this;
this.frontTransfer = new engine.Container();
this.backTransfer = new engine.Container();
this.frontTransfer.width = 0;
this.frontTransfer.height = 0;
this.frontTransfer.alpha = 1;
// this.frontTransfer.x = 0;
// this.frontTransfer.y = 434;
this.backTransfer.width = 0;
this.backTransfer.height = 0;
this.backTransfer.alpha = 1;
// this.backTransfer.x = 0;
// this.backTransfer.y = 390;
this.rect = new engine.Rect();
// this.rect.width = 608;
this.rect.width = 611;
this.rect.height = 704;
this.rect.x = 65;
this.rect.y = 263;
this.NpcBg = new engine.Container();
this.addChild(this.NpcBg);
this.addChild(this.rect);
let gameBg = new engine.Sprite(getTextureByName("游戏背景"));
gameBg.x = 65;
gameBg.y = 263;
this.NpcBg.addChild(gameBg);
this.frontDesk = new engine.Sprite(getTextureByName("前传输带"));
this.frontDesk.x = 60;
this.frontDesk.y = 781;
this.backDesk = new engine.Sprite(getTextureByName("后传输带"));
this.backDesk.x = 60;
this.backDesk.y = 712;
this.NpcBg.addChild(this.backDesk);
this.NpcBg.addChild(this.frontDesk);
this.NpcBg.addChild(this.backTransfer);
this.NpcBg.addChild(this.frontTransfer);
this.NpcBg.addChild(this._Zhuazi);
this.NpcBg.mask = this.rect;
this._Zhuazi.setup();
// this._Zhuazi.move();
this.backTransfer.addChild(this._backBoxs);
this._backBoxs.setup();
this.frontTransfer.addChild(this._frontBoxs);
this._frontBoxs.setup();
// this.player.fillColor="rgba(0, 0, 0,1)"
//console.log(this.player.fillColor)
// this.rectBg = new engine.Rect();
// this.rectBg.alpha = 0;
// this.rectBg.width = 750;
// this.rectBg.height = 1624;
// this.addChild(this.rectBg);
}
/**
*
* @param 暂停move
*/
stopMove() {
this._frontBoxs.stop();
}
/**
* 赋值x距离值
*/
setMoveX(x, item) {
this.moveTime = x;
this.prizeBox = item;
this._Zhuazi.move();
}
/**
* 显示隐藏盒子
*/
setVisible(isshow) {
this._frontBoxs.showHidePrizeBox(isshow);
}
/**
* 获取中奖盒子移动的距离
*/
getMoveX() {
return this.moveTime;
}
/**
* 重置moveTime
*/
resetMoveX() {
this.moveTime = null;
}
/**
* 获取中奖盒子
*/
getBox() {
return this.prizeBox;
}
/**
* 重置场景
*/
reset() {
this.startstatus = false;
this.ifPrize = false;
this._Zhuazi.getReset();
}
/**
* 开始
*/
start(type=null) {
this.speed = 1;
this.gameIng = true;
console.log('执行', type);
this.startstatus = true;
this.ifPrize = type && type.prize || false;
// this.creatNpc()
// this.beginNpc();
// this.countdown = props.countDown;
// this.countdownTimer = setInterval(() => {
// if (this.gameIng) {
// if (this.countdown > 0) {
// engine.globalEvent.dispatchEvent("food-fell-time-update", {
// time: this.countdown
// });
// this.countdown -= 1;
// } else {
// engine.globalEvent.dispatchEvent("food-fell-game-over", {
// score: this.score,
// reason: 1
// });
// this.died();
// }
// }
// }, 1000);
}
/**
* npc开始掉落
*/
beginNpc() {
this.timer = setTimeout(() => {
if (this.gameIng) {
// this.speed += props.acceleratedSpeed;
// this.creatNpc()
}
//递归执行
// this.beginNpc();
}, 2000 / this.speed);
}
/**
* 暂停
*/
pause() {
this.gameIng = false;
}
/**
* 恢复
*/
revive() {
this.gameIng = true;
}
/**
* 重新开始
*/
resume() {
this.reset();
this.start();
}
/**
* 初始化盒子位置
*/
initNpc() {
this.box1 = new engine.Sprite(getTextureByName("草泥马盒"));
this.box2 = new engine.Sprite(getTextureByName("狗盒"));
this.box3 = new engine.Sprite(getTextureByName("猫盒"));
this.box4 = new engine.Sprite(getTextureByName("草泥马盒"));
this.box5 = new engine.Sprite(getTextureByName("猫盒"));
this.box1.x = 120;
this.box1.y = 434;
this.box2.x = 306;
this.box2.y = 434;
this.box3.x = 487;
this.box3.y = 434;
this.box4.x = 240;
this.box4.scaleX = 0.5;
this.box4.scaleY = 0.5;
this.box4.y = 390;
this.box5.x = 434;
this.box5.y = 390;
this.box5.scaleX = 0.5;
this.box5.scaleY = 0.5;
this.backTransfer.addChild(this.box4);
this.backTransfer.addChild(this.box5);
this.frontTransfer.addChild(this.box1);
this.frontTransfer.addChild(this.box2);
this.frontTransfer.addChild(this.box3);
}
/**
* 创建NPC
*/
// private creatNpc() {
// // this.initNpc();
// let goods = (this._goods = <Goods>ObjectPool.getObject(PoolName));
// console.log(goods);
// this.goodsItems.push(goods);
// this.NpcBg.addChild(goods);
// goods.addEventListener(
// engine.Event.ENTER_FRAME,
// (goods["onGoodsEnter"] = () => {
// if (goods.y > 1624) {
// this.removeNpc(goods);
// } else {
// if (this.gameIng) {
// //速度叠加
// // goods.y += (4 * this.speed)
// goods.x += 2 * this.speed;
// //如果玩家和物品发生碰撞
// if (this.hasHit(this.player, goods)) {
// if (goods["npcType"] == "rain") {
// console.log("碰到雨滴");
// this.score += props.rainScore;
// this.waterSvga.visible = true;
// this.waterSvga.play(false, false);
// this.waterSvga.once(
// engine.Event.END_FRAME,
// () => {
// this.waterSvga.visible = false;
// },
// this
// );
// } else if (goods["npcType"] == "stone") {
// console.log("碰到石头");
// this.score += props.stoneScore;
// } else if (goods["npcType"] == "boom") {
// console.log("碰到炸弹");
// this.boomSvga.visible = true;
// this.boomSvga.play(false, false);
// this.boomSvga.once(
// engine.Event.END_FRAME,
// () => {
// this.boomSvga.visible = false;
// },
// this
// );
// engine.globalEvent.dispatchEvent("food-fell-game-over", {
// score: this.score,
// reason: 2
// });
// this.died();
// }
// engine.globalEvent.dispatchEvent("food-fell-score-update", {
// score: this.score
// });
// this.removeNpc(goods);
// }
// }
// }
// }),
// this
// );
// }
/**
* 玩家死亡
*/
private died() {
this.score = 0;
this.pause();
}
/**
* 回收指定物品
* @param goods 物品
*/
private removeNpc(goods) {
this.NpcBg.removeChild(goods);
ObjectPool.recycleObject(PoolName, goods);
goods.removeEventListener(
engine.Event.ENTER_FRAME,
goods["onGoodsEnter"],
this
);
let index = this.goodsItems.indexOf(goods);
if (index > -1) {
this.goodsItems.splice(index, 1);
}
}
/**
* 回收对象
*/
private recycleGoods() {
clearTimeout(this.timer);
clearInterval(this.countdownTimer);
for (let goods of this.goodsItems) {
if (goods) {
this.removeChild(goods);
ObjectPool.recycleObject(PoolName, goods);
goods.removeEventListener(
engine.Event.ENTER_FRAME,
goods["onGoodsEnter"],
this
);
}
}
this.goodsItems = [];
}
/**
* 碰撞检测
* @param a a盒子
* @param b b盒子
*/
private hasHit(a, b) {
if (
Math.abs(a.x + a.width / 2 - (b.x + b.width / 2)) <
a.width / 2 + b.width / 2 &&
Math.abs(a.y + a.height / 2 - (b.y + b.height / 2)) <
a.height / 2 + b.height / 2
) {
return true;
} else {
return false;
}
}
}
/**
* 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('doll-machine-reset', this.reset, this);
engine.globalEvent.addEventListener('doll-machine-prize', this.start, this);
// engine.globalEvent.addEventListener('food-fell-start', this.start, this);
// engine.globalEvent.addEventListener('food-fell-pause', this.pause, this);
// engine.globalEvent.addEventListener('food-fell-resume', this.resume, this);
// engine.globalEvent.addEventListener('food-fell-revive', this.revive, this);
// engine.globalEvent.addEventListener('food-fell-clear', this.clear, this);
// this.addEventListener(engine.MouseEvent.CLICK, this.onTap, this);
let gameView = this._gameView = new GameView();
this.addChild(gameView);
// gameView.reset();
// gameView.start()
}
reset(event: engine.Event) {
injectProps(event.data);
this._gameView.visible = true;
this._gameView.reset();
}
start(event: engine.Event) {
console.log('监听开始');
injectProps(event.data);
// this._status = 1;
this._gameView.start(event.data);
}
pause() {
this._gameView.pause();
}
resume() {
this._gameView.resume();
}
revive() {
this._gameView.revive();
}
clear() {
this._gameView.visible = false;
}
private onTap(event) {
// this._gameView.tap(event);
}
}
/**
* Created by rockyl on 2020-02-02.
*
* 掉落物品
*/
import { getTextureByName } from "./utils";
import { props } from "../props";
export class Goods extends engine.Container {
private _body: engine.Rect;
private _toY;
constructor() {
super();
let body;
body = this._body = new engine.Rect();
// let rain = new engine.Sprite(getTextureByName('雨滴'));
// rain["npcType"]="rain"
// let stone = new engine.Sprite(getTextureByName('石块'));
// stone["npcType"]="stone"
// let boom = new engine.Sprite(getTextureByName('炸弹'));
// boom["npcType"]="boom"
let box1 = new engine.Sprite(getTextureByName("草泥马盒"));
box1["npcType"] = "box1";
let box2 = new engine.Sprite(getTextureByName("狗盒"));
box2["npcType"] = "box2";
let box3 = new engine.Sprite(getTextureByName("猫盒"));
box3["npcType"] = "box3";
// rain.visible=false;
// stone.visible=false;
// boom.visible=false;
// body.addChild(rain)
// body.addChild(stone)
// body.addChild(boom)
box1.visible = false;
box2.visible = false;
box3.visible = false;
body.addChild(box1);
body.addChild(box2);
body.addChild(box3);
this.addChild(body);
body.width = 0.0001;
body.height = 0.0001;
body.mouseEnabled = false;
}
getRandomNumberByRange(start, end) {
return Math.floor(Math.random() * (end - start) + start);
}
// reset() {
// this.visible = true;
// this.rotation = 0;
// this.anchorOffsetY = 0;
// this.y = 0;
// this.x = (750-120)*Math.random()+30;
// this.rotation = 0;
// let random=Math.random()
// if(random<props.goodsProbability[0]){
// this.showNpc("box1")
// }else if(random>=props.goodsProbability[0]&&random<=(props.goodsProbability[0]+props.goodsProbability[1])){
// this.showNpc("box2")
// }else if(random>(props.goodsProbability[0]+props.goodsProbability[1])){
// this.showNpc("box3")
// }
// }
reset() {
this.visible = true;
this.y = 200;
this.x = 0;
this.rotation = 0;
let random = Math.random();
if (random < 0.3) {
this.showNpc("box1");
} else if (random < 0.6) {
this.showNpc("box2");
} else {
this.showNpc("box3");
}
// this.showNpc("box1");
// this.showNpc("box2");
// this.showNpc("box3");
}
showNpc(type) {
for (let i = 0; i < this._body.children.length; i++) {
this._body.children[i].visible = false;
this._body.children[i].mouseEnabled = false;
}
for (let i = 0; i < this._body.children.length; i++) {
if (this._body.children[i]["npcType"] == type) {
this["npcType"] = type;
console.log(type);
this._body.children[i].visible = true;
this._body.children[i].mouseEnabled = false;
}
}
}
set anchorOffsetY(v) {
this._body.y = v;
}
}
import { getTextureByName } from "./utils";
import { props } from "../props";
import GameView from './GameView';
export class Zhuazi extends engine.Container {
private bashouGan: engine.Sprite;
private bashou: engine.Sprite;
private ganzi: engine.Sprite;
private left_zhuazi: engine.Sprite;
private right_zhuazi: engine.Sprite;
private connect: engine.Sprite;
private ganNode: engine.Container;
private moveNode: engine.Container;
private moveArr = [];
private zhuaziY;
//盒子1
private box1: engine.Container;
//盒子2
private box2: engine.Container;
//盒子3
private box3: engine.Container;
//盒子4
private box4: engine.Container;
//盒子5
private box5: engine.Container;
private itemShow: engine.Container;
private prizeBoxs = [];
public GameView: GameView;
constructor() {
super();
}
setup() {
this.ganNode = new engine.Container();
this.moveNode = new engine.Container();
this.ganNode.x = 280;
this.ganNode.y = 350;
this.bashouGan = new engine.Sprite(getTextureByName("把手杆子"));
this.bashouGan.x = 60;
this.bashouGan.y = 275;
this.bashou = new engine.Sprite(getTextureByName("把手"));
this.bashou.x = 0;
this.bashou.y = 263;
this.ganzi = new engine.Sprite(getTextureByName("伸缩杆"));
this.ganzi.x = 97;
this.ganzi.y = 290;
this.connect = new engine.Sprite(getTextureByName("连接点"));
this.connect.x = 18;
this.connect.y = -5;
this.left_zhuazi = new engine.Sprite(getTextureByName("左爪"));
this.left_zhuazi.x = -15;
this.left_zhuazi.y = 60;
this.left_zhuazi.anchorX = this.left_zhuazi.width;
this.left_zhuazi.anchorY = 0;
this.right_zhuazi = new engine.Sprite(getTextureByName("右爪"));
this.right_zhuazi.x = 98;
this.right_zhuazi.y = 60;
this.ganNode.addChild(this.left_zhuazi);
this.ganNode.addChild(this.right_zhuazi);
this.ganNode.addChild(this.connect);
this.ganNode.x = 30;
this.zhuaziY = this.ganNode.y;
this.moveNode.addChild(this.ganzi);
this.moveNode.addChild(this.ganNode);
this.moveNode.addChild(this.bashou);
this.moveNode.x = 262;
// this.moveNode.
// this.moveArr = [this.bashou, this.ganzi, this.ganNode];
this.addChild(this.bashouGan);
// this.addChild(this.ganzi);
// this.addChild(this.bashou);
// this.addChild(this.ganNode);
this.addChild(this.moveNode);
this.createPrizeBox();
// setTimeout(() => {
// this.move();
// }, 2000)
}
createPrizeBox() {
this.box1 = new engine.Sprite(getTextureByName("中奖狗盒"));
this.box1["npcType"] = "box1";
this.box2 = new engine.Sprite(getTextureByName("中奖猫盒"));
this.box2["npcType"] = "box2";
this.box3 = new engine.Sprite(getTextureByName("中奖草泥马盒"));
this.box3["npcType"] = "box3";
this.box4 = new engine.Sprite(getTextureByName("中奖狗盒"));
this.box4["npcType"] = "box4";
this.box5 = new engine.Sprite(getTextureByName("中奖猫盒"));
this.box5["npcType"] = "box5";
this.prizeBoxs = [this.box1, this.box2, this.box3, this.box4, this.box5];
this.prizeBoxs.forEach(item => {
this.ganNode.addChild(item);
item.visible = false;
item.x = 15;
item.y = 48;
})
}
showPrizeBox() {
this.prizeBoxs.forEach(item => {
console.log(this.GameView.getBox()['npcType']);
if (item['npcType'] === this.GameView.getBox()['npcType']) {
item.visible = true;
this.itemShow = item;
} else {
item.visible = false;
}
})
}
move() {
let rndist = Math.random();
let halfWidth = this.bashou.width / 2;
let randomX = rndist * (rndist > 0.5 ? 1 : -1) * props.bashouMoveDist;
console.log(randomX);
engine.Tween.get(this.moveNode).to({ x: 370 + halfWidth - 71}, 1000).call(() => {
this.zhangkai();
});
}
zhangkai() {
this.left_zhuazi.anchorX = this.left_zhuazi.width;
this.left_zhuazi.anchorY = 0;
engine.Tween.get(this.left_zhuazi, { loop: false }).to({ rotation: props.leftRotation}, 1000);
engine.Tween.get(this.right_zhuazi, { loop: false }).to({ rotation: props.rightRotation }, 1000);
setTimeout(() => {
this.getLong();
}, 500);
}
getLong() {
let droptime = Number((this.GameView.getMoveX() / 60 - 1).toFixed(2)) * 1000;
console.log('dr', droptime);
let times = (props.ganMoveEndY - this.ganzi.y ) / this.ganzi.height;
console.log(Number(times.toFixed(2)) );
engine.Tween.get(this.ganzi).to({ scaleY: Number(times.toFixed(2)) }, droptime).to({ scaleY: 1 }, droptime)
console.log('node', this.zhuaziY);
engine.Tween.get(this.ganNode).to({ y: props.ganMoveEndY }, droptime).call(() => {
this.GameView.stopMove();
if (this.GameView.ifPrize) {
this.showPrizeBox();
this.GameView.setVisible(false);
}
}).to({ y: this.zhuaziY }, droptime).call(() => {
// this.getReset();
if (this.GameView.ifPrize) {
this.itemShow.visible = false;
}
engine.globalEvent.dispatchEvent('doll-machine-gameover');
})
}
getReset() {
// if (this.GameView.ifPrize) {
// this.itemShow.visible = false;
// }
this.left_zhuazi.anchorX = this.left_zhuazi.width;
this.left_zhuazi.anchorY = 0;
engine.Tween.get(this.moveNode, {loop: false}).to({x: 262}, 1000);
engine.Tween.get(this.left_zhuazi, { loop: false }).to({ rotation: 0 }, 1000);
engine.Tween.get(this.right_zhuazi, { loop: false }).to({ rotation: 0 }, 1000);
this.GameView.resetMoveX();
}
}
\ No newline at end of file
import { getTextureByName } from "./utils";
import { props } from "../props";
export class BackBoxs extends engine.Container {
//盒子1
private box1: engine.Container;
//盒子2
private box2: engine.Container;
//盒子3
private box3: engine.Container;
//盒子4
private box4: engine.Container;
//盒子5
private box5: engine.Container;
private backBoxs=[];
constructor() {
super();
}
setup() {
let initX , initY = 0;
this.box1 = new engine.Sprite(getTextureByName("后狗盒"));
initX = this.box1.x = 188;
initY = this.box1.y = 616;
this.box2 = new engine.Sprite(getTextureByName("后猫盒"));
this.box3 = new engine.Sprite(getTextureByName("后草泥马盒"));
this.box4 = new engine.Sprite(getTextureByName("后狗盒"));
this.box5 = new engine.Sprite(getTextureByName("后猫盒"));
this.backBoxs = [this.box1, this.box2, this.box3, this.box4, this.box5];
for (let i = 0; i < this.backBoxs.length; i++) {
// this.backBoxs[i].scaleX = 0.5;
// this.backBoxs[i].scaleY = 0.5;
if(i == 0) {
this.backBoxs[i].x = initX;
} else {
this.backBoxs[i].x = this.backBoxs[i - 1].x + this.backBoxs[i].width + props.backmargin;
}
this.backBoxs[i].y = initY;
this.addChild(this.backBoxs[i]);
}
this.addEventListener(engine.Event.ENTER_FRAME, this.frameMove, this);
}
frameMove() {
this.backBoxs.forEach((item) => {
item.x -= props.moveSpeed;
if (item.x <= 0) {
let lastitem = this.backBoxs.shift();
lastitem.x = this.backBoxs[this.backBoxs.length - 1].x + item.width + props.backmargin;
this.backBoxs.push(lastitem);
}
})
}
}
\ No newline at end of file
import { getTextureByName } from "./utils";
import GameView from './GameView';
import { props } from "../props";
export class FrontBoxs extends engine.Container {
//盒子1
private box1: engine.Container;
//盒子2
private box2: engine.Container;
//盒子3
private box3: engine.Container;
//盒子4
private box4: engine.Container;
//盒子5
private box5: engine.Container;
// 需隐藏的盒子
private hideBox: engine.Container;
private frontBoxs=[];
public GameView: GameView;
constructor() {
super();
}
setup() {
let initX , initY = 0;
this.box1 = new engine.Sprite(getTextureByName("狗盒"));
this.box1["npcType"] = "box1";
initX = this.box1.x = 435;
initY = this.box1.y = 614;
this.box2 = new engine.Sprite(getTextureByName("猫盒"));
this.box2["npcType"] = "box2";
this.box3 = new engine.Sprite(getTextureByName("草泥马盒"));
this.box3["npcType"] = "box3";
this.box4 = new engine.Sprite(getTextureByName("狗盒"));
this.box4["npcType"] = "box4";
this.box5 = new engine.Sprite(getTextureByName("猫盒"));
this.box5["npcType"] = "box5";
this.frontBoxs = [this.box1, this.box2, this.box3, this.box4];
for(let i = 0; i < this.frontBoxs.length; i++) {
if(i == 0) {
this.frontBoxs[i].x = initX ;
} else {
this.frontBoxs[i].x = this.frontBoxs[i - 1].x - this.box1.width - props.frontmargin;
}
this.frontBoxs[i].y = initY;
this.addChild(this.frontBoxs[i]);
}
this.addEventListener(engine.Event.ENTER_FRAME, this.frameMove, this);
}
frameMove() {
this.frontBoxs.forEach((item, index) => {
item.x += props.moveSpeed;
if(item.x <=0 && !item.visible) {
item.visible = true;
}
if(item.x >= 750) {
let lastitem = this.frontBoxs.shift();
lastitem.x = this.frontBoxs[this.frontBoxs.length - 1].x - this.box1.width - props.frontmargin;
if (!this.GameView.getMoveX() && item.x <= 0 && this.GameView.startstatus) {
this.GameView.setMoveX((370 - item.x - 13) / props.moveSpeed, item);
this.hideBox = item;
}
this.frontBoxs.push(lastitem);
}
})
}
stop() {
// this.removeEventListener(engine.Event.ENTER_FRAME, this.frameMove, this);
}
showHidePrizeBox(isshow) {
this.hideBox.visible = isshow
}
}
\ No newline at end of file
/**
* 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();
});
/**
* 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;
}
\ No newline at end of file
/**
* Created by rockyl on 2019-11-20.
*/
import {GameWrapper} from "./game/GameWrapper";
import {injectProps, prepareProps} from "./props";
export default function (props) {
prepareProps();
injectProps(props);
let instance = new GameWrapper();
return instance;
}
/**
* Created by rockyl on 2020-01-21.
*/
export let props: any = {};
export function prepareProps() {
let metaProps = getProps();
engine.injectProp(props, metaProps);
}
export function injectProps(p) {
engine.injectProp(props, p);
}
/**
* Created by renjianfeng on 2020-03-13.
*/
const customId = "doll-machine2";
(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,
}
}],
}, null, function () {
setTimeout(() => {
engine.addCustomModule(customId, engine.gameStage.sceneContainer.getChildAt(0));
}, 100);
setTimeout(() => {
engine.globalEvent.dispatchEvent('food-fell-reset', {
"goodsProbability": [0.8,0.1,0.1],
"countDown": 30,
"acceleratedSpeed":0.1
});
engine.globalEvent.dispatchEvent('food-fell-start');
}, 500);
});
engine.globalEvent.addEventListener('food-fell-time-update', (e) => {
console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('food-fell-score-update', (e) => {
console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('food-fell-game-over', (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: red;
}
</style>
</head>
<body>
<div id="game-container" style="line-height:0;font-size:0"></div>
<script crossorigin="anonymous" src="//yun.duiba.com.cn/editor/zeroing/libs/engine.50cdcef6ebe4e8c0fbc624f9d4fbf225102c5750.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/50a7212a113175fa18c866b005d98f07c558dc77.png",
"uuid": "66f23d13-82a5-4cec-9496-301ec240d087",
"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['doll-machine2'] = factory(global.tslib));
}(this, (function (tslib) { 'use strict';
var props = {};
function prepareProps() {
var metaProps = getProps();
engine.injectProp(props, metaProps);
}
function injectProps(p) {
engine.injectProp(props, p);
}
//# sourceMappingURL=props.js.map
function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
//# sourceMappingURL=utils.js.map
var FrontBoxs = (function (_super) {
tslib.__extends(FrontBoxs, _super);
function FrontBoxs() {
var _this = _super.call(this) || this;
_this.frontBoxs = [];
return _this;
}
FrontBoxs.prototype.setup = function () {
var initX, initY = 0;
for (var i = 0; i < props.dollNum; i++) {
if (!new engine.Sprite(getTextureByName('frontbox_' + i))) {
return;
}
this.frontBoxs[i] = new engine.Sprite(getTextureByName('frontbox_' + i));
initX = this.frontBoxs[0].x = props.frontInitX;
initY = this.frontBoxs[0].y = props.frontInitY;
this.frontBoxs[i]['npcType'] = 'box' + i;
}
this.frontBoxs[props.dollNum] = new engine.Sprite(getTextureByName('frontbox_0'));
this.frontBoxs[props.dollNum]['npcType'] = 'box' + props.dollNum;
console.log(this.frontBoxs);
for (var i = 0; i < this.frontBoxs.length; i++) {
if (i == 0) {
this.frontBoxs[i].x = initX;
}
else {
this.frontBoxs[i].x = this.frontBoxs[i - 1].x - this.frontBoxs[0].width - props.frontmargin;
}
console.log(this.frontBoxs[i].x);
this.frontBoxs[i].y = initY;
this.addChild(this.frontBoxs[i]);
console.log('aaa', this.frontBoxs[i].x);
}
this.addEventListener(engine.Event.ENTER_FRAME, this.frameMove, this);
};
FrontBoxs.prototype.frameMove = function () {
var _this = this;
this.frontBoxs.forEach(function (item, index) {
item.x += props.moveSpeed;
if (item.x <= 0 && !item.visible) {
item.visible = true;
}
if (item.x >= 750) {
var tmpIndex = 0;
if (index <= 0) {
tmpIndex = _this.frontBoxs.length - 1;
}
else {
tmpIndex = index - 1;
}
item.x = _this.frontBoxs[tmpIndex].x - _this.frontBoxs[0].width - props.frontmargin;
if (!_this.GameView.getMoveX() && item.x <= 0 && _this.GameView.startstatus) {
_this.GameView.setMoveX((370 - item.x - 13) / props.moveSpeed, item);
_this.hideBox = item;
}
}
});
};
FrontBoxs.prototype.stop = function () {
};
FrontBoxs.prototype.showHidePrizeBox = function (isshow) {
this.hideBox.visible = isshow;
};
return FrontBoxs;
}(engine.Container));
//# sourceMappingURL=frontBox.js.map
var BackBoxs = (function (_super) {
tslib.__extends(BackBoxs, _super);
function BackBoxs() {
var _this = _super.call(this) || this;
_this.backBoxs = [];
return _this;
}
BackBoxs.prototype.setup = function () {
var initX, initY = 0;
for (var i = 0; i < props.dollNum; i++) {
this.backBoxs[i] = new engine.Sprite(getTextureByName('backbox_' + i));
initX = this.backBoxs[0].x = props.backInitX;
initY = this.backBoxs[0].y = props.backInitY - props.initOffsetTop;
this.backBoxs[i]['npcType'] = 'box' + i;
}
this.backBoxs[props.dollNum] = new engine.Sprite(getTextureByName('backbox_0'));
this.backBoxs[props.dollNum]['npcType'] = 'box' + props.dollNum;
for (var i = 0; i < this.backBoxs.length; i++) {
if (i == 0) {
this.backBoxs[i].x = initX;
}
else {
this.backBoxs[i].x = this.backBoxs[i - 1].x + this.backBoxs[i].width + props.backmargin;
}
this.backBoxs[i].y = initY;
this.addChild(this.backBoxs[i]);
}
this.addEventListener(engine.Event.ENTER_FRAME, this.frameMove, this);
};
BackBoxs.prototype.frameMove = function () {
var _this = this;
this.backBoxs.forEach(function (item) {
item.x -= props.moveSpeed;
if (item.x <= 0) {
var lastitem = _this.backBoxs.shift();
lastitem.x = _this.backBoxs[_this.backBoxs.length - 1].x + item.width + props.backmargin;
_this.backBoxs.push(lastitem);
}
});
};
return BackBoxs;
}(engine.Container));
//# sourceMappingURL=backBox.js.map
var Zhuazi = (function (_super) {
tslib.__extends(Zhuazi, _super);
function Zhuazi() {
var _this = _super.call(this) || this;
_this.moveArr = [];
_this.prizeBoxs = [];
return _this;
}
Zhuazi.prototype.setup = function () {
this.ganNode = new engine.Container();
this.moveNode = new engine.Container();
this.ganNode.x = 280;
this.ganNode.y = 350;
this.bashouGan = new engine.Sprite(getTextureByName("把手杆子"));
this.bashouGan.x = 60;
this.bashouGan.y = 12;
this.bashou = new engine.Sprite(getTextureByName("把手"));
this.bashou.x = 0;
this.bashou.y = 0;
this.ganzi = new engine.Sprite(getTextureByName("伸缩杆"));
this.ganzi.x = 97;
this.ganzi.y = 27;
this.connect = new engine.Sprite(getTextureByName("连接点"));
this.connect.x = 18;
this.connect.y = -5;
this.left_zhuazi = new engine.Sprite(getTextureByName("左爪"));
this.left_zhuazi.x = props.leftLocX;
this.left_zhuazi.y = props.leftLocY;
this.left_zhuazi.anchorX = this.left_zhuazi.width;
this.left_zhuazi.anchorY = 0;
this.right_zhuazi = new engine.Sprite(getTextureByName("右爪"));
this.right_zhuazi.x = props.rightLocX;
this.right_zhuazi.y = props.rightLocY;
this.ganNode.addChild(this.left_zhuazi);
this.ganNode.addChild(this.right_zhuazi);
this.ganNode.addChild(this.connect);
this.ganNode.x = 30;
this.ganNode.y = this.ganNode.y - 263;
this.zhuaziY = this.ganNode.y;
this.moveNode.addChild(this.ganzi);
this.moveNode.addChild(this.ganNode);
this.moveNode.addChild(this.bashou);
this.moveNode.x = 262;
this.bashouGan.y = this.bashouGan.y;
this.moveNode.y = this.moveNode.y;
this.addChild(this.bashouGan);
this.addChild(this.moveNode);
if (!props.ganziShow) {
this.bashouGan.visible = false;
}
if (!props.bashouShow) {
this.bashou.visible = false;
}
this.createPrizeBox();
};
Zhuazi.prototype.createPrizeBox = function () {
var _this = this;
for (var i = 0; i < props.dollNum; i++) {
if (!new engine.Sprite(getTextureByName('prizebox_' + i))) {
return;
}
this.prizeBoxs[i] = new engine.Sprite(getTextureByName('prizebox_' + i));
this.prizeBoxs[i]['npcType'] = 'box' + i;
}
this.prizeBoxs[props.dollNum] = new engine.Sprite(getTextureByName('prizebox_0'));
this.prizeBoxs[props.dollNum]['npcType'] = 'box' + props.dollNum;
this.prizeBoxs.forEach(function (item) {
_this.ganNode.addChild(item);
item.visible = false;
item.x = props.prizeBoxInitX;
item.y = props.prizeBoxInitY;
});
};
Zhuazi.prototype.showPrizeBox = function () {
var _this = this;
this.prizeBoxs.forEach(function (item) {
console.log(_this.GameView.getBox()['npcType']);
if (item['npcType'] === _this.GameView.getBox()['npcType']) {
item.visible = true;
_this.itemShow = item;
}
else {
item.visible = false;
}
});
};
Zhuazi.prototype.move = function () {
var _this = this;
var rndist = Math.random();
var halfWidth = this.bashou.width / 2;
var randomX = rndist * (rndist > 0.5 ? 1 : -1) * props.bashouMoveDist;
console.log(randomX);
engine.Tween.get(this.moveNode).to({ x: 370 + halfWidth - 71 }, 1000).call(function () {
_this.zhangkai();
});
};
Zhuazi.prototype.zhangkai = function () {
var _this = this;
this.left_zhuazi.anchorX = this.left_zhuazi.width;
this.left_zhuazi.anchorY = 0;
engine.Tween.get(this.left_zhuazi, { loop: false }).to({ rotation: props.leftRotation }, 1000);
engine.Tween.get(this.right_zhuazi, { loop: false }).to({ rotation: props.rightRotation }, 1000);
setTimeout(function () {
_this.getLong();
}, 500);
};
Zhuazi.prototype.getLong = function () {
var _this = this;
var droptime = Number((this.GameView.getMoveX() / 60 - 1).toFixed(2)) * 1000 - 130;
console.log('dr', droptime);
var times = (props.ganMoveEndY - this.ganzi.y) / this.ganzi.height;
console.log(Number(times.toFixed(2)));
engine.Tween.get(this.ganzi).to({ scaleY: Number(times.toFixed(2)) }, droptime).to({ scaleY: 1 }, droptime);
console.log('node', this.zhuaziY);
engine.Tween.get(this.ganNode).to({ y: props.ganMoveEndY }, droptime).call(function () {
_this.GameView.stopMove();
if (_this.GameView.ifPrize) {
_this.showPrizeBox();
_this.GameView.setVisible(false);
}
}).to({ y: this.zhuaziY }, droptime).call(function () {
if (_this.GameView.ifPrize) {
_this.itemShow.visible = false;
}
engine.globalEvent.dispatchEvent('doll-machine2-game-end');
});
};
Zhuazi.prototype.getReset = function () {
this.left_zhuazi.anchorX = this.left_zhuazi.width;
this.left_zhuazi.anchorY = 0;
engine.Tween.get(this.moveNode, { loop: false }).to({ x: 262 }, 1000);
engine.Tween.get(this.left_zhuazi, { loop: false }).to({ rotation: 0 }, 1000);
engine.Tween.get(this.right_zhuazi, { loop: false }).to({ rotation: 0 }, 1000);
this.GameView.resetMoveX();
};
return Zhuazi;
}(engine.Container));
//# sourceMappingURL=Zhuazi.js.map
var GameView = (function (_super) {
tslib.__extends(GameView, _super);
function GameView() {
var _this = _super.call(this) || this;
_this.startstatus = false;
_this.ifPrize = false;
_this.goodsItems = [];
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
return _this;
}
GameView.prototype.setup = function () {
var _this = this;
if (this._hasSetup) {
return;
}
this._hasSetup = true;
var frontBoxs = (this._frontBoxs = new FrontBoxs());
this._frontBoxs.GameView = this;
var backBoxs = (this._backBoxs = new BackBoxs());
this._Zhuazi = new Zhuazi();
this._Zhuazi.GameView = this;
this.frontTransfer = new engine.Container();
this.backTransfer = new engine.Container();
this.frontTransfer.width = 0;
this.frontTransfer.height = 0;
this.frontTransfer.alpha = 1;
this.backTransfer.width = 0;
this.backTransfer.height = 0;
this.backTransfer.alpha = 1;
this.rect = new engine.Rect();
this.rect.width = props.gameStageWidth;
this.rect.height = props.gameStageHeight;
this.rect.x = 65;
this.rect.y = 0;
this.NpcBg = new engine.Container();
this.NpcBg.x = 0;
this.NpcBg.y = 0;
this.addChild(this.NpcBg);
this.addChild(this.rect);
this.frontDesk = new engine.Sprite(getTextureByName("前传输带"));
this.frontDesk.x = props.initOffsetLeft;
this.frontDesk.y = props.frontDeskY - props.initOffsetTop;
this.backDesk = new engine.Sprite(getTextureByName("后传输带"));
this.backDesk.x = props.initOffsetLeft;
this.backDesk.y = props.backDeskY - props.initOffsetTop;
if (props.single) {
this.backDesk.visible = false;
}
var pcarr = [this.backDesk, this.frontDesk, this.backTransfer, this.frontTransfer, this._Zhuazi];
pcarr.forEach(function (item) {
_this.NpcBg.addChild(item);
});
this.NpcBg.mask = this.rect;
this._Zhuazi.setup();
this.backTransfer.addChild(this._backBoxs);
this._backBoxs.setup();
if (props.single) {
this.backTransfer.visible = false;
}
this.frontTransfer.addChild(this._frontBoxs);
this._frontBoxs.setup();
};
GameView.prototype.stopMove = function () {
this._frontBoxs.stop();
};
GameView.prototype.setMoveX = function (x, item) {
this.moveTime = x;
this.prizeBox = item;
this._Zhuazi.move();
};
GameView.prototype.setVisible = function (isshow) {
this._frontBoxs.showHidePrizeBox(isshow);
};
GameView.prototype.getMoveX = function () {
return this.moveTime;
};
GameView.prototype.resetMoveX = function () {
this.moveTime = null;
};
GameView.prototype.getBox = function () {
return this.prizeBox;
};
GameView.prototype.reset = function () {
this.startstatus = false;
this.ifPrize = false;
this._Zhuazi.getReset();
};
GameView.prototype.start = function (type) {
if (type === void 0) { type = null; }
this.speed = 1;
this.gameIng = true;
console.log('执行', type);
this.startstatus = true;
this.ifPrize = type && type.prize || false;
};
GameView.prototype.beginNpc = function () {
var _this = this;
this.timer = setTimeout(function () {
if (_this.gameIng) ;
}, 2000 / this.speed);
};
GameView.prototype.pause = function () {
this.gameIng = false;
};
GameView.prototype.revive = function () {
this.gameIng = true;
};
GameView.prototype.resume = function () {
this.reset();
this.start();
};
return GameView;
}(engine.Container));
var GameWrapper = (function (_super) {
tslib.__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('doll-machine2-game-init', _this.reset, _this);
engine.globalEvent.addEventListener('doll-machine2-game-start', _this.start, _this);
var gameView = _this._gameView = new GameView();
_this.addChild(gameView);
return _this;
}
GameWrapper.prototype.reset = function (event) {
injectProps(event.data);
this._gameView.visible = true;
this._gameView.reset();
};
GameWrapper.prototype.start = function (event) {
console.log('监听开始');
injectProps(event.data);
this._gameView.start(event.data);
};
GameWrapper.prototype.pause = function () {
this._gameView.pause();
};
GameWrapper.prototype.resume = function () {
this._gameView.resume();
};
GameWrapper.prototype.revive = function () {
this._gameView.revive();
};
GameWrapper.prototype.clear = function () {
this._gameView.visible = false;
};
GameWrapper.prototype.onTap = function (event) {
};
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/doll-machine2/src/props.ts","src/custom/doll-machine2/src/game/utils.ts","src/custom/doll-machine2/src/game/frontBox.ts","src/custom/doll-machine2/src/game/backBox.ts","src/custom/doll-machine2/src/game/Zhuazi.ts","src/custom/doll-machine2/src/game/GameView.ts","src/custom/doll-machine2/src/game/GameWrapper.ts","src/custom/doll-machine2/src/index.ts"],"sourcesContent":["/**\n * Created by rockyl on 2020-01-21.\n */\n\nexport let props: any = {};\n\nexport function prepareProps() {\n\tlet metaProps = getProps();\n\n\tengine.injectProp(props, metaProps);\n}\n\nexport function injectProps(p) {\n\tengine.injectProp(props, p);\n}\n","/**\n * Created by rockyl on 2020-01-21.\n */\n\nexport function getTexture(uuid) {\n\treturn engine.Texture.from(getAssetByUUID(uuid).uuid);\n}\n\nexport function getTextureByName(name) {\n\treturn getTexture(engine.getAssetByName(name).uuid);\n}\n\nexport function playSound(name) {\n\tengine.playSound(engine.getAssetByName(name).uuid, {keep: true});\n}\nexport function createSvga(name, anchorName?) {\n\tlet inst = new svga.Svga();\n\tinst.source = 'asset://' + engine.getAssetByName(name).uuid;\n\treturn inst;\n}","import { getTextureByName } from \"./utils\";\nimport GameView from './GameView';\nimport { props } from \"../props\";\nexport class FrontBoxs extends engine.Container {\n //盒子1\n private box1: engine.Container;\n //盒子2\n private box2: engine.Container;\n //盒子3 \n private box3: engine.Container;\n //盒子4\n private box4: engine.Container;\n //盒子5\n private box5: engine.Container;\n // 需隐藏的盒子\n private hideBox: engine.Container;\n private frontBoxs=[];\n public GameView: GameView;\n constructor() {\n super();\n }\n setup() {\n let initX , initY = 0;\n for(let i = 0; i < props.dollNum; i++) {\n if (!new engine.Sprite(getTextureByName('frontbox_' + i))) {\n return;\n }\n\n this.frontBoxs[i] = new engine.Sprite(getTextureByName('frontbox_'+i));\n initX = this.frontBoxs[0].x = props.frontInitX;\n initY = this.frontBoxs[0].y = props.frontInitY;\n this.frontBoxs[i]['npcType'] = 'box'+i;\n }\n this.frontBoxs[props.dollNum] = new engine.Sprite(getTextureByName('frontbox_0'));\n this.frontBoxs[props.dollNum]['npcType'] = 'box' + props.dollNum;\n console.log(this.frontBoxs);\n \n for(let i = 0; i < this.frontBoxs.length; i++) {\n if(i == 0) {\n this.frontBoxs[i].x = initX ;\n } else {\n this.frontBoxs[i].x = this.frontBoxs[i - 1].x - this.frontBoxs[0].width - props.frontmargin;\n }\n console.log(this.frontBoxs[i].x);\n this.frontBoxs[i].y = initY;\n this.addChild(this.frontBoxs[i]);\n console.log('aaa', this.frontBoxs[i].x);\n }\n // console.log(this.frontBoxs);\n this.addEventListener(engine.Event.ENTER_FRAME, this.frameMove, this);\n }\n frameMove() {\n this.frontBoxs.forEach((item, index) => {\n item.x += props.moveSpeed;\n if (item.x <= 0 && !item.visible) {\n item.visible = true;\n }\n if (item.x >= 750) {\n //let lastitem = this.frontBoxs.shift();\n let tmpIndex = 0;\n if (index <= 0) {\n tmpIndex = this.frontBoxs.length - 1;\n } else {\n tmpIndex = index - 1;\n }\n\n item.x = this.frontBoxs[tmpIndex].x - this.frontBoxs[0].width - props.frontmargin;\n\n if (!this.GameView.getMoveX() && item.x <= 0 && this.GameView.startstatus) {\n this.GameView.setMoveX((370 - item.x - 13) / props.moveSpeed, item);\n this.hideBox = item;\n }\n //this.frontBoxs.push(lastitem);\n }\n })\n }\n stop() {\n // this.removeEventListener(engine.Event.ENTER_FRAME, this.frameMove, this);\n }\n showHidePrizeBox(isshow) {\n this.hideBox.visible = isshow\n }\n}","import { getTextureByName } from \"./utils\";\nimport { props } from \"../props\";\nexport class BackBoxs extends engine.Container {\n private backBoxs=[];\n constructor() {\n super();\n }\n setup() {\n let initX , initY = 0;\n for (let i = 0; i < props.dollNum; i++) {\n this.backBoxs[i] = new engine.Sprite(getTextureByName('backbox_' + i));\n initX = this.backBoxs[0].x = props.backInitX;\n initY = this.backBoxs[0].y = props.backInitY - props.initOffsetTop;\n this.backBoxs[i]['npcType'] = 'box' + i;\n }\n this.backBoxs[props.dollNum] = new engine.Sprite(getTextureByName('backbox_0'));\n this.backBoxs[props.dollNum]['npcType'] = 'box' + props.dollNum;\n for (let i = 0; i < this.backBoxs.length; i++) {\n if(i == 0) {\n this.backBoxs[i].x = initX;\n } else {\n this.backBoxs[i].x = this.backBoxs[i - 1].x + this.backBoxs[i].width + props.backmargin;\n }\n this.backBoxs[i].y = initY;\n \n this.addChild(this.backBoxs[i]);\n }\n this.addEventListener(engine.Event.ENTER_FRAME, this.frameMove, this);\n }\n frameMove() {\n this.backBoxs.forEach((item) => {\n item.x -= props.moveSpeed;\n if (item.x <= 0) {\n let lastitem = this.backBoxs.shift();\n lastitem.x = this.backBoxs[this.backBoxs.length - 1].x + item.width + props.backmargin;\n this.backBoxs.push(lastitem);\n }\n })\n }\n}","import { getTextureByName } from \"./utils\";\nimport { props } from \"../props\";\nimport GameView from './GameView';\nexport class Zhuazi extends engine.Container {\n private bashouGan: engine.Sprite;\n private bashou: engine.Sprite;\n private ganzi: engine.Sprite;\n private left_zhuazi: engine.Sprite;\n private right_zhuazi: engine.Sprite;\n private connect: engine.Sprite;\n private ganNode: engine.Container;\n private moveNode: engine.Container;\n private moveArr = [];\n private zhuaziY;\n private itemShow: engine.Container;\n private prizeBoxs = [];\n public GameView: GameView;\n constructor() {\n super();\n }\n setup() {\n this.ganNode = new engine.Container();\n this.moveNode = new engine.Container();\n this.ganNode.x = 280;\n this.ganNode.y = 350;\n this.bashouGan = new engine.Sprite(getTextureByName(\"把手杆子\"));\n this.bashouGan.x = 60;\n this.bashouGan.y = 12;\n this.bashou = new engine.Sprite(getTextureByName(\"把手\"));\n this.bashou.x = 0;\n this.bashou.y = 0;\n this.ganzi = new engine.Sprite(getTextureByName(\"伸缩杆\"));\n this.ganzi.x = 97;\n this.ganzi.y = 27;\n this.connect = new engine.Sprite(getTextureByName(\"连接点\"));\n this.connect.x = 18;\n this.connect.y = -5;\n this.left_zhuazi = new engine.Sprite(getTextureByName(\"左爪\"));\n this.left_zhuazi.x = props.leftLocX;\n this.left_zhuazi.y = props.leftLocY;\n this.left_zhuazi.anchorX = this.left_zhuazi.width;\n this.left_zhuazi.anchorY = 0;\n this.right_zhuazi = new engine.Sprite(getTextureByName(\"右爪\"));\n this.right_zhuazi.x = props.rightLocX;\n this.right_zhuazi.y = props.rightLocY;\n this.ganNode.addChild(this.left_zhuazi);\n this.ganNode.addChild(this.right_zhuazi);\n this.ganNode.addChild(this.connect);\n this.ganNode.x = 30;\n this.ganNode.y = this.ganNode.y - 263;\n this.zhuaziY = this.ganNode.y;\n this.moveNode.addChild(this.ganzi);\n this.moveNode.addChild(this.ganNode);\n this.moveNode.addChild(this.bashou);\n this.moveNode.x = 262;\n this.bashouGan.y = this.bashouGan.y;\n this.moveNode.y = this.moveNode.y;\n this.addChild(this.bashouGan);\n this.addChild(this.moveNode);\n if (!props.ganziShow) {\n this.bashouGan.visible = false;\n }\n if (!props.bashouShow) {\n this.bashou.visible = false;\n }\n this.createPrizeBox();\n \n }\n createPrizeBox() {\n for (let i = 0; i < props.dollNum; i++) {\n if (!new engine.Sprite(getTextureByName('prizebox_' + i))) {\n return;\n }\n this.prizeBoxs[i] = new engine.Sprite(getTextureByName('prizebox_' + i));\n this.prizeBoxs[i]['npcType'] = 'box' + i;\n }\n this.prizeBoxs[props.dollNum] = new engine.Sprite(getTextureByName('prizebox_0'));\n this.prizeBoxs[props.dollNum]['npcType'] = 'box' + props.dollNum;\n\n this.prizeBoxs.forEach(item => {\n this.ganNode.addChild(item);\n item.visible = false;\n item.x = props.prizeBoxInitX;\n item.y = props.prizeBoxInitY;\n })\n }\n showPrizeBox() {\n this.prizeBoxs.forEach(item => {\n console.log(this.GameView.getBox()['npcType']);\n if (item['npcType'] === this.GameView.getBox()['npcType']) {\n item.visible = true;\n this.itemShow = item;\n } else {\n item.visible = false;\n }\n })\n \n }\n move() {\n let rndist = Math.random();\n let halfWidth = this.bashou.width / 2;\n let randomX = rndist * (rndist > 0.5 ? 1 : -1) * props.bashouMoveDist;\n console.log(randomX);\n engine.Tween.get(this.moveNode).to({ x: 370 + halfWidth - 71}, 1000).call(() => {\n this.zhangkai();\n });\n }\n zhangkai() {\n this.left_zhuazi.anchorX = this.left_zhuazi.width;\n this.left_zhuazi.anchorY = 0;\n engine.Tween.get(this.left_zhuazi, { loop: false }).to({ rotation: props.leftRotation}, 1000);\n engine.Tween.get(this.right_zhuazi, { loop: false }).to({ rotation: props.rightRotation }, 1000);\n setTimeout(() => {\n this.getLong();\n }, 500);\n }\n getLong() {\n let droptime = Number((this.GameView.getMoveX() / 60 - 1).toFixed(2)) * 1000 -130;\n console.log('dr', droptime);\n let times = (props.ganMoveEndY - this.ganzi.y ) / this.ganzi.height;\n console.log(Number(times.toFixed(2)) );\n engine.Tween.get(this.ganzi).to({ scaleY: Number(times.toFixed(2)) }, droptime).to({ scaleY: 1 }, droptime)\n console.log('node', this.zhuaziY);\n engine.Tween.get(this.ganNode).to({ y: props.ganMoveEndY }, droptime).call(() => {\n this.GameView.stopMove();\n if (this.GameView.ifPrize) {\n this.showPrizeBox();\n this.GameView.setVisible(false);\n }\n }).to({ y: this.zhuaziY }, droptime).call(() => {\n // this.getReset();\n if (this.GameView.ifPrize) {\n this.itemShow.visible = false;\n }\n engine.globalEvent.dispatchEvent('doll-machine2-game-end');\n })\n }\n getReset() {\n // if (this.GameView.ifPrize) {\n // this.itemShow.visible = false;\n // }\n this.left_zhuazi.anchorX = this.left_zhuazi.width;\n this.left_zhuazi.anchorY = 0;\n engine.Tween.get(this.moveNode, {loop: false}).to({x: 262}, 1000);\n engine.Tween.get(this.left_zhuazi, { loop: false }).to({ rotation: 0 }, 1000);\n engine.Tween.get(this.right_zhuazi, { loop: false }).to({ rotation: 0 }, 1000);\n this.GameView.resetMoveX();\n }\n}","/**\n * Created by rockyl on 2018/8/16.\n */\n\nimport { props } from \"../props\";\nimport { playSound, createSvga } from \"./utils\";\nimport ObjectPool = engine.ObjectPool;\nimport { getTextureByName } from \"./utils\";\nimport { Goods } from \"./Goods\";\nimport { PoolName } from \"./object-pool-init\";\nimport { FrontBoxs } from \"./frontBox\";\nimport { BackBoxs } from \"./backBox\";\nimport { Zhuazi } from './Zhuazi';\n\nexport default class GameView extends engine.Container {\n private _hasSetup;\n\n //触摸层\n private rectBg: engine.Rect;\n //npc层\n private NpcBg: engine.Container;\n //盒子1\n private box1: engine.Container;\n //盒子2\n private box2: engine.Container;\n //盒子3\n private box3: engine.Container;\n //盒子4\n private box4: engine.Container;\n //盒子5\n private box5: engine.Container;\n //前传输区域\n private frontTransfer: engine.Container;\n //后传输区域\n private backTransfer: engine.Container;\n //前台板\n private frontDesk: engine.Sprite;\n //后台板\n private backDesk: engine.Sprite;\n private _frontBoxs: FrontBoxs;\n\tprivate _backBoxs: BackBoxs;\n\tprivate _Zhuazi: Zhuazi;\n\tprivate prizeBox: engine.Container;\n\tprivate rect;\n //当前分数\n\tprivate score;\n\t\n\t//中奖盒子移动距离\n\tprivate moveTime;\n\n //游戏状态\n private gameIng;\n //是否已获取位移值\n public startstatus=false;\n //是否中奖\n public ifPrize=false;\n //npc出身计时器\n private timer;\n //倒计时计时器\n private countdownTimer: any;\n //倒计时\n private countdown: number;\n\n //当前速度\n private speed: number;\n\n // 当前场景上面的物品\n private goodsItems = [];\n\n private _goods: Goods;\n\n constructor() {\n super();\n this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);\n }\n\n // private waterSvga;\n // private boomSvga;\n // private playerSvga;\n\n setup() {\n if (this._hasSetup) {\n return;\n }\n\n this._hasSetup = true;\n\t\tconst frontBoxs = (this._frontBoxs = new FrontBoxs());\n\t\tthis._frontBoxs.GameView = this;\n\t\tconst backBoxs = (this._backBoxs = new BackBoxs());\n\t\tthis._Zhuazi = new Zhuazi();\n\t\tthis._Zhuazi.GameView = this;\n this.frontTransfer = new engine.Container();\n this.backTransfer = new engine.Container();\n this.frontTransfer.width = 0;\n this.frontTransfer.height = 0;\n this.frontTransfer.alpha = 1;\n // this.frontTransfer.x = 0;\n // this.frontTransfer.y = 434;\n\n this.backTransfer.width = 0;\n this.backTransfer.height = 0;\n this.backTransfer.alpha = 1;\n // this.backTransfer.x = 0;\n // this.backTransfer.y = 390;\n\t\tthis.rect = new engine.Rect();\n this.rect.width = props.gameStageWidth;\n this.rect.height = props.gameStageHeight;\n\t\tthis.rect.x = 65;\n this.rect.y = 0;\n this.NpcBg = new engine.Container();\n this.NpcBg.x = 0;\n this.NpcBg.y = 0;\n\t\tthis.addChild(this.NpcBg);\n\t\tthis.addChild(this.rect);\n\t\t\n\t\t\n\t\t\n\t\t// let gameBg = new engine.Sprite(getTextureByName(\"游戏背景\"));\n\t\t// gameBg.x = 65;\n\t\t// gameBg.y = 263;\n\t\t// this.NpcBg.addChild(gameBg);\n\t\t\n this.frontDesk = new engine.Sprite(getTextureByName(\"前传输带\"));\n this.frontDesk.x = props.initOffsetLeft;\n this.frontDesk.y = props.frontDeskY - props.initOffsetTop;\n\n this.backDesk = new engine.Sprite(getTextureByName(\"后传输带\"));\n this.backDesk.x = props.initOffsetLeft;\n this.backDesk.y = props.backDeskY - props.initOffsetTop;\n if(props.single) {\n this.backDesk.visible = false;\n }\n let pcarr = [this.backDesk, this.frontDesk, this.backTransfer, this.frontTransfer, this._Zhuazi];\n pcarr.forEach(item => {\n this.NpcBg.addChild(item);\n })\n\t\tthis.NpcBg.mask = this.rect;\n\t\tthis._Zhuazi.setup();\n\t\t\n\t\t// this._Zhuazi.move();\n\t\tthis.backTransfer.addChild(this._backBoxs);\n this._backBoxs.setup();\n if (props.single) {\n this.backTransfer.visible = false;\n }\n\t\tthis.frontTransfer.addChild(this._frontBoxs);\n\t\tthis._frontBoxs.setup();\n\t}\n\t/**\n\t * \n\t * @param 暂停move\n\t */\n\tstopMove() {\n\t\tthis._frontBoxs.stop();\n\t}\n\t/**\n\t * 赋值x距离值\n\t */\n\tsetMoveX(x, item) {\n\t\tthis.moveTime = x;\n this.prizeBox = item;\n\t\tthis._Zhuazi.move();\n }\n\t/**\n\t * 显示隐藏盒子\n\t */\n\tsetVisible(isshow) {\n\t\tthis._frontBoxs.showHidePrizeBox(isshow);\n\t}\n\t/**\n\t * 获取中奖盒子移动的距离\n\t */\n\tgetMoveX() {\n\t\treturn this.moveTime;\n }\n /**\n * 重置moveTime\n */\n resetMoveX() {\n this.moveTime = null;\n }\n\t/**\n\t * 获取中奖盒子\n\t */\n\tgetBox() {\n\t\treturn this.prizeBox;\n\t}\n /**\n * 重置场景\n */\n reset() {\n this.startstatus = false;\n this.ifPrize = false;\n\t\tthis._Zhuazi.getReset();\n }\n\n /**\n * 开始\n */\n start(type=null) {\n this.speed = 1;\n this.gameIng = true;\n console.log('执行', type);\n this.startstatus = true;\n this.ifPrize = type && type.prize || false;\n }\n\n /**\n * npc开始掉落\n */\n beginNpc() {\n this.timer = setTimeout(() => {\n if (this.gameIng) {\n // this.speed += props.acceleratedSpeed;\n // this.creatNpc()\n }\n //递归执行\n // this.beginNpc();\n }, 2000 / this.speed);\n }\n\n /**\n * 暂停\n */\n pause() {\n this.gameIng = false;\n }\n\n /**\n * 恢复\n */\n revive() {\n this.gameIng = true;\n }\n\n /**\n * 重新开始\n */\n resume() {\n this.reset();\n this.start();\n }\n}\n","/**\n * Created by rockyl on 2020-01-09.\n */\n\nimport GameView from \"./GameView\";\nimport {injectProps} from \"../props\";\n\n\nexport class GameWrapper extends engine.Container {\n\tprivate _status;\n\tprivate _gameView: GameView;\n\n\n\n\n\n\tconstructor() {\n\t\tsuper();\n\t\tengine.globalEvent.addEventListener('doll-machine2-game-init', this.reset, this);\n\t\tengine.globalEvent.addEventListener('doll-machine2-game-start', this.start, this);\n\n\t\tlet gameView = this._gameView = new GameView();\n\t\tthis.addChild(gameView);\n\t\t// gameView.reset();\n\t\t// gameView.start()\n\t}\n\n\treset(event: engine.Event) {\t\t\n\t\tinjectProps(event.data);\n\t\tthis._gameView.visible = true;\n\t\tthis._gameView.reset();\n\t}\n\n\tstart(event: engine.Event) {\n\t\tconsole.log('监听开始');\n\t\tinjectProps(event.data);\n\t\t// this._status = 1;\n\t\tthis._gameView.start(event.data);\n\t}\n\n\tpause() {\n\t\tthis._gameView.pause();\n\t}\n\n\tresume() {\n\t\tthis._gameView.resume();\n\t}\n\n\trevive() {\n\t\tthis._gameView.revive();\n\t}\n\n\tclear() {\n\t\tthis._gameView.visible = false;\n\t}\n\n\tprivate onTap(event) {\n\t//\tthis._gameView.tap(event);\n\t}\n}\n","/**\n * Created by rockyl on 2019-11-20.\n */\n\nimport {GameWrapper} from \"./game/GameWrapper\";\nimport {injectProps, prepareProps} from \"./props\";\n\nexport default function (props) {\n\tprepareProps();\n\tinjectProps(props);\n\n\tlet instance = new GameWrapper();\n\treturn instance;\n}\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,UAAgB,gBAAgB,CAAC,IAAI;KACpC,OAAO,UAAU,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;CACrD,CAAC;AAED;;CCTA;KAA+BA,mCAAgB;KAe7C;SAAA,YACE,iBAAO,SACR;SAJO,eAAS,GAAC,EAAE,CAAC;;MAIpB;KACD,yBAAK,GAAL;SACE,IAAI,KAAK,EAAG,KAAK,GAAG,CAAC,CAAC;SACtB,KAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE;aACrC,IAAI,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC,EAAE;iBACzD,OAAO;cACR;aAED,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,WAAW,GAAC,CAAC,CAAC,CAAC,CAAC;aACvE,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC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C;MACxB;KAED,4BAAM,GAAN;SACC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;MACxB;KAED,2BAAK,GAAL;SACC,IAAI,CAAC,SAAS,CAAC,OAAO,GAAG,KAAK,CAAC;MAC/B;KAEO,2BAAK,GAAb,UAAc,KAAK;MAElB;KACF,kBAAC;CAAD,CAAC,CAnDgC,MAAM,CAAC,SAAS,GAmDhD;;;iBCpDwB,KAAK;KAC7B,YAAY,EAAE,CAAC;KACf,WAAW,CAAC,KAAK,CAAC,CAAC;KAEnB,IAAI,QAAQ,GAAG,IAAI,WAAW,EAAE,CAAC;KACjC,OAAO,QAAQ,CAAC;CACjB,CAAC;;;;;;;;;"}
\ No newline at end of file
/**
* Created by rockyl on 2020-01-21.
*/
let customModuleProps = {
};
{
"name": "娃娃机2",
"desc": "娃娃机通用模块",
"props": {
"single": {
"alias": "是否是单层娃娃",
"type": "boolean",
"default": true
},
"dollNum": {
"alias": "一屏展示娃娃个数(最大为4)",
"type": "number",
"default": 4
},
"initOffsetTop": {
"alias": "整体距离上边距",
"type": "number",
"default": 0
},
"initOffsetLeft": {
"alias": "整体距离左边距",
"type": "number",
"default": 60
},
"frontDeskY": {
"alias": "前排传输带Y位置",
"type": "number",
"default": 518
},
"frontInitX": {
"alias": "前排最右侧娃娃初始X位置",
"type": "number",
"default": 600
},
"frontInitY": {
"alias": "前排最右侧娃娃初始Y位置",
"type": "number",
"default": 351
},
"backDeskY": {
"alias": "后排传输带Y位置",
"type": "number",
"default": 449
},
"backInitX": {
"alias": "后排最右侧娃娃初始X位置",
"type": "number",
"default": 188
},
"backInitY": {
"alias": "后排最右侧娃娃初始Y位置",
"type": "number",
"default": 353
},
"ganziShow": {
"alias": "是否显示杆子",
"type": "boolean",
"default": true
},
"bashouShow": {
"alias": "是否显示把手",
"type": "boolean",
"default": true
},
"gameStageWidth": {
"alias": "游戏场景宽度",
"type": "number",
"default": 611
},
"gameStageHeight": {
"alias": "游戏场景高度",
"type": "number",
"default": 704
},
"frontmargin": {
"alias": "前排娃娃的间距",
"type": "number",
"default": 13
},
"backmargin": {
"alias": "后排娃娃的间距",
"type": "number",
"default": 50
},
"moveSpeed": {
"alias": "娃娃移动的速度",
"type": "number",
"default": 3
},
"bashouMoveDist": {
"alias": "爪子整体左右移动的范围",
"type": "number",
"default": 200
},
"ganMoveEndY": {
"alias": "杆子最后需要移动到的y值位置",
"type": "number",
"default": 357
},
"leftRotation": {
"alias": "左边爪子旋转角度",
"type": "number",
"default": 20
},
"leftLocX": {
"alias": "左边爪子X位置",
"type": "number",
"default": -15
},
"leftLocY": {
"alias": "左边爪子Y位置",
"type": "number",
"default": 60
},
"rightRotation": {
"alias": "右边爪子旋转角度",
"type": "number",
"default": -20
},
"rightLocX": {
"alias": "右边爪子X位置",
"type": "number",
"default": 98
},
"rightLocY": {
"alias": "右边爪子Y位置",
"type": "number",
"default": 60
},
"prizeBoxInitX": {
"alias": "中奖娃娃的x位置",
"type": "number",
"default": 15
},
"prizeBoxInitY": {
"alias": "中奖娃娃的y位置",
"type": "number",
"default": 48
}
},
"assets": [
{
"name": "游戏背景",
"url": "//yun.duiba.com.cn/aurora/assets/460fd0242aada85de5554391756db6ed2a232a9b.png",
"uuid": "05c378c3-bed0-4d5c-bed8-f05ae7920931",
"ext": ".png"
},
{
"name": "frontbox_0",
"url": "//yun.duiba.com.cn/aurora/assets/fde8c60981791e5136c7914274c2a2d0936626cd.png",
"uuid": "aa30ee7c-a6ad-4e10-9b6a-13b139664ab5",
"ext": ".png"
},
{
"name": "frontbox_1",
"url": "//yun.duiba.com.cn/aurora/assets/befb2c9ddfd8a5c4acd5126b2d793f7c1bcc40f2.png",
"uuid": "4483b626-697a-4aa4-ba57-0c22ddc7c0e6",
"ext": ".png"
},
{
"name": "frontbox_2",
"url": "///yun.duiba.com.cn/aurora/assets/50991e640e6bcc2eee02ba945d48a8430ddd2bee.png",
"uuid": "b70f2980-a2b3-4ef7-b060-b14dc7a8c9c8",
"ext": ".png"
},
{
"name": "frontbox_3",
"url": "//yun.duiba.com.cn/aurora/assets/fde8c60981791e5136c7914274c2a2d0936626cd.png",
"uuid": "aa30ee7c-a6ad-4e10-9b6a-13b139664ab1",
"ext": ".png"
},
{
"name": "backbox_0",
"url": "//yun.duiba.com.cn/aurora/assets/94884eafc876346e283efef2aa29bd6d2c36f627.png",
"uuid": "3f3feb30-6700-4ac7-a14e-6d7e41e8d4e8",
"ext": ".png"
},
{
"name": "backbox_1",
"url": "//yun.duiba.com.cn/aurora/assets/7deaaf45e03a626efbced90e4ad3d22373b01bd3.png",
"uuid": "b1422629-55d2-4b8b-bdd0-1b043f965248",
"ext": ".png"
},
{
"name": "backbox_2",
"url": "//yun.duiba.com.cn/aurora/assets/28a5b5b04c84d6acc86b7efb81dd6d7f717e0cda.png",
"uuid": "708da046-26e1-4ff7-abb6-35bf825a5d5b",
"ext": ".png"
},
{
"name": "backbox_3",
"url": "//yun.duiba.com.cn/aurora/assets/28a5b5b04c84d6acc86b7efb81dd6d7f717e0cda.png",
"uuid": "708da046-26e1-4ff7-abb6-35bf825a5d51",
"ext": ".png"
},
{
"name": "backbox_4",
"url": "//yun.duiba.com.cn/aurora/assets/28a5b5b04c84d6acc86b7efb81dd6d7f717e0cda.png",
"uuid": "708da046-26e1-4ff7-abb6-35bf825a5d55",
"ext": ".png"
},
{
"name": "prizebox_0",
"url": "//yun.duiba.com.cn/aurora/assets/a47f438d016d1b178cdb5241651a78e4ea365e75.png",
"uuid": "c106cd1d-52a0-422a-976c-67151af0b484",
"ext": ".png"
},
{
"name": "prizebox_1",
"url": "//yun.duiba.com.cn/aurora/assets/fd60c2da0ce78f7b7bed0e9c45644882a1a40d90.png",
"uuid": "3ff6fb20-4a2f-4789-998d-6078e3b603ec",
"ext": ".png"
},
{
"name": "prizebox_2",
"url": "//yun.duiba.com.cn/aurora/assets/6211ab330a3768ff0a1920cff0ec41f29fa0903b.png",
"uuid": "04fa3325-87fc-4009-bfba-26a95d92d80c",
"ext": ".png"
},
{
"name": "prizebox_3",
"url": "//yun.duiba.com.cn/aurora/assets/6211ab330a3768ff0a1920cff0ec41f29fa0903b.png",
"uuid": "04fa3325-87fc-4009-bfba-26a95d92d800",
"ext": ".png"
},
{
"name": "prizebox_4",
"url": "//yun.duiba.com.cn/aurora/assets/6211ab330a3768ff0a1920cff0ec41f29fa0903b.png",
"uuid": "04fa3325-87fc-4009-bfba-26a95d92d80a",
"ext": ".png"
},
{
"name": "前传输带",
"url": "//yun.duiba.com.cn/aurora/assets/7bccbc67b3f896176bed7d21c5f4d4307c3919be.png",
"uuid": "06bd03a4-43c3-49bb-94c5-6ef365f70291",
"ext": ".png"
},
{
"name": "后传输带",
"url": "//yun.duiba.com.cn/aurora/assets/df9b718f80747a1e21349d2b9ac35d5e19a61dad.png",
"uuid": "aa0c6ebc-164f-4767-90ca-a79be4316365",
"ext": ".png"
},
{
"name": "把手杆子",
"url": "//yun.duiba.com.cn/aurora/assets/5a9e4ba7ca6701eae85b6d6dcb0612ecb9a3eff9.png",
"uuid": "f2f1a937-00f4-442f-af4f-0bcb00656e69",
"ext": ".png"
},
{
"name": "把手",
"url": "//yun.duiba.com.cn/aurora/assets/71255a6f3cdf9f66d53589e46d72fcd20fef468d.png",
"uuid": "d9b395b5-4e46-43a5-aa2b-bfdd81c07fa7",
"ext": ".png"
},
{
"name": "伸缩杆",
"url": "//yun.duiba.com.cn/aurora/assets/a9cf8b147c52b7d4247e80e90e098f787808bfa9.png",
"uuid": "fddb4636-9c62-47b2-ba5e-f2cd820dbccc",
"ext": ".png"
},
{
"name": "左爪",
"url": "//yun.duiba.com.cn/aurora/assets/1e8634fd94bda455d11956c2847d3823e80701d3.png",
"uuid": "739014d2-3193-4853-bf8d-349bd3e8d990",
"ext": ".png"
},
{
"name": "右爪",
"url": "//yun.duiba.com.cn/aurora/assets/4bfc510e0d1fa1db77f5effa187294af38b74ff6.png",
"uuid": "4fb43b19-67e9-42cc-b461-35c005c714fb",
"ext": ".png"
},
{
"name": "连接点",
"url": "//yun.duiba.com.cn/aurora/assets/39f39234631f739e70e9ab8b713284379f4016fb.png",
"uuid": "2021124f-ffcb-487f-a24f-a00f3d8aae95",
"ext": ".png"
}
],
"events": {
"in": {
"doll-machine2-game-init": {
"alias": "重置"
},
"doll-machine2-game-start": {
"alias": "开始",
"data": {
"prize": true
}
}
},
"out": {
"doll-machine2-game-end": {
"alias": "重置完毕",
"data": null
}
}
}
}
/**
* Created by rockyl on 2018/8/16.
*/
import { props } from "../props";
import { playSound, createSvga } from "./utils";
import ObjectPool = engine.ObjectPool;
import { getTextureByName } from "./utils";
import { Goods } from "./Goods";
import { PoolName } from "./object-pool-init";
import { FrontBoxs } from "./frontBox";
import { BackBoxs } from "./backBox";
import { Zhuazi } from './Zhuazi';
export default class GameView extends engine.Container {
private _hasSetup;
//触摸层
private rectBg: engine.Rect;
//npc层
private NpcBg: engine.Container;
//盒子1
private box1: engine.Container;
//盒子2
private box2: engine.Container;
//盒子3
private box3: engine.Container;
//盒子4
private box4: engine.Container;
//盒子5
private box5: engine.Container;
//前传输区域
private frontTransfer: engine.Container;
//后传输区域
private backTransfer: engine.Container;
//前台板
private frontDesk: engine.Sprite;
//后台板
private backDesk: engine.Sprite;
private _frontBoxs: FrontBoxs;
private _backBoxs: BackBoxs;
private _Zhuazi: Zhuazi;
private prizeBox: engine.Container;
private rect;
//当前分数
private score;
//中奖盒子移动距离
private moveTime;
//游戏状态
private gameIng;
//是否已获取位移值
public startstatus=false;
//是否中奖
public ifPrize=false;
//npc出身计时器
private timer;
//倒计时计时器
private countdownTimer: any;
//倒计时
private countdown: number;
//当前速度
private speed: number;
// 当前场景上面的物品
private goodsItems = [];
private _goods: Goods;
constructor() {
super();
this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);
}
// private waterSvga;
// private boomSvga;
// private playerSvga;
setup() {
if (this._hasSetup) {
return;
}
this._hasSetup = true;
const frontBoxs = (this._frontBoxs = new FrontBoxs());
this._frontBoxs.GameView = this;
const backBoxs = (this._backBoxs = new BackBoxs());
this._Zhuazi = new Zhuazi();
this._Zhuazi.GameView = this;
this.frontTransfer = new engine.Container();
this.backTransfer = new engine.Container();
this.frontTransfer.width = 0;
this.frontTransfer.height = 0;
this.frontTransfer.alpha = 1;
// this.frontTransfer.x = 0;
// this.frontTransfer.y = 434;
this.backTransfer.width = 0;
this.backTransfer.height = 0;
this.backTransfer.alpha = 1;
// this.backTransfer.x = 0;
// this.backTransfer.y = 390;
this.rect = new engine.Rect();
this.rect.width = props.gameStageWidth;
this.rect.height = props.gameStageHeight;
this.rect.x = 65;
this.rect.y = 0;
this.NpcBg = new engine.Container();
this.NpcBg.x = 0;
this.NpcBg.y = 0;
this.addChild(this.NpcBg);
this.addChild(this.rect);
// let gameBg = new engine.Sprite(getTextureByName("游戏背景"));
// gameBg.x = 65;
// gameBg.y = 263;
// this.NpcBg.addChild(gameBg);
this.frontDesk = new engine.Sprite(getTextureByName("前传输带"));
this.frontDesk.x = props.initOffsetLeft;
this.frontDesk.y = props.frontDeskY - props.initOffsetTop;
this.backDesk = new engine.Sprite(getTextureByName("后传输带"));
this.backDesk.x = props.initOffsetLeft;
this.backDesk.y = props.backDeskY - props.initOffsetTop;
if(props.single) {
this.backDesk.visible = false;
}
let pcarr = [this.backDesk, this.frontDesk, this.backTransfer, this.frontTransfer, this._Zhuazi];
pcarr.forEach(item => {
this.NpcBg.addChild(item);
})
this.NpcBg.mask = this.rect;
this._Zhuazi.setup();
// this._Zhuazi.move();
this.backTransfer.addChild(this._backBoxs);
this._backBoxs.setup();
if (props.single) {
this.backTransfer.visible = false;
}
this.frontTransfer.addChild(this._frontBoxs);
this._frontBoxs.setup();
}
/**
*
* @param 暂停move
*/
stopMove() {
this._frontBoxs.stop();
}
/**
* 赋值x距离值
*/
setMoveX(x, item) {
this.moveTime = x;
this.prizeBox = item;
this._Zhuazi.move();
}
/**
* 显示隐藏盒子
*/
setVisible(isshow) {
this._frontBoxs.showHidePrizeBox(isshow);
}
/**
* 获取中奖盒子移动的距离
*/
getMoveX() {
return this.moveTime;
}
/**
* 重置moveTime
*/
resetMoveX() {
this.moveTime = null;
}
/**
* 获取中奖盒子
*/
getBox() {
return this.prizeBox;
}
/**
* 重置场景
*/
reset() {
this.startstatus = false;
this.ifPrize = false;
this._Zhuazi.getReset();
}
/**
* 开始
*/
start(type=null) {
this.speed = 1;
this.gameIng = true;
console.log('执行', type);
this.startstatus = true;
this.ifPrize = type && type.prize || false;
}
/**
* npc开始掉落
*/
beginNpc() {
this.timer = setTimeout(() => {
if (this.gameIng) {
// this.speed += props.acceleratedSpeed;
// this.creatNpc()
}
//递归执行
// this.beginNpc();
}, 2000 / this.speed);
}
/**
* 暂停
*/
pause() {
this.gameIng = false;
}
/**
* 恢复
*/
revive() {
this.gameIng = true;
}
/**
* 重新开始
*/
resume() {
this.reset();
this.start();
}
}
/**
* 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('doll-machine2-game-init', this.reset, this);
engine.globalEvent.addEventListener('doll-machine2-game-start', this.start, this);
let gameView = this._gameView = new GameView();
this.addChild(gameView);
// gameView.reset();
// gameView.start()
}
reset(event: engine.Event) {
injectProps(event.data);
this._gameView.visible = true;
this._gameView.reset();
}
start(event: engine.Event) {
console.log('监听开始');
injectProps(event.data);
// this._status = 1;
this._gameView.start(event.data);
}
pause() {
this._gameView.pause();
}
resume() {
this._gameView.resume();
}
revive() {
this._gameView.revive();
}
clear() {
this._gameView.visible = false;
}
private onTap(event) {
// this._gameView.tap(event);
}
}
/**
* Created by rockyl on 2020-02-02.
*
* 掉落物品
*/
import { getTextureByName } from "./utils";
import { props } from "../props";
export class Goods extends engine.Container {
private _body: engine.Rect;
private _toY;
constructor() {
super();
let body;
body = this._body = new engine.Rect();
// let rain = new engine.Sprite(getTextureByName('雨滴'));
// rain["npcType"]="rain"
// let stone = new engine.Sprite(getTextureByName('石块'));
// stone["npcType"]="stone"
// let boom = new engine.Sprite(getTextureByName('炸弹'));
// boom["npcType"]="boom"
let box1 = new engine.Sprite(getTextureByName("草泥马盒"));
box1["npcType"] = "box1";
let box2 = new engine.Sprite(getTextureByName("狗盒"));
box2["npcType"] = "box2";
let box3 = new engine.Sprite(getTextureByName("猫盒"));
box3["npcType"] = "box3";
// rain.visible=false;
// stone.visible=false;
// boom.visible=false;
// body.addChild(rain)
// body.addChild(stone)
// body.addChild(boom)
box1.visible = false;
box2.visible = false;
box3.visible = false;
body.addChild(box1);
body.addChild(box2);
body.addChild(box3);
this.addChild(body);
body.width = 0.0001;
body.height = 0.0001;
body.mouseEnabled = false;
}
getRandomNumberByRange(start, end) {
return Math.floor(Math.random() * (end - start) + start);
}
// reset() {
// this.visible = true;
// this.rotation = 0;
// this.anchorOffsetY = 0;
// this.y = 0;
// this.x = (750-120)*Math.random()+30;
// this.rotation = 0;
// let random=Math.random()
// if(random<props.goodsProbability[0]){
// this.showNpc("box1")
// }else if(random>=props.goodsProbability[0]&&random<=(props.goodsProbability[0]+props.goodsProbability[1])){
// this.showNpc("box2")
// }else if(random>(props.goodsProbability[0]+props.goodsProbability[1])){
// this.showNpc("box3")
// }
// }
reset() {
this.visible = true;
this.y = 200;
this.x = 0;
this.rotation = 0;
let random = Math.random();
if (random < 0.3) {
this.showNpc("box1");
} else if (random < 0.6) {
this.showNpc("box2");
} else {
this.showNpc("box3");
}
// this.showNpc("box1");
// this.showNpc("box2");
// this.showNpc("box3");
}
showNpc(type) {
for (let i = 0; i < this._body.children.length; i++) {
this._body.children[i].visible = false;
this._body.children[i].mouseEnabled = false;
}
for (let i = 0; i < this._body.children.length; i++) {
if (this._body.children[i]["npcType"] == type) {
this["npcType"] = type;
console.log(type);
this._body.children[i].visible = true;
this._body.children[i].mouseEnabled = false;
}
}
}
set anchorOffsetY(v) {
this._body.y = v;
}
}
import { getTextureByName } from "./utils";
import { props } from "../props";
import GameView from './GameView';
export class Zhuazi extends engine.Container {
private bashouGan: engine.Sprite;
private bashou: engine.Sprite;
private ganzi: engine.Sprite;
private left_zhuazi: engine.Sprite;
private right_zhuazi: engine.Sprite;
private connect: engine.Sprite;
private ganNode: engine.Container;
private moveNode: engine.Container;
private moveArr = [];
private zhuaziY;
private itemShow: engine.Container;
private prizeBoxs = [];
public GameView: GameView;
constructor() {
super();
}
setup() {
this.ganNode = new engine.Container();
this.moveNode = new engine.Container();
this.ganNode.x = 280;
this.ganNode.y = 350;
this.bashouGan = new engine.Sprite(getTextureByName("把手杆子"));
this.bashouGan.x = 60;
this.bashouGan.y = 12;
this.bashou = new engine.Sprite(getTextureByName("把手"));
this.bashou.x = 0;
this.bashou.y = 0;
this.ganzi = new engine.Sprite(getTextureByName("伸缩杆"));
this.ganzi.x = 97;
this.ganzi.y = 27;
this.connect = new engine.Sprite(getTextureByName("连接点"));
this.connect.x = 18;
this.connect.y = -5;
this.left_zhuazi = new engine.Sprite(getTextureByName("左爪"));
this.left_zhuazi.x = props.leftLocX;
this.left_zhuazi.y = props.leftLocY;
this.left_zhuazi.anchorX = this.left_zhuazi.width;
this.left_zhuazi.anchorY = 0;
this.right_zhuazi = new engine.Sprite(getTextureByName("右爪"));
this.right_zhuazi.x = props.rightLocX;
this.right_zhuazi.y = props.rightLocY;
this.ganNode.addChild(this.left_zhuazi);
this.ganNode.addChild(this.right_zhuazi);
this.ganNode.addChild(this.connect);
this.ganNode.x = 30;
this.ganNode.y = this.ganNode.y - 263;
this.zhuaziY = this.ganNode.y;
this.moveNode.addChild(this.ganzi);
this.moveNode.addChild(this.ganNode);
this.moveNode.addChild(this.bashou);
this.moveNode.x = 262;
this.bashouGan.y = this.bashouGan.y;
this.moveNode.y = this.moveNode.y;
this.addChild(this.bashouGan);
this.addChild(this.moveNode);
if (!props.ganziShow) {
this.bashouGan.visible = false;
}
if (!props.bashouShow) {
this.bashou.visible = false;
}
this.createPrizeBox();
}
createPrizeBox() {
for (let i = 0; i < props.dollNum; i++) {
if (!new engine.Sprite(getTextureByName('prizebox_' + i))) {
return;
}
this.prizeBoxs[i] = new engine.Sprite(getTextureByName('prizebox_' + i));
this.prizeBoxs[i]['npcType'] = 'box' + i;
}
this.prizeBoxs[props.dollNum] = new engine.Sprite(getTextureByName('prizebox_0'));
this.prizeBoxs[props.dollNum]['npcType'] = 'box' + props.dollNum;
this.prizeBoxs.forEach(item => {
this.ganNode.addChild(item);
item.visible = false;
item.x = props.prizeBoxInitX;
item.y = props.prizeBoxInitY;
})
}
showPrizeBox() {
this.prizeBoxs.forEach(item => {
console.log(this.GameView.getBox()['npcType']);
if (item['npcType'] === this.GameView.getBox()['npcType']) {
item.visible = true;
this.itemShow = item;
} else {
item.visible = false;
}
})
}
move() {
let rndist = Math.random();
let halfWidth = this.bashou.width / 2;
let randomX = rndist * (rndist > 0.5 ? 1 : -1) * props.bashouMoveDist;
console.log(randomX);
engine.Tween.get(this.moveNode).to({ x: 370 + halfWidth - 71}, 1000).call(() => {
this.zhangkai();
});
}
zhangkai() {
this.left_zhuazi.anchorX = this.left_zhuazi.width;
this.left_zhuazi.anchorY = 0;
engine.Tween.get(this.left_zhuazi, { loop: false }).to({ rotation: props.leftRotation}, 1000);
engine.Tween.get(this.right_zhuazi, { loop: false }).to({ rotation: props.rightRotation }, 1000);
setTimeout(() => {
this.getLong();
}, 500);
}
getLong() {
let droptime = Number((this.GameView.getMoveX() / 60 - 1).toFixed(2)) * 1000 -130;
console.log('dr', droptime);
let times = (props.ganMoveEndY - this.ganzi.y ) / this.ganzi.height;
console.log(Number(times.toFixed(2)) );
engine.Tween.get(this.ganzi).to({ scaleY: Number(times.toFixed(2)) }, droptime).to({ scaleY: 1 }, droptime)
console.log('node', this.zhuaziY);
engine.Tween.get(this.ganNode).to({ y: props.ganMoveEndY }, droptime).call(() => {
this.GameView.stopMove();
if (this.GameView.ifPrize) {
this.showPrizeBox();
this.GameView.setVisible(false);
}
}).to({ y: this.zhuaziY }, droptime).call(() => {
// this.getReset();
if (this.GameView.ifPrize) {
this.itemShow.visible = false;
}
engine.globalEvent.dispatchEvent('doll-machine2-game-end');
})
}
getReset() {
// if (this.GameView.ifPrize) {
// this.itemShow.visible = false;
// }
this.left_zhuazi.anchorX = this.left_zhuazi.width;
this.left_zhuazi.anchorY = 0;
engine.Tween.get(this.moveNode, {loop: false}).to({x: 262}, 1000);
engine.Tween.get(this.left_zhuazi, { loop: false }).to({ rotation: 0 }, 1000);
engine.Tween.get(this.right_zhuazi, { loop: false }).to({ rotation: 0 }, 1000);
this.GameView.resetMoveX();
}
}
\ No newline at end of file
import { getTextureByName } from "./utils";
import { props } from "../props";
export class BackBoxs extends engine.Container {
private backBoxs=[];
constructor() {
super();
}
setup() {
let initX , initY = 0;
for (let i = 0; i < props.dollNum; i++) {
this.backBoxs[i] = new engine.Sprite(getTextureByName('backbox_' + i));
initX = this.backBoxs[0].x = props.backInitX;
initY = this.backBoxs[0].y = props.backInitY - props.initOffsetTop;
this.backBoxs[i]['npcType'] = 'box' + i;
}
this.backBoxs[props.dollNum] = new engine.Sprite(getTextureByName('backbox_0'));
this.backBoxs[props.dollNum]['npcType'] = 'box' + props.dollNum;
for (let i = 0; i < this.backBoxs.length; i++) {
if(i == 0) {
this.backBoxs[i].x = initX;
} else {
this.backBoxs[i].x = this.backBoxs[i - 1].x + this.backBoxs[i].width + props.backmargin;
}
this.backBoxs[i].y = initY;
this.addChild(this.backBoxs[i]);
}
this.addEventListener(engine.Event.ENTER_FRAME, this.frameMove, this);
}
frameMove() {
this.backBoxs.forEach((item) => {
item.x -= props.moveSpeed;
if (item.x <= 0) {
let lastitem = this.backBoxs.shift();
lastitem.x = this.backBoxs[this.backBoxs.length - 1].x + item.width + props.backmargin;
this.backBoxs.push(lastitem);
}
})
}
}
\ No newline at end of file
import { getTextureByName } from "./utils";
import GameView from './GameView';
import { props } from "../props";
export class FrontBoxs extends engine.Container {
//盒子1
private box1: engine.Container;
//盒子2
private box2: engine.Container;
//盒子3
private box3: engine.Container;
//盒子4
private box4: engine.Container;
//盒子5
private box5: engine.Container;
// 需隐藏的盒子
private hideBox: engine.Container;
private frontBoxs=[];
public GameView: GameView;
constructor() {
super();
}
setup() {
let initX , initY = 0;
for(let i = 0; i < props.dollNum; i++) {
if (!new engine.Sprite(getTextureByName('frontbox_' + i))) {
return;
}
this.frontBoxs[i] = new engine.Sprite(getTextureByName('frontbox_'+i));
initX = this.frontBoxs[0].x = props.frontInitX;
initY = this.frontBoxs[0].y = props.frontInitY;
this.frontBoxs[i]['npcType'] = 'box'+i;
}
this.frontBoxs[props.dollNum] = new engine.Sprite(getTextureByName('frontbox_0'));
this.frontBoxs[props.dollNum]['npcType'] = 'box' + props.dollNum;
console.log(this.frontBoxs);
for(let i = 0; i < this.frontBoxs.length; i++) {
if(i == 0) {
this.frontBoxs[i].x = initX ;
} else {
this.frontBoxs[i].x = this.frontBoxs[i - 1].x - this.frontBoxs[0].width - props.frontmargin;
}
console.log(this.frontBoxs[i].x);
this.frontBoxs[i].y = initY;
this.addChild(this.frontBoxs[i]);
console.log('aaa', this.frontBoxs[i].x);
}
// console.log(this.frontBoxs);
this.addEventListener(engine.Event.ENTER_FRAME, this.frameMove, this);
}
frameMove() {
this.frontBoxs.forEach((item, index) => {
item.x += props.moveSpeed;
if (item.x <= 0 && !item.visible) {
item.visible = true;
}
if (item.x >= 750) {
//let lastitem = this.frontBoxs.shift();
let tmpIndex = 0;
if (index <= 0) {
tmpIndex = this.frontBoxs.length - 1;
} else {
tmpIndex = index - 1;
}
item.x = this.frontBoxs[tmpIndex].x - this.frontBoxs[0].width - props.frontmargin;
if (!this.GameView.getMoveX() && item.x <= 0 && this.GameView.startstatus) {
this.GameView.setMoveX((370 - item.x - 13) / props.moveSpeed, item);
this.hideBox = item;
}
//this.frontBoxs.push(lastitem);
}
})
}
stop() {
// this.removeEventListener(engine.Event.ENTER_FRAME, this.frameMove, this);
}
showHidePrizeBox(isshow) {
this.hideBox.visible = isshow
}
}
\ No newline at end of file
/**
* 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();
});
/**
* 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;
}
\ No newline at end of file
/**
* Created by rockyl on 2019-11-20.
*/
import {GameWrapper} from "./game/GameWrapper";
import {injectProps, prepareProps} from "./props";
export default function (props) {
prepareProps();
injectProps(props);
let instance = new GameWrapper();
return instance;
}
/**
* Created by rockyl on 2020-01-21.
*/
export let props: any = {};
export function prepareProps() {
let metaProps = getProps();
engine.injectProp(props, metaProps);
}
export function injectProps(p) {
engine.injectProp(props, p);
}
/**
* Created by rockyl on 2019-12-16.
*/
const customId = 'dxbcyj-game';
(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,
}
}],
}, null, function () {
setTimeout(() => {
engine.addCustomModule(customId, engine.gameStage.sceneContainer.getChildAt(0));
}, 100);
setTimeout(() => {
//engine.globalEvent.dispatchEvent('dxbcyj-game-start', {guide: 0});
}, 500);
});
engine.globalEvent.addEventListener('dxbcyj-game-result', (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: transparent;
}
</style>
</head>
<body>
<div id="game-container" style="line-height:0;font-size:0"></div>
<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/svga.fd3923ae6e664251ca7981801a65809cc5f36bc3.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 = [
];
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['dxbcyj-game'] = 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);
}
var ObjectPool = engine.ObjectPool;
var Road = (function (_super) {
tslib.__extends(Road, _super);
function Road() {
return _super !== null && _super.apply(this, arguments) || this;
}
Road.prototype.setup = function () {
this.lastPos = 0;
this.addPier();
};
Road.prototype.getFristPier = function () {
return this.getChildAt(0).width;
};
Road.prototype.getDistance = function () {
var distance = [];
var pier1 = this.getChildAt(0);
var pier2 = this.getChildAt(1);
distance.push(pier2.x - pier1.x);
distance.push(pier2.width);
return distance;
};
Road.prototype.addPier = function () {
while (this.children.length < props.pierCount + 1) {
var childrenNum = this.children.length;
var randomPos = this.makeRandomFloat(props.pierMaxDistance, props.pierMinDistance);
var pier = ObjectPool.getObject('pier');
this.addChild(pier);
if (childrenNum == 0) {
pier.x = 0;
}
else {
pier.x = this.lastPos + randomPos;
}
this.lastPos = pier.x;
}
};
Road.prototype.moveAddPier = function () {
var randomPos = this.makeRandomFloat(props.pierMaxDistance, props.pierMinDistance);
var pier = ObjectPool.getObject('pier');
var lastChild = this.getChildAt(this.children.length - 1);
pier.x = lastChild.x + randomPos;
this.addChild(pier);
};
Road.prototype.makeRandomFloat = function (max, min) {
if (min === void 0) { min = 0; }
return Math.random() * (max - min) + min;
};
Road.prototype.setViewport = function () {
var _this = this;
var tmpMovepos = this.getMovePos();
this.children.forEach(function (item, index) {
_this.playTween(item, index, tmpMovepos);
});
};
Road.prototype.getMovePos = function () {
var movePos = this.getChildAt(1);
return movePos.x;
};
Road.prototype.playTween = function (item, index, tmpMovepos) {
var _this = this;
engine.Tween.get(item, { loop: false })
.to({ x: item.x - tmpMovepos }, props.pierMoveTime)
.call(function () {
if (_this.getChildIndex(item) == 0) {
engine.Tween.removeTweens(item);
_this.removeChild(item);
ObjectPool.recycleObject('pier', item);
}
if (index == 0) {
_this.moveAddPier();
}
});
};
Road.prototype.getStartGold = function (index, isClose) {
if (isClose === void 0) { isClose = true; }
var tmpNode = this.getChildAt(index);
var haveGold = tmpNode.haveGold;
if (haveGold && isClose) {
tmpNode.closeGold();
}
return haveGold;
};
Road.prototype.setGuide = function () {
var tmpNode = this.getChildAt(1);
if (!tmpNode.haveGold) {
tmpNode.children.forEach(function (item) {
if (item.name == 'gold') {
item.visible = true;
}
});
tmpNode.haveGold = true;
}
};
return Road;
}(engine.Container));
function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
function getStage() {
return engine.gameStage.stage;
}
function createSvga(name) {
var inst = new svga.Svga();
inst.source = engine.getAssetByName(name).uuid;
return inst;
}
var GuideLayer = (function (_super) {
tslib.__extends(GuideLayer, _super);
function GuideLayer() {
var _this = _super.call(this) || this;
_this._canClear = [];
_this.setup();
return _this;
}
GuideLayer.prototype.setup = function () {
};
GuideLayer.prototype.show = function (id, options, callback) {
this.visible = true;
this._callBack = callback ? callback : null;
if (!this.guideMask) {
this._options = options;
var _a = this.stage, width = _a.width, height = _a.height;
var guideMask = this.guideMask = new engine.Container();
var guideHole = this._guideHole = new engine.Image(getTextureByName('guide'));
guideHole.x = options.x;
guideHole.y = options.y;
guideHole.width = 250;
guideHole.height = 250;
guideHole.name = 'guideHole';
guideMask.addChild(guideHole);
this.createRect(guideMask, 0, 0, width, guideHole.y);
this.createRect(guideMask, 0, guideHole.y, guideHole.x, guideHole.height);
this.createRect(guideMask, guideHole.x + guideHole.width, guideHole.y, width - guideHole.x - guideHole.width, guideHole.height);
this.createRect(guideMask, 0, guideHole.y + guideHole.height, width, height - guideHole.y - guideHole.height);
this.guideStep(id);
var label = this.label = new engine.Label();
label.fillColor = 'white';
label.size = 30;
label.text = options.guideText;
label.x = (width - label.width) / 2;
label.y = guideHole.y + guideHole.height + 50;
label.textAlign = engine.TEXT_ALIGN.CENTER;
label.name = 'labHint';
guideMask.addChild(label);
this.addChild(guideMask);
}
this.once(engine.MouseEvent.CLICK, function () {
this.removeChild(this.guideMask);
this.guideMask = null;
if (this._callBack) {
this._callBack();
}
}, this);
};
GuideLayer.prototype.createRect = function (container, x, y, width, height) {
var rect = new engine.Rect();
rect.x = x;
rect.y = y;
rect.width = width;
rect.height = height;
rect.fillColor = 'black';
rect.alpha = 0.7;
container.addChild(rect);
};
GuideLayer.prototype.guideStep = function (id) {
if (id == 1) {
var guideHand = new engine.Image(getTextureByName('guideHand'));
guideHand.x = this._options.x + 300;
guideHand.y = this._options.y + 100;
this.guideMask.addChild(guideHand);
var rect = new engine.Rect();
rect.x = this._options.x + 200;
rect.y = this._options.y - 15;
rect.width = props.strutWidth;
rect.height = 200;
rect.fillColor = props.strutColor;
this.guideMask.addChild(rect);
this._canClear.push(guideHand);
this._canClear.push(rect);
}
if (id == 2) {
var know = new engine.Image(getTextureByName('know'));
know.x = (this.stage.width - know.width) / 2;
know.y = this._options.y + 400;
this.guideMask.addChild(know);
this._canClear.push(know);
}
};
return GuideLayer;
}(engine.Container));
var LoopComponent = (function (_super) {
tslib.__extends(LoopComponent, _super);
function LoopComponent() {
var _this = _super.call(this) || this;
_this.onceInfo = { width: 0, height: 0, count: 0 };
_this.loopInfo = { width: 0, height: 0, count: 0 };
_this.parts = [];
return _this;
}
LoopComponent.prototype.setup = function (parts, info) {
var _this = this;
parts.forEach(function (item, index) {
var part;
if (typeof item == 'string') {
part = new engine.Sprite(getTextureByName(item));
}
else if (item instanceof engine.Texture) {
part = new engine.Sprite(item);
}
else {
part = item;
}
_this.addChild(part);
_this.parts.push(part);
if (index == 0) {
info.width = part.width;
info.height = part.height;
}
});
info.count = parts.length;
this.setViewport(0, 0);
};
LoopComponent.prototype.changeBg = function (changName) {
this.parts.forEach(function (item, index) {
item.texture = getTextureByName(changName);
});
};
LoopComponent.prototype.setupLoop = function (resArr) {
this.setup(resArr, this.loopInfo);
};
LoopComponent.prototype.setViewport = function (x, y) {
if (y === void 0) { y = 0; }
var sizeField = y == 0 ? 'width' : 'height';
var posField = y == 0 ? 'x' : 'y';
var pos = y == 0 ? x : y;
var index;
var onceSize = this.onceInfo[sizeField];
var onceCount = this.onceInfo.count;
var loopCount = this.loopInfo.count;
var loopSize = this.loopInfo[sizeField];
index = onceSize == 0 ? -1 : Math.floor(pos / onceSize);
if (index < 0 || index >= onceCount) {
var loopIndex = Math.floor((pos - onceCount * onceSize) / this.loopInfo[sizeField]);
index = onceCount + loopIndex;
}
var formerIndex = index < onceCount ? index : (index) % loopCount + onceCount;
var latterIndex = index < onceCount ? index + 1 : (index - onceCount + 1) % loopCount + onceCount;
var former = this.parts[formerIndex];
var latter = this.parts[latterIndex];
if (!former || !latter) {
console.log(formerIndex, latterIndex);
}
former[posField] = -(pos - loopSize * (index < onceCount ? index : index - onceCount) - (index < onceCount ? 0 : onceCount * onceSize));
latter[posField] = former.x + (index < onceCount ? onceSize : loopSize);
};
return LoopComponent;
}(engine.Container));
var Background = (function (_super) {
tslib.__extends(Background, _super);
function Background() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.partResHHL = ['hhl_after', 'hhl_front'];
_this.partResHB = ['hb_after', 'hb_front'];
_this.partResWH = ['wh_after', 'wh_front'];
_this.speeds = [];
_this.resArray = [];
_this.frameMovePos = 0;
return _this;
}
Background.prototype.initBg = function () {
this.sumMovePos = 0;
this.speeds.push(props.afterBGMoveSpeed);
this.speeds.push(props.frontBGMoveSpeed);
var bottomBg = new engine.Rect();
bottomBg.x = 0;
bottomBg.y = 0;
bottomBg.width = getStage().width;
bottomBg.height = 0;
bottomBg.fillColor = 0x75c9f5;
this.addChild(bottomBg);
this.resArray.push(this.partResHHL);
this.resArray.push(this.partResHB);
this.resArray.push(this.partResWH);
this._bgIndex = 0;
var parts = [];
for (var i = 0; i < 2; i++) {
var part = new LoopComponent();
part.setupLoop([
this.resArray[0][i],
this.resArray[0][i],
]);
parts.push(part);
this.addChild(part);
}
parts[1].y = 200;
};
Background.prototype.setViewport = function (pos) {
this.needFrameSum = (props.pierMoveTime / 1000) * 60;
this.frameMovePos = pos / this.needFrameSum;
this.frameIndex = 0;
this.addEventListener(engine.Event.ENTER_FRAME, this.frameBack, this);
};
Background.prototype.frameBack = function () {
if (this.frameIndex < this.needFrameSum) {
for (var i = 0; i < 2; i++) {
var part = this.getChildAt(i + 1);
var speed = this.speeds[i];
var tmpPos = ((this.frameMovePos * this.frameIndex) + this.sumMovePos) * speed;
part.setViewport(tmpPos);
}
this.frameIndex++;
}
else {
this.sumMovePos += this.frameMovePos * this.needFrameSum;
this.frameIndex = 0;
this.removeEventListener(engine.Event.ENTER_FRAME, this.frameBack, this);
}
};
Background.prototype.changeBg = function (index) {
for (var i = 0; i < 2; i++) {
var part = this.getChildAt(i + 1);
part.changeBg(this.resArray[index][i]);
if (i == 1 && index == 1) {
part.y = 400;
}
if (i == 1 && index == 2) {
part.y = 250;
}
}
this._bgIndex = index;
};
Background.prototype.getBgIndex = function () {
return this._bgIndex;
};
return Background;
}(engine.Container));
var Pier = (function (_super) {
tslib.__extends(Pier, _super);
function Pier() {
var _this = _super.call(this) || this;
_this.bmp = new engine.Sprite();
_this.addChild(_this.bmp);
return _this;
}
Pier.prototype.init = function () {
var bmp = this.bmp;
bmp.alpha = 1;
bmp.texture = getTextureByName('pier');
bmp.x = 0;
bmp.y = bmp.height;
if (this.children.length < 2) {
var gold = new engine.Sprite();
gold.texture = getTextureByName('gold');
gold.name = 'gold';
this.addChild(gold);
}
this.setGoldPosX(bmp);
this.setShowGold();
};
Pier.prototype.setShowGold = function () {
var nodeGold = this.getChildByName('gold');
var randomWard = Math.random();
nodeGold.alpha = 1;
var isShow = randomWard < props.reward ? true : false;
nodeGold.visible = isShow;
this.haveGold = isShow;
};
Pier.prototype.setGoldPosX = function (bmp) {
var nodeGold = this.getChildByName('gold');
var pos = bmp.width / 2 - nodeGold.width / 2;
nodeGold.x = pos;
nodeGold.y = bmp.height - nodeGold.height - 50;
nodeGold.visible = false;
};
Pier.prototype.closeGold = function () {
var _this = this;
this.children.forEach(function (item) {
if (item.name == 'gold') {
item.anchorX = item.width / 2;
item.anchorY = item.height / 2;
engine.Tween.get(item, { loop: false })
.to({ scaleX: 2.5, scaleY: 2.5 }, 200, engine.Ease.cubicOut)
.to({ scaleX: 1, scaleY: 1, alpha: 0 }, 200, engine.Ease.cubicIn)
.call(function () {
item.visible = false;
_this.haveGold = false;
});
}
});
};
return Pier;
}(engine.Container));
var Player = (function (_super) {
tslib.__extends(Player, _super);
function Player() {
return _super !== null && _super.apply(this, arguments) || this;
}
Player.prototype.initPlayer = function (pierWidth) {
this._container = new engine.Container();
this.addChild(this._container);
this.playerNode = createSvga('walk');
this._container.addChild(this.playerNode);
this.playerNode.y = 675;
this.playerNode.x = pierWidth / 2 - 80;
this.playerNode.play();
};
Player.prototype.setViewport = function (pos, callBack, pierWidth) {
var tmpPos = 0;
var isSuccess = false;
if (!pierWidth) {
tmpPos = pos;
isSuccess = true;
}
else {
tmpPos = pierWidth - this.playerNode.x + pos - 60;
}
this.playGoTween(tmpPos, callBack, isSuccess);
};
Player.prototype.playGoTween = function (pos, callBack, isSuccess) {
var _this = this;
engine.Tween.get(this._container, { loop: false })
.to({ x: pos }, props.playerMoveSpeed)
.call(function () {
engine.Tween.removeTweens(_this._container);
if (isSuccess) {
if (callBack) {
callBack();
}
}
else {
_this.playDropTween(callBack);
}
});
};
Player.prototype.playDropTween = function (callBack) {
var _this = this;
engine.Tween.get(this._container, { loop: false })
.to({ y: 2000 }, 1000)
.call(function () {
engine.Tween.removeTweens(_this._container);
if (callBack) {
callBack();
}
});
};
Player.prototype.setBackViewport = function (callBack) {
var _this = this;
engine.Tween.get(this._container, { loop: false })
.to({ x: 0 }, props.pierMoveTime)
.call(function () {
engine.Tween.removeTweens(_this._container);
if (callBack) {
callBack();
}
});
};
return Player;
}(engine.Container));
var Strut = (function (_super) {
tslib.__extends(Strut, _super);
function Strut() {
return _super !== null && _super.apply(this, arguments) || this;
}
Strut.prototype.init = function () {
this._strut = new engine.Rect();
this.addChild(this._strut);
this._strut.width = props.strutWidth;
this._strut.y = 833;
this._strut.fillColor = props.strutColor;
this._strut.rotation = 180;
};
Strut.prototype.onMouseDown = function (pierWidth, distance, callBack) {
this._strut.x = pierWidth - 60;
this._distance = distance;
this._callBack = callBack;
this._strut.visible = true;
this.addEventListener(engine.Event.ENTER_FRAME, this.frameStrut, this);
};
Strut.prototype.onMouseUp = function () {
var _this = this;
this.removeEventListener(engine.Event.ENTER_FRAME, this.frameStrut, this);
setTimeout(function () {
_this.strutRotation();
}, 200);
};
Strut.prototype.strutRotation = function () {
var _this = this;
engine.Tween.get(this._strut, { loop: false })
.to({ rotation: 270 }, props.strutRotationSpeed)
.call(function () {
_this.judgeResult();
engine.Tween.removeTweens(_this._strut);
});
};
Strut.prototype.judgeResult = function () {
var isSuccess = false;
if (this._distance[0] - this._distance[1] + 100 <= this._strut.height && this._strut.height <= this._distance[0] + 20) {
isSuccess = true;
}
if (this._callBack) {
this._callBack(isSuccess);
}
};
Strut.prototype.frameStrut = function () {
if (this._strut.height < 1000) {
this._strut.height += props.strutUpSpeed;
}
};
Strut.prototype.rest = function () {
this._strut.width = props.strutWidth;
this._strut.y = 833;
this._strut.fillColor = props.strutColor;
this._strut.rotation = 180;
this._strut.height = 0;
this._strut.visible = false;
};
Strut.prototype.getStrutHeight = function () {
var distance = this._strut.height > 1000 ? 1000 : this._strut.height;
return distance;
};
return Strut;
}(engine.Container));
var ScoreLabel = (function (_super) {
tslib.__extends(ScoreLabel, _super);
function ScoreLabel() {
return _super !== null && _super.apply(this, arguments) || this;
}
ScoreLabel.prototype.updateScore = function (score, animation) {
if (animation === void 0) { animation = true; }
this._value = score;
if (animation && this._tmp) {
this.animationUpdate();
}
else {
this.updateLocal(score);
}
};
ScoreLabel.prototype.animationUpdate = function () {
var _this = this;
var tmpInterval = setInterval(function () {
_this._tmp += 1;
if (_this._tmp <= _this._value) {
_this.text = _this._tmp;
}
else {
_this._tmp = _this._value;
clearInterval(tmpInterval);
}
}, 50);
};
ScoreLabel.prototype.updateLocal = function (v) {
this._tmp = v;
this.text = v;
};
return ScoreLabel;
}(engine.Label));
var ObjectPool$1 = engine.ObjectPool;
var PoolName = 'pier';
ObjectPool$1.registerPool(PoolName, function () {
return new Pier();
}, function (item, data) {
item.init();
});
var GameView = (function (_super) {
tslib.__extends(GameView, _super);
function GameView() {
var _this = _super.call(this) || this;
_this.moveX = 0;
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
return _this;
}
GameView.prototype.setup = function () {
if (this._hasSetup) {
return;
}
this._hasSetup = true;
this._backgroud = new Background();
this.addChild(this._backgroud);
this._backgroud.initBg();
var road = this._road = new Road();
this.addChild(road);
road.setup();
var pierWidth = this._road.getFristPier();
var player = this._player = new Player();
this.addChild(player);
player.initPlayer(pierWidth);
var strut = this._strut = new Strut();
this.addChild(strut);
strut.init();
this._scoreContainer = new engine.Container();
this.addChild(this._scoreContainer);
this.initLabScore();
};
GameView.prototype.start = function (guide) {
return tslib.__awaiter(this, void 0, void 0, function () {
var initScore;
return tslib.__generator(this, function (_a) {
this._isTouchLayer = true;
this._sumScore = 0;
this._isMouseDown = false;
this._guide = guide;
initScore = this._road.getStartGold(0) ? props.goldScore : 0;
this.updateScore(initScore);
if (this._guide == '1') {
this.setGuide();
}
else {
this.initTouch();
this.registerEvent();
}
return [2];
});
});
};
GameView.prototype.setGuide = function () {
var _this = this;
this._road.setGuide();
var guideLayer = this.guideLayer = new GuideLayer();
this.addChild(guideLayer);
this.guideLayer.show(1, { x: 20, y: 650, guideText: props.guideText1 }, function () {
var posX = _this._road.getMovePos();
_this.guideLayer.show(2, { x: posX + 20, y: 620, guideText: props.guideText2 }, function () {
_this.initTouch();
_this.registerEvent();
});
});
};
GameView.prototype.initLabScore = function () {
var scoreBg = new engine.Sprite(getTextureByName('scoreBg'));
scoreBg.x = getStage().width / 2 - scoreBg.width / 2;
scoreBg.y = 80;
var scoreHint = new engine.Sprite(getTextureByName('scoreHint'));
scoreHint.x = getStage().width / 2 - scoreHint.width / 2;
scoreHint.y = 40;
this._scoreContainer.addChild(scoreHint);
this.labScore = new ScoreLabel();
this.labScore.fillColor = 0xff7646;
this.labScore.size = 70;
this.labScore.width = getStage().width;
this.labScore.height = scoreBg.height;
this.labScore.textAlign = engine.TEXT_ALIGN.CENTER;
this.labScore.x = 0;
this.labScore.y = scoreBg.y + 10;
this._scoreContainer.addChild(this.labScore);
};
GameView.prototype.registerEvent = function () {
this._touchLayer.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onMouseDown, this);
this._touchLayer.addEventListener(engine.MouseEvent.MOUSE_UP, this.onMouseUp, this);
};
GameView.prototype.removeListener = function () {
this._touchLayer.removeEventListener(engine.MouseEvent.MOUSE_DOWN, this.onMouseDown, this);
this._touchLayer.removeEventListener(engine.MouseEvent.MOUSE_UP, this.onMouseUp, this);
};
GameView.prototype.initTouch = function () {
this._touchLayer = new engine.Rect();
this.addChild(this._touchLayer);
this._touchLayer.width = getStage().width;
this._touchLayer.height = getStage().height;
this._touchLayer.x = 0;
this._touchLayer.y = 0;
this._touchLayer.alpha = 0;
};
GameView.prototype.setScoreShow = function () {
};
GameView.prototype.onMouseDown = function () {
if (this._isTouchLayer) {
this._isMouseDown = true;
this._strut.onMouseDown(this._road.getFristPier(), this._road.getDistance(), this.goCallBcak.bind(this));
}
};
GameView.prototype.onMouseUp = function () {
if (this._isTouchLayer && this._isMouseDown) {
this._strut.onMouseUp();
this._isMouseDown = false;
this._isTouchLayer = false;
}
};
GameView.prototype.goCallBcak = function (isSuccess) {
var _this = this;
if (isSuccess) {
console.log('成功了');
var movePos = this._road.getMovePos();
if (this._road.getStartGold(1, false)) {
this.updateScore(props.singleScore + props.goldScore);
}
else {
this.updateScore(props.singleScore);
}
this._player.setViewport(movePos, this.complete.bind(this));
}
else {
console.log('失败了');
this._player.setViewport(this._strut.getStrutHeight(), function () {
console.log('掉下去了');
engine.globalEvent.dispatchEvent('dxbcyj-game-result', { score: _this._sumScore });
}, this._road.getFristPier());
}
};
GameView.prototype.complete = function () {
var _this = this;
this._road.getStartGold(1);
var movePos = this._road.getMovePos();
this._road.setViewport();
this._backgroud.setViewport(movePos);
this._player.setBackViewport(function () {
_this._isTouchLayer = true;
});
this.closeStrut();
};
GameView.prototype.closeStrut = function () {
this._strut.rest();
};
GameView.prototype.updateScore = function (score) {
this._sumScore += score;
if (0 <= this._sumScore && this._sumScore <= props.bgFristScore) {
this.changeBg(0);
}
else if (props.bgFristScore < this._sumScore && this._sumScore <= props.bgSecondScore) {
this.changeBg(1);
}
else {
this.changeBg(2);
}
this.labScore.updateScore(this._sumScore);
};
GameView.prototype.getScore = function () {
return this._sumScore;
};
GameView.prototype.changeBg = function (index) {
if (this._backgroud.getBgIndex() != index) {
this._backgroud.changeBg(index);
}
};
return GameView;
}(engine.Container));
var GameWrapper = (function (_super) {
tslib.__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('dxbcyj-game-start', _this.start, _this);
var gameView = _this._gameView = new GameView();
_this.addChild(gameView);
return _this;
}
GameWrapper.prototype.start = function (event) {
this._gameView.start(event.data.guide);
};
return GameWrapper;
}(engine.Container));
function index (props) {
prepareProps();
injectProps(props);
var instance = new GameWrapper();
return instance;
}
return index;
})));
//# sourceMappingURL=main.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sources":["src/custom/dxbcyj-game/src/props.ts","src/custom/dxbcyj-game/src/game/Road.ts","src/custom/dxbcyj-game/src/game/utils.ts","src/custom/dxbcyj-game/src/game/GuideLayer.ts","src/custom/dxbcyj-game/src/game/LoopComponent.ts","src/custom/dxbcyj-game/src/game/Background.ts","src/custom/dxbcyj-game/src/game/Pier.ts","src/custom/dxbcyj-game/src/game/Player.ts","src/custom/dxbcyj-game/src/game/Strut.ts","src/custom/dxbcyj-game/src/game/ScoreLabel.ts","src/custom/dxbcyj-game/src/game/GameView.ts","src/custom/dxbcyj-game/src/game/GameWrapper.ts","src/custom/dxbcyj-game/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\r\nimport { props } from './../props';\r\nimport ObjectPool = engine.ObjectPool;\r\nimport {getStage} from \"./utils\";\r\nimport { Pier } from './Pier';\r\nimport GameView from './GameView';\r\n\r\nexport class Road extends engine.Container{\r\n //container: engine.Container;\r\n lastPos;\r\n setup(){\r\n // this.container = new engine.Container();\r\n // this.addChild(this.container);\r\n this.lastPos = 0;\r\n this.addPier();\r\n\r\n }\r\n getFristPier(){\r\n return this.getChildAt(0).width;\r\n }\r\n getDistance(){\r\n let distance = [];\r\n let pier1 = this.getChildAt(0);\r\n let pier2 = this.getChildAt(1);\r\n distance.push(pier2.x - pier1.x);\r\n distance.push(pier2.width);\r\n\r\n return distance;\r\n }\r\n addPier(){ \r\n while(this.children.length < props.pierCount + 1){\r\n let childrenNum = this.children.length;\r\n let randomPos = this.makeRandomFloat(props.pierMaxDistance,props.pierMinDistance);\r\n const pier: Pier = ObjectPool.getObject('pier');\r\n this.addChild(pier);\r\n if(childrenNum == 0){\r\n pier.x = 0;\r\n }else{\r\n pier.x = this.lastPos + randomPos;\r\n }\r\n this.lastPos = pier.x;\r\n }\r\n }\r\n moveAddPier(){\r\n let randomPos = this.makeRandomFloat(props.pierMaxDistance,props.pierMinDistance);\r\n const pier: Pier = ObjectPool.getObject('pier');\r\n let lastChild = this.getChildAt(this.children.length -1);\r\n pier.x = lastChild.x + randomPos;\r\n this.addChild(pier);\r\n\r\n }\r\n makeRandomFloat(max: number, min: number = 0): number {\r\n return Math.random() * (max - min) + min;\r\n }\r\n setViewport(){\r\n let tmpMovepos = this.getMovePos();\r\n this.children.forEach((item,index) => {\r\n this.playTween(item,index,tmpMovepos);\r\n })\r\n }\r\n //获得移动位移\r\n getMovePos(){\r\n let movePos:any = this.getChildAt(1);\r\n return movePos.x;\r\n }\r\n playTween(item,index,tmpMovepos){\r\n engine.Tween.get(item,{loop:false})\r\n .to({x : item.x - tmpMovepos},props.pierMoveTime)\r\n .call(()=>{\r\n if(this.getChildIndex(item) == 0){\r\n engine.Tween.removeTweens(item);\r\n this.removeChild(item);\r\n ObjectPool.recycleObject('pier',item);\r\n }\r\n if(index == 0){\r\n this.moveAddPier();\r\n }\r\n })\r\n }\r\n //桥墩是否有金币\r\n getStartGold(index,isClose = true){\r\n let tmpNode:any = this.getChildAt(index);\r\n let haveGold = tmpNode.haveGold;\r\n if(haveGold && isClose){\r\n tmpNode.closeGold();\r\n }\r\n return haveGold;\r\n } \r\n //设置新手引导 第二个桥墩要有金币\r\n setGuide(){\r\n let tmpNode:any = this.getChildAt(1);\r\n if(!tmpNode.haveGold){\r\n tmpNode.children.forEach((item) => {\r\n if(item.name == 'gold'){\r\n item.visible = true;\r\n }\r\n })\r\n tmpNode.haveGold = true;\r\n }\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 getStage(){\r\n\treturn engine.gameStage.stage;\r\n}\r\n\r\nexport function createSvga(name) {\r\n\tlet inst = new svga.Svga();\r\n\tinst.source = engine.getAssetByName(name).uuid;\r\n\t// let anchor = props[(anchorName)];\r\n\t// if (anchor) {\r\n\t// \tinst.x = -anchor.x;\r\n\t// \tinst.y = -anchor.y;\r\n\r\n\t// \tinst.anchorX = anchor.x;\r\n\t// \tinst.anchorY = anchor.y;\r\n\t// }\r\n\treturn inst;\r\n}\r\n","/**\r\n * Created by rockyl on 2020-01-30.\r\n */\r\nimport {props} from \"../props\";\r\nimport {getTextureByName} from \"./utils\";\r\n\r\nexport class GuideLayer extends engine.Container {\r\n\tprivate guideMask: engine.Container;\r\n\tprivate _options;\r\n\t_guideHole;\r\n\t_canClear:any = [];\r\n\t_callBack;\r\n\tprivate label: engine.Label;\r\n\r\n\tconstructor() {\r\n\t\tsuper();\r\n\r\n\t\tthis.setup();\r\n\t}\r\n\r\n\tprivate setup() {\r\n\r\n\t}\r\n\r\n\tshow(id, options,callback?) {\r\n\t\tthis.visible = true;\r\n\t\tthis._callBack = callback?callback:null;\r\n\t\tif (!this.guideMask) {\r\n\t\t\tthis._options = options;\r\n\t\t\tconst {width, height} = this.stage;\r\n\t\t\tlet guideMask = this.guideMask = new engine.Container();\r\n\t\t\t\r\n\t\t\tlet guideHole = this._guideHole= new engine.Image(getTextureByName('guide'));\r\n\t\t\tguideHole.x = options.x;\r\n\t\t\tguideHole.y = options.y;\r\n\t\t\tguideHole.width = 250;\r\n\t\t\tguideHole.height = 250;\r\n\t\t\tguideHole.name = 'guideHole';\r\n\t\t\tguideMask.addChild(guideHole);\r\n\r\n\t\t\t\r\n\t\t\tthis.createRect(guideMask, 0, 0, width, guideHole.y);\r\n\t\t\tthis.createRect(guideMask, 0, guideHole.y, guideHole.x, guideHole.height);\r\n\t\t\tthis.createRect(guideMask, guideHole.x + guideHole.width, guideHole.y, width - guideHole.x - guideHole.width, guideHole.height);\r\n\t\t\tthis.createRect(guideMask, 0, guideHole.y + guideHole.height, width, height - guideHole.y - guideHole.height);\r\n\t\t\tthis.guideStep(id);\r\n\t\t\tlet label = this.label = new engine.Label();\r\n\t\t\tlabel.fillColor = 'white';\r\n\t\t\tlabel.size = 30;\r\n\t\t\tlabel.text = options.guideText;\r\n\t\t\tlabel.x = (width - label.width) / 2;\r\n\t\t\tlabel.y = guideHole.y + guideHole.height + 50;\r\n\t\t\tlabel.textAlign = engine.TEXT_ALIGN.CENTER;\r\n\t\t\tlabel.name = 'labHint';\r\n\t\t\tguideMask.addChild(label);\r\n\r\n\t\t\tthis.addChild(guideMask);\r\n\t\t}\r\n\t\tthis.once(engine.MouseEvent.CLICK, function(){\r\n\t\r\n\t\t\tthis.removeChild(this.guideMask);\r\n\t\t\tthis.guideMask = null;\r\n\t\t\r\n\t\t\tif(this._callBack){\r\n\t\t\t\tthis._callBack();\r\n\t\t\t}\r\n\t\t\r\n\t\t}, this);\r\n\t}\r\n\r\n\tcreateRect(container, x, y, width, height) {\r\n\t\tlet rect = new engine.Rect();\r\n\t\trect.x = x;\r\n\t\trect.y = y;\r\n\t\trect.width = width;\r\n\t\trect.height = height;\r\n\t\trect.fillColor = 'black';\r\n\t\trect.alpha = 0.7;\r\n\r\n\t\tcontainer.addChild(rect);\r\n\t}\r\n\tguideStep(id){\r\n\t\tif(id == 1){\r\n\t\t\tlet guideHand = new engine.Image(getTextureByName('guideHand'));\r\n\t\t\tguideHand.x = this._options.x + 300;\r\n\t\t\tguideHand.y = this._options.y + 100;\r\n\t\t\tthis.guideMask.addChild(guideHand);\r\n\t\r\n\t\t\tlet rect = new engine.Rect();\r\n\t\t\trect.x = this._options.x + 200;\r\n\t\t\trect.y = this._options.y - 15;\r\n\t\t\trect.width = props.strutWidth;\r\n\t\t\trect.height = 200;\r\n\t\t\trect.fillColor = props.strutColor;\r\n\t\t\tthis.guideMask.addChild(rect);\r\n\r\n\t\t\tthis._canClear.push(guideHand);\r\n\t\t\tthis._canClear.push(rect);\r\n\t\t}\r\n\t\tif(id == 2){\r\n\r\n\t\t\tlet know = new engine.Image(getTextureByName('know'));\r\n\t\t\tknow.x = (this.stage.width - know.width) / 2;\r\n\t\t\tknow.y = this._options.y + 400;\r\n\t\t\tthis.guideMask.addChild(know);\r\n\t\t\tthis._canClear.push(know);\r\n\t\t}\r\n\t}\r\n}\r\n","\r\nimport {getTextureByName} from \"./utils\";\r\nexport class LoopComponent extends engine.Container{\r\n parts: any[];\r\n\r\n\tonceInfo: any = {width: 0, height: 0, count: 0};\r\n\tloopInfo: any = {width: 0, height: 0, count: 0};\r\n\r\n\tconstructor() {\r\n\t\tsuper();\r\n\r\n\t\tthis.parts = [];\r\n }\r\n private setup(parts, info) {\r\n parts.forEach((item, index) => {\r\n\t\t\tlet part;\r\n\t\t\tif(typeof item == 'string'){\r\n\t\t\t\tpart = new engine.Sprite(getTextureByName(item));\r\n\t\t\t\r\n\t\t\t}else if(item instanceof engine.Texture){\r\n\t\t\t\tpart = new engine.Sprite(item);\r\n\t\t\t}else {\r\n\t\t\t\tpart = item;\r\n\t\t\t}\r\n\t\t\tthis.addChild(part);\r\n\t\t\tthis.parts.push(part);\r\n\r\n\t\t\tif (index == 0) {\r\n\t\t\t\tinfo.width = part.width;\r\n\t\t\t\tinfo.height = part.height;\r\n\t\t\t}\r\n\t\t});\r\n\t\tinfo.count = parts.length;\r\n\r\n\t\tthis.setViewport(0, 0)\r\n }\r\n\r\n\tchangeBg(changName){\r\n\t\tthis.parts.forEach((item, index) => {\r\n\t\t\titem.texture = getTextureByName(changName)\r\n\t\t});\r\n\t}\r\n\tsetupLoop(resArr) {\r\n\t\tthis.setup(resArr, this.loopInfo);\r\n }\r\n setViewport(x, y = 0) {\r\n\t\tconst sizeField = y == 0 ? 'width' : 'height';\r\n\t\tconst posField = y == 0 ? 'x' : 'y';\r\n\t\tconst pos = y == 0 ? x : y;\r\n\r\n\t\tlet index;\r\n\t\tconst onceSize = this.onceInfo[sizeField];\r\n\t\tconst onceCount = this.onceInfo.count;\r\n\t\tconst loopCount = this.loopInfo.count;\r\n\t\tconst loopSize = this.loopInfo[sizeField];\r\n\t\tindex = onceSize == 0 ? -1 : Math.floor(pos / onceSize);\r\n\r\n\t\tif (index < 0 || index >= onceCount) {\r\n\t\t\tconst loopIndex = Math.floor((pos - onceCount * onceSize) / this.loopInfo[sizeField]);\r\n\t\t\tindex = onceCount + loopIndex;\r\n\t\t}\r\n\r\n\t\tlet formerIndex = index < onceCount ? index : (index) % loopCount + onceCount;\r\n\t\tlet latterIndex = index < onceCount ? index + 1 : (index - onceCount + 1) % loopCount + onceCount;\r\n\t\tlet former = this.parts[formerIndex];\r\n\t\tlet latter = this.parts[latterIndex];\r\n\t\tif(!former || !latter){\r\n\t\t\tconsole.log(formerIndex, latterIndex);\r\n\t\t}\r\n\t\tformer[posField] = -(pos - loopSize * (index < onceCount ? index : index - onceCount) - (index < onceCount ? 0 : onceCount * onceSize));\r\n\t\tlatter[posField] = former.x + (index < onceCount ? onceSize : loopSize);\r\n\t}\r\n}","\r\n\r\nimport {getTextureByName} from \"./utils\";\r\nimport {getStage} from \"./utils\";\r\nimport {LoopComponent} from \"./LoopComponent\";\r\nimport { props } from './../props';\r\n\r\nexport class Background extends engine.Container{\r\n partResHHL = ['hhl_after', 'hhl_front'];\r\n partResHB = ['hb_after','hb_front'];\r\n partResWH = ['wh_after','wh_front'];\r\n speeds = [];\r\n resArray=[];\r\n frameMovePos = 0;\r\n frameIndex;\r\n sumMovePos;\r\n _bgIndex;\r\n //需要的总帧数\r\n needFrameSum;\r\n initBg(){\r\n this.sumMovePos = 0;\r\n this.speeds.push(props.afterBGMoveSpeed);\r\n this.speeds.push(props.frontBGMoveSpeed);\r\n \r\n let bottomBg = new engine.Rect();\r\n bottomBg.x = 0;\r\n bottomBg.y = 0;\r\n bottomBg.width = getStage().width;\r\n bottomBg.height = 0;\r\n bottomBg.fillColor = 0x75c9f5;\r\n\r\n this.addChild(bottomBg);\r\n this.resArray.push(this.partResHHL)\r\n this.resArray.push(this.partResHB)\r\n this.resArray.push(this.partResWH)\r\n this._bgIndex = 0;\r\n\t\tconst parts = [];\r\n\t\tfor(let i = 0; i < 2; i++){\r\n\t\t\tlet part = new LoopComponent();\r\n\t\t\tpart.setupLoop([\r\n\t\t\t\tthis.resArray[0][i],\r\n\t\t\t\tthis.resArray[0][i],\r\n\t\t\t]);\r\n\t\t\tparts.push(part);\r\n this.addChild(part);\r\n }\r\n \r\n //(height - parts[1].height) / 2 - 200\r\n parts[1].y = 200;\r\n }\r\n \r\n setViewport(pos) {\r\n this.needFrameSum = (props.pierMoveTime/1000)*60;\r\n this.frameMovePos = pos/this.needFrameSum;\r\n this.frameIndex = 0;\r\n this.addEventListener(engine.Event.ENTER_FRAME,this.frameBack,this);\r\n }\r\n frameBack(){\r\n if( this.frameIndex < this.needFrameSum){\r\n for (let i = 0; i < 2; i++) {\r\n const part = <LoopComponent>this.getChildAt(i + 1);\r\n const speed = this.speeds[i];\r\n let tmpPos = ((this.frameMovePos * this.frameIndex) + this.sumMovePos ) * speed;\r\n part.setViewport(tmpPos)\r\n }\r\n this.frameIndex++\r\n }else{\r\n this.sumMovePos += this.frameMovePos * this.needFrameSum;\r\n this.frameIndex = 0\r\n this.removeEventListener(engine.Event.ENTER_FRAME,this.frameBack,this);\r\n } \r\n }\r\n changeBg(index){\r\n for (let i = 0; i < 2; i++) {\r\n const part = <LoopComponent>this.getChildAt(i + 1);\r\n part.changeBg(this.resArray[index][i]);\r\n if(i == 1 && index ==1){\r\n part.y = 400;\r\n } \r\n if(i == 1 && index ==2){\r\n part.y = 250;\r\n } \r\n }\r\n this._bgIndex = index;\r\n }\r\n getBgIndex(){\r\n return this._bgIndex;\r\n }\r\n}","import { props } from './../props';\r\nimport {getTextureByName,getStage} from \"./utils\";\r\nexport class Pier extends engine.Container {\r\n bmp;\r\n public haveGold;\r\n constructor() {\r\n\t\tsuper();\r\n this.bmp = new engine.Sprite();\r\n this.addChild(this.bmp);\r\n\t\t\r\n }\r\n init(){\r\n\t\tconst bmp = this.bmp;\r\n\t\tbmp.alpha = 1;\r\n\t\tbmp.texture = getTextureByName('pier');\r\n\t\tbmp.x = 0;\r\n bmp.y = bmp.height ;\r\n if(this.children.length < 2){\r\n const gold = new engine.Sprite();\r\n gold.texture = getTextureByName('gold');\r\n gold.name = 'gold';\r\n this.addChild(gold);\r\n }\r\n this.setGoldPosX(bmp);\r\n this.setShowGold();\r\n }\r\n setShowGold(){\r\n let nodeGold = this.getChildByName('gold');\r\n let randomWard = Math.random();\r\n nodeGold.alpha = 1;\r\n let isShow = randomWard < props.reward ? true : false ;\r\n nodeGold.visible = isShow;\r\n this.haveGold = isShow;\r\n }\r\n setGoldPosX(bmp){\r\n let nodeGold = this.getChildByName('gold');\r\n let pos = bmp.width / 2 - nodeGold.width/2;\r\n nodeGold.x = pos\r\n nodeGold.y = bmp.height - nodeGold.height - 50;\r\n nodeGold.visible = false;\r\n }\r\n closeGold(){\r\n this.children.forEach((item) => {\r\n if(item.name == 'gold')\r\n {\r\n item.anchorX = item.width/2;\r\n item.anchorY = item.height/2;\r\n engine.Tween.get(item,{loop:false})\r\n .to({scaleX:2.5,scaleY:2.5},200,engine.Ease.cubicOut)\r\n .to({scaleX:1,scaleY:1,alpha:0},200,engine.Ease.cubicIn)\r\n .call(()=>{\r\n item.visible = false;\r\n this.haveGold = false;\r\n })\r\n }\r\n })\r\n }\r\n}","import {props} from \"../props\";\r\nimport {createSvga, playSound} from \"./utils\";\r\nexport class Player extends engine.Container{\r\n _container;\r\n private playerNode: svga.Svga;\r\n\r\n initPlayer(pierWidth){\r\n \r\n this._container = new engine.Container();\r\n this.addChild(this._container);\r\n\r\n\r\n this.playerNode = createSvga('walk');\r\n this._container.addChild(this.playerNode);\r\n this.playerNode.y = 675;\r\n this.playerNode.x = pierWidth/2 - 80;\r\n this.playerNode.play();\r\n }\r\n setViewport(pos,callBack,pierWidth?){\r\n let tmpPos = 0;\r\n let isSuccess = false;\r\n if(!pierWidth){\r\n tmpPos = pos;\r\n isSuccess = true;\r\n }else{\r\n tmpPos = pierWidth - this.playerNode.x + pos - 60;\r\n }\r\n this.playGoTween(tmpPos,callBack,isSuccess)\r\n }\r\n playGoTween(pos,callBack,isSuccess){\r\n engine.Tween.get(this._container,{loop:false})\r\n .to({x : pos},props.playerMoveSpeed)\r\n .call(()=>{\r\n engine.Tween.removeTweens(this._container);\r\n if(isSuccess){\r\n if(callBack){\r\n callBack();\r\n }\r\n }else{\r\n this.playDropTween(callBack);\r\n }\r\n \r\n })\r\n }\r\n playDropTween(callBack){\r\n engine.Tween.get(this._container,{loop:false})\r\n .to({y : 2000},1000)\r\n .call(()=>{\r\n engine.Tween.removeTweens(this._container);\r\n if(callBack){\r\n callBack();\r\n }\r\n })\r\n }\r\n setBackViewport(callBack){\r\n engine.Tween.get(this._container,{loop:false})\r\n .to({x : 0},props.pierMoveTime)\r\n .call(()=>{\r\n engine.Tween.removeTweens(this._container);\r\n if(callBack){\r\n callBack();\r\n }\r\n })\r\n }\r\n\r\n}","import { props } from \"../props\";\r\n\r\nexport class Strut extends engine.Container{\r\n _strut: engine.Rect;\r\n _distance;\r\n _callBack;\r\n init(){\r\n this._strut = new engine.Rect();\r\n this.addChild(this._strut);\r\n this._strut.width = props.strutWidth;\r\n this._strut.y = 833;\r\n this._strut.fillColor = props.strutColor;\r\n this._strut.rotation = 180;\r\n }\r\n onMouseDown(pierWidth,distance,callBack){\r\n this._strut.x = pierWidth - 60;\r\n this._distance = distance;\r\n this._callBack = callBack;\r\n this._strut.visible = true;\r\n this.addEventListener(engine.Event.ENTER_FRAME,this.frameStrut,this);\r\n }\r\n onMouseUp(){\r\n this.removeEventListener(engine.Event.ENTER_FRAME,this.frameStrut,this);\r\n setTimeout(() => {\r\n this.strutRotation();\r\n }, 200);\r\n }\r\n strutRotation(){\r\n engine.Tween.get(this._strut,{loop:false})\r\n .to({rotation:270},props.strutRotationSpeed)\r\n .call(()=>{\r\n this.judgeResult();\r\n engine.Tween.removeTweens(this._strut);\r\n })\r\n }\r\n judgeResult(){\r\n let isSuccess = false;\r\n if(this._distance[0] - this._distance[1] + 100 <= this._strut.height && this._strut.height <= this._distance[0] + 20){\r\n isSuccess = true;\r\n }\r\n if(this._callBack){\r\n this._callBack(isSuccess);\r\n }\r\n }\r\n frameStrut(){\r\n if(this._strut.height < 1000){\r\n this._strut.height += props.strutUpSpeed;\r\n }\r\n }\r\n rest(){\r\n this._strut.width = props.strutWidth;\r\n this._strut.y = 833;\r\n this._strut.fillColor = props.strutColor;\r\n this._strut.rotation = 180;\r\n this._strut.height = 0;\r\n this._strut.visible = false;\r\n }\r\n getStrutHeight(){\r\n let distance = this._strut.height > 1000 ? 1000 :this._strut.height;\r\n return distance;\r\n }\r\n\r\n}","/**\r\n * Created by rockyl on 2018/9/10.\r\n *\r\n * 分数标签\r\n */\r\n\r\nexport class ScoreLabel extends engine.Label {\r\n _value;\r\n _tmp;\r\n\tupdateScore(score,animation = true) {\r\n this._value = score;\r\n\r\n\t\tif (animation && this._tmp) {\r\n this.animationUpdate();\r\n\t\t} else {\r\n this.updateLocal(score);\r\n\t\t}\r\n }\r\n \r\n animationUpdate(){\r\n let tmpInterval = setInterval(()=>{\r\n this._tmp += 1;\r\n if(this._tmp <= this._value){\r\n this.text = this._tmp\r\n }else{\r\n this._tmp = this._value;\r\n clearInterval(tmpInterval);\r\n }\r\n },50)\r\n }\r\n\r\n updateLocal(v){\r\n this._tmp = v;\r\n this.text = v;\r\n }\r\n\r\n}\r\n","\r\nimport { Road } from './Road';\r\n/**\r\n * Created by rockyl on 2018/8/16.\r\n */\r\n\r\nimport {props} from \"../props\";\r\nimport {getStage,getTextureByName} from \"./utils\";\r\nimport {GuideLayer} from \"./GuideLayer\";\r\nimport { Background } from \"./Background\";\r\nimport ObjectPool = engine.ObjectPool;\r\nimport { Pier } from './Pier';\r\nimport { Player } from './Player';\r\nimport { Strut } from './Strut';\r\nimport { ScoreLabel } from './ScoreLabel';\r\n\r\nexport const PoolName: string = 'pier';\r\n\r\nObjectPool.registerPool(PoolName, function () {\r\n\treturn new Pier();\r\n}, function (item: Pier, data) {\r\n\titem.init();\r\n});\r\n\r\nexport default class GameView extends engine.Container {\r\n\tguideLayer: GuideLayer;\r\n\t\r\n\tprivate _hasSetup;\r\n\t_backgroud:Background;\r\n\t_road:Road;\r\n\t_player:Player;\r\n\t_strut:Strut;\r\n\t_touchLayer: engine.Rect;\r\n\t_isTouchLayer;\r\n\t_scoreContainer;\r\n\tmoveX = 0;\r\n\tlabScore:ScoreLabel;\r\n\t_sumScore;\r\n\t_isMouseDown;\r\n\r\n\t_guide;\r\n\tconstructor() {\r\n\t\tsuper();\t\r\n\t\tthis.once(engine.Event.ADDED_TO_STAGE, this.setup, this);\r\n\t}\r\n\tsetup(){\r\n\t\tif (this._hasSetup) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tthis._hasSetup = true;\r\n\t\t\r\n\t\tthis._backgroud = new Background();\r\n\t\tthis.addChild(this._backgroud);\r\n\t\tthis._backgroud.initBg();\r\n\r\n\t\tconst road = this._road = new Road();\r\n\t\tthis.addChild(road);\r\n\t\troad.setup();\r\n\r\n\t\tlet pierWidth = this._road.getFristPier();\r\n\t\tconst player = this._player = new Player();\r\n\t\tthis.addChild(player);\r\n\t\tplayer.initPlayer(pierWidth);\r\n\r\n\t\tconst strut = this._strut = new Strut();\r\n\t\tthis.addChild(strut);\r\n\t\tstrut.init();\r\n\r\n\t\tthis._scoreContainer = new engine.Container();\r\n\t\tthis.addChild(this._scoreContainer);\r\n\t\tthis.initLabScore();\r\n\r\n\t}\r\n\tasync start(guide) {\r\n\t\tthis._isTouchLayer = true;\r\n\t\tthis._sumScore = 0;\r\n\t\tthis._isMouseDown = false;\r\n\t\tthis._guide = guide;\r\n\r\n\t\tlet initScore = this._road.getStartGold(0) ? props.goldScore : 0;\r\n\t\tthis.updateScore(initScore);\r\n\r\n\t\t//是否是新手\r\n\t\tif(this._guide == '1'){\r\n\t\t\tthis.setGuide();\r\n\t\t}else{\r\n\t\t\tthis.initTouch();\r\n\t\t\tthis.registerEvent();\r\n\t\t}\r\n\t} \r\n\t//新手引导\r\n\tsetGuide(){\r\n\t\tthis._road.setGuide();\r\n\t\tconst guideLayer = this.guideLayer = new GuideLayer();\r\n\t\tthis.addChild(guideLayer);\r\n\t\tthis.guideLayer.show(1, {x:20,y: 650,guideText:props.guideText1},()=>{\r\n\t\t\tlet posX = this._road.getMovePos();\r\n\t\t\tthis.guideLayer.show(2, {x:posX + 20,y: 620,guideText:props.guideText2},()=>{\r\n\t\t\t\tthis.initTouch();\r\n\t\t\t\tthis.registerEvent();\r\n\t\t\t})\r\n\t\t});\r\n\t}\r\n\t//分数显示\r\n\tinitLabScore(){\r\n\t\tconst scoreBg = new engine.Sprite(getTextureByName('scoreBg'));\r\n\t\tscoreBg.x = getStage().width/2 - scoreBg.width/2; \r\n\t\tscoreBg.y = 80;\r\n\t\t//this._scoreContainer.addChild(scoreBg);\r\n\t\r\n\t\tconst scoreHint = new engine.Sprite(getTextureByName('scoreHint'));\r\n\t\tscoreHint.x = getStage().width/2 - scoreHint.width/2; \r\n\t\tscoreHint.y = 40;\r\n\t\tthis._scoreContainer.addChild(scoreHint);\r\n\r\n\t\tthis.labScore = new ScoreLabel();\r\n this.labScore.fillColor = 0xff7646;\r\n\t\tthis.labScore.size = 70;\r\n\t\tthis.labScore.width = getStage().width;\r\n\t\tthis.labScore.height = scoreBg.height;\r\n\t\tthis.labScore.textAlign = engine.TEXT_ALIGN.CENTER;\r\n\t\tthis.labScore.x = 0;\r\n\t\tthis.labScore.y = scoreBg.y+10;\r\n\t\tthis._scoreContainer.addChild(this.labScore);\r\n }\r\n\tregisterEvent(){\r\n this._touchLayer.addEventListener(engine.MouseEvent.MOUSE_DOWN,this.onMouseDown,this);\r\n this._touchLayer.addEventListener(engine.MouseEvent.MOUSE_UP,this.onMouseUp,this);\r\n\t}\r\n\tremoveListener(){\r\n this._touchLayer.removeEventListener(engine.MouseEvent.MOUSE_DOWN,this.onMouseDown,this);\r\n this._touchLayer.removeEventListener(engine.MouseEvent.MOUSE_UP,this.onMouseUp,this);\r\n\t}\r\n\t//触碰层\r\n\tinitTouch(){\r\n this._touchLayer = new engine.Rect();\r\n this.addChild(this._touchLayer);\r\n this._touchLayer.width = getStage().width;\r\n this._touchLayer.height = getStage().height;\r\n this._touchLayer.x = 0;\r\n this._touchLayer.y = 0;\r\n this._touchLayer.alpha = 0;\r\n\t}\r\n\tsetScoreShow(){\r\n\r\n\t}\r\n\t//鼠标事件\r\n\tonMouseDown(){\r\n\t\tif(this._isTouchLayer){\r\n\t\t\tthis._isMouseDown = true;\r\n\t\t\tthis._strut.onMouseDown(this._road.getFristPier(),this._road.getDistance(),this.goCallBcak.bind(this));\r\n\t\t}\r\n\t}\r\n\tonMouseUp(){\r\n\t\tif(this._isTouchLayer && this._isMouseDown){\r\n\t\t\tthis._strut.onMouseUp();\r\n\t\t\tthis._isMouseDown = false;\r\n\t\t\tthis._isTouchLayer = false;\r\n\t\t}\r\n\t}\r\n\t//撑杆回调\r\n\tgoCallBcak(isSuccess){\r\n\t\tif(isSuccess){\r\n\t\t\tconsole.log('成功了');\r\n\t\t\tlet movePos = this._road.getMovePos();\r\n\t\t\tif(this._road.getStartGold(1,false)){\r\n\t\t\t\tthis.updateScore(props.singleScore + props.goldScore);\r\n\t\t\t}else{\r\n\t\t\t\tthis.updateScore(props.singleScore);\r\n\t\t\t}\r\n\t\t\t//人物前行\r\n\t\t\tthis._player.setViewport(movePos,this.complete.bind(this));\r\n\t\t\t\r\n\t\t}else{\r\n\t\t\tconsole.log('失败了');\r\n\t\t\tthis._player.setViewport(this._strut.getStrutHeight(),()=>{\r\n\t\t\t\tconsole.log('掉下去了');\r\n\t\t\t\tengine.globalEvent.dispatchEvent('dxbcyj-game-result',{score:this._sumScore});\r\n\t\t\t},this._road.getFristPier())\r\n\t\t}\r\n\t}\r\n\t//人物前行结束回调\r\n\tcomplete(){\r\n\t\t//关闭金币\r\n\t\tthis._road.getStartGold(1);\r\n\t\t//获得位移距离\r\n\t\tlet movePos = this._road.getMovePos();\r\n\t\tthis._road.setViewport();\r\n\t\tthis._backgroud.setViewport(movePos);\r\n\t\t//移动完成 可以再次操作\r\n\t\tthis._player.setBackViewport(()=>{\r\n\t\t\tthis._isTouchLayer = true;\r\n\t\t});\r\n\t\tthis.closeStrut();\r\n\t}\r\n\t//重置撑杆\r\n\tcloseStrut(){\r\n\t\tthis._strut.rest();\r\n\t}\r\n\t//分数更新\r\n\tupdateScore(score){\r\n\t\tthis._sumScore += score;\r\n\t\tif(0 <= this._sumScore && this._sumScore <= props.bgFristScore){\r\n\t\t\tthis.changeBg(0);\r\n\t\t}else if(props.bgFristScore < this._sumScore && this._sumScore <= props.bgSecondScore){\r\n\t\t\tthis.changeBg(1);\r\n\t\t}else{\r\n\t\t\tthis.changeBg(2);\r\n\t\t}\r\n\t\tthis.labScore.updateScore(this._sumScore);\r\n\t}\r\n\tgetScore(){\r\n\t\treturn this._sumScore;\r\n\t}\r\n\r\n\tchangeBg(index){\r\n\t\tif(this._backgroud.getBgIndex() != index){\r\n\t\t\tthis._backgroud.changeBg(index);\r\n\t\t}\r\n\t}\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\n\r\nexport class GameWrapper extends engine.Container {\r\n\tprivate _gameView: GameView;\r\n\r\n\tconstructor() {\r\n\t\tsuper();\r\n\r\n\t\tengine.globalEvent.addEventListener('dxbcyj-game-start', this.start, this);\r\n\r\n\t\tlet gameView = this._gameView = new GameView();\r\n\t\tthis.addChild(gameView);\r\n\r\n\t\t//this.once(engine.Event.ENTER_FRAME, this.onAddedToStage, this);\r\n\t}\r\n\r\n\tstart(event: engine.Event) {\r\n\t\tthis._gameView.start(event.data.guide);\r\n\t}\r\n\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\treturn instance;\r\n}\r\n"],"names":["__extends","ObjectPool"],"mappings":";;;;;;CAIO,IAAI,KAAK,GAAQ,EAAE,CAAC;AAE3B,UAAgB,YAAY;KAC3B,IAAI,SAAS,GAAG,QAAQ,EAAE,CAAC;KAE3B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;CACrC,CAAC;AAED,UAAgB,WAAW,CAAC,CAAC;KAC5B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;CAC7B,CAAC;;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AC,CAAC;MAC1C;KACD,2BAAQ,GAAR;SACC,OAAO,IAAI,CAAC,SAAS,CAAC;MACtB;KAED,2BAAQ,GAAR,UAAS,KAAK;SACb,IAAG,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,IAAI,KAAK,EAAC;aACxC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;UAChC;MACD;KACF,eAAC;CAAD,CAAC,CApMqC,MAAM,CAAC,SAAS,GAoMrD;;CCpND;KAAiCA,qCAAgB;KAGhD;SAAA,YACC,iBAAO,SAQP;SANA,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,mBAAmB,EAAE,KAAI,CAAC,KAAK,EAAE,KAAI,CAAC,CAAC;SAE3E,IAAI,QAAQ,GAAG,KAAI,CAAC,SAAS,GAAG,IAAI,QAAQ,EAAE,CAAC;SAC/C,KAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;;MAGxB;KAED,2BAAK,GAAL,UAAM,KAAmB;SACxB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;MACvC;KAEF,kBAAC;CAAD,CAAC,CAlBgC,MAAM,CAAC,SAAS,GAkBhD;;iBCnBwB,KAAK;KAC7B,YAAY,EAAE,CAAC;KACf,WAAW,CAAC,KAAK,CAAC,CAAC;KAEnB,IAAI,QAAQ,GAAG,IAAI,WAAW,EAAE,CAAC;KACjC,OAAO,QAAQ,CAAC;CACjB,CAAC;;;;;;;;"}
\ No newline at end of file
/**
* Created by rockyl on 2020-01-21.
*/
let customModuleProps = {
};
{
"name": "度小宝出游记",
"desc": "度小宝出游记模块",
"props": {
"guideText1": {
"alias": "引导1的文本",
"type": "string",
"default": "长按屏幕\n杆子变长即可通过"
},
"guideText2": {
"alias": "引导2的文本",
"type": "string",
"default": "当度小宝获得金币时积分+5"
},
"pierMinDistance": {
"alias": "障碍物最小间距",
"type": "number",
"default": 350
},
"pierMaxDistance": {
"alias": "障碍物最大间距",
"type": "number",
"default": 500
},
"frontBGMoveSpeed": {
"alias": "前背影移动速度",
"type": "number",
"default": 0.5
},
"afterBGMoveSpeed": {
"alias": "后背影移动速度",
"type": "number",
"default": 0.2
},
"reward": {
"alias": "出现金币的概率(0-1区间 1为必出现 0为必不出现)",
"type": "number",
"default": 0
},
"pierCount": {
"alias": "一屏中最多出现的桥墩数量(最好默认为2)",
"type": "number",
"default": 2
},
"pierMoveTime": {
"alias": "一个周期内桥墩移动的总时长(毫秒)",
"type": "number",
"default": 1000
},
"strutUpSpeed": {
"alias": "撑杆上升速度(每帧上升增量,一秒60帧)",
"type": "number",
"default": 10
},
"strutWidth": {
"alias": "撑杆宽度",
"type": "number",
"default": 5
},
"strutColor": {
"alias": "撑杆颜色",
"type": "string",
"default": "#000000"
},
"strutRotationSpeed": {
"alias": "撑杆旋转总时长(毫秒)",
"type": "number",
"default": 300
},
"playerMoveSpeed": {
"alias": "人物移动总时长(毫秒)",
"type": "number",
"default": 1200
},
"singleScore": {
"alias": "每个桥墩分数",
"type": "number",
"default": 5
},
"goldScore": {
"alias": "每个金币分数",
"type": "number",
"default": 5
},
"bgFristScore": {
"alias": "第一张图的分数区间最大值(超过此值就更换第二张背景图)",
"type": "number",
"default": 30
},
"bgSecondScore": {
"alias": "第二张图的分数区间最大值(超过此值就更换第三张背景图)",
"type": "number",
"default": 80
}
},
"assets": [
{
"name": "hhl_after",
"url": "//yun.duiba.com.cn/aurora/assets/88252cca633a2f6d5c863d1678cb3d92c4e0e2a2.png",
"uuid": "76e73c53-d727-4746-b86e-92997af58c7f",
"ext": ".png"
},
{
"name": "hhl_front",
"url": "//yun.duiba.com.cn/aurora/assets/5c5a2581c91346de4d9fe66782aa8687cc9135e5.png",
"uuid": "848e2fdf-dcf0-44e2-b269-fdf0e2f84710",
"ext": ".png"
},
{
"name": "pier",
"url": "//yun.duiba.com.cn/aurora/assets/faf5cf941f1c3118bcf087352b812c2fb65ae992.png",
"uuid": "d784fe9f-5d1d-4522-ab4b-d6875a3da33f",
"ext": ".png"
},
{
"name": "gold",
"url": "//yun.duiba.com.cn/aurora/assets/ae210ad26cee13f8fb6e69be62f7f5498be50a5b.png",
"uuid": "7f4e19f2-c80f-4a65-bec2-1f3c3dc6d210",
"ext": ".png"
},
{
"name": "hb_after",
"url": "//yun.duiba.com.cn/aurora/assets/aaa76c50cfb00c602cc393df658670e1465a9b4e.png",
"uuid": "48a6636c-e04a-4836-8ae1-ed84db74c4f6",
"ext": ".png"
},
{
"name": "hb_front",
"url": "//yun.duiba.com.cn/aurora/assets/40d1dccd9d0c1dc1f4354d62e7c0b2eaab88457f.png",
"uuid": "b77802ea-7ee7-444e-aa11-72f85990f0c7",
"ext": ".png"
},
{
"name": "wh_after",
"url": "//yun.duiba.com.cn/aurora/assets/4e4f0adbca2b1d1e131271cc1ceddd97c3529f8b.png",
"uuid": "5efd9347-5e0d-4876-a483-7c22f3fdc3fb",
"ext": ".png"
},
{
"name": "wh_front",
"url": "//yun.duiba.com.cn/aurora/assets/b68ed0e4f49ac03736d80365e2ab66614ae97894.png",
"uuid": "8683ad45-3e7e-4944-ade0-eb4d5e48839f",
"ext": ".png"
},
{
"name": "walk",
"url": "//yun.duiba.com.cn/aurora/assets/a4ab1e1a2b49d140db4a0806562098a8b1619b06.svga",
"uuid": "10cd1fdd-4fd8-43cf-a1c7-6ff5846d8a91",
"ext": ".svga"
},
{
"name": "scoreBg",
"url": "//yun.duiba.com.cn/aurora/assets/1a61bd62c82c2ba872443fb14e0f5304d7aee224.png",
"uuid": "fb7f0d1a-c548-43ae-a86e-46ba98155813",
"ext": ".png"
},
{
"name": "scoreHint",
"url": "//yun.duiba.com.cn/aurora/assets/6bb8c64878288b074f840ea74f2956d0d0c65125.png",
"uuid": "0ab7dc8d-1388-4679-8637-54d6f3cd3a28",
"ext": ".png"
},
{
"name": "guide",
"url": "//yun.duiba.com.cn/aurora/assets/75cc4ea91654fd1e9900d071cac5ca5296b1bd19.png",
"uuid": "e904cd4e-cd87-421e-8292-25137299236e",
"ext": ".png"
},
{
"name": "guideHand",
"url": "//yun.duiba.com.cn/aurora/assets/4f014befa3c812e6882d578a6867afd3d05d7fe3.png",
"uuid": "fb1c2ead-dda8-495d-a846-7e4a26289d01",
"ext": ".png"
},
{
"name": "know",
"url": "//yun.duiba.com.cn/aurora/assets/3e695571aebebba6add5aae3d743fbd16b8ee915.png",
"uuid": "4999d4c5-507e-4ae9-8310-b90bf017a74f",
"ext": ".png"
}
],
"events": {
"in": {
"dxbcyj-game-start": {
"alias": "开始",
"data": {
}
}
},
"out": {
"dxbcyj-game-result": {
"alias": "游戏结束",
"data": {
}
}
}
}
}
\ No newline at end of file
import {getTextureByName} from "./utils";
import {getStage} from "./utils";
import {LoopComponent} from "./LoopComponent";
import { props } from './../props';
export class Background extends engine.Container{
partResHHL = ['hhl_after', 'hhl_front'];
partResHB = ['hb_after','hb_front'];
partResWH = ['wh_after','wh_front'];
speeds = [];
resArray=[];
frameMovePos = 0;
frameIndex;
sumMovePos;
_bgIndex;
//需要的总帧数
needFrameSum;
initBg(){
this.sumMovePos = 0;
this.speeds.push(props.afterBGMoveSpeed);
this.speeds.push(props.frontBGMoveSpeed);
let bottomBg = new engine.Rect();
bottomBg.x = 0;
bottomBg.y = 0;
bottomBg.width = getStage().width;
bottomBg.height = 0;
bottomBg.fillColor = 0x75c9f5;
this.addChild(bottomBg);
this.resArray.push(this.partResHHL)
this.resArray.push(this.partResHB)
this.resArray.push(this.partResWH)
this._bgIndex = 0;
const parts = [];
for(let i = 0; i < 2; i++){
let part = new LoopComponent();
part.setupLoop([
this.resArray[0][i],
this.resArray[0][i],
]);
parts.push(part);
this.addChild(part);
}
//(height - parts[1].height) / 2 - 200
parts[1].y = 200;
}
setViewport(pos) {
this.needFrameSum = (props.pierMoveTime/1000)*60;
this.frameMovePos = pos/this.needFrameSum;
this.frameIndex = 0;
this.addEventListener(engine.Event.ENTER_FRAME,this.frameBack,this);
}
frameBack(){
if( this.frameIndex < this.needFrameSum){
for (let i = 0; i < 2; i++) {
const part = <LoopComponent>this.getChildAt(i + 1);
const speed = this.speeds[i];
let tmpPos = ((this.frameMovePos * this.frameIndex) + this.sumMovePos ) * speed;
part.setViewport(tmpPos)
}
this.frameIndex++
}else{
this.sumMovePos += this.frameMovePos * this.needFrameSum;
this.frameIndex = 0
this.removeEventListener(engine.Event.ENTER_FRAME,this.frameBack,this);
}
}
changeBg(index){
for (let i = 0; i < 2; i++) {
const part = <LoopComponent>this.getChildAt(i + 1);
part.changeBg(this.resArray[index][i]);
if(i == 1 && index ==1){
part.y = 400;
}
if(i == 1 && index ==2){
part.y = 250;
}
}
this._bgIndex = index;
}
getBgIndex(){
return this._bgIndex;
}
}
\ No newline at end of file
import { Road } from './Road';
/**
* Created by rockyl on 2018/8/16.
*/
import {props} from "../props";
import {getStage,getTextureByName} from "./utils";
import {GuideLayer} from "./GuideLayer";
import { Background } from "./Background";
import ObjectPool = engine.ObjectPool;
import { Pier } from './Pier';
import { Player } from './Player';
import { Strut } from './Strut';
import { ScoreLabel } from './ScoreLabel';
export const PoolName: string = 'pier';
ObjectPool.registerPool(PoolName, function () {
return new Pier();
}, function (item: Pier, data) {
item.init();
});
export default class GameView extends engine.Container {
guideLayer: GuideLayer;
private _hasSetup;
_backgroud:Background;
_road:Road;
_player:Player;
_strut:Strut;
_touchLayer: engine.Rect;
_isTouchLayer;
_scoreContainer;
moveX = 0;
labScore:ScoreLabel;
_sumScore;
_isMouseDown;
_guide;
constructor() {
super();
this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);
}
setup(){
if (this._hasSetup) {
return;
}
this._hasSetup = true;
this._backgroud = new Background();
this.addChild(this._backgroud);
this._backgroud.initBg();
const road = this._road = new Road();
this.addChild(road);
road.setup();
let pierWidth = this._road.getFristPier();
const player = this._player = new Player();
this.addChild(player);
player.initPlayer(pierWidth);
const strut = this._strut = new Strut();
this.addChild(strut);
strut.init();
this._scoreContainer = new engine.Container();
this.addChild(this._scoreContainer);
this.initLabScore();
}
async start(guide) {
this._isTouchLayer = true;
this._sumScore = 0;
this._isMouseDown = false;
this._guide = guide;
let initScore = this._road.getStartGold(0) ? props.goldScore : 0;
this.updateScore(initScore);
//是否是新手
if(this._guide == '1'){
this.setGuide();
}else{
this.initTouch();
this.registerEvent();
}
}
//新手引导
setGuide(){
this._road.setGuide();
const guideLayer = this.guideLayer = new GuideLayer();
this.addChild(guideLayer);
this.guideLayer.show(1, {x:20,y: 650,guideText:props.guideText1},()=>{
let posX = this._road.getMovePos();
this.guideLayer.show(2, {x:posX + 20,y: 620,guideText:props.guideText2},()=>{
this.initTouch();
this.registerEvent();
})
});
}
//分数显示
initLabScore(){
const scoreBg = new engine.Sprite(getTextureByName('scoreBg'));
scoreBg.x = getStage().width/2 - scoreBg.width/2;
scoreBg.y = 80;
//this._scoreContainer.addChild(scoreBg);
const scoreHint = new engine.Sprite(getTextureByName('scoreHint'));
scoreHint.x = getStage().width/2 - scoreHint.width/2;
scoreHint.y = 40;
this._scoreContainer.addChild(scoreHint);
this.labScore = new ScoreLabel();
this.labScore.fillColor = 0xff7646;
this.labScore.size = 70;
this.labScore.width = getStage().width;
this.labScore.height = scoreBg.height;
this.labScore.textAlign = engine.TEXT_ALIGN.CENTER;
this.labScore.x = 0;
this.labScore.y = scoreBg.y+10;
this._scoreContainer.addChild(this.labScore);
}
registerEvent(){
this._touchLayer.addEventListener(engine.MouseEvent.MOUSE_DOWN,this.onMouseDown,this);
this._touchLayer.addEventListener(engine.MouseEvent.MOUSE_UP,this.onMouseUp,this);
}
removeListener(){
this._touchLayer.removeEventListener(engine.MouseEvent.MOUSE_DOWN,this.onMouseDown,this);
this._touchLayer.removeEventListener(engine.MouseEvent.MOUSE_UP,this.onMouseUp,this);
}
//触碰层
initTouch(){
this._touchLayer = new engine.Rect();
this.addChild(this._touchLayer);
this._touchLayer.width = getStage().width;
this._touchLayer.height = getStage().height;
this._touchLayer.x = 0;
this._touchLayer.y = 0;
this._touchLayer.alpha = 0;
}
setScoreShow(){
}
//鼠标事件
onMouseDown(){
if(this._isTouchLayer){
this._isMouseDown = true;
this._strut.onMouseDown(this._road.getFristPier(),this._road.getDistance(),this.goCallBcak.bind(this));
}
}
onMouseUp(){
if(this._isTouchLayer && this._isMouseDown){
this._strut.onMouseUp();
this._isMouseDown = false;
this._isTouchLayer = false;
}
}
//撑杆回调
goCallBcak(isSuccess){
if(isSuccess){
console.log('成功了');
let movePos = this._road.getMovePos();
if(this._road.getStartGold(1,false)){
this.updateScore(props.singleScore + props.goldScore);
}else{
this.updateScore(props.singleScore);
}
//人物前行
this._player.setViewport(movePos,this.complete.bind(this));
}else{
console.log('失败了');
this._player.setViewport(this._strut.getStrutHeight(),()=>{
console.log('掉下去了');
engine.globalEvent.dispatchEvent('dxbcyj-game-result',{score:this._sumScore});
},this._road.getFristPier())
}
}
//人物前行结束回调
complete(){
//关闭金币
this._road.getStartGold(1);
//获得位移距离
let movePos = this._road.getMovePos();
this._road.setViewport();
this._backgroud.setViewport(movePos);
//移动完成 可以再次操作
this._player.setBackViewport(()=>{
this._isTouchLayer = true;
});
this.closeStrut();
}
//重置撑杆
closeStrut(){
this._strut.rest();
}
//分数更新
updateScore(score){
this._sumScore += score;
if(0 <= this._sumScore && this._sumScore <= props.bgFristScore){
this.changeBg(0);
}else if(props.bgFristScore < this._sumScore && this._sumScore <= props.bgSecondScore){
this.changeBg(1);
}else{
this.changeBg(2);
}
this.labScore.updateScore(this._sumScore);
}
getScore(){
return this._sumScore;
}
changeBg(index){
if(this._backgroud.getBgIndex() != index){
this._backgroud.changeBg(index);
}
}
}
/**
* Created by rockyl on 2020-01-09.
*/
import GameView from "./GameView";
export class GameWrapper extends engine.Container {
private _gameView: GameView;
constructor() {
super();
engine.globalEvent.addEventListener('dxbcyj-game-start', this.start, this);
let gameView = this._gameView = new GameView();
this.addChild(gameView);
//this.once(engine.Event.ENTER_FRAME, this.onAddedToStage, this);
}
start(event: engine.Event) {
this._gameView.start(event.data.guide);
}
}
/**
* Created by rockyl on 2020-01-30.
*/
import {props} from "../props";
import {getTextureByName} from "./utils";
export class GuideLayer extends engine.Container {
private guideMask: engine.Container;
private _options;
_guideHole;
_canClear:any = [];
_callBack;
private label: engine.Label;
constructor() {
super();
this.setup();
}
private setup() {
}
show(id, options,callback?) {
this.visible = true;
this._callBack = callback?callback:null;
if (!this.guideMask) {
this._options = options;
const {width, height} = this.stage;
let guideMask = this.guideMask = new engine.Container();
let guideHole = this._guideHole= new engine.Image(getTextureByName('guide'));
guideHole.x = options.x;
guideHole.y = options.y;
guideHole.width = 250;
guideHole.height = 250;
guideHole.name = 'guideHole';
guideMask.addChild(guideHole);
this.createRect(guideMask, 0, 0, width, guideHole.y);
this.createRect(guideMask, 0, guideHole.y, guideHole.x, guideHole.height);
this.createRect(guideMask, guideHole.x + guideHole.width, guideHole.y, width - guideHole.x - guideHole.width, guideHole.height);
this.createRect(guideMask, 0, guideHole.y + guideHole.height, width, height - guideHole.y - guideHole.height);
this.guideStep(id);
let label = this.label = new engine.Label();
label.fillColor = 'white';
label.size = 30;
label.text = options.guideText;
label.x = (width - label.width) / 2;
label.y = guideHole.y + guideHole.height + 50;
label.textAlign = engine.TEXT_ALIGN.CENTER;
label.name = 'labHint';
guideMask.addChild(label);
this.addChild(guideMask);
}
this.once(engine.MouseEvent.CLICK, function(){
this.removeChild(this.guideMask);
this.guideMask = null;
if(this._callBack){
this._callBack();
}
}, this);
}
createRect(container, x, y, width, height) {
let rect = new engine.Rect();
rect.x = x;
rect.y = y;
rect.width = width;
rect.height = height;
rect.fillColor = 'black';
rect.alpha = 0.7;
container.addChild(rect);
}
guideStep(id){
if(id == 1){
let guideHand = new engine.Image(getTextureByName('guideHand'));
guideHand.x = this._options.x + 300;
guideHand.y = this._options.y + 100;
this.guideMask.addChild(guideHand);
let rect = new engine.Rect();
rect.x = this._options.x + 200;
rect.y = this._options.y - 15;
rect.width = props.strutWidth;
rect.height = 200;
rect.fillColor = props.strutColor;
this.guideMask.addChild(rect);
this._canClear.push(guideHand);
this._canClear.push(rect);
}
if(id == 2){
let know = new engine.Image(getTextureByName('know'));
know.x = (this.stage.width - know.width) / 2;
know.y = this._options.y + 400;
this.guideMask.addChild(know);
this._canClear.push(know);
}
}
}
import {getTextureByName} from "./utils";
export class LoopComponent extends engine.Container{
parts: any[];
onceInfo: any = {width: 0, height: 0, count: 0};
loopInfo: any = {width: 0, height: 0, count: 0};
constructor() {
super();
this.parts = [];
}
private setup(parts, info) {
parts.forEach((item, index) => {
let part;
if(typeof item == 'string'){
part = new engine.Sprite(getTextureByName(item));
}else if(item instanceof engine.Texture){
part = new engine.Sprite(item);
}else {
part = item;
}
this.addChild(part);
this.parts.push(part);
if (index == 0) {
info.width = part.width;
info.height = part.height;
}
});
info.count = parts.length;
this.setViewport(0, 0)
}
changeBg(changName){
this.parts.forEach((item, index) => {
item.texture = getTextureByName(changName)
});
}
setupLoop(resArr) {
this.setup(resArr, this.loopInfo);
}
setViewport(x, y = 0) {
const sizeField = y == 0 ? 'width' : 'height';
const posField = y == 0 ? 'x' : 'y';
const pos = y == 0 ? x : y;
let index;
const onceSize = this.onceInfo[sizeField];
const onceCount = this.onceInfo.count;
const loopCount = this.loopInfo.count;
const loopSize = this.loopInfo[sizeField];
index = onceSize == 0 ? -1 : Math.floor(pos / onceSize);
if (index < 0 || index >= onceCount) {
const loopIndex = Math.floor((pos - onceCount * onceSize) / this.loopInfo[sizeField]);
index = onceCount + loopIndex;
}
let formerIndex = index < onceCount ? index : (index) % loopCount + onceCount;
let latterIndex = index < onceCount ? index + 1 : (index - onceCount + 1) % loopCount + onceCount;
let former = this.parts[formerIndex];
let latter = this.parts[latterIndex];
if(!former || !latter){
console.log(formerIndex, latterIndex);
}
former[posField] = -(pos - loopSize * (index < onceCount ? index : index - onceCount) - (index < onceCount ? 0 : onceCount * onceSize));
latter[posField] = former.x + (index < onceCount ? onceSize : loopSize);
}
}
\ No newline at end of file
import { props } from './../props';
import {getTextureByName,getStage} from "./utils";
export class Pier extends engine.Container {
bmp;
public haveGold;
constructor() {
super();
this.bmp = new engine.Sprite();
this.addChild(this.bmp);
}
init(){
const bmp = this.bmp;
bmp.alpha = 1;
bmp.texture = getTextureByName('pier');
bmp.x = 0;
bmp.y = bmp.height ;
if(this.children.length < 2){
const gold = new engine.Sprite();
gold.texture = getTextureByName('gold');
gold.name = 'gold';
this.addChild(gold);
}
this.setGoldPosX(bmp);
this.setShowGold();
}
setShowGold(){
let nodeGold = this.getChildByName('gold');
let randomWard = Math.random();
nodeGold.alpha = 1;
let isShow = randomWard < props.reward ? true : false ;
nodeGold.visible = isShow;
this.haveGold = isShow;
}
setGoldPosX(bmp){
let nodeGold = this.getChildByName('gold');
let pos = bmp.width / 2 - nodeGold.width/2;
nodeGold.x = pos
nodeGold.y = bmp.height - nodeGold.height - 50;
nodeGold.visible = false;
}
closeGold(){
this.children.forEach((item) => {
if(item.name == 'gold')
{
item.anchorX = item.width/2;
item.anchorY = item.height/2;
engine.Tween.get(item,{loop:false})
.to({scaleX:2.5,scaleY:2.5},200,engine.Ease.cubicOut)
.to({scaleX:1,scaleY:1,alpha:0},200,engine.Ease.cubicIn)
.call(()=>{
item.visible = false;
this.haveGold = false;
})
}
})
}
}
\ No newline at end of file
import {props} from "../props";
import {createSvga, playSound} from "./utils";
export class Player extends engine.Container{
_container;
private playerNode: svga.Svga;
initPlayer(pierWidth){
this._container = new engine.Container();
this.addChild(this._container);
this.playerNode = createSvga('walk');
this._container.addChild(this.playerNode);
this.playerNode.y = 675;
this.playerNode.x = pierWidth/2 - 80;
this.playerNode.play();
}
setViewport(pos,callBack,pierWidth?){
let tmpPos = 0;
let isSuccess = false;
if(!pierWidth){
tmpPos = pos;
isSuccess = true;
}else{
tmpPos = pierWidth - this.playerNode.x + pos - 60;
}
this.playGoTween(tmpPos,callBack,isSuccess)
}
playGoTween(pos,callBack,isSuccess){
engine.Tween.get(this._container,{loop:false})
.to({x : pos},props.playerMoveSpeed)
.call(()=>{
engine.Tween.removeTweens(this._container);
if(isSuccess){
if(callBack){
callBack();
}
}else{
this.playDropTween(callBack);
}
})
}
playDropTween(callBack){
engine.Tween.get(this._container,{loop:false})
.to({y : 2000},1000)
.call(()=>{
engine.Tween.removeTweens(this._container);
if(callBack){
callBack();
}
})
}
setBackViewport(callBack){
engine.Tween.get(this._container,{loop:false})
.to({x : 0},props.pierMoveTime)
.call(()=>{
engine.Tween.removeTweens(this._container);
if(callBack){
callBack();
}
})
}
}
\ No newline at end of file
import { props } from './../props';
import ObjectPool = engine.ObjectPool;
import {getStage} from "./utils";
import { Pier } from './Pier';
import GameView from './GameView';
export class Road extends engine.Container{
//container: engine.Container;
lastPos;
setup(){
// this.container = new engine.Container();
// this.addChild(this.container);
this.lastPos = 0;
this.addPier();
}
getFristPier(){
return this.getChildAt(0).width;
}
getDistance(){
let distance = [];
let pier1 = this.getChildAt(0);
let pier2 = this.getChildAt(1);
distance.push(pier2.x - pier1.x);
distance.push(pier2.width);
return distance;
}
addPier(){
while(this.children.length < props.pierCount + 1){
let childrenNum = this.children.length;
let randomPos = this.makeRandomFloat(props.pierMaxDistance,props.pierMinDistance);
const pier: Pier = ObjectPool.getObject('pier');
this.addChild(pier);
if(childrenNum == 0){
pier.x = 0;
}else{
pier.x = this.lastPos + randomPos;
}
this.lastPos = pier.x;
}
}
moveAddPier(){
let randomPos = this.makeRandomFloat(props.pierMaxDistance,props.pierMinDistance);
const pier: Pier = ObjectPool.getObject('pier');
let lastChild = this.getChildAt(this.children.length -1);
pier.x = lastChild.x + randomPos;
this.addChild(pier);
}
makeRandomFloat(max: number, min: number = 0): number {
return Math.random() * (max - min) + min;
}
setViewport(){
let tmpMovepos = this.getMovePos();
this.children.forEach((item,index) => {
this.playTween(item,index,tmpMovepos);
})
}
//获得移动位移
getMovePos(){
let movePos:any = this.getChildAt(1);
return movePos.x;
}
playTween(item,index,tmpMovepos){
engine.Tween.get(item,{loop:false})
.to({x : item.x - tmpMovepos},props.pierMoveTime)
.call(()=>{
if(this.getChildIndex(item) == 0){
engine.Tween.removeTweens(item);
this.removeChild(item);
ObjectPool.recycleObject('pier',item);
}
if(index == 0){
this.moveAddPier();
}
})
}
//桥墩是否有金币
getStartGold(index,isClose = true){
let tmpNode:any = this.getChildAt(index);
let haveGold = tmpNode.haveGold;
if(haveGold && isClose){
tmpNode.closeGold();
}
return haveGold;
}
//设置新手引导 第二个桥墩要有金币
setGuide(){
let tmpNode:any = this.getChildAt(1);
if(!tmpNode.haveGold){
tmpNode.children.forEach((item) => {
if(item.name == 'gold'){
item.visible = true;
}
})
tmpNode.haveGold = true;
}
}
}
\ No newline at end of file
/**
* Created by rockyl on 2018/9/10.
*
* 分数标签
*/
export class ScoreLabel extends engine.Label {
_value;
_tmp;
updateScore(score,animation = true) {
this._value = score;
if (animation && this._tmp) {
this.animationUpdate();
} else {
this.updateLocal(score);
}
}
animationUpdate(){
let tmpInterval = setInterval(()=>{
this._tmp += 1;
if(this._tmp <= this._value){
this.text = this._tmp
}else{
this._tmp = this._value;
clearInterval(tmpInterval);
}
},50)
}
updateLocal(v){
this._tmp = v;
this.text = v;
}
}
import { props } from "../props";
export class Strut extends engine.Container{
_strut: engine.Rect;
_distance;
_callBack;
init(){
this._strut = new engine.Rect();
this.addChild(this._strut);
this._strut.width = props.strutWidth;
this._strut.y = 833;
this._strut.fillColor = props.strutColor;
this._strut.rotation = 180;
}
onMouseDown(pierWidth,distance,callBack){
this._strut.x = pierWidth - 60;
this._distance = distance;
this._callBack = callBack;
this._strut.visible = true;
this.addEventListener(engine.Event.ENTER_FRAME,this.frameStrut,this);
}
onMouseUp(){
this.removeEventListener(engine.Event.ENTER_FRAME,this.frameStrut,this);
setTimeout(() => {
this.strutRotation();
}, 200);
}
strutRotation(){
engine.Tween.get(this._strut,{loop:false})
.to({rotation:270},props.strutRotationSpeed)
.call(()=>{
this.judgeResult();
engine.Tween.removeTweens(this._strut);
})
}
judgeResult(){
let isSuccess = false;
if(this._distance[0] - this._distance[1] + 100 <= this._strut.height && this._strut.height <= this._distance[0] + 20){
isSuccess = true;
}
if(this._callBack){
this._callBack(isSuccess);
}
}
frameStrut(){
if(this._strut.height < 1000){
this._strut.height += props.strutUpSpeed;
}
}
rest(){
this._strut.width = props.strutWidth;
this._strut.y = 833;
this._strut.fillColor = props.strutColor;
this._strut.rotation = 180;
this._strut.height = 0;
this._strut.visible = false;
}
getStrutHeight(){
let distance = this._strut.height > 1000 ? 1000 :this._strut.height;
return distance;
}
}
\ No newline at end of file
import { Pier } from './Pier';
/**
* Created by rockyl on 2020-02-03.
*/
import ObjectPool = engine.ObjectPool;
export const PoolName: string = 'pier';
ObjectPool.registerPool(PoolName, function () {
return new Pier();
}, function (item: Pier, data) {
item.init();
});
/**
* 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 getStage(){
return engine.gameStage.stage;
}
export function createSvga(name) {
let inst = new svga.Svga();
inst.source = engine.getAssetByName(name).uuid;
// let anchor = props[(anchorName)];
// if (anchor) {
// inst.x = -anchor.x;
// inst.y = -anchor.y;
// inst.anchorX = anchor.x;
// inst.anchorY = anchor.y;
// }
return inst;
}
/**
* 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);
}
{"version":3,"file":"index.js","sources":["src/custom/food-fell/src/props.ts","src/custom/food-fell/src/game/utils.ts","src/custom/food-fell/src/game/Goods.ts","src/custom/food-fell/src/game/object-pool-init.ts","src/custom/food-fell/src/game/GameView.ts","src/custom/food-fell/src/game/GameWrapper.ts","src/custom/food-fell/src/index.ts"],"sourcesContent":["/**\n * Created by rockyl on 2020-01-21.\n */\n\nexport let props: any = {};\n\nexport function prepareProps() {\n\tlet metaProps = getProps();\n\n\tengine.injectProp(props, metaProps);\n}\n\nexport function injectProps(p) {\n\tengine.injectProp(props, p);\n}\n","/**\n * Created by rockyl on 2020-01-21.\n */\n\nexport function getTexture(uuid) {\n\treturn engine.Texture.from(getAssetByUUID(uuid).uuid);\n}\n\nexport function getTextureByName(name) {\n\treturn getTexture(engine.getAssetByName(name).uuid);\n}\n\nexport function playSound(name) {\n\tengine.playSound(engine.getAssetByName(name).uuid, {keep: true});\n}\nexport function createSvga(name, anchorName?) {\n\tlet inst = new svga.Svga();\n\tinst.source = 'asset://' + engine.getAssetByName(name).uuid;\n\treturn inst;\n}","/**\n * Created by rockyl on 2020-02-02.\n *\n * 掉落物品\n */\nimport {getTextureByName} from \"./utils\";\nimport {props} from \"../props\";\n\nexport class Goods extends engine.Container {\n\tprivate _body:engine.Rect\n\tprivate _toY;\n\n\tconstructor() {\n\t\tsuper();\n\n\t\tlet body\n\t\tbody = this._body =new engine.Rect()\n\t\t\n\t\t\n\t\tlet rain = new engine.Sprite(getTextureByName('雨滴'));\n\t\train[\"npcType\"]=\"rain\"\n\t\tlet stone = new engine.Sprite(getTextureByName('石块'));\n\t\tstone[\"npcType\"]=\"stone\"\n\t\tlet boom = new engine.Sprite(getTextureByName('炸弹'));\n\t\tboom[\"npcType\"]=\"boom\"\n\n\t\train.visible=false;\n\t\tstone.visible=false;\n\t\tboom.visible=false;\n\t\tbody.addChild(rain)\n\t\tbody.addChild(stone)\n\t\tbody.addChild(boom)\n\t\t\n\t\tthis.addChild(body);\n\t\tbody.width=.0001;\n\t\tbody.height=.0001;\n\t\tbody.mouseEnabled=false;\n\t}\n\n\n\tgetRandomNumberByRange(start, end) {\n\t\treturn Math.floor(Math.random() * (end - start) + start)\n\t}\n\n\treset() {\n\t\tthis.visible = true;\n\t\tthis.rotation = 0;\n\t\tthis.anchorOffsetY = 0;\n\t\tthis.y = 0;\n\t\tthis.x = (750-120)*Math.random()+30;\n\t\tthis.rotation = 0;\n\t\tlet random=Math.random()\n\n\t\tif(random<props.goodsProbability[0]){\n\t\t\tthis.showNpc(\"rain\")\n\t\t}else if(random>=props.goodsProbability[0]&&random<=(props.goodsProbability[0]+props.goodsProbability[1])){\n\t\t\tthis.showNpc(\"stone\")\n\t\t}else if(random>(props.goodsProbability[0]+props.goodsProbability[1])){\n\t\t\tthis.showNpc(\"boom\")\n\t\t}\n\t}\n\n\n\tshowNpc(type){\n\t\tfor(let i=0;i<this._body.children.length;i++){\n\t\t\tthis._body.children[i].visible=false;\n\t\t\tthis._body.children[i].mouseEnabled=false;\n\t\t}\n\n\t\tfor(let i=0;i<this._body.children.length;i++){\n\t\t\tif(this._body.children[i][\"npcType\"]==type){\n\t\t\t\tthis[\"npcType\"]=type\n\t\t\t\tthis._body.children[i].visible=true;\n\t\t\t\tthis._body.children[i].mouseEnabled=false;\n\t\t\t}\n\t\t}\n\t\t\n\t}\n\n\tset anchorOffsetY(v) {\n\t\tthis._body.y = v;\n\t}\n}\n","/**\n * Created by rockyl on 2020-02-03.\n */\n\nimport {Goods} from \"./Goods\";\nimport ObjectPool = engine.ObjectPool;\n\nexport const PoolName: string = 'goods';\n\nObjectPool.registerPool(PoolName, function () {\n\treturn new Goods();\n}, function (item: Goods, data) {\n\titem.reset();\n});\n","/**\n * Created by rockyl on 2018/8/16.\n */\n\nimport { props } from \"../props\";\nimport { playSound, createSvga } from \"./utils\";\nimport ObjectPool = engine.ObjectPool;\nimport { getTextureByName } from \"./utils\";\nimport { Goods } from \"./Goods\";\nimport { PoolName } from \"./object-pool-init\";\n\n\n\nexport default class GameView extends engine.Container {\n\n\tprivate _hasSetup;\n\n\t//玩家\n\tprivate player: engine.Container;\n\t//触摸层\n\tprivate rectBg: engine.Rect;\n\t//npc层\n\tprivate NpcBg: engine.Container;\n\n\t//当前分数\n\tprivate score\n\n\t//游戏状态\n\tprivate gameIng;\n\n\t//npc出身计时器\n\tprivate timer\n\t//倒计时计时器\n\tprivate countdownTimer: any\n\t//倒计时\n\tprivate countdown: number\n\n\t//当前速度\n\tprivate speed: number\n\n\t// 当前场景上面的物品\n\tprivate goodsItems = []\n\n\n\tprivate _goods: Goods;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.once(engine.Event.ADDED_TO_STAGE, this.setup, this);\n\t}\n\n\tprivate waterSvga\n\tprivate boomSvga\n\tprivate playerSvga\n\n\tsetup() {\n\t\tif (this._hasSetup) {\n\t\t\treturn;\n\t\t}\n\t\tthis._hasSetup = true;\n\t\tthis.NpcBg = new engine.Container();\n\t\tthis.NpcBg.alpha = 1;\n\t\tthis.NpcBg.width = 0;\n\t\tthis.NpcBg.height = 0;\n\t\tthis.addChild(this.NpcBg)\n\n\t\n\n\t\tthis.player = new engine.Container();\n\t\tthis.player.mouseEnabled = false;\n\t//\tthis.player.fillColor=\"rgba(0, 0, 0,1)\"\n\t\t//console.log(this.player.fillColor)\n\t\n\t\tthis.addChild(this.player);\n\n\t\tthis.waterSvga=createSvga(\"水花\")\n\t\tthis.playerSvga=createSvga(\"玩家\")\n\t\tthis.boomSvga=createSvga(\"炸弹svga\")\n\t\tthis.player.addChild(this.playerSvga);\n\t\tthis.player.addChild(this.waterSvga);\n\t\tthis.player.addChild(this.boomSvga);\n\t\tthis.playerSvga.gotoAndPlay(1);\n\n\t\tthis.visible=false;\n\t\tsetTimeout(()=>{\n\t\t\tthis.visible=true;\n\t\t\t// this.player.width=this.playerSvga.width;\n\t\t\t// this.player.height=this.playerSvga.height;\n\t\t\tthis.player.anchorY = this.player.height / 2;\n\t\t\tthis.player.anchorX = this.player.width / 2;\n\t\t\tconsole.log(this.player.width)\n\t\t\tconsole.log(this.playerSvga.width)\n\t\t\tthis.player.x = 375 - this.player.width / 2;\n\t\t\tthis.player.y = props.playerPositionY;\n\t\t},300)\n\n\t\t\n\t\tthis.rectBg = new engine.Rect();\n\t\tthis.rectBg.alpha = 0;\n\t\tthis.rectBg.width = 750;\n\t\tthis.rectBg.height = 1624;\n\t\tthis.addChild(this.rectBg)\n\n\t\tthis.rectBg.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDownStage, this);\n\t\tthis.rectBg.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMoveStage, this);\n\t\tthis.rectBg.addEventListener(engine.MouseEvent.MOUSE_OUT, this.onOutStage, this);\n\n\t\n\t}\n\n\n\t/**\n\t * 重置场景\n\t */\n\treset() {\n\t\tthis.recycleGoods()\n\t}\n\n\t/**\n\t * 开始\n\t */\n\tstart() {\n\t\tthis.score = 0;\n\t\tthis.speed = 1\n\t\tthis.gameIng = true;\n\t\tthis.creatNpc()\n\t\tthis.beginNpc()\n\t\tthis.countdown = props.countDown;\n\t\t\n\t\tthis.countdownTimer = setInterval(() => {\n\t\t\tif (this.gameIng) {\n\t\t\t\tif (this.countdown > 0) {\n\t\t\t\t\tengine.globalEvent.dispatchEvent('food-fell-time-update', {\n\t\t\t\t\t\ttime: this.countdown,\n\t\t\t\t\t});\n\t\t\t\t\tthis.countdown -= 1\n\t\t\t\t} else {\n\t\t\t\t\tengine.globalEvent.dispatchEvent('food-fell-game-over', {\n\t\t\t\t\t\tscore: this.score,\n\t\t\t\t\t\treason: 1\n\t\t\t\t\t});\n\t\t\t\t\tthis.died()\n\t\t\t\t}\n\t\t\t}\n\t\t}, 1000)\n\t}\n\n\t/**\n\t * npc开始掉落\n\t */\n\tbeginNpc() {\n\t\tthis.timer = setTimeout(() => {\n\t\t\tif (this.gameIng) {\n\t\t\t\tthis.speed += props.acceleratedSpeed;\n\t\t\t\tthis.creatNpc()\n\t\t\t}\n\t\t\t//递归执行\n\t\t\tthis.beginNpc()\n\t\t}, 2000 / this.speed)\n\t}\n\n\t/**\n\t * 暂停\n\t */\n\tpause() {\n\t\tthis.gameIng = false;\n\t}\n\n\t/**\n\t * 恢复\n\t */\n\trevive() {\n\t\tthis.gameIng = true;\n\t}\n\n\t/**\n\t * 重新开始\n\t */\n\tresume() {\n\t\tthis.reset()\n\t\tthis.start()\n\t}\n\n\t/**\n\t * 创建NPC\n\t */\n\tprivate creatNpc() {\n\t\tlet goods = this._goods = <Goods>ObjectPool.getObject(PoolName);\n\t\tthis.goodsItems.push(goods)\n\t\tthis.NpcBg.addChild(goods);\n\t\tgoods.addEventListener(engine.Event.ENTER_FRAME, goods[\"onGoodsEnter\"] = () => {\n\t\t\tif (goods.y > 1624) {\n\t\t\t\tthis.removeNpc(goods)\n\t\t\t} else {\n\t\t\t\tif (this.gameIng) {\n\t\t\t\t\t//速度叠加\n\t\t\t\t\tgoods.y += (4 * this.speed)\n\t\t\t\t\t//如果玩家和物品发生碰撞\n\t\t\t\t\tif (this.hasHit(this.player, goods)) {\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (goods[\"npcType\"] == \"rain\") {\n\t\t\t\t\t\t\tconsole.log(\"碰到雨滴\")\n\t\t\t\t\t\t\tthis.score += props.rainScore\n\t\t\t\t\t\t\tthis.waterSvga.visible=true;\n\t\t\t\t\t\t\tthis.waterSvga.play(false, false)\n\t\t\t\t\t\t\tthis.waterSvga.once(engine.Event.END_FRAME, ()=>{\n\t\t\t\t\t\t\t\tthis.waterSvga.visible=false;\n\t\t\t\t\t\t\t}, this);\n\t\t\t\t\t\t} else if (goods[\"npcType\"] == \"stone\") {\n\t\t\t\t\t\t\tconsole.log(\"碰到石头\")\n\t\t\t\t\t\t\tthis.score += props.stoneScore\n\t\t\t\t\t\t} else if (goods[\"npcType\"] == \"boom\") {\n\t\t\t\t\t\t\tconsole.log(\"碰到炸弹\")\n\t\t\t\t\t\t\tthis.boomSvga.visible=true;\n\t\t\t\t\t\t\tthis.boomSvga.play(false, false)\n\t\t\t\t\t\t\tthis.boomSvga.once(engine.Event.END_FRAME, ()=>{\n\t\t\t\t\t\t\t\tthis.boomSvga.visible=false;\n\t\t\t\t\t\t\t}, this);\n\t\t\t\t\t\t\tengine.globalEvent.dispatchEvent('food-fell-game-over', {\n\t\t\t\t\t\t\t\tscore: this.score,\n\t\t\t\t\t\t\t\treason: 2\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tthis.died()\n\t\t\t\t\t\t}\n\t\t\t\t\t\tengine.globalEvent.dispatchEvent('food-fell-score-update', {\n\t\t\t\t\t\t\tscore: this.score,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tthis.removeNpc(goods)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t}, this);\n\t}\n\n\t/**\n\t * 玩家死亡\n\t */\n\tprivate died() {\n\t\tthis.score = 0\n\t\tthis.pause()\n\t}\n\n\t/**\n\t * 回收指定物品\n\t * @param goods 物品\n\t */\n\tprivate removeNpc(goods) {\n\t\tthis.NpcBg.removeChild(goods);\n\t\tObjectPool.recycleObject(PoolName, goods);\n\t\tgoods.removeEventListener(engine.Event.ENTER_FRAME, goods[\"onGoodsEnter\"], this);\n\t\tlet index = this.goodsItems.indexOf(goods);\n\t\tif (index > -1) {\n\t\t\tthis.goodsItems.splice(index, 1);\n\t\t}\n\t}\n\n\t/**\n\t * 回收对象\n\t */\n\tprivate recycleGoods() {\n\t\tclearTimeout(this.timer)\n\t\tclearInterval(this.countdownTimer)\n\t\tfor (let goods of this.goodsItems) {\n\t\t\tif (goods) {\n\t\t\t\tthis.removeChild(goods);\n\t\t\t\tObjectPool.recycleObject(PoolName, goods);\n\t\t\t\tgoods.removeEventListener(engine.Event.ENTER_FRAME, goods[\"onGoodsEnter\"], this);\n\t\t\t}\n\t\t}\n\t\tthis.goodsItems = []\n\t}\n\n\tprivate moveCatchX = 0\n\tprivate playerCatchX = 0\n\n\t/**\n\t * 碰撞检测\n\t * @param a a盒子\n\t * @param b b盒子\n\t */\n\tprivate hasHit(a, b) {\n\t\tif (\n\t\t\tMath.abs((a.x + a.width / 2) - (b.x + b.width / 2)) < a.width / 2 + b.width / 2\n\t\t\t&&\n\t\t\tMath.abs((a.y + a.height / 2) - (b.y + b.height / 2)) < a.height / 2 + b.height / 2\n\t\t) {\n\t\t\treturn true;\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tprivate onDownStage = (e) => {\n\t\tthis.moveCatchX = e.localX;\n\t\tthis.playerCatchX = this.player.x\n\t}\n\n\tprivate onMoveStage = (e) => {\n\t\tif (this.gameIng) {\n\t\t\tthis.player.x = this.playerCatchX + (e.localX - this.moveCatchX)\n\t\t}\n\t}\n\n\tprivate onOutStage = (e) => {\n\t\tthis.moveCatchX = 0\n\t}\n}\n","/**\n * Created by rockyl on 2020-01-09.\n */\n\nimport GameView from \"./GameView\";\nimport {injectProps} from \"../props\";\n\n\nexport class GameWrapper extends engine.Container {\n\tprivate _status;\n\tprivate _gameView: GameView;\n\n\n\n\n\n\tconstructor() {\n\t\tsuper();\n\t\tengine.globalEvent.addEventListener('food-fell-reset', this.reset, this);\n\t\tengine.globalEvent.addEventListener('food-fell-start', this.start, this);\n\t\tengine.globalEvent.addEventListener('food-fell-pause', this.pause, this);\n\t\tengine.globalEvent.addEventListener('food-fell-resume', this.resume, this);\n\t\tengine.globalEvent.addEventListener('food-fell-revive', this.revive, this);\n\t\tengine.globalEvent.addEventListener('food-fell-clear', this.clear, this);\n\n\t\tthis.addEventListener(engine.MouseEvent.CLICK, this.onTap, this);\n\n\t\tlet gameView = this._gameView = new GameView();\n\t\tthis.addChild(gameView);\n\t\t// gameView.reset()\n\t\t// gameView.start()\n\t}\n\n\treset(event: engine.Event) {\t\t\n\t\tinjectProps(event.data);\n\t\tthis._gameView.visible = true;\n\t\tthis._gameView.reset();\n\t}\n\n\tstart(event: engine.Event) {\n\t\tinjectProps(event.data);\n\t\tthis._status = 1;\n\t\tthis._gameView.start();\n\t}\n\n\tpause() {\n\t\tthis._gameView.pause();\n\t}\n\n\tresume() {\n\t\tthis._gameView.resume();\n\t}\n\n\trevive() {\n\t\tthis._gameView.revive();\n\t}\n\n\tclear() {\n\t\tthis._gameView.visible = false;\n\t}\n\n\tprivate onTap(event) {\n\t//\tthis._gameView.tap(event);\n\t}\n}\n","/**\n * Created by rockyl on 2019-11-20.\n */\n\nimport {GameWrapper} from \"./game/GameWrapper\";\nimport {injectProps, prepareProps} from \"./props\";\n\nexport default function (props) {\n\tprepareProps();\n\tinjectProps(props);\n\n\tlet instance = new GameWrapper();\n\treturn instance;\n}\n"],"names":["__extends","ObjectPool"],"mappings":";;;;;;CAIO,IAAI,KAAK,GAAQ,EAAE,CAAC;AAE3B,UAAgB,YAAY;KAC3B,IAAI,SAAS,GAAG,QAAQ,EAAE,CAAC;KAE3B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;CACrC,CAAC;AAED,UAAgB,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,UAAgB,gBAAgB,CAAC,IAAI;KACpC,OAAO,UAAU,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;CACrD,CAAC;AAED,UAGgB,UAAU,CAAC,IAAI,EAAE,UAAW;KAC3C,IAAI,IAAI,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;KAC3B,IAAI,CAAC,MAAM,GAAG,UAAU,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC;KAC5D,OAAO,IAAI,CAAC;CACb,CAAC;;CCXD;KAA2BA,+BAAgB;KAI1C;SAAA,YACC,iBAAO,SAwBP;SAtBA,IAAI,IAAI,CAAA;SACR,IAAI,GAAG,KAAI,CAAC,KAAK,GAAE,IAAI,MAAM,CAAC,IAAI,EAAE,CAAA;SAGpC,IAAI,IAAI,GAAG,IAAI,MAAM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,EAAE,KAAI,CAAC,CAAC;SAEjE,IAAI,QAAQ,GAAG,KAAI,CAAC,SAAS,GAAG,IAAI,QAAQ,EAAE,CAAC;SAC/C,KAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;;MAGxB;KAED,2BAAK,GAAL,UAAM,KAAmB;SACxB,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SACxB,IAAI,CAAC,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC;SAC9B,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;MACvB;KAED,2BAAK,GAAL,UAAM,KAAmB;SACxB,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SACxB,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;SACjB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;MACvB;KAED,2BAAK,GAAL;SACC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;MACvB;KAED,4BAAM,GAAN;SACC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;MACxB;KAED,4BAAM,GAAN;SACC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;MACxB;KAED,2BAAK,GAAL;SACC,IAAI,CAAC,SAAS,CAAC,OAAO,GAAG,KAAK,CAAC;MAC/B;KAEO,2BAAK,GAAb,UAAc,KAAK;MAElB;KACF,kBAAC;CAAD,CAAC,CAxDgC,MAAM,CAAC,SAAS,GAwDhD;;iBCzDwB,KAAK;KAC7B,YAAY,EAAE,CAAC;KACf,WAAW,CAAC,KAAK,CAAC,CAAC;KAEnB,IAAI,QAAQ,GAAG,IAAI,WAAW,EAAE,CAAC;KACjC,OAAO,QAAQ,CAAC;CACjB,CAAC;;;;;;;;"} <<<<<<< HEAD
\ No newline at end of file {"version":3,"file":"index.js","sources":["src/custom/food-fell/src/props.ts","src/custom/food-fell/src/game/utils.ts","src/custom/food-fell/src/game/Goods.ts","src/custom/food-fell/src/game/object-pool-init.ts","src/custom/food-fell/src/game/GameView.ts","src/custom/food-fell/src/game/GameWrapper.ts","src/custom/food-fell/src/index.ts"],"sourcesContent":["/**\n * Created by rockyl on 2020-01-21.\n */\n\nexport let props: any = {};\n\nexport function prepareProps() {\n\tlet metaProps = getProps();\n\n\tengine.injectProp(props, metaProps);\n}\n\nexport function injectProps(p) {\n\tengine.injectProp(props, p);\n}\n","/**\n * Created by rockyl on 2020-01-21.\n */\n\nexport function getTexture(uuid) {\n\treturn engine.Texture.from(getAssetByUUID(uuid).uuid);\n}\n\nexport function getTextureByName(name) {\n\treturn getTexture(engine.getAssetByName(name).uuid);\n}\n\nexport function playSound(name) {\n\tengine.playSound(engine.getAssetByName(name).uuid, {keep: true});\n}\nexport function createSvga(name, anchorName?) {\n\tlet inst = new svga.Svga();\n\tinst.source = 'asset://' + engine.getAssetByName(name).uuid;\n\treturn inst;\n}","/**\n * Created by rockyl on 2020-02-02.\n *\n * 掉落物品\n */\nimport {getTextureByName} from \"./utils\";\nimport {props} from \"../props\";\n\nexport class Goods extends engine.Container {\n\tprivate _body:engine.Rect\n\tprivate _toY;\n\n\tconstructor() {\n\t\tsuper();\n\n\t\tlet body\n\t\tbody = this._body =new engine.Rect()\n\t\t\n\t\t\n\t\tlet rain = new engine.Sprite(getTextureByName('雨滴'));\n\t\train[\"npcType\"]=\"rain\"\n\t\tlet stone = new engine.Sprite(getTextureByName('石块'));\n\t\tstone[\"npcType\"]=\"stone\"\n\t\tlet boom = new engine.Sprite(getTextureByName('炸弹'));\n\t\tboom[\"npcType\"]=\"boom\"\n\n\t\train.visible=false;\n\t\tstone.visible=false;\n\t\tboom.visible=false;\n\t\tbody.addChild(rain)\n\t\tbody.addChild(stone)\n\t\tbody.addChild(boom)\n\t\t\n\t\tthis.addChild(body);\n\t\tbody.width=.0001;\n\t\tbody.height=.0001;\n\t\tbody.mouseEnabled=false;\n\t}\n\n\n\tgetRandomNumberByRange(start, end) {\n\t\treturn Math.floor(Math.random() * (end - start) + start)\n\t}\n\n\treset() {\n\t\tthis.visible = true;\n\t\tthis.rotation = 0;\n\t\tthis.anchorOffsetY = 0;\n\t\tthis.y = 0;\n\t\tthis.x = (750-120)*Math.random()+30;\n\t\tthis.rotation = 0;\n\t\tlet random=Math.random()\n\n\t\tif(random<props.goodsProbability[0]){\n\t\t\tthis.showNpc(\"rain\")\n\t\t}else if(random>=props.goodsProbability[0]&&random<=(props.goodsProbability[0]+props.goodsProbability[1])){\n\t\t\tthis.showNpc(\"stone\")\n\t\t}else if(random>(props.goodsProbability[0]+props.goodsProbability[1])){\n\t\t\tthis.showNpc(\"boom\")\n\t\t}\n\t}\n\n\n\tshowNpc(type){\n\t\tfor(let i=0;i<this._body.children.length;i++){\n\t\t\tthis._body.children[i].visible=false;\n\t\t\tthis._body.children[i].mouseEnabled=false;\n\t\t}\n\n\t\tfor(let i=0;i<this._body.children.length;i++){\n\t\t\tif(this._body.children[i][\"npcType\"]==type){\n\t\t\t\tthis[\"npcType\"]=type\n\t\t\t\tthis._body.children[i].visible=true;\n\t\t\t\tthis._body.children[i].mouseEnabled=false;\n\t\t\t}\n\t\t}\n\t\t\n\t}\n\n\tset anchorOffsetY(v) {\n\t\tthis._body.y = v;\n\t}\n}\n","/**\n * Created by rockyl on 2020-02-03.\n */\n\nimport {Goods} from \"./Goods\";\nimport ObjectPool = engine.ObjectPool;\n\nexport const PoolName: string = 'goods';\n\nObjectPool.registerPool(PoolName, function () {\n\treturn new Goods();\n}, function (item: Goods, data) {\n\titem.reset();\n});\n","/**\n * Created by rockyl on 2018/8/16.\n */\n\nimport { props } from \"../props\";\nimport { playSound, createSvga } from \"./utils\";\nimport ObjectPool = engine.ObjectPool;\nimport { getTextureByName } from \"./utils\";\nimport { Goods } from \"./Goods\";\nimport { PoolName } from \"./object-pool-init\";\n\n\n\nexport default class GameView extends engine.Container {\n\n\tprivate _hasSetup;\n\n\t//玩家\n\tprivate player: engine.Container;\n\t//触摸层\n\tprivate rectBg: engine.Rect;\n\t//npc层\n\tprivate NpcBg: engine.Container;\n\n\t//当前分数\n\tprivate score\n\n\t//游戏状态\n\tprivate gameIng;\n\n\t//npc出身计时器\n\tprivate timer\n\t//倒计时计时器\n\tprivate countdownTimer: any\n\t//倒计时\n\tprivate countdown: number\n\n\t//当前速度\n\tprivate speed: number\n\n\t// 当前场景上面的物品\n\tprivate goodsItems = []\n\n\n\tprivate _goods: Goods;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.once(engine.Event.ADDED_TO_STAGE, this.setup, this);\n\t}\n\n\tprivate waterSvga\n\tprivate boomSvga\n\tprivate playerSvga\n\n\tsetup() {\n\t\tif (this._hasSetup) {\n\t\t\treturn;\n\t\t}\n\t\tthis._hasSetup = true;\n\t\tthis.NpcBg = new engine.Container();\n\t\tthis.NpcBg.alpha = 1;\n\t\tthis.NpcBg.width = 0;\n\t\tthis.NpcBg.height = 0;\n\t\tthis.addChild(this.NpcBg)\n\n\t\n\n\t\tthis.player = new engine.Container();\n\t\tthis.player.mouseEnabled = false;\n\t//\tthis.player.fillColor=\"rgba(0, 0, 0,1)\"\n\t\t//console.log(this.player.fillColor)\n\t\n\t\tthis.addChild(this.player);\n\n\t\tthis.waterSvga=createSvga(\"水花\")\n\t\tthis.playerSvga=createSvga(\"玩家\")\n\t\tthis.boomSvga=createSvga(\"炸弹svga\")\n\t\tthis.player.addChild(this.playerSvga);\n\t\tthis.player.addChild(this.waterSvga);\n\t\tthis.player.addChild(this.boomSvga);\n\t\tthis.playerSvga.gotoAndPlay(1);\n\n\t\tthis.visible=false;\n\t\tsetTimeout(()=>{\n\t\t\tthis.visible=true;\n\t\t\t// this.player.width=this.playerSvga.width;\n\t\t\t// this.player.height=this.playerSvga.height;\n\t\t\tthis.player.anchorY = this.player.height / 2;\n\t\t\tthis.player.anchorX = this.player.width / 2;\n\t\t\tconsole.log(this.player.width)\n\t\t\tconsole.log(this.playerSvga.width)\n\t\t\tthis.player.x = 375 - this.player.width / 2;\n\t\t\tthis.player.y = props.playerPositionY;\n\t\t},300)\n\n\t\t\n\t\tthis.rectBg = new engine.Rect();\n\t\tthis.rectBg.alpha = 0;\n\t\tthis.rectBg.width = 750;\n\t\tthis.rectBg.height = 1624;\n\t\tthis.addChild(this.rectBg)\n\n\t\tthis.rectBg.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDownStage, this);\n\t\tthis.rectBg.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMoveStage, this);\n\t\tthis.rectBg.addEventListener(engine.MouseEvent.MOUSE_OUT, this.onOutStage, this);\n\n\t\n\t}\n\n\n\t/**\n\t * 重置场景\n\t */\n\treset() {\n\t\tthis.recycleGoods()\n\t}\n\n\t/**\n\t * 开始\n\t */\n\tstart() {\n\t\tthis.score = 0;\n\t\tthis.speed = 1\n\t\tthis.gameIng = true;\n\t\tthis.creatNpc()\n\t\tthis.beginNpc()\n\t\tthis.countdown = props.countDown;\n\t\t\n\t\tthis.countdownTimer = setInterval(() => {\n\t\t\tif (this.gameIng) {\n\t\t\t\tif (this.countdown > 0) {\n\t\t\t\t\tengine.globalEvent.dispatchEvent('food-fell-time-update', {\n\t\t\t\t\t\ttime: this.countdown,\n\t\t\t\t\t});\n\t\t\t\t\tthis.countdown -= 1\n\t\t\t\t} else {\n\t\t\t\t\tengine.globalEvent.dispatchEvent('food-fell-game-over', {\n\t\t\t\t\t\tscore: this.score,\n\t\t\t\t\t\treason: 1\n\t\t\t\t\t});\n\t\t\t\t\tthis.died()\n\t\t\t\t}\n\t\t\t}\n\t\t}, 1000)\n\t}\n\n\t/**\n\t * npc开始掉落\n\t */\n\tbeginNpc() {\n\t\tthis.timer = setTimeout(() => {\n\t\t\tif (this.gameIng) {\n\t\t\t\tthis.speed += props.acceleratedSpeed;\n\t\t\t\tthis.creatNpc()\n\t\t\t}\n\t\t\t//递归执行\n\t\t\tthis.beginNpc()\n\t\t}, 2000 / this.speed)\n\t}\n\n\t/**\n\t * 暂停\n\t */\n\tpause() {\n\t\tthis.gameIng = false;\n\t}\n\n\t/**\n\t * 恢复\n\t */\n\trevive() {\n\t\tthis.gameIng = true;\n\t}\n\n\t/**\n\t * 重新开始\n\t */\n\tresume() {\n\t\tthis.reset()\n\t\tthis.start()\n\t}\n\n\t/**\n\t * 创建NPC\n\t */\n\tprivate creatNpc() {\n\t\tlet goods = this._goods = <Goods>ObjectPool.getObject(PoolName);\n\t\tthis.goodsItems.push(goods)\n\t\tthis.NpcBg.addChild(goods);\n\t\tgoods.addEventListener(engine.Event.ENTER_FRAME, goods[\"onGoodsEnter\"] = () => {\n\t\t\tif (goods.y > 1624) {\n\t\t\t\tthis.removeNpc(goods)\n\t\t\t} else {\n\t\t\t\tif (this.gameIng) {\n\t\t\t\t\t//速度叠加\n\t\t\t\t\tgoods.y += (4 * this.speed)\n\t\t\t\t\t//如果玩家和物品发生碰撞\n\t\t\t\t\tif (this.hasHit(this.player, goods)) {\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (goods[\"npcType\"] == \"rain\") {\n\t\t\t\t\t\t\tconsole.log(\"碰到雨滴\")\n\t\t\t\t\t\t\tthis.score += props.rainScore\n\t\t\t\t\t\t\tthis.waterSvga.visible=true;\n\t\t\t\t\t\t\tthis.waterSvga.play(false, false)\n\t\t\t\t\t\t\tthis.waterSvga.once(engine.Event.END_FRAME, ()=>{\n\t\t\t\t\t\t\t\tthis.waterSvga.visible=false;\n\t\t\t\t\t\t\t}, this);\n\t\t\t\t\t\t} else if (goods[\"npcType\"] == \"stone\") {\n\t\t\t\t\t\t\tconsole.log(\"碰到石头\")\n\t\t\t\t\t\t\tthis.score += props.stoneScore\n\t\t\t\t\t\t} else if (goods[\"npcType\"] == \"boom\") {\n\t\t\t\t\t\t\tconsole.log(\"碰到炸弹\")\n\t\t\t\t\t\t\tthis.boomSvga.visible=true;\n\t\t\t\t\t\t\tthis.boomSvga.play(false, false)\n\t\t\t\t\t\t\tthis.boomSvga.once(engine.Event.END_FRAME, ()=>{\n\t\t\t\t\t\t\t\tthis.boomSvga.visible=false;\n\t\t\t\t\t\t\t}, this);\n\t\t\t\t\t\t\tengine.globalEvent.dispatchEvent('food-fell-game-over', {\n\t\t\t\t\t\t\t\tscore: this.score,\n\t\t\t\t\t\t\t\treason: 2\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tthis.died()\n\t\t\t\t\t\t}\n\t\t\t\t\t\tengine.globalEvent.dispatchEvent('food-fell-score-update', {\n\t\t\t\t\t\t\tscore: this.score,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tthis.removeNpc(goods)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t}, this);\n\t}\n\n\t/**\n\t * 玩家死亡\n\t */\n\tprivate died() {\n\t\tthis.score = 0\n\t\tthis.pause()\n\t}\n\n\t/**\n\t * 回收指定物品\n\t * @param goods 物品\n\t */\n\tprivate removeNpc(goods) {\n\t\tthis.NpcBg.removeChild(goods);\n\t\tObjectPool.recycleObject(PoolName, goods);\n\t\tgoods.removeEventListener(engine.Event.ENTER_FRAME, goods[\"onGoodsEnter\"], this);\n\t\tlet index = this.goodsItems.indexOf(goods);\n\t\tif (index > -1) {\n\t\t\tthis.goodsItems.splice(index, 1);\n\t\t}\n\t}\n\n\t/**\n\t * 回收对象\n\t */\n\tprivate recycleGoods() {\n\t\tclearTimeout(this.timer)\n\t\tclearInterval(this.countdownTimer)\n\t\tfor (let goods of this.goodsItems) {\n\t\t\tif (goods) {\n\t\t\t\tthis.removeChild(goods);\n\t\t\t\tObjectPool.recycleObject(PoolName, goods);\n\t\t\t\tgoods.removeEventListener(engine.Event.ENTER_FRAME, goods[\"onGoodsEnter\"], this);\n\t\t\t}\n\t\t}\n\t\tthis.goodsItems = []\n\t}\n\n\tprivate moveCatchX = 0\n\tprivate playerCatchX = 0\n\n\t/**\n\t * 碰撞检测\n\t * @param a a盒子\n\t * @param b b盒子\n\t */\n\tprivate hasHit(a, b) {\n\t\tif (\n\t\t\tMath.abs((a.x + a.width / 2) - (b.x + b.width / 2)) < a.width / 2 + b.width / 2\n\t\t\t&&\n\t\t\tMath.abs((a.y + a.height / 2) - (b.y + b.height / 2)) < a.height / 2 + b.height / 2\n\t\t) {\n\t\t\treturn true;\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tprivate onDownStage = (e) => {\n\t\tthis.moveCatchX = e.localX;\n\t\tthis.playerCatchX = this.player.x\n\t}\n\n\tprivate onMoveStage = (e) => {\n\t\tif (this.gameIng) {\n\t\t\tthis.player.x = this.playerCatchX + (e.localX - this.moveCatchX)\n\t\t}\n\t}\n\n\tprivate onOutStage = (e) => {\n\t\tthis.moveCatchX = 0\n\t}\n}\n","/**\n * Created by rockyl on 2020-01-09.\n */\n\nimport GameView from \"./GameView\";\nimport {injectProps} from \"../props\";\n\n\nexport class GameWrapper extends engine.Container {\n\tprivate _status;\n\tprivate _gameView: GameView;\n\n\n\n\n\n\tconstructor() {\n\t\tsuper();\n\t\tengine.globalEvent.addEventListener('food-fell-reset', this.reset, this);\n\t\tengine.globalEvent.addEventListener('food-fell-start', this.start, this);\n\t\tengine.globalEvent.addEventListener('food-fell-pause', this.pause, this);\n\t\tengine.globalEvent.addEventListener('food-fell-resume', this.resume, this);\n\t\tengine.globalEvent.addEventListener('food-fell-revive', this.revive, this);\n\t\tengine.globalEvent.addEventListener('food-fell-clear', this.clear, this);\n\n\t\tthis.addEventListener(engine.MouseEvent.CLICK, this.onTap, this);\n\n\t\tlet gameView = this._gameView = new GameView();\n\t\tthis.addChild(gameView);\n\t\t// gameView.reset()\n\t\t// gameView.start()\n\t}\n\n\treset(event: engine.Event) {\t\t\n\t\tinjectProps(event.data);\n\t\tthis._gameView.visible = true;\n\t\tthis._gameView.reset();\n\t}\n\n\tstart(event: engine.Event) {\n\t\tinjectProps(event.data);\n\t\tthis._status = 1;\n\t\tthis._gameView.start();\n\t}\n\n\tpause() {\n\t\tthis._gameView.pause();\n\t}\n\n\tresume() {\n\t\tthis._gameView.resume();\n\t}\n\n\trevive() {\n\t\tthis._gameView.revive();\n\t}\n\n\tclear() {\n\t\tthis._gameView.visible = false;\n\t}\n\n\tprivate onTap(event) {\n\t//\tthis._gameView.tap(event);\n\t}\n}\n","/**\n * Created by rockyl on 2019-11-20.\n */\n\nimport {GameWrapper} from \"./game/GameWrapper\";\nimport {injectProps, prepareProps} from \"./props\";\n\nexport default function (props) {\n\tprepareProps();\n\tinjectProps(props);\n\n\tlet instance = new GameWrapper();\n\treturn instance;\n}\n"],"names":["__extends","ObjectPool"],"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;;UCVgB,UAAU,CAAC,IAAI;KAC9B,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;CACvD,CAAC;AAED,UAAgB,gBAAgB,CAAC,IAAI;KACpC,OAAO,UAAU,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;CACrD,CAAC;AAED,UAGgB,UAAU,CAAC,IAAI,EAAE,UAAW;KAC3C,IAAI,IAAI,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;KAC3B,IAAI,CAAC,MAAM,GAAG,UAAU,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC;KAC5D,OAAO,IAAI,CAAC;CACb,CAAC;;CCXD;KAA2BA,+BAAgB;KAI1C;SAAA,YACC,iBAAO,SAwBP;SAtBA,IAAI,IAAI,CAAA;SACR,IAAI,GAAG,KAAI,CAAC,KAAK,GAAE,IAAI,MAAM,CAAC,IAAI,EAAE,CAAA;SAG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AC,KAAK,EAAE,KAAI,CAAC,KAAK,EAAE,KAAI,CAAC,CAAC;SAEjE,IAAI,QAAQ,GAAG,KAAI,CAAC,SAAS,GAAG,IAAI,QAAQ,EAAE,CAAC;SAC/C,KAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;;MAGxB;KAED,2BAAK,GAAL,UAAM,KAAmB;SACxB,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SACxB,IAAI,CAAC,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC;SAC9B,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;MACvB;KAED,2BAAK,GAAL,UAAM,KAAmB;SACxB,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SACxB,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;SACjB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;MACvB;KAED,2BAAK,GAAL;SACC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;MACvB;KAED,4BAAM,GAAN;SACC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;MACxB;KAED,4BAAM,GAAN;SACC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;MACxB;KAED,2BAAK,GAAL;SACC,IAAI,CAAC,SAAS,CAAC,OAAO,GAAG,KAAK,CAAC;MAC/B;KAEO,2BAAK,GAAb,UAAc,KAAK;MAElB;KACF,kBAAC;CAAD,CAAC,CAxDgC,MAAM,CAAC,SAAS,GAwDhD;;iBCzDwB,KAAK;KAC7B,YAAY,EAAE,CAAC;KACf,WAAW,CAAC,KAAK,CAAC,CAAC;KAEnB,IAAI,QAAQ,GAAG,IAAI,WAAW,EAAE,CAAC;KACjC,OAAO,QAAQ,CAAC;CACjB,CAAC;;;;;;;;"}
=======
{"version":3,"file":"index.js","sources":["src/custom/food-fell/src/props.ts","src/custom/food-fell/src/game/utils.ts","src/custom/food-fell/src/game/Goods.ts","src/custom/food-fell/src/game/object-pool-init.ts","src/custom/food-fell/src/game/GameView.ts","src/custom/food-fell/src/game/GameWrapper.ts","src/custom/food-fell/src/index.ts"],"sourcesContent":["/**\n * Created by rockyl on 2020-01-21.\n */\n\nexport let props: any = {};\n\nexport function prepareProps() {\n\tlet metaProps = getProps();\n\n\tengine.injectProp(props, metaProps);\n}\n\nexport function injectProps(p) {\n\tengine.injectProp(props, p);\n}\n","/**\n * Created by rockyl on 2020-01-21.\n */\n\nexport function getTexture(uuid) {\n\treturn engine.Texture.from(getAssetByUUID(uuid).uuid);\n}\n\nexport function getTextureByName(name) {\n\treturn getTexture(engine.getAssetByName(name).uuid);\n}\n\nexport function playSound(name) {\n\tengine.playSound(engine.getAssetByName(name).uuid, {keep: true});\n}\nexport function createSvga(name, anchorName?) {\n\tlet inst = new svga.Svga();\n\tinst.source = 'asset://' + engine.getAssetByName(name).uuid;\n\treturn inst;\n}","/**\n * Created by rockyl on 2020-02-02.\n *\n * 掉落物品\n */\nimport {getTextureByName} from \"./utils\";\nimport {props} from \"../props\";\n\nexport class Goods extends engine.Container {\n\tprivate _body:engine.Rect\n\tprivate _toY;\n\n\tconstructor() {\n\t\tsuper();\n\n\t\tlet body\n\t\tbody = this._body =new engine.Rect()\n\t\t\n\t\t\n\t\tlet rain = new engine.Sprite(getTextureByName('雨滴'));\n\t\train[\"npcType\"]=\"rain\"\n\t\tlet stone = new engine.Sprite(getTextureByName('石块'));\n\t\tstone[\"npcType\"]=\"stone\"\n\t\tlet boom = new engine.Sprite(getTextureByName('炸弹'));\n\t\tboom[\"npcType\"]=\"boom\"\n\n\t\train.visible=false;\n\t\tstone.visible=false;\n\t\tboom.visible=false;\n\t\tbody.addChild(rain)\n\t\tbody.addChild(stone)\n\t\tbody.addChild(boom)\n\t\t\n\t\tthis.addChild(body);\n\t\tbody.width=.0001;\n\t\tbody.height=.0001;\n\t\tbody.mouseEnabled=false;\n\t}\n\n\n\tgetRandomNumberByRange(start, end) {\n\t\treturn Math.floor(Math.random() * (end - start) + start)\n\t}\n\n\treset() {\n\t\tthis.visible = true;\n\t\tthis.rotation = 0;\n\t\tthis.anchorOffsetY = 0;\n\t\tthis.y = 0;\n\t\tthis.x = (750-120)*Math.random()+30;\n\t\tthis.rotation = 0;\n\t\tlet random=Math.random()\n\n\t\tif(random<props.goodsProbability[0]){\n\t\t\tthis.showNpc(\"rain\")\n\t\t}else if(random>=props.goodsProbability[0]&&random<=(props.goodsProbability[0]+props.goodsProbability[1])){\n\t\t\tthis.showNpc(\"stone\")\n\t\t}else if(random>(props.goodsProbability[0]+props.goodsProbability[1])){\n\t\t\tthis.showNpc(\"boom\")\n\t\t}\n\t}\n\n\n\tshowNpc(type){\n\t\tfor(let i=0;i<this._body.children.length;i++){\n\t\t\tthis._body.children[i].visible=false;\n\t\t\tthis._body.children[i].mouseEnabled=false;\n\t\t}\n\n\t\tfor(let i=0;i<this._body.children.length;i++){\n\t\t\tif(this._body.children[i][\"npcType\"]==type){\n\t\t\t\tthis[\"npcType\"]=type\n\t\t\t\tthis._body.children[i].visible=true;\n\t\t\t\tthis._body.children[i].mouseEnabled=false;\n\t\t\t}\n\t\t}\n\t\t\n\t}\n\n\tset anchorOffsetY(v) {\n\t\tthis._body.y = v;\n\t}\n}\n","/**\n * Created by rockyl on 2020-02-03.\n */\n\nimport {Goods} from \"./Goods\";\nimport ObjectPool = engine.ObjectPool;\n\nexport const PoolName: string = 'goods';\n\nObjectPool.registerPool(PoolName, function () {\n\treturn new Goods();\n}, function (item: Goods, data) {\n\titem.reset();\n});\n","/**\n * Created by rockyl on 2018/8/16.\n */\n\nimport { props } from \"../props\";\nimport { playSound, createSvga } from \"./utils\";\nimport ObjectPool = engine.ObjectPool;\nimport { getTextureByName } from \"./utils\";\nimport { Goods } from \"./Goods\";\nimport { PoolName } from \"./object-pool-init\";\n\n\n\nexport default class GameView extends engine.Container {\n\n\tprivate _hasSetup;\n\n\t//玩家\n\tprivate player: engine.Container;\n\t//触摸层\n\tprivate rectBg: engine.Rect;\n\t//npc层\n\tprivate NpcBg: engine.Container;\n\n\t//当前分数\n\tprivate score\n\n\t//游戏状态\n\tprivate gameIng;\n\n\t//npc出身计时器\n\tprivate timer\n\t//倒计时计时器\n\tprivate countdownTimer: any\n\t//倒计时\n\tprivate countdown: number\n\n\t//当前速度\n\tprivate speed: number\n\n\t// 当前场景上面的物品\n\tprivate goodsItems = []\n\n\n\tprivate _goods: Goods;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.once(engine.Event.ADDED_TO_STAGE, this.setup, this);\n\t}\n\n\tprivate waterSvga\n\tprivate boomSvga\n\tprivate playerSvga\n\n\tsetup() {\n\t\tif (this._hasSetup) {\n\t\t\treturn;\n\t\t}\n\t\tthis._hasSetup = true;\n\t\tthis.NpcBg = new engine.Container();\n\t\tthis.NpcBg.alpha = 1;\n\t\tthis.NpcBg.width = 0;\n\t\tthis.NpcBg.height = 0;\n\t\tthis.addChild(this.NpcBg)\n\n\t\n\n\t\tthis.player = new engine.Container();\n\t\tthis.player.mouseEnabled = false;\n\t//\tthis.player.fillColor=\"rgba(0, 0, 0,1)\"\n\t\t//console.log(this.player.fillColor)\n\t\n\t\tthis.addChild(this.player);\n\n\t\tthis.waterSvga=createSvga(\"水花\")\n\t\tthis.playerSvga=createSvga(\"玩家\")\n\t\tthis.boomSvga=createSvga(\"炸弹svga\")\n\t\tthis.player.addChild(this.playerSvga);\n\t\tthis.player.addChild(this.waterSvga);\n\t\tthis.player.addChild(this.boomSvga);\n\t\tthis.playerSvga.gotoAndPlay(1);\n\n\t\tthis.visible=false;\n\t\tsetTimeout(()=>{\n\t\t\tthis.visible=true;\n\t\t\t// this.player.width=this.playerSvga.width;\n\t\t\t// this.player.height=this.playerSvga.height;\n\t\t\tthis.player.anchorY = this.player.height / 2;\n\t\t\tthis.player.anchorX = this.player.width / 2;\n\t\t\tconsole.log(this.player.width)\n\t\t\tconsole.log(this.playerSvga.width)\n\t\t\tthis.player.x = 375 - this.player.width / 2;\n\t\t\tthis.player.y = props.playerPositionY;\n\t\t},300)\n\n\t\t\n\t\tthis.rectBg = new engine.Rect();\n\t\tthis.rectBg.alpha = 0;\n\t\tthis.rectBg.width = 750;\n\t\tthis.rectBg.height = 1624;\n\t\tthis.addChild(this.rectBg)\n\n\t\tthis.rectBg.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDownStage, this);\n\t\tthis.rectBg.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMoveStage, this);\n\t\tthis.rectBg.addEventListener(engine.MouseEvent.MOUSE_OUT, this.onOutStage, this);\n\n\t\n\t}\n\n\n\t/**\n\t * 重置场景\n\t */\n\treset() {\n\t\tthis.recycleGoods()\n\t}\n\n\t/**\n\t * 开始\n\t */\n\tstart() {\n\t\tthis.score = 0;\n\t\tthis.speed = 1\n\t\tthis.gameIng = true;\n\t\tthis.creatNpc()\n\t\tthis.beginNpc()\n\t\tthis.countdown = props.countDown;\n\t\t\n\t\tthis.countdownTimer = setInterval(() => {\n\t\t\tif (this.gameIng) {\n\t\t\t\tif (this.countdown > 0) {\n\t\t\t\t\tengine.globalEvent.dispatchEvent('food-fell-time-update', {\n\t\t\t\t\t\ttime: this.countdown,\n\t\t\t\t\t});\n\t\t\t\t\tthis.countdown -= 1\n\t\t\t\t} else {\n\t\t\t\t\tengine.globalEvent.dispatchEvent('food-fell-game-over', {\n\t\t\t\t\t\tscore: this.score,\n\t\t\t\t\t\treason: 1\n\t\t\t\t\t});\n\t\t\t\t\tthis.died()\n\t\t\t\t}\n\t\t\t}\n\t\t}, 1000)\n\t}\n\n\t/**\n\t * npc开始掉落\n\t */\n\tbeginNpc() {\n\t\tthis.timer = setTimeout(() => {\n\t\t\tif (this.gameIng) {\n\t\t\t\tthis.speed += props.acceleratedSpeed;\n\t\t\t\tthis.creatNpc()\n\t\t\t}\n\t\t\t//递归执行\n\t\t\tthis.beginNpc()\n\t\t}, 2000 / this.speed)\n\t}\n\n\t/**\n\t * 暂停\n\t */\n\tpause() {\n\t\tthis.gameIng = false;\n\t}\n\n\t/**\n\t * 恢复\n\t */\n\trevive() {\n\t\tthis.gameIng = true;\n\t}\n\n\t/**\n\t * 重新开始\n\t */\n\tresume() {\n\t\tthis.reset()\n\t\tthis.start()\n\t}\n\n\t/**\n\t * 创建NPC\n\t */\n\tprivate creatNpc() {\n\t\tlet goods = this._goods = <Goods>ObjectPool.getObject(PoolName);\n\t\tthis.goodsItems.push(goods)\n\t\tthis.NpcBg.addChild(goods);\n\t\tgoods.addEventListener(engine.Event.ENTER_FRAME, goods[\"onGoodsEnter\"] = () => {\n\t\t\tif (goods.y > 1624) {\n\t\t\t\tthis.removeNpc(goods)\n\t\t\t} else {\n\t\t\t\tif (this.gameIng) {\n\t\t\t\t\t//速度叠加\n\t\t\t\t\tgoods.y += (4 * this.speed)\n\t\t\t\t\t//如果玩家和物品发生碰撞\n\t\t\t\t\tif (this.hasHit(this.player, goods)) {\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (goods[\"npcType\"] == \"rain\") {\n\t\t\t\t\t\t\tconsole.log(\"碰到雨滴\")\n\t\t\t\t\t\t\tthis.score += props.rainScore\n\t\t\t\t\t\t\tthis.waterSvga.visible=true;\n\t\t\t\t\t\t\tthis.waterSvga.play(false, false)\n\t\t\t\t\t\t\tthis.waterSvga.once(engine.Event.END_FRAME, ()=>{\n\t\t\t\t\t\t\t\tthis.waterSvga.visible=false;\n\t\t\t\t\t\t\t}, this);\n\t\t\t\t\t\t} else if (goods[\"npcType\"] == \"stone\") {\n\t\t\t\t\t\t\tconsole.log(\"碰到石头\")\n\t\t\t\t\t\t\tthis.score += props.stoneScore\n\t\t\t\t\t\t} else if (goods[\"npcType\"] == \"boom\") {\n\t\t\t\t\t\t\tconsole.log(\"碰到炸弹\")\n\t\t\t\t\t\t\tthis.boomSvga.visible=true;\n\t\t\t\t\t\t\tthis.boomSvga.play(false, false)\n\t\t\t\t\t\t\tthis.boomSvga.once(engine.Event.END_FRAME, ()=>{\n\t\t\t\t\t\t\t\tthis.boomSvga.visible=false;\n\t\t\t\t\t\t\t}, this);\n\t\t\t\t\t\t\tengine.globalEvent.dispatchEvent('food-fell-game-over', {\n\t\t\t\t\t\t\t\tscore: this.score,\n\t\t\t\t\t\t\t\treason: 2\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tthis.died()\n\t\t\t\t\t\t}\n\t\t\t\t\t\tengine.globalEvent.dispatchEvent('food-fell-score-update', {\n\t\t\t\t\t\t\tscore: this.score,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tthis.removeNpc(goods)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t}, this);\n\t}\n\n\t/**\n\t * 玩家死亡\n\t */\n\tprivate died() {\n\t\tthis.score = 0\n\t\tthis.pause()\n\t}\n\n\t/**\n\t * 回收指定物品\n\t * @param goods 物品\n\t */\n\tprivate removeNpc(goods) {\n\t\tthis.NpcBg.removeChild(goods);\n\t\tObjectPool.recycleObject(PoolName, goods);\n\t\tgoods.removeEventListener(engine.Event.ENTER_FRAME, goods[\"onGoodsEnter\"], this);\n\t\tlet index = this.goodsItems.indexOf(goods);\n\t\tif (index > -1) {\n\t\t\tthis.goodsItems.splice(index, 1);\n\t\t}\n\t}\n\n\t/**\n\t * 回收对象\n\t */\n\tprivate recycleGoods() {\n\t\tclearTimeout(this.timer)\n\t\tclearInterval(this.countdownTimer)\n\t\tfor (let goods of this.goodsItems) {\n\t\t\tif (goods) {\n\t\t\t\tthis.removeChild(goods);\n\t\t\t\tObjectPool.recycleObject(PoolName, goods);\n\t\t\t\tgoods.removeEventListener(engine.Event.ENTER_FRAME, goods[\"onGoodsEnter\"], this);\n\t\t\t}\n\t\t}\n\t\tthis.goodsItems = []\n\t}\n\n\tprivate moveCatchX = 0\n\tprivate playerCatchX = 0\n\n\t/**\n\t * 碰撞检测\n\t * @param a a盒子\n\t * @param b b盒子\n\t */\n\tprivate hasHit(a, b) {\n\t\tif (\n\t\t\tMath.abs((a.x + a.width / 2) - (b.x + b.width / 2)) < a.width / 2 + b.width / 2\n\t\t\t&&\n\t\t\tMath.abs((a.y + a.height / 2) - (b.y + b.height / 2)) < a.height / 2 + b.height / 2\n\t\t) {\n\t\t\treturn true;\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tprivate onDownStage = (e) => {\n\t\tthis.moveCatchX = e.localX;\n\t\tthis.playerCatchX = this.player.x\n\t}\n\n\tprivate onMoveStage = (e) => {\n\t\tif (this.gameIng) {\n\t\t\tthis.player.x = this.playerCatchX + (e.localX - this.moveCatchX)\n\t\t}\n\t}\n\n\tprivate onOutStage = (e) => {\n\t\tthis.moveCatchX = 0\n\t}\n}\n","/**\n * Created by rockyl on 2020-01-09.\n */\n\nimport GameView from \"./GameView\";\nimport {injectProps} from \"../props\";\n\n\nexport class GameWrapper extends engine.Container {\n\tprivate _status;\n\tprivate _gameView: GameView;\n\n\n\n\n\n\tconstructor() {\n\t\tsuper();\n\t\tengine.globalEvent.addEventListener('food-fell-reset', this.reset, this);\n\t\tengine.globalEvent.addEventListener('food-fell-start', this.start, this);\n\t\tengine.globalEvent.addEventListener('food-fell-pause', this.pause, this);\n\t\tengine.globalEvent.addEventListener('food-fell-resume', this.resume, this);\n\t\tengine.globalEvent.addEventListener('food-fell-revive', this.revive, this);\n\t\tengine.globalEvent.addEventListener('food-fell-clear', this.clear, this);\n\n\t\tthis.addEventListener(engine.MouseEvent.CLICK, this.onTap, this);\n\n\t\tlet gameView = this._gameView = new GameView();\n\t\tthis.addChild(gameView);\n\t\t// gameView.reset()\n\t\t// gameView.start()\n\t}\n\n\treset(event: engine.Event) {\t\t\n\t\tinjectProps(event.data);\n\t\tthis._gameView.visible = true;\n\t\tthis._gameView.reset();\n\t}\n\n\tstart(event: engine.Event) {\n\t\tinjectProps(event.data);\n\t\tthis._status = 1;\n\t\tthis._gameView.start();\n\t}\n\n\tpause() {\n\t\tthis._gameView.pause();\n\t}\n\n\tresume() {\n\t\tthis._gameView.resume();\n\t}\n\n\trevive() {\n\t\tthis._gameView.revive();\n\t}\n\n\tclear() {\n\t\tthis._gameView.visible = false;\n\t}\n\n\tprivate onTap(event) {\n\t//\tthis._gameView.tap(event);\n\t}\n}\n","/**\n * Created by rockyl on 2019-11-20.\n */\n\nimport {GameWrapper} from \"./game/GameWrapper\";\nimport {injectProps, prepareProps} from \"./props\";\n\nexport default function (props) {\n\tprepareProps();\n\tinjectProps(props);\n\n\tlet instance = new GameWrapper();\n\treturn instance;\n}\n"],"names":["__extends","ObjectPool"],"mappings":";;;;;;CAIO,IAAI,KAAK,GAAQ,EAAE,CAAC;AAE3B,UAAgB,YAAY;KAC3B,IAAI,SAAS,GAAG,QAAQ,EAAE,CAAC;KAE3B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;CACrC,CAAC;AAED,UAAgB,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,UAAgB,gBAAgB,CAAC,IAAI;KACpC,OAAO,UAAU,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;CACrD,CAAC;AAED,UAGgB,UAAU,CAAC,IAAI,EAAE,UAAW;KAC3C,IAAI,IAAI,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;KAC3B,IAAI,CAAC,MAAM,GAAG,UAAU,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC;KAC5D,OAAO,IAAI,CAAC;CACb,CAAC;;CCXD;KAA2BA,+BAAgB;KAI1C;SAAA,YACC,iBAAO,SAwBP;SAtBA,IAAI,IAAI,CAAA;SACR,IAAI,GAAG,KAAI,CAAC,KAAK,GAAE,IAAI,MA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open-gift";
(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,
}
}],
}, null, function () {
setTimeout(() => {
engine.addCustomModule(customId, engine.gameStage.sceneContainer.getChildAt(0));
}, 100);
setTimeout(() => {
engine.globalEvent.dispatchEvent('food-fell-reset', {
"goodsProbability": [0.8,0.1,0.1],
"countDown": 30,
"acceleratedSpeed":0.1
});
engine.globalEvent.dispatchEvent('food-fell-start');
}, 500);
});
engine.globalEvent.addEventListener('food-fell-time-update', (e) => {
console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('food-fell-score-update', (e) => {
console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('food-fell-game-over', (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: red;
}
</style>
</head>
<body>
<div id="game-container" style="line-height:0;font-size:0"></div>
<script crossorigin="anonymous" src="//yun.duiba.com.cn/editor/zeroing/libs/engine.50cdcef6ebe4e8c0fbc624f9d4fbf225102c5750.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/50a7212a113175fa18c866b005d98f07c558dc77.png",
"uuid": "66f23d13-82a5-4cec-9496-301ec240d087",
"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['open-gift'] = factory(global.tslib));
}(this, (function (tslib) { 'use strict';
var props = {};
function prepareProps() {
var metaProps = getProps();
engine.injectProp(props, metaProps);
}
function injectProps(p) {
engine.injectProp(props, p);
}
//# sourceMappingURL=props.js.map
function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
function createSvga(name, anchorName) {
var inst = new svga.Svga();
inst.source = 'asset://' + engine.getAssetByName(name).uuid;
return inst;
}
//# sourceMappingURL=utils.js.map
var GameView = (function (_super) {
tslib.__extends(GameView, _super);
function GameView() {
var _this = _super.call(this) || this;
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
return _this;
}
GameView.prototype.setup = function () {
if (this._hasSetup) {
return;
}
this._hasSetup = true;
this.NpcBg = new engine.Container();
this.NpcBg.x = props.initX;
this.NpcBg.y = props.initY;
this.addChild(this.NpcBg);
this.bottomCircle = new engine.Sprite(getTextureByName('底座'));
this.bottomCircle.x = 17;
this.bottomCircle.y = 305;
this.loveDot = new engine.Sprite(getTextureByName('点缀'));
this.loveDot.x = 0;
this.loveDot.y = 6;
this.giftboxSvga = createSvga('初始礼盒');
this.giftboxSvga.x = 105;
this.giftboxSvga.y = 37;
this.giftAfterSvga = createSvga("拆礼盒");
this.giftAfterSvga.x = 105;
this.giftAfterSvga.y = 0;
this.giftAfterSvga.visible = false;
this.NpcBg.addChild(this.bottomCircle);
this.NpcBg.addChild(this.giftboxSvga);
this.NpcBg.addChild(this.giftAfterSvga);
this.NpcBg.addChild(this.loveDot);
this.giftboxSvga.play(false, true);
};
GameView.prototype.reset = function () {
this.giftboxSvga.visible = true;
this.giftAfterSvga.visible = false;
};
GameView.prototype.start = function () {
this.giftAfterSvga.visible = true;
this.giftboxSvga.visible = false;
this.giftAfterSvga.play(false, false);
this.giftAfterSvga.once(engine.Event.END_FRAME, function () {
engine.globalEvent.dispatchEvent('open-gift-game-end');
}, this);
};
GameView.prototype.resume = function () {
this.reset();
this.start();
};
return GameView;
}(engine.Container));
var GameWrapper = (function (_super) {
tslib.__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('open-gift-game-init', _this.reset, _this);
engine.globalEvent.addEventListener('open-gift-game-start', _this.start, _this);
var gameView = _this._gameView = new GameView();
_this.addChild(gameView);
return _this;
}
GameWrapper.prototype.reset = function (event) {
injectProps(event.data);
this._gameView.visible = true;
this._gameView.reset();
};
GameWrapper.prototype.start = function (event) {
console.log('监听开始');
injectProps(event.data);
this._gameView.start();
};
GameWrapper.prototype.clear = function () {
this._gameView.visible = false;
};
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/open-gift/src/props.ts","src/custom/open-gift/src/game/utils.ts","src/custom/open-gift/src/game/GameView.ts","src/custom/open-gift/src/game/GameWrapper.ts","src/custom/open-gift/src/index.ts"],"sourcesContent":["/**\n * Created by rockyl on 2020-01-21.\n */\n\nexport let props: any = {};\n\nexport function prepareProps() {\n\tlet metaProps = getProps();\n\n\tengine.injectProp(props, metaProps);\n}\n\nexport function injectProps(p) {\n\tengine.injectProp(props, p);\n}\n","/**\n * Created by rockyl on 2020-01-21.\n */\n\nexport function getTexture(uuid) {\n\treturn engine.Texture.from(getAssetByUUID(uuid).uuid);\n}\n\nexport function getTextureByName(name) {\n\treturn getTexture(engine.getAssetByName(name).uuid);\n}\n\nexport function playSound(name) {\n\tengine.playSound(engine.getAssetByName(name).uuid, {keep: true});\n}\nexport function createSvga(name, anchorName?) {\n\tlet inst = new svga.Svga();\n\tinst.source = 'asset://' + engine.getAssetByName(name).uuid;\n\treturn inst;\n}","/**\n * Created by rockyl on 2018/8/16.\n */\n\nimport { props } from \"../props\";\nimport ObjectPool = engine.ObjectPool;\nimport { getTextureByName, createSvga } from \"./utils\";\n\nexport default class GameView extends engine.Container {\n private _hasSetup;\n \n //npc层\n private NpcBg: engine.Container;\n //底座\n private bottomCircle: engine.Container;\n //爱心点缀\n private loveDot: engine.Container;\n //礼盒\n private giftboxSvga;\n //礼盒前动画\n private giftAfterSvga\n \n\tprivate rect;\n\n constructor() {\n super();\n this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);\n }\n\n setup() {\n if (this._hasSetup) {\n return;\n }\n\n this._hasSetup = true;\n\n this.NpcBg = new engine.Container();\n this.NpcBg.x = props.initX;\n this.NpcBg.y = props.initY;\n this.addChild(this.NpcBg);\n this.bottomCircle = new engine.Sprite(getTextureByName('底座'));\n this.bottomCircle.x = 17;\n this.bottomCircle.y = 305;\n this.loveDot = new engine.Sprite(getTextureByName('点缀'));\n this.loveDot.x = 0;\n this.loveDot.y = 6;\n\n this.giftboxSvga = createSvga('初始礼盒');\n this.giftboxSvga.x = 105;\n this.giftboxSvga.y = 37;\n this.giftAfterSvga = createSvga(\"拆礼盒\");\n this.giftAfterSvga.x = 105;\n this.giftAfterSvga.y = 0;\n this.giftAfterSvga.visible = false;\n this.NpcBg.addChild(this.bottomCircle);\n this.NpcBg.addChild(this.giftboxSvga);\n this.NpcBg.addChild(this.giftAfterSvga);\n this.NpcBg.addChild(this.loveDot);\n this.giftboxSvga.play(false, true)\n\t\t// this.rect = new engine.Rect();\n // this.rect.width = props.gameStageWidth;\n // this.rect.height = props.gameStageHeight;\n\t\t// this.rect.x = 0;\n\t\t// this.rect.y = 0;\n\t\t// this.addChild(this.rect);\n\n // this.NpcBg.mask = this.rect;\n\t}\n /**\n * 重置场景\n */\n reset() {\n this.giftboxSvga.visible = true;\n this.giftAfterSvga.visible = false;\n }\n\n /**\n * 开始\n */\n start() {\n this.giftAfterSvga.visible = true;\n this.giftboxSvga.visible = false;\n this.giftAfterSvga.play(false, false)\n this.giftAfterSvga.once(engine.Event.END_FRAME, () => {\n engine.globalEvent.dispatchEvent('open-gift-game-end');\n }, this);\n }\n\n /**\n * 重新开始\n */\n resume() {\n this.reset();\n this.start();\n }\n}\n","/**\n * Created by rockyl on 2020-01-09.\n */\n\nimport GameView from \"./GameView\";\nimport {injectProps} from \"../props\";\n\n\nexport class GameWrapper extends engine.Container {\n\tprivate _status;\n\tprivate _gameView: GameView;\n\n\n\n\n\n\tconstructor() {\n\t\tsuper();\n\t\tengine.globalEvent.addEventListener('open-gift-game-init', this.reset, this);\n\t\tengine.globalEvent.addEventListener('open-gift-game-start', this.start, this);\n\n\t\tlet gameView = this._gameView = new GameView();\n\t\tthis.addChild(gameView);\n\t\t// gameView.reset();\n\t\t// gameView.start()\n\t}\n\n\treset(event: engine.Event) {\t\t\n\t\tinjectProps(event.data);\n\t\tthis._gameView.visible = true;\n\t\tthis._gameView.reset();\n\t}\n\n\tstart(event: engine.Event) {\n\t\tconsole.log('监听开始');\n\t\tinjectProps(event.data);\n\t\t// this._status = 1;\n\t\tthis._gameView.start();\n\t}\n\n\tclear() {\n\t\tthis._gameView.visible = false;\n\t}\n}\n","/**\n * Created by rockyl on 2019-11-20.\n */\n\nimport {GameWrapper} from \"./game/GameWrapper\";\nimport {injectProps, prepareProps} from \"./props\";\n\nexport default function (props) {\n\tprepareProps();\n\tinjectProps(props);\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SACxB,IAAI,CAAC,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC;SAC9B,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;MACvB;KAED,2BAAK,GAAL,UAAM,KAAmB;SACxB,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;SACpB,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SAExB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;MACvB;KAED,2BAAK,GAAL;SACC,IAAI,CAAC,SAAS,CAAC,OAAO,GAAG,KAAK,CAAC;MAC/B;KACF,kBAAC;CAAD,CAAC,CAnCgC,MAAM,CAAC,SAAS,GAmChD;;;iBCpCwB,KAAK;KAC7B,YAAY,EAAE,CAAC;KACf,WAAW,CAAC,KAAK,CAAC,CAAC;KAEnB,IAAI,QAAQ,GAAG,IAAI,WAAW,EAAE,CAAC;KACjC,OAAO,QAAQ,CAAC;CACjB,CAAC;;;;;;;;;"}
\ No newline at end of file
/**
* Created by rockyl on 2020-01-21.
*/
let customModuleProps = {
};
{
"name": "拆礼盒",
"desc": "拆礼盒模块",
"props": {
"initX": {
"alias": "游戏场景初始X位置",
"type": "number",
"default": 0
},
"initY": {
"alias": "游戏场景初始Y位置",
"type": "number",
"default": 0
},
"gameStageWidth": {
"alias": "游戏场景宽度",
"type": "number",
"default": 534
},
"gameStageHeight": {
"alias": "游戏场景高度",
"type": "number",
"default": 408
}
},
"assets": [
{
"name": "底座",
"url": "//yun.duiba.com.cn/aurora/assets/d6ed718f0d236febaa4d1331950e5a190f225cb5.png",
"uuid": "7a0f8b48-449c-46d9-bd80-64455a30e641",
"ext": ".png"
},
{
"name": "点缀",
"url": "//yun.duiba.com.cn/aurora/assets/e08f680bbd26c4dcc47fd67ee2e145c46d6fcd1a.png",
"uuid": "c7426dc4-d631-4947-accc-015666277208",
"ext": ".png"
},
{
"name": "初始礼盒",
"url": "//yun.duiba.com.cn/aurora/assets/b9bb4e52c3734025fc96a92cb574c92209927b61.svga",
"uuid": "947cb448-1992-49f1-a9ed-e359b944953a",
"ext": ".svga"
},
{
"name": "拆礼盒",
"url": "//yun.duiba.com.cn/aurora/assets/8e86f8696710de414f0f36dc330db6e4bd0683d6.svga",
"uuid": "d9222991-064c-4816-85ee-6964ba78fbd0",
"ext": ".svga"
}
],
"events": {
"in": {
"open-gift-game-init": {
"alias": "重置"
},
"open-gift-game-start": {
"alias": "开始",
"data": {
"prize": true
}
}
},
"out": {
"open-gift-game-end": {
"alias": "动画完毕",
"data": null
}
}
}
}
/**
* Created by rockyl on 2018/8/16.
*/
import { props } from "../props";
import ObjectPool = engine.ObjectPool;
import { getTextureByName, createSvga } from "./utils";
export default class GameView extends engine.Container {
private _hasSetup;
//npc层
private NpcBg: engine.Container;
//底座
private bottomCircle: engine.Container;
//爱心点缀
private loveDot: engine.Container;
//礼盒
private giftboxSvga;
//礼盒前动画
private giftAfterSvga
private rect;
constructor() {
super();
this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);
}
setup() {
if (this._hasSetup) {
return;
}
this._hasSetup = true;
this.NpcBg = new engine.Container();
this.NpcBg.x = props.initX;
this.NpcBg.y = props.initY;
this.addChild(this.NpcBg);
this.bottomCircle = new engine.Sprite(getTextureByName('底座'));
this.bottomCircle.x = 17;
this.bottomCircle.y = 305;
this.loveDot = new engine.Sprite(getTextureByName('点缀'));
this.loveDot.x = 0;
this.loveDot.y = 6;
this.giftboxSvga = createSvga('初始礼盒');
this.giftboxSvga.x = 105;
this.giftboxSvga.y = 37;
this.giftAfterSvga = createSvga("拆礼盒");
this.giftAfterSvga.x = 105;
this.giftAfterSvga.y = 0;
this.giftAfterSvga.visible = false;
this.NpcBg.addChild(this.bottomCircle);
this.NpcBg.addChild(this.giftboxSvga);
this.NpcBg.addChild(this.giftAfterSvga);
this.NpcBg.addChild(this.loveDot);
this.giftboxSvga.play(false, true)
// this.rect = new engine.Rect();
// this.rect.width = props.gameStageWidth;
// this.rect.height = props.gameStageHeight;
// this.rect.x = 0;
// this.rect.y = 0;
// this.addChild(this.rect);
// this.NpcBg.mask = this.rect;
}
/**
* 重置场景
*/
reset() {
this.giftboxSvga.visible = true;
this.giftAfterSvga.visible = false;
}
/**
* 开始
*/
start() {
this.giftAfterSvga.visible = true;
this.giftboxSvga.visible = false;
this.giftAfterSvga.play(false, false)
this.giftAfterSvga.once(engine.Event.END_FRAME, () => {
engine.globalEvent.dispatchEvent('open-gift-game-end');
}, this);
}
/**
* 重新开始
*/
resume() {
this.reset();
this.start();
}
}
/**
* 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('open-gift-game-init', this.reset, this);
engine.globalEvent.addEventListener('open-gift-game-start', this.start, this);
let gameView = this._gameView = new GameView();
this.addChild(gameView);
// gameView.reset();
// gameView.start()
}
reset(event: engine.Event) {
injectProps(event.data);
this._gameView.visible = true;
this._gameView.reset();
}
start(event: engine.Event) {
console.log('监听开始');
injectProps(event.data);
// this._status = 1;
this._gameView.start();
}
clear() {
this._gameView.visible = false;
}
}
/**
* Created by rockyl on 2020-01-21.
*/
export function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
export function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
export function playSound(name) {
engine.playSound(engine.getAssetByName(name).uuid, {keep: true});
}
export function createSvga(name, anchorName?) {
let inst = new svga.Svga();
inst.source = 'asset://' + engine.getAssetByName(name).uuid;
return inst;
}
\ No newline at end of file
/**
* Created by rockyl on 2019-11-20.
*/
import {GameWrapper} from "./game/GameWrapper";
import {injectProps, prepareProps} from "./props";
export default function (props) {
prepareProps();
injectProps(props);
let instance = new GameWrapper();
return instance;
}
/**
* Created by rockyl on 2020-01-21.
*/
export let props: any = {};
export function prepareProps() {
let metaProps = getProps();
engine.injectProp(props, metaProps);
}
export function injectProps(p) {
engine.injectProp(props, p);
}
...@@ -20,6 +20,7 @@ class AnimationPool extends Pool<PoolFrameAnimation> { ...@@ -20,6 +20,7 @@ class AnimationPool extends Pool<PoolFrameAnimation> {
} else { } else {
let anim = new PoolFrameAnimation(key); let anim = new PoolFrameAnimation(key);
this.layer.addChild(anim); this.layer.addChild(anim);
return anim; return anim;
} }
} }
......
...@@ -19,7 +19,7 @@ export class Test1 extends engine.Container { ...@@ -19,7 +19,7 @@ export class Test1 extends engine.Container {
} }
private onGameStart(e){ private onGameStart(e){
console.log(e.type, e.data); console.log(e.type, e.data, 'test');
let rect = new engine.Rect(); let rect = new engine.Rect();
rect.x = 100; rect.x = 100;
......
/**
* Created by rockyl on 2019-12-16.
*/
const customId = 'walking-cat';
(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,
}
}],
}, null, function () {
setTimeout(() => {
engine.addCustomModule(customId, engine.gameStage.sceneContainer.getChildAt(0));
}, 100);
setTimeout(() => {
// engine.globalEvent.dispatchEvent('lipstick-turntable-reset', {
// turntableAssetName: '橘色转盘',
// countDown: 5,
// });
engine.globalEvent.dispatchEvent('walking-cat-start');
}, 500);
});
engine.globalEvent.addEventListener('walking-cat-game-end', (e) => {
console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('walking-cat-game-changScore', (e) => {
console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('lipstick-turntable-hit', (e) => {
console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('lipstick-turntable-countdown', (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: transparent;
}
</style>
</head>
<body>
<div id="game-container" style="line-height:0;font-size:0"></div>
<script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.ebc906f6b50b8da0a669f77027981d5f3cb560ce.js"></script>
<script src="//yun.duiba.com.cn/js-libs/p2.js/0.7.1/p2.min.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": "橘色转盘",
"url": "//yun.duiba.com.cn/aurora/assets/9dfdf39ce4f4693c336cbdd996e05bd392921e0e.png",
"uuid": "b6ed99bc-2da1-4e6d-840e-54371be041aa",
"ext": '.png'
},
{
"name": "蓝色转盘",
"url": "//yun.duiba.com.cn/aurora/assets/088cff75c4035b87ff421c2dd87391c6a7bea607.png",
"uuid": "4d8e2af4-4f8e-4f84-ab05-8ae172bbf8a6",
"ext": '.png'
},
{
"name": "紫色转盘",
"url": "//yun.duiba.com.cn/aurora/assets/e0ac6904227d8e3878ed23be33e58d3ce2180f2d.png",
"uuid": "c3dd14af-1b98-4cb8-b725-fa75cf15e96d",
"ext": '.png'
},
];
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['walking-cat'] = factory(global.tslib));
}(this, (function (tslib) { 'use strict';
function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
function getStage() {
return engine.gameStage.stage;
}
function getfactor() {
return 10;
}
//# sourceMappingURL=utils.js.map
var props = {};
function prepareProps() {
var metaProps = getProps();
engine.injectProp(props, metaProps);
}
function injectProps(p) {
engine.injectProp(props, p);
}
//# sourceMappingURL=props.js.map
var ScoreLabel = (function (_super) {
tslib.__extends(ScoreLabel, _super);
function ScoreLabel() {
return _super !== null && _super.apply(this, arguments) || this;
}
ScoreLabel.prototype.updateScore = function (score, formatFun, animation) {
if (formatFun === void 0) { formatFun = null; }
if (animation === void 0) { animation = true; }
this.formatFun = formatFun;
this._value = score;
if (animation) {
engine.Tween.get(this, null, null, true)
.to({ temp: score }, 300);
}
else {
this.updateLocal(score);
}
};
Object.defineProperty(ScoreLabel.prototype, "score", {
get: function () {
return this._value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ScoreLabel.prototype, "temp", {
get: function () {
return this._temp;
},
set: function (v) {
this._temp = v;
this.updateLocal(v);
},
enumerable: true,
configurable: true
});
ScoreLabel.prototype.updateLocal = function (v) {
this.text = this.formatFun && this.formatFun(v) || v;
};
return ScoreLabel;
}(engine.Label));
//# sourceMappingURL=ScoreLabel.js.map
var PlayGame = (function (_super) {
tslib.__extends(PlayGame, _super);
function PlayGame() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.addlabelScore = null;
_this.formatScore = function (s) {
var t = (Math.ceil(s * 10) / 10).toString();
t += t.indexOf('.') < 0 ? '.0' : '';
return t;
};
return _this;
}
Object.defineProperty(PlayGame, "instance", {
get: function () {
if (this._instance == undefined) {
this._instance = new PlayGame();
}
return this._instance;
},
enumerable: true,
configurable: true
});
PlayGame.prototype.start = function (revive) {
if (revive === void 0) { revive = false; }
if (!revive) {
this.normalScore = 0;
this.rewardScore = 0;
this.lastDialogTs = 0;
this.initTouch();
this.initLabScore();
this.initAddlabel();
this.initDialog();
}
this.registerEvent();
};
PlayGame.prototype.registerEvent = function () {
this.touchLayer.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onMouseDown, this);
this.touchLayer.addEventListener(engine.MouseEvent.MOUSE_UP, this.onMouseUp, this);
this.GameView.addEventListener(engine.Event.COMPLETE, this.onGameComplete, this);
this.GameView.addEventListener('scoreChange', this.onScoreChange, this);
};
PlayGame.prototype.initTouch = function () {
this.touchLayer = new engine.Rect();
this.addChild(this.touchLayer);
this.touchLayer.width = getStage().width;
this.touchLayer.height = getStage().height;
this.touchLayer.x = 0;
this.touchLayer.y = 0;
this.touchLayer.alpha = 0;
};
PlayGame.prototype.removeListener = function () {
this.touchLayer.removeEventListener(engine.MouseEvent.MOUSE_DOWN, this.onMouseDown, this);
this.touchLayer.removeEventListener(engine.MouseEvent.MOUSE_UP, this.onMouseUp, this);
this.GameView.removeEventListener(engine.Event.COMPLETE, this.onGameComplete, this);
this.GameView.removeEventListener('scoreChange', this.onScoreChange, this);
};
PlayGame.prototype.initLabScore = function () {
this.labScore = new ScoreLabel();
this.labScore.visible = props.showScore;
this.labScore.updateScore(0, this.formatScore, false);
this.labScore.fillColor = 'yellow';
this.labScore.size = 46;
this.labScore.x = 610;
engine.Tween.get(this.labScore, { loop: false })
.set({ y: -100 })
.wait(300)
.to({ y: 40 }, 200, engine.Ease.backOut);
this.addChild(this.labScore);
};
PlayGame.prototype.initAddlabel = function () {
this.addlabelScore = new engine.Label();
this.addlabelScore.fillColor = 'yellow';
this.addlabelScore.size = 40;
this.addlabelScore.text = '';
this.addlabelScore.x = 378;
this.addlabelScore.y = 582;
this.addlabelScore.visible = false;
this.addChild(this.addlabelScore);
};
PlayGame.prototype.initDialog = function () {
this.dialog = new engine.Image();
this.dialog.x = 390;
this.dialog.y = 323;
this.addChild(this.dialog);
};
PlayGame.prototype.onMouseDown = function () {
this.GameView.down();
};
PlayGame.prototype.onMouseUp = function () {
this.GameView.up();
};
PlayGame.prototype.onGameComplete = function () {
console.log('死亡');
this.removeListener();
var score = this.getScore();
engine.globalEvent.dispatchEvent('walking-cat-game-end', { score: score });
};
PlayGame.prototype.getScore = function (round) {
if (round === void 0) { round = false; }
var score = (this.normalScore + this.rewardScore) / 10;
score *= (props.scoreTimes || 1);
if (round) {
return Math.round(score);
}
return score;
};
PlayGame.prototype.onScoreChange = function (event) {
var _a = event.data, score = _a.score, passType = _a.passType, rewardScore = _a.rewardScore;
var scoreAdd;
if (rewardScore) {
this.rewardScore += rewardScore;
scoreAdd = rewardScore;
}
else {
scoreAdd = score - this.normalScore;
this.normalScore = score;
}
var curScore = this.getScore();
this.labScore.updateScore(curScore, this.formatScore);
if (passType > 0 && passType <= 4) {
var now = Date.now();
if (now - this.lastDialogTs > 15000) {
this.play(1);
this.lastDialogTs = now;
}
}
else if (passType == 10) {
this.play(0);
this.lastDialogTs = Date.now();
this.GameView.setWitchFace('happy');
}
if (scoreAdd > 0) {
var labScoreAdd_1 = this.addlabelScore;
labScoreAdd_1.visible = props.showScore;
labScoreAdd_1.alpha = 0;
labScoreAdd_1.verticalCenter = 0;
labScoreAdd_1.text = '+' + (scoreAdd / 10 * (props.scoreTimes || 1));
engine.Tween.get(labScoreAdd_1, null, null, true)
.to({ verticalCenter: -50, alpha: 1, }, 200, engine.Ease.cubicIn)
.wait(300)
.to({ verticalCenter: -100, alpha: 0, }, 100, engine.Ease.cubicOut)
.call(function () {
labScoreAdd_1.visible = false;
}, this);
}
engine.globalEvent.dispatchEvent('walking-cat-game-changScore', { score: curScore });
};
PlayGame.prototype.play = function (id) {
var img = this.dialog;
img.texture = getTextureByName('dialog_' + id);
img.scaleX = img.scaleY = 0;
img.alpha = 1;
img.visible = true;
engine.Tween.get(img, null, null, true)
.to({
scaleX: 1, scaleY: 1
}, 500, engine.Ease.backOut)
.wait(500)
.to({
alpha: 0,
}, 300)
.call(function () {
img.visible = false;
});
};
PlayGame.prototype.revive = function () {
this.GameView.reset(true);
this.GameView.start(true);
};
return PlayGame;
}(engine.Container));
//# sourceMappingURL=PlayGame.js.map
var LoopComponent = (function (_super) {
tslib.__extends(LoopComponent, _super);
function LoopComponent() {
var _this = _super.call(this) || this;
_this.onceInfo = { width: 0, height: 0, count: 0 };
_this.loopInfo = { width: 0, height: 0, count: 0 };
_this.parts = [];
return _this;
}
LoopComponent.prototype.setup = function (parts, info) {
var _this = this;
parts.forEach(function (item, index) {
var part;
if (typeof item == 'string') {
part = new engine.Sprite(getTextureByName(item));
}
else if (item instanceof engine.Texture) {
part = new engine.Sprite(item);
}
else {
part = item;
}
_this.addChild(part);
_this.parts.push(part);
if (index == 0) {
info.width = part.width;
info.height = part.height;
}
});
info.count = parts.length;
this.setViewport(0, 0);
};
LoopComponent.prototype.setupOnce = function (resArr) {
this.setup(resArr, this.onceInfo);
};
LoopComponent.prototype.setupLoop = function (resArr) {
this.setup(resArr, this.loopInfo);
};
LoopComponent.prototype.setViewport = function (x, y) {
if (y === void 0) { y = 0; }
var sizeField = y == 0 ? 'width' : 'height';
var posField = y == 0 ? 'x' : 'y';
var pos = y == 0 ? x : y;
var index;
var onceSize = this.onceInfo[sizeField];
var onceCount = this.onceInfo.count;
var loopCount = this.loopInfo.count;
var loopSize = this.loopInfo[sizeField];
index = onceSize == 0 ? -1 : Math.floor(pos / onceSize);
if (index < 0 || index >= onceCount) {
var loopIndex = Math.floor((pos - onceCount * onceSize) / this.loopInfo[sizeField]);
index = onceCount + loopIndex;
}
var formerIndex = index < onceCount ? index : (index) % loopCount + onceCount;
var latterIndex = index < onceCount ? index + 1 : (index - onceCount + 1) % loopCount + onceCount;
var former = this.parts[formerIndex];
var latter = this.parts[latterIndex];
if (!former || !latter) {
console.log(formerIndex, latterIndex);
}
former[posField] = -(pos - loopSize * (index < onceCount ? index : index - onceCount) - (index < onceCount ? 0 : onceCount * onceSize));
latter[posField] = former.x + (index < onceCount ? onceSize : loopSize);
};
return LoopComponent;
}(engine.Container));
//# sourceMappingURL=LoopComponent.js.map
var Background = (function (_super) {
tslib.__extends(Background, _super);
function Background() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.partRes = ['bg_far', 'bg_mid', 'bg_near'];
_this.speeds = [0.05, 0.5, 1];
return _this;
}
Background.prototype.setup = function () {
var bottomBg = new engine.Rect();
bottomBg.x = 0;
bottomBg.y = 0;
bottomBg.width = getStage().width;
bottomBg.height = 0;
bottomBg.fillColor = 0x75c9f5;
this.addChild(bottomBg);
var parts = [];
for (var i = 0; i < 3; i++) {
var part = new LoopComponent();
part.setupLoop([
this.partRes[i],
this.partRes[i],
]);
parts.push(part);
this.addChild(part);
}
var height = getStage().height;
parts[0].y = (height - parts[0].height) / 2 - 400;
parts[1].y = (height - parts[1].height) / 2 - 120;
parts[2].y = (height - parts[2].height) / 2 + 300;
bottomBg.y = parts[2].y;
bottomBg.height = height - parts[2].y;
var moon = new engine.Sprite(getTextureByName('moon'));
moon.x = 100;
moon.y = 100;
this.addChild(moon);
};
Background.prototype.setViewport = function (pos) {
for (var i = 0; i < 3; i++) {
var part = this.getChildAt(i + 1);
var speed = this.speeds[i];
part.setViewport(pos * speed);
}
};
Background.prototype.reset = function (revive) {
};
return Background;
}(engine.Container));
//# sourceMappingURL=Background.js.map
var localWave = (function () {
function localWave() {
this._oldProperties = {};
this._t = 0;
}
localWave.prototype.init = function (target, duration, calProps, loop, autoPlay, reverse, delay, offset) {
if (calProps === void 0) { calProps = null; }
if (loop === void 0) { loop = 0; }
if (autoPlay === void 0) { autoPlay = true; }
if (reverse === void 0) { reverse = false; }
if (delay === void 0) { delay = 0; }
if (offset === void 0) { offset = 0; }
this.target = target;
this._calProps = calProps ? calProps : localWave.round;
this.duration = duration;
this.loop = loop;
this.reverse = reverse;
this.delay = delay;
this.offset = offset;
this.updateRegisterPos();
if (autoPlay) {
this.play();
}
};
localWave.prototype.updateRegisterPos = function () {
this._oldProperties.x = this.target.x;
this._oldProperties.y = this.target.y;
this._oldProperties.scaleX = this.target.scaleX;
this._oldProperties.scaleY = this.target.scaleY;
this._oldProperties.skewX = this.target.skewX;
this._oldProperties.skewY = this.target.skewY;
this._oldProperties.rotation = this.target.rotation;
this._oldProperties.alpha = this.target.alpha;
};
localWave.prototype.play = function () {
if (this._tween) {
return this._tween;
}
this._count = 0;
return this._playStep();
};
localWave.prototype._playStep = function () {
if (this.loop > 0 && this._count >= this.loop) {
this.stop();
return;
}
this._count++;
this.t = this.reverse ? Math.PI * 2 : 0;
this._tween = engine.Tween.get(this);
this._tween.wait(this.delay).to({ t: this.reverse ? 0 : Math.PI * 2 }, this.duration).call(this._playStep, this);
return this._tween;
};
Object.defineProperty(localWave.prototype, "t", {
get: function () {
return this._t;
},
set: function (value) {
if (!this.target.stage) {
return;
}
this._t = value;
var props = this._calProps.call(this, this._t + this.offset);
if (props.hasOwnProperty('x')) {
this.target.x = (props.x || 0) + this._oldProperties.x;
}
if (props.hasOwnProperty('y')) {
this.target.y = (props.y || 0) + this._oldProperties.y;
}
if (props.hasOwnProperty('sx')) {
this.target.scaleX = props.sx;
}
if (props.hasOwnProperty('sy')) {
this.target.scaleY = props.sy;
}
if (props.hasOwnProperty('skewX')) {
this.target.skewX = props.skewX;
}
if (props.hasOwnProperty('skewY')) {
this.target.skewY = props.skewY;
}
if (props.hasOwnProperty('r')) {
this.target.rotation = props.r;
}
if (props.hasOwnProperty('alpha')) {
this.target.alpha = props.alpha;
}
},
enumerable: true,
configurable: true
});
localWave.prototype.stop = function (recovery, animation, duration) {
if (recovery === void 0) { recovery = false; }
if (duration === void 0) { duration = 1000; }
if (!this._tween) {
return;
}
engine.Tween.removeTweens(this);
if (recovery) {
engine.Tween.get(this.target).to(this._oldProperties, duration);
}
this._tween = null;
};
Object.defineProperty(localWave.prototype, "playing", {
get: function () {
return this._tween != null;
},
enumerable: true,
configurable: true
});
localWave.round = function (h, t) {
return { x: Math.cos(t) * h, y: Math.sin(t) * h };
};
localWave.cos = function (h, t) {
return { x: Math.cos(t) * h, y: 0 };
};
localWave.sin = function (h, t) {
h = h || 1;
return { x: 0, y: Math.sin(t) * h };
};
localWave.rotate = function (t) {
return { r: 360 * t / Math.PI / 2 };
};
localWave.shake = function (angle, count, t) {
return { r: Math.sin(t * count) * angle };
};
localWave.breath = function (scale, t) {
return { sx: Math.sin(t) * scale + 1, sy: -Math.sin(t + Math.PI / 4) * scale + 1 };
};
localWave.zoom = function (scale, t) {
scale = scale || 0.1;
return { sx: Math.sin(t) * scale + 1, sy: Math.sin(t) * scale + 1 };
};
localWave.fade = function (base, t) {
return { alpha: (Math.sin(t) + 1) * 0.5 + base };
};
return localWave;
}());
//# sourceMappingURL=localWave.js.map
var Block = (function (_super) {
tslib.__extends(Block, _super);
function Block() {
var _this = _super.call(this) || this;
_this.bmp = new engine.Sprite();
_this.addChild(_this.bmp = new engine.Sprite());
return _this;
}
Block.prototype.reset = function (_a) {
var type = _a.type;
this.type = type;
var bmp = this.bmp;
bmp.alpha = 1;
bmp.texture = this.getBlock();
var _b = Block.configs[type], width = _b.width, off = _b.off;
bmp.x = -(off + width / 2);
bmp.y = -(bmp.height / 2);
};
Block.prototype.getBlock = function () {
return getTextureByName('block_' + this.type);
};
Block.prototype.playEffect = function () {
};
Block.prototype.playFadeOut = function () {
return this.getTweenPromise(engine.Tween.get(this.bmp)
.to({ alpha: 0 }, 100)
.to({ alpha: 1 }, 100)
.to({ alpha: 0 }, 100));
};
Block.prototype.onEffectComplete = function (event) {
this.effectResolve && this.effectResolve();
this.effectResolve = null;
};
Block.prototype.getTweenPromise = function (tween) {
return new Promise(function (resolve) {
tween.call(resolve);
});
};
Block.configs = [
{ ratio: 0.6, width: 15, off: 32, effect: '', effect_offset: { x: 0, y: 0 } },
{ ratio: 0.1, width: 10, off: 18, effect: '', effect_offset: { x: 0, y: 0 } },
{ ratio: 0.15, width: 30, off: 32, effect: '', effect_offset: { x: 0, y: 0 } },
{ ratio: 0.1, width: 86, off: 28, effect: '', effect_offset: { x: 0, y: 0 } },
{ ratio: 0.5, width: 70, off: 20, effect: '', effect_offset: { x: 0, y: -20 } },
{ ratio: 0, width: 0, off: 0, effect: '', effect_offset: { x: 0, y: 0 } },
{ ratio: 0, width: 0, off: 0, effect: '', effect_offset: { x: 0, y: 0 } },
{ ratio: 0, width: 0, off: 0, effect: '', effect_offset: { x: 0, y: 0 } },
{ ratio: 0, width: 0, off: 0, effect: '', effect_offset: { x: 0, y: 0 } },
{ ratio: 0, width: 0, off: 0, effect: '', effect_offset: { x: 0, y: 0 } },
{ ratio: 0, width: 123, off: 23, effect: '', effect_offset: { x: 0, y: 0 } },
];
return Block;
}(engine.Container));
//# sourceMappingURL=Block.js.map
var ObjectPool = engine.ObjectPool;
var Road = (function (_super) {
tslib.__extends(Road, _super);
function Road() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.dustIndex = 0;
_this.index = 0;
_this.minDistance = parseInt(props.blockMinDistance) || 100;
_this.maxDistance = parseInt(props.blockMaxDistance) || 300;
_this.basePos = getStage().width / 2 - 100;
_this.padding = 500;
return _this;
}
Road.prototype.preSetup = function () {
this.addChild(this.container = new engine.Container());
var flag = this.flag = new engine.Sprite(getTextureByName('flag_record'));
this.anchorRate(flag, 0.5, 1);
flag.y = -230;
flag.x = this.transScoreToFlagPos();
flag.visible = flag.x > 0;
this.addChild(flag);
};
Road.prototype.setup = function () {
this.dustNode = new engine.Container();
this.dustSprite = new engine.Sprite();
this.dustSprite.visible = false;
this.dustNode.y = -1000;
this.dustNode.x = -450;
this.dustNode.addChild(this.dustSprite);
this.addChild(this.dustNode);
var reward = this.reward = new engine.Sprite();
reward.visible = false;
reward.y = -500;
this.addChild(reward);
this.aniReward = new localWave();
this.aniReward.init(reward, 2000, localWave.sin.bind(null, 10));
};
Road.prototype.start = function (revive) {
if (revive === void 0) { revive = false; }
if (revive) ;
else {
this.rewardIndex = 0;
this.showReward();
}
};
Road.prototype.reset = function (revive) {
if (revive === void 0) { revive = false; }
if (!revive) {
this.index = 0;
this.lastPos = 0;
this.clear();
this.fill();
this.flag.x = this.transScoreToFlagPos();
this.flag.visible = this.flag.x > 0;
}
};
Road.prototype.anchorRate = function (target, rx, ry, width, height, resetPos) {
if (width === void 0) { width = 0; }
if (height === void 0) { height = 0; }
if (resetPos === void 0) { resetPos = true; }
if (width == 0) {
width = target.width;
}
if (height == 0) {
height = target.height;
}
if (resetPos) {
if (rx == 0) {
target.x -= target.anchorOffsetX;
}
if (ry == 0) {
target.y -= target.anchorOffsetY;
}
}
target.anchorOffsetX = width * rx;
target.anchorOffsetY = height * ry;
if (resetPos) {
if (rx > 0) {
target.x += target.anchorOffsetX;
}
if (ry > 0) {
target.y += target.anchorOffsetY;
}
}
};
Road.prototype.transScoreToFlagPos = function () {
return -1;
};
Road.prototype.clear = function () {
while (this.container.children.length > 0) {
this.removeBlockAt(0);
}
};
Road.prototype.addBlock = function () {
var type = 0, v;
if (this.index > 10) {
do {
var rv = Math.random();
v = 0;
for (var i = 0; i < 5; i++) {
v += Block.configs[i].ratio;
if (rv < v) {
type = i;
break;
}
}
} while (this.lastBlockType == type);
this.lastBlockType = type;
}
var block = ObjectPool.getObject('block', { type: type });
var width = Block.configs[type].width;
var distance = this.index == 0 ?
this.maxDistance :
this.makeRandomFloat(this.maxDistance, this.minDistance);
var pos = this.lastPos + distance;
block.x = pos;
this.container.addChild(block);
this.lastPos = pos + width;
this.index++;
};
Road.prototype.removeBlockAt = function (index) {
var block = this.container.removeChildAt(index);
ObjectPool.recycleObject('block', block);
};
Road.prototype.removeBlock = function (block) {
this.container.removeChild(block);
ObjectPool.recycleObject('block', block);
};
Road.prototype.fill = function () {
if (isNaN(this.lastPos)) {
return;
}
while (true) {
if (this.lastPos + this.x > getStage().width + this.padding) {
break;
}
this.addBlock();
}
};
Road.prototype.makeRandomFloat = function (max, min) {
if (min === void 0) { min = 0; }
return Math.random() * (max - min) + min;
};
Road.prototype.setViewport = function (pos) {
this.x = this.basePos - pos;
while (this.container.children.length > 0) {
if (this.container.getChildAt(0).x >= pos - this.padding) {
break;
}
this.removeBlockAt(0);
}
this.fill();
};
Road.prototype.showReward = function (type) {
this.rewardIndex++;
var pos = this.rewardIndex * getStage().width * 3;
var reward = this.reward;
reward.visible = true;
reward.alpha = 1;
reward.texture = getTextureByName('menu_block_10');
reward.x = pos;
this.aniReward.updateRegisterPos();
};
Road.prototype.hideReward = function () {
var _this = this;
var reward = this.reward;
this.tweenReward = engine.Tween.get(reward)
.to({ alpha: 0 }, 200)
.call(function () {
_this.tweenReward = null;
_this.showReward();
});
};
Road.prototype.hitReward = function (pos) {
if (this.reward.visible && pos >= this.reward.x && !this.tweenReward) {
this.hideReward();
return true;
}
};
Road.prototype.playDust = function (pos) {
this.dustSprite.x = pos;
this.dustSprite.visible = true;
this.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);
};
Road.prototype.onEnterFrame = function () {
if (this.dustIndex < 12) {
this.dustSprite.texture = getTextureByName('dust_' + this.dustIndex);
this.dustIndex++;
}
else {
this.dustIndex = 0;
this.dustSprite.visible = false;
this.removeEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);
}
};
Road.prototype.hitBlock = function (pos) {
var _this = this;
var target, lastTarget;
var foot = { a: pos - 84 / 2, b: pos + 84 / 2 };
this.container.children.some(function (block, i) {
var width = Block.configs[block.type].width;
var line = { a: block.x - width / 2, b: block.x + width / 2 };
if (_this.lineHitTest(foot, line)) {
target = block;
return true;
}
});
if (!target) {
for (var i = this.container.children.length; i > 0; i--) {
var block = this.container.getChildAt(i - 1);
if (block.x < pos) {
lastTarget = block;
break;
}
}
}
return {
target: target,
lastTarget: lastTarget,
};
};
Road.prototype.lineHitTest = function (l0, l1) {
return l0.a < l1.b && l0.b > l1.a;
};
return Road;
}(engine.Container));
//# sourceMappingURL=Road.js.map
var factor = 10;
var Head = (function (_super) {
tslib.__extends(Head, _super);
function Head() {
var _this = _super.call(this) || this;
_this.imgFace = new engine.Sprite(getTextureByName('head_0'));
_this.addChild(_this.imgFace);
_this.imgFace.anchorTexture.set(107 / _this.imgFace.width, 155 / _this.imgFace.height);
_this.imgFace.y = 65;
_this._headType = '';
return _this;
}
Head.prototype.localUpdate = function (x, y, rotation, sleeping) {
this.x = x;
this.y = y;
this.rotation = rotation;
};
Object.defineProperty(Head.prototype, "fWidth", {
get: function () {
return this.width / factor;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Head.prototype, "fHeight", {
get: function () {
return this.height / factor;
},
enumerable: true,
configurable: true
});
Head.prototype.switchFace = function (type, playAni) {
if (type == this._headType) {
return;
}
var headName = '';
if (type == 'normal') {
headName = 'head_0';
}
else if (type == 'happy') {
headName = 'head_1';
}
else if (type == 1 || type == 0 || type == 2) {
headName = 'head_2';
}
else if (type == 3) {
headName = 'head_3';
}
else if (type == 4) {
headName = 'head_4';
}
this._headType = type;
this.imgFace.texture = getTextureByName(headName);
};
return Head;
}(engine.Container));
//# sourceMappingURL=Head.js.map
var PlayerPart = (function (_super) {
tslib.__extends(PlayerPart, _super);
function PlayerPart(name) {
var _this = _super.call(this) || this;
_this.changeRes(name);
return _this;
}
PlayerPart.prototype.changeRes = function (name) {
this.name = name;
this.texture = getTextureByName('body_normal_' + name);
};
PlayerPart.prototype.setSkin = function (name) {
this.texture = getTextureByName('body_' + name + '_' + this.name);
};
PlayerPart.prototype.localUpdate = function (x, y, rotation, sleeping) {
this.x = x;
this.y = y;
this.rotation = rotation;
};
Object.defineProperty(PlayerPart.prototype, "fSize", {
get: function () {
return { width: this.fWidth, height: this.fHeight };
},
enumerable: true,
configurable: true
});
Object.defineProperty(PlayerPart.prototype, "fWidth", {
get: function () {
return this.width / getfactor();
},
enumerable: true,
configurable: true
});
Object.defineProperty(PlayerPart.prototype, "fHeight", {
get: function () {
return this.height / getfactor();
},
enumerable: true,
configurable: true
});
PlayerPart.prototype.reset = function () {
};
return PlayerPart;
}(engine.Sprite));
//# sourceMappingURL=PlayerPart.js.map
var PlayerStat;
(function (PlayerStat) {
PlayerStat[PlayerStat["RELEASE"] = 0] = "RELEASE";
PlayerStat[PlayerStat["RISING"] = 1] = "RISING";
PlayerStat[PlayerStat["FALL"] = 2] = "FALL";
})(PlayerStat || (PlayerStat = {}));
var Player = (function (_super) {
tslib.__extends(Player, _super);
function Player() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.partMass = 0.1;
_this.footMass = 0.1;
_this.shouldersDistance = 50 / getfactor();
_this.speed = 30;
_this.skin = '';
_this.originPos = {};
_this.safePos = 0;
_this.onPostStep = function (e) {
var side = _this.currentSide;
var footHang = _this.foots[_this.currentSide];
var footFall = _this.foots[_this.anotherSide];
switch (_this.state) {
case PlayerStat.FALL:
break;
case PlayerStat.RISING:
var footOffset = footHang.position[0] - footFall.position[0];
var speed = _this.speed;
_this.upperLegs[side].angularVelocity = 10;
_this.upperLegs[side].velocity = [
footOffset < 0 ? speed - 10 : speed,
0
];
_this.lowerLegs[side].velocity = [
footOffset < 0 ? speed - 10 : speed,
footOffset < 0 ? 3 : 2
];
_this.head.velocity = [speed * 0.5, 20];
_this.dispatchEvent('move', {
pos: (_this.leftFoot.position[0] + _this.rightFoot.position[0]) / 2 * getfactor(),
bodyPos: _this.body.position[0] * getfactor(),
}, true);
if (footOffset > 50) {
_this.up();
}
break;
case PlayerStat.RELEASE:
_this.head.velocity = [0, 30];
break;
}
};
_this.onFootDown = function () {
var pos = _this.foots[_this.currentSide].position[0] * getfactor();
var mileage = Math.max(_this.foots[0].position[0], _this.foots[1].position[0]) * getfactor();
_this.safePos = _this.foots[_this.currentSide].position[0];
_this.dispatchEvent('foot_down', {
mileage: mileage,
pos: pos,
}, true);
};
return _this;
}
Player.prototype.setup = function (options) {
var collisionGroup = options.collisionGroup, collisionMask = options.collisionMask, world = options.world, ground = options.ground;
this.world = world;
world.on('postStep', this.onPostStep);
var bodyPartShapes = [];
var leftFootDisplay = this.createDisplay('foot');
var lowerLeftLegDisplay = this.createDisplay('lower_left_leg');
var upperLeftLegDisplay = this.createDisplay('upper_left_leg');
var rightFootDisplay = this.createDisplay('foot');
var lowerRightLegDisplay = this.createDisplay('lower_right_leg');
var upperRightLegDisplay = this.createDisplay('upper_right_leg');
var bodyDisplay = this.createDisplay('body', { x: 50, y: 0 });
var headDisplay = new Head();
var upperLeftArmDisplay = this.createDisplay('upper_left_arm');
var lowerLeftArmDisplay = this.createDisplay('lower_left_arm', { x: -20, y: 0 });
var upperRightArmDisplay = this.createDisplay('upper_right_arm');
var lowerRightArmDisplay = this.createDisplay('lower_right_arm', { x: -39, y: 0 });
var leftFootShape = new p2.Box(leftFootDisplay.fSize);
bodyPartShapes.push(leftFootShape);
this.originPos['leftFoot'] = [
-this.shouldersDistance / 2,
leftFootDisplay.fHeight / 2
];
var leftFoot = this.leftFoot = new p2.Body({
allowSleep: false,
mass: this.footMass,
position: this.originPos['leftFoot'],
});
leftFoot.displays = [leftFootDisplay];
leftFoot.addShape(leftFootShape);
var lowerLeftLegShape = new p2.Box(lowerLeftLegDisplay.fSize);
bodyPartShapes.push(lowerLeftLegShape);
this.originPos['lowerLeftLeg'] = [
-this.shouldersDistance / 2,
leftFoot.position[1] + lowerLeftLegDisplay.fHeight / 2 + 5 / getfactor()
];
var lowerLeftLeg = this.lowerLeftLeg = new p2.Body({
allowSleep: false,
mass: this.partMass,
position: this.originPos['lowerLeftLeg'],
});
lowerLeftLeg.displays = [lowerLeftLegDisplay];
lowerLeftLeg.addShape(lowerLeftLegShape);
var leftAnkleJoint = new p2.RevoluteConstraint(lowerLeftLeg, leftFoot, {
localPivotA: [0, -lowerLeftLegDisplay.fHeight / 2 + 5 / getfactor()],
localPivotB: [-leftFootDisplay.fWidth / 2 + 18 / getfactor(), 0],
});
leftAnkleJoint.setLimits(-Math.PI / 3, Math.PI / 3);
var leftFootGroundCons = this.leftFootGroundCons = new p2.RevoluteConstraint(leftFoot, ground, {
localPivotA: [0, -leftFootDisplay.fHeight / 2],
localPivotB: [leftFoot.position[0], 0],
});
leftFootGroundCons.setLimits(0, 0);
var upperLeftLegShape = new p2.Box(upperLeftLegDisplay.fSize);
bodyPartShapes.push(upperLeftLegShape);
this.originPos['upperLeftLeg'] = [
-this.shouldersDistance / 2,
lowerLeftLeg.position[1] + lowerLeftLegDisplay.fHeight / 2 + upperLeftLegDisplay.fHeight / 2 - 40 / getfactor()
];
var upperLeftLeg = this.upperLeftLeg = new p2.Body({
allowSleep: false,
mass: this.partMass,
position: this.originPos['upperLeftLeg'],
});
upperLeftLeg.displays = [upperLeftLegDisplay];
upperLeftLeg.addShape(upperLeftLegShape);
var leftKneeJoint = new p2.RevoluteConstraint(upperLeftLeg, lowerLeftLeg, {
localPivotA: [0, -upperLeftLegDisplay.fHeight / 2 + 20 / getfactor()],
localPivotB: [0, lowerLeftLegDisplay.fHeight / 2 - 20 / getfactor()],
});
leftKneeJoint.setLimits(-Math.PI, 0);
var rightFootShape = new p2.Box(rightFootDisplay.fSize);
bodyPartShapes.push(rightFootShape);
this.originPos['rightFoot'] = [
this.shouldersDistance / 2,
rightFootDisplay.fHeight / 2
];
var rightFoot = this.rightFoot = new p2.Body({
allowSleep: false,
mass: this.footMass,
position: this.originPos['rightFoot'],
});
rightFoot.displays = [rightFootDisplay];
rightFoot.addShape(rightFootShape);
var lowerRightLegShape = new p2.Box(lowerRightLegDisplay.fSize);
bodyPartShapes.push(lowerRightLegShape);
this.originPos['lowerRightLeg'] = [
this.shouldersDistance / 2,
rightFoot.position[1] + lowerRightLegDisplay.fHeight / 2 + 5 / getfactor()
];
var lowerRightLeg = this.lowerRightLeg = new p2.Body({
allowSleep: false,
mass: this.partMass,
position: this.originPos['lowerRightLeg'],
});
lowerRightLeg.displays = [lowerRightLegDisplay];
lowerRightLeg.addShape(lowerRightLegShape);
var rightAnkleJoint = new p2.RevoluteConstraint(lowerRightLeg, rightFoot, {
localPivotA: [0, -lowerRightLegDisplay.fHeight / 2 + 5 / getfactor()],
localPivotB: [-rightFootDisplay.fWidth / 2 + 18 / getfactor(), 0],
});
rightAnkleJoint.setLimits(-Math.PI / 3, Math.PI / 3);
var rightFootGroundCons = this.rightFootGroundCons = new p2.RevoluteConstraint(rightFoot, ground, {
localPivotA: [0, -rightFootDisplay.fHeight / 2],
localPivotB: [rightFoot.position[0], 0],
});
rightFootGroundCons.setLimits(0, 0);
var upperRightLegShape = new p2.Box(upperRightLegDisplay.fSize);
bodyPartShapes.push(upperRightLegShape);
this.originPos['upperRightLeg'] = [
this.shouldersDistance / 2,
lowerRightLeg.position[1] + lowerRightLegDisplay.fHeight / 2 + upperRightLegDisplay.fHeight / 2 - 40 / getfactor()
];
var upperRightLeg = this.upperRightLeg = new p2.Body({
allowSleep: false,
mass: this.partMass,
position: this.originPos['upperRightLeg'],
});
upperRightLeg.displays = [upperRightLegDisplay];
upperRightLeg.addShape(upperRightLegShape);
var rightKneeJoint = new p2.RevoluteConstraint(upperRightLeg, lowerRightLeg, {
localPivotA: [0, -upperRightLegDisplay.fHeight / 2 + 20 / getfactor()],
localPivotB: [0, lowerRightLegDisplay.fHeight / 2 - 20 / getfactor()],
});
rightKneeJoint.setLimits(-Math.PI, 0);
var bodyWidth = 120 / getfactor();
var bodyHeight = 250 / getfactor();
var bodyShape = new p2.Box({ width: bodyWidth, height: bodyHeight });
bodyPartShapes.push(bodyShape);
this.originPos['body'] = [
0,
upperRightLeg.position[1] + upperRightLegDisplay.fHeight / 2 + bodyHeight / 2 - 60 / getfactor()
];
var body = this.body = new p2.Body({
allowSleep: false,
mass: this.partMass,
position: this.originPos['body'],
});
body.displays = [bodyDisplay];
body.addShape(bodyShape);
var leftHipJoint = new p2.RevoluteConstraint(body, upperLeftLeg, {
localPivotA: [-20 / getfactor(), -bodyHeight / 2 + 30 / getfactor()],
localPivotB: [0, upperLeftLegDisplay.fHeight / 2 - 30 / getfactor()],
});
leftHipJoint.setLimits(-Math.PI / 6 * 2, Math.PI / 6 * 2);
var rightHipJoint = new p2.RevoluteConstraint(body, upperRightLeg, {
localPivotA: [-20 / getfactor(), -bodyHeight / 2 + 30 / getfactor()],
localPivotB: [0, upperRightLegDisplay.fHeight / 2 - 30 / getfactor()],
});
rightHipJoint.setLimits(-Math.PI / 6 * 2, Math.PI / 6 * 2);
var headShape = new p2.Circle({ radius: 85 / getfactor() });
bodyPartShapes.push(headShape);
this.originPos['head'] = [
0,
body.position[1] + bodyHeight / 2 + 85 / getfactor()
];
var head = this.head = new p2.Body({
allowSleep: false,
mass: this.partMass,
position: this.originPos['head'],
});
head.addShape(headShape);
head.displays = [headDisplay];
var headJoint = new p2.RevoluteConstraint(body, head, {
localPivotA: [0, bodyHeight / 2 - 10 / getfactor()],
localPivotB: [0, (-85 + 10) / getfactor()],
});
headJoint.setLimits(-Math.PI / 6 * 2, Math.PI / 6 * 2);
var upperLeftArmShape = new p2.Box(upperLeftArmDisplay.fSize);
bodyPartShapes.push(upperLeftArmShape);
this.originPos['upperLeftArm'] = [
-this.shouldersDistance / 2 - 10 / getfactor(),
body.position[1] + bodyHeight / 2 - upperLeftArmDisplay.fHeight / 2
];
var upperLeftArm = this.upperLeftArm = new p2.Body({
allowSleep: false,
mass: this.partMass,
position: this.originPos['upperLeftArm'],
});
upperLeftArm.displays = [upperLeftArmDisplay];
upperLeftArm.addShape(upperLeftArmShape);
var leftShoulderJoint = new p2.RevoluteConstraint(body, upperLeftArm, {
localPivotA: [-this.shouldersDistance / 2 + 10 / getfactor(), bodyHeight / 2],
localPivotB: [0, upperLeftArmDisplay.fHeight / 2],
});
leftShoulderJoint.setLimits(-Math.PI / 2, 0);
var width = 50 / getfactor();
var lowerLeftArmShape = new p2.Box({ width: width, height: lowerLeftArmDisplay.fHeight });
bodyPartShapes.push(lowerLeftArmShape);
this.originPos['lowerLeftArm'] = [
-this.shouldersDistance / 2 - 10 / getfactor() + 10 / getfactor(),
upperLeftArm.position[1] - upperLeftArmDisplay.fHeight / 2 - lowerLeftArmDisplay.fHeight / 2 + 20 / getfactor()
];
var lowerLeftArm = this.lowerLeftArm = new p2.Body({
allowSleep: false,
mass: this.partMass,
position: this.originPos['lowerLeftArm'],
});
lowerLeftArm.displays = [lowerLeftArmDisplay];
lowerLeftArm.addShape(lowerLeftArmShape);
var leftElbowJoint = new p2.RevoluteConstraint(upperLeftArm, lowerLeftArm, {
localPivotA: [0, -upperLeftArmDisplay.fHeight / 2 + 10 / getfactor()],
localPivotB: [-10 / getfactor(), lowerLeftLegDisplay.fHeight / 2 - 10 / getfactor()],
});
leftElbowJoint.setLimits(0, Math.PI * 2 / 3);
var upperRightArmShape = new p2.Box(upperRightArmDisplay.fSize);
bodyPartShapes.push(upperRightArmShape);
this.originPos['upperRightArm'] = [
this.shouldersDistance / 2,
body.position[1] + bodyHeight / 2 - upperRightArmDisplay.fHeight / 2
];
var upperRightArm = this.upperRightArm = new p2.Body({
allowSleep: false,
mass: this.partMass,
position: this.originPos['upperRightArm'],
});
upperRightArm.displays = [upperRightArmDisplay];
upperRightArm.addShape(upperRightArmShape);
var rightShoulderJoint = new p2.RevoluteConstraint(body, upperRightArm, {
localPivotA: [this.shouldersDistance / 2 + 10 / getfactor(), bodyHeight / 2],
localPivotB: [0, upperRightArmDisplay.fHeight / 2],
});
rightShoulderJoint.setLimits(-Math.PI / 2, 0);
var width = 30 / getfactor();
var lowerRightArmShape = new p2.Box({ width: width, height: lowerRightArmDisplay.fHeight });
bodyPartShapes.push(lowerRightArmShape);
this.originPos['lowerRightArm'] = [
this.shouldersDistance / 2,
upperRightArm.position[1] - upperRightArmDisplay.fHeight / 2 - lowerRightArmDisplay.fHeight / 2 + 40 / getfactor()
];
var lowerRightArm = this.lowerRightArm = new p2.Body({
allowSleep: false,
mass: this.partMass,
position: this.originPos['lowerRightArm'],
});
lowerRightArm.displays = [lowerRightArmDisplay];
lowerRightArm.addShape(lowerRightArmShape);
var rightElbowJoint = new p2.RevoluteConstraint(upperRightArm, lowerRightArm, {
localPivotA: [0, -upperRightArmDisplay.fHeight / 2 + 20 / getfactor()],
localPivotB: [0, lowerRightLegDisplay.fHeight / 2 - 20 / getfactor()],
});
rightElbowJoint.setLimits(0, Math.PI * 2 / 3);
var bodies = [
lowerRightArm, upperRightArm,
lowerRightLeg, upperRightLeg, rightFoot,
body,
lowerLeftLeg, upperLeftLeg, leftFoot,
lowerLeftArm, upperLeftArm,
head,
];
bodies.forEach(function (body) {
world.addBody(body);
});
var joints = [
leftAnkleJoint,
leftKneeJoint,
rightAnkleJoint,
rightKneeJoint,
headJoint,
leftHipJoint,
rightHipJoint,
leftShoulderJoint,
leftElbowJoint,
rightShoulderJoint,
rightElbowJoint,
leftFootGroundCons,
rightFootGroundCons,
];
joints.forEach(function (joint) {
world.addConstraint(joint);
});
for (var i = 0; i < bodyPartShapes.length; i++) {
var s = bodyPartShapes[i];
s.collisionGroup = collisionGroup;
s.collisionMask = collisionMask;
}
this.foots = [leftFoot, rightFoot];
this.lowerLegs = [lowerLeftLeg, lowerRightLeg];
this.upperLegs = [upperLeftLeg, upperRightLeg];
this.footGroundCons = [leftFootGroundCons, rightFootGroundCons];
};
Player.prototype.reset = function (revive) {
var _this = this;
if (revive === void 0) { revive = false; }
if (revive) ;
else {
this.step = -1;
this.safePos = 0;
[
'lowerLeftLeg',
'upperLeftLeg',
'lowerRightLeg',
'upperRightLeg',
'body',
'head',
'upperLeftArm',
'lowerLeftArm',
'upperRightArm',
'lowerRightArm',
].forEach(function (partName) {
var part = _this[partName];
part.position[0] = _this.safePos + _this.originPos[partName][0];
});
}
for (var i = 0; i < 2; i++) {
var cons = this.footGroundCons[i];
cons.pivotB[0] = this.foots[i].position[0] = this.safePos + (i == 0 ? -1 : 1) * this.shouldersDistance / 2;
if (this.state == PlayerStat.FALL) {
this.world.addConstraint(cons);
}
}
this.switchFace('normal', false);
this.setSkin('normal');
this.state = PlayerStat.RELEASE;
};
Player.prototype.createDisplay = function (resName, offset) {
if (offset === void 0) { offset = null; }
var bmp = new PlayerPart(resName);
var anchorX = bmp.width / 2 + (offset ? offset.x : 0);
var anchorY = bmp.height / 2 + (offset ? offset.y : 0);
bmp.anchorTexture.set(anchorX / bmp.width, anchorY / bmp.height);
return bmp;
};
Object.defineProperty(Player.prototype, "currentSide", {
get: function () {
return this.step % 2;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Player.prototype, "anotherSide", {
get: function () {
return (this.step + 1) % 2;
},
enumerable: true,
configurable: true
});
Player.prototype.down = function () {
if (this.state == PlayerStat.RISING) {
return;
}
this.step++;
var cons = this.footGroundCons[this.currentSide];
this.world.removeConstraint(cons);
this.state = PlayerStat.RISING;
};
Player.prototype.up = function () {
if (this.state == PlayerStat.RELEASE) {
return;
}
var side = this.currentSide;
this.foots[side].velocity = [0, 0];
this.body.velocity = [0, 0];
var currentFoot = this.foots[side];
var cons = this.footGroundCons[side];
cons.pivotB[0] = currentFoot.position[0];
this.world.addConstraint(cons);
this.state = PlayerStat.RELEASE;
setTimeout(this.onFootDown, 200);
};
Player.prototype.fall = function () {
this.body.velocity = [0, -30];
this.head.velocity = [-50, -50];
this.world.removeConstraint(this.footGroundCons[0]);
this.world.removeConstraint(this.footGroundCons[1]);
this.foots[this.currentSide].velocity[0] = 60;
this.foots[this.anotherSide].velocity[0] = 70;
this.state = PlayerStat.FALL;
};
Player.prototype.switchFace = function (type, playAni) {
if (playAni === void 0) { playAni = true; }
var headDisplay = this.head.displays[0];
headDisplay.switchFace(type, playAni);
};
Player.prototype.setSkin = function (name) {
var _this = this;
if (this.skin == name) {
return;
}
this.skin = name;
[
'leftFoot',
'lowerLeftLeg',
'upperLeftLeg',
'rightFoot',
'lowerRightLeg',
'upperRightLeg',
'body',
'upperLeftArm',
'lowerLeftArm',
'upperRightArm',
'lowerRightArm',
].forEach(function (partName) {
var part = _this[partName];
part.displays[0].setSkin(name);
});
};
Player.prototype.fade = function (alpha, animation) {
var _this = this;
if (animation === void 0) { animation = true; }
[
'leftFoot',
'lowerLeftLeg',
'upperLeftLeg',
'rightFoot',
'lowerRightLeg',
'upperRightLeg',
'body',
'head',
'upperLeftArm',
'lowerLeftArm',
'upperRightArm',
'lowerRightArm',
].forEach(function (partName) {
var display = _this[partName].displays[0];
if (animation) {
engine.Tween.get(display, null, null, true)
.to({ alpha: alpha }, 200);
}
else {
display.alpha = alpha;
}
});
};
return Player;
}(engine.EventDispatcher));
//# sourceMappingURL=Player.js.map
var ObjectPool$1 = engine.ObjectPool;
var PoolName = 'block';
ObjectPool$1.registerPool(PoolName, function () {
return new Block();
}, function (item, data) {
item.reset(data);
});
var GameView = (function (_super) {
tslib.__extends(GameView, _super);
function GameView() {
var _this = _super.call(this) || this;
_this.offset = { x: -100, y: 320 };
_this.worldFPS = 60;
_this._viewport = {
x: 0,
y: 0,
};
return _this;
}
Object.defineProperty(GameView, "instance", {
get: function () {
if (this._instance == undefined) {
this._instance = new GameView();
}
return this._instance;
},
enumerable: true,
configurable: true
});
GameView.prototype.eventStart = function () {
var _this = this;
if (this.hasPreSetup) {
return;
}
this.hasPreSetup = true;
var background = this.background = new Background();
background.setup();
this.addChild(background);
var road = this.road = new Road();
road.y = getStage().height / 2 + 310;
this.addChild(road);
this.road.preSetup();
this.setupWorld();
this.player.fade(0, false);
this.viewport = 0;
this.startWorld();
this.reset();
this.setup();
var playHint = new engine.Label();
playHint.fillColor = 'block';
playHint.size = 30;
playHint.text = '注意不要踩到线和陷阱哦,后果很严重哦~';
playHint.x = (getStage().width - playHint.width) / 2;
playHint.y = getStage().height / 2 + 500;
this.addChild(playHint);
this.playGame = new PlayGame();
setTimeout(function () {
_this.playGame.GameView = _this;
_this.addChild(_this.playGame);
_this.start();
}, 500);
};
GameView.prototype.setup = function () {
if (this.hasSetup) {
return;
}
this.hasSetup = true;
this.road.setup();
};
GameView.prototype.setupWorld = function () {
var OTHER = Math.pow(2, 1), BODYPARTS = Math.pow(2, 2), GROUND = Math.pow(2, 3);
var world = this.world = new p2.World({});
world.sleepMode = p2.World.BODY_SLEEPING;
var planeShape = new p2.Plane();
var ground = new p2.Body({
position: [0, 0],
});
ground.addShape(planeShape);
planeShape.collisionGroup = GROUND;
planeShape.collisionMask = BODYPARTS | OTHER;
world.addBody(ground);
var player = this.player = new Player();
player.setup({
collisionGroup: BODYPARTS,
collisionMask: GROUND | OTHER,
world: world,
ground: ground,
});
player.addEventListener('move', this.onMove, this);
player.addEventListener('foot_down', this.onFootDown, this);
};
GameView.prototype.onTicker = function (dt) {
var world = this.world;
this.world.step(this.worldFPS / 1000);
var l = world.bodies.length;
for (var i = 0; i < l; i++) {
var body = world.bodies[i];
var display = body.displays ? body.displays[0] : null;
if (display) {
if (!this.contains(display)) {
this.addChild(display);
}
display.localUpdate(body.position[0] * getfactor() + getStage().width / 2 + this.offset.x - this.viewport, getStage().height / 2 - body.position[1] * getfactor() + this.offset.y, 360 - (body.angle + body.shapes[0].angle) * 180 / Math.PI, body.sleepState == p2.Body.SLEEPING);
}
}
return false;
};
GameView.prototype.reset = function (revive) {
if (revive === void 0) { revive = false; }
this.background.reset(revive);
this.road.reset(revive);
this.player.reset(revive);
this.player.fade(0);
this.viewport = revive ? this.revivePos : 0;
};
GameView.prototype.start = function (revive) {
if (revive === void 0) { revive = false; }
this.road.start(revive);
this.player.fade(1);
this.playGame.start(revive);
};
GameView.prototype.startWorld = function () {
if (this.playing) {
return;
}
this.playing = true;
engine.gameStage.addEventListener(engine.Event.ENTER_FRAME, this.onTicker, this);
};
GameView.prototype.stopWorld = function () {
if (!this.playing) {
return;
}
this.playing = false;
engine.gameStage.removeEventListener(engine.Event.ENTER_FRAME, this.onTicker, this);
};
Object.defineProperty(GameView.prototype, "viewport", {
get: function () {
return this._viewport.x;
},
set: function (v) {
this._viewport.x = v;
this.updateViewport();
},
enumerable: true,
configurable: true
});
GameView.prototype.updateViewport = function () {
var _a = this._viewport, x = _a.x, y = _a.y;
var pos = Math.max(0, x);
this.background.setViewport(pos);
this.road.setViewport(pos);
};
GameView.prototype.onMove = function (event) {
var _a = event.data, pos = _a.pos, bodyPos = _a.bodyPos;
this.viewport = pos;
if (this.road.hitReward(bodyPos)) {
this.dispatchEvent('scoreChange', {
rewardScore: 100,
passType: 10,
}, true);
}
};
GameView.prototype.down = function () {
if (this.lock) {
return;
}
this.player.down();
};
GameView.prototype.up = function () {
if (this.lock) {
return;
}
this.player.up();
};
GameView.prototype.onFootDown = function (event) {
var _a = event.data, mileage = _a.mileage, pos = _a.pos;
this.revivePos = pos;
var _b = this.road.hitBlock(pos), target = _b.target, lastTarget = _b.lastTarget;
this.road.playDust(pos);
if (target) {
this.lock = true;
this.stopWorld();
this.dispatchEvent(engine.Event.COMPLETE, null, true);
target.playFadeOut();
target.playEffect();
if (target.type == 4) {
this.player.setSkin('gray');
}
this.road.removeBlock(target);
this.player.switchFace(target.type);
if (target.type == 0) {
this.player.fall();
}
this.lock = false;
this.startWorld();
}
else {
this.player.switchFace('normal');
var score = Math.floor(mileage / 50 * 5);
this.dispatchEvent('scoreChange', {
score: score,
passType: lastTarget ? lastTarget.type : -1,
}, true);
}
};
GameView.prototype.setWitchFace = function (type) {
this.player.switchFace(type);
};
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('walking-cat-start', _this.start, _this);
engine.globalEvent.addEventListener('walking-cat-revive', _this.revive, _this);
engine.globalEvent.addEventListener('walking-cat-showScore', _this.revive, _this);
var gameView = _this._gameView = new GameView();
_this.addChild(gameView);
return _this;
}
GameWrapper.prototype.start = function (event) {
injectProps(event.data);
this._gameView.eventStart();
};
GameWrapper.prototype.revive = function () {
console.log('复活');
this._gameView.reset(true);
this._gameView.start(true);
};
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
This source diff could not be displayed because it is too large. You can view the blob instead.
/**
* Created by rockyl on 2020-01-21.
*/
let customModuleProps = {
};
{
"name": "猫步前行",
"desc": "猫步前行模块",
"props": {
"blockMinDistance": {
"alias": "障碍物最小间距",
"type": "number",
"default": 150
},
"blockMaxDistance": {
"alias": "障碍物最大间距",
"type": "number",
"default": 350
},
"maxScore": {
"alias": "最大分数",
"type": "number",
"default": 100
},
"scoreTimes": {
"alias": "时间倍率",
"type": "number",
"default": 1
},
"showScore": {
"alias": "是否显示分数",
"type": "boolean",
"default": true
}
},
"assets": [
{
"name": "bg_far",
"url": "//yun.duiba.com.cn/aurora/assets/88b99a184b1d91ec207c3899da4e33d204d85849.jpg",
"uuid": "755ce179-ea64-4723-b86f-d75fec134578",
"ext": ".jpg"
},
{
"name": "bg_mid",
"url": "//yun.duiba.com.cn/aurora/assets/8422a19eddca5948b779efe47248db8a742f5714.png",
"uuid": "41c5721d-cb13-4f31-9dce-29c3ff115897",
"ext": ".png"
},
{
"name": "bg_near",
"url": "//yun.duiba.com.cn/aurora/assets/30653d0b47998d7413c5d767dcff605a4174cedd.jpg",
"uuid": "bab097bf-c891-4bda-9c2f-5ee752480841",
"ext": ".jpg"
},
{
"name": "moon",
"url": "//yun.duiba.com.cn/aurora/assets/0361ea50ed4716a99f8a76581edc7223d21bd62a.png",
"uuid": "97d31833-f9f0-4eb0-ab01-d9c8576e0f02",
"ext": ".png"
},
{
"name": "block_0",
"url": "//yun.duiba.com.cn/aurora/assets/e01d62022b585d5255b54f0dad936da4463118d3.png",
"uuid": "0feae6ef-3b0d-484c-be13-2fc10627e2fe",
"ext": ".png"
},
{
"name": "block_1",
"url": "//yun.duiba.com.cn/aurora/assets/5a70669941b6d0f503e8e9aa76e68f95d599ec99.png",
"uuid": "c5e5a381-bbe4-4dc1-8818-f089bb6f9c61",
"ext": ".png"
},
{
"name": "block_2",
"url": "//yun.duiba.com.cn/aurora/assets/24c974c21131b590891c6fb7ec72b9539a864588.png",
"uuid": "585ea53f-fdf3-463f-917e-d6b8cd96c499",
"ext": ".png"
},
{
"name": "block_3",
"url": "//yun.duiba.com.cn/aurora/assets/c2412641cd12f00b033cca5f2dafee7470559b60.png",
"uuid": "74f67ccc-95ec-4580-886d-0b4e187d0774",
"ext": ".png"
},
{
"name": "block_4",
"url": "//yun.duiba.com.cn/aurora/assets/9dbf27eed32fdbfce72eabd0c04aed1e3f42fe22.png",
"uuid": "a169afaa-08fd-4c5a-925b-be382f4ec9dc",
"ext": ".png"
},
{
"name": "flag_record",
"url": "//yun.duiba.com.cn/aurora/assets/53a59eb76dfb45099da4f240b86d15828749f0e8.png",
"uuid": "8c9f66a6-9748-455d-83c6-5ce6a55fbed2",
"ext": ".png"
},
{
"name": "dust_0",
"url": "//yun.duiba.com.cn/aurora/assets/b6719afed81d25b73cb112019d723134ca13df7c.png",
"uuid": "d2a3e515-f4c3-4090-9ec2-10937c5b2cbe",
"ext": ".png"
},
{
"name": "dust_1",
"url": "//yun.duiba.com.cn/aurora/assets/8be3c18b1c1119f6e40b9155aad8b26061cb47b3.png",
"uuid": "fe3b9f95-3df2-4026-9497-67dad642136e",
"ext": ".png"
},
{
"name": "dust_2",
"url": "//yun.duiba.com.cn/aurora/assets/3e98b389b933baa5f50bf2e8d342e000ce575fb7.png",
"uuid": "a07f4696-a682-4729-91e4-02f7141a49c8",
"ext": ".png"
},
{
"name": "dust_3",
"url": "//yun.duiba.com.cn/aurora/assets/0ad9f8a2b2d567d6452903023f7c549fd870d075.png",
"uuid": "3a0254c7-3b74-43a9-9abd-7637fc283dd5",
"ext": ".png"
},
{
"name": "dust_4",
"url": "//yun.duiba.com.cn/aurora/assets/8180658a2ac225d899794c4251b870688dcd1859.png",
"uuid": "0026bd07-8e2a-41d0-8953-1de2f99d7661",
"ext": ".png"
},
{
"name": "dust_5",
"url": "//yun.duiba.com.cn/aurora/assets/db20fa6912a19d65bc958d31f09c0757cf9b806c.png",
"uuid": "761f766b-15b2-4334-a920-1c8de8e25cd0",
"ext": ".png"
},
{
"name": "dust_6",
"url": "//yun.duiba.com.cn/aurora/assets/4ddbc7683055eaa1550ffc753c919fcbd649e08b.png",
"uuid": "36b1721f-659c-4b97-8468-604ea33e27a5",
"ext": ".png"
},
{
"name": "dust_7",
"url": "//yun.duiba.com.cn/aurora/assets/384b4da951496703bf95f007ffcad02203973cc5.png",
"uuid": "5359045c-9e8a-4324-bf15-df793559bfaa",
"ext": ".png"
},
{
"name": "dust_8",
"url": "//yun.duiba.com.cn/aurora/assets/5a0674b72b1932581ce09f993141ecc2ac86e9be.png",
"uuid": "04e0b191-393b-4705-9594-0af37e0e869b",
"ext": ".png"
},
{
"name": "dust_9",
"url": "//yun.duiba.com.cn/aurora/assets/faa629cb99a8c6996919f7c979c111373f0b8920.png",
"uuid": "ca81348a-1a4b-49d9-9e0a-0e19b5d2c887",
"ext": ".png"
},
{
"name": "dust_10",
"url": "//yun.duiba.com.cn/aurora/assets/ea6d57192dc436a50e934548cba53885bcfe5b26.png",
"uuid": "3b57c024-0272-4d4e-a857-16e31ec26c2d",
"ext": ".png"
},
{
"name": "dust_11",
"url": "//yun.duiba.com.cn/aurora/assets/b8bacf81393af61e42fc298e11f27eab4b946881.png",
"uuid": "d751c409-14fb-444e-b352-63244868c43a",
"ext": ".png"
},
{
"name": "menu_block_10",
"url": "//yun.duiba.com.cn/aurora/assets/995c15e67de28088ccc6a5cabf270f8e8ef22415.png",
"uuid": "5b6845de-bd5e-4bfa-b4a4-d2b8f6166ad6",
"ext": ".png"
},
{
"name": "body_normal_body",
"url": "//yun.duiba.com.cn/aurora/assets/2a19cc08e72d78d0287ce30c7dfb4b695371c8ba.png",
"uuid": "20f22f45-d558-4332-a0d5-212ae1a256e5",
"ext": ".png"
},
{
"name": "body_normal_foot",
"url": "//yun.duiba.com.cn/aurora/assets/27716e26f91252735ba1e071f0ced93b9aee4182.png",
"uuid": "34cf1f23-e70c-4c19-9e37-2de4de693fcf",
"ext": ".png"
},
{
"name": "body_normal_lower_left_arm",
"url": "//yun.duiba.com.cn/aurora/assets/4197679b407e24e892f7749488f1b8062d712a35.png",
"uuid": "b62a99b0-bff3-4b44-97bd-fe606502d3e7",
"ext": ".png"
},
{
"name": "body_normal_lower_left_leg",
"url": "//yun.duiba.com.cn/aurora/assets/4abc68dea6205eb070460b31dc289144509cfadd.png",
"uuid": "dceb7805-b91b-44c9-b9d8-eea72565810f",
"ext": ".png"
},
{
"name": "body_normal_lower_right_arm",
"url": "//yun.duiba.com.cn/aurora/assets/4f3a8fb6f567b1d0c425673a6790585fae3372ee.png",
"uuid": "dd3b9db5-14d5-4d8f-831e-d6f854ef97d0",
"ext": ".png"
},
{
"name": "body_normal_lower_right_leg",
"url": "//yun.duiba.com.cn/aurora/assets/0e05af056b9df883e3a281322c16a95e24f2ee51.png",
"uuid": "b6524f1f-8d94-435e-84c9-b9bb7c691119",
"ext": ".png"
},
{
"name": "body_normal_upper_left_arm",
"url": "//yun.duiba.com.cn/aurora/assets/67da6919e38eddf06d8f61ea77a8ca4f264cfe8a.png",
"uuid": "40b913a7-fe43-479d-b796-1bc337ab2f4a",
"ext": ".png"
},
{
"name": "body_normal_upper_left_leg",
"url": "//yun.duiba.com.cn/aurora/assets/2f3b13a48a873161a0d620f761efc830ec3da9e1.png",
"uuid": "e98509e0-704e-4ac3-9770-3bffd7ee0ef4",
"ext": ".png"
},
{
"name": "body_normal_upper_right_arm",
"url": "//yun.duiba.com.cn/aurora/assets/8587e14a8b7d2e57f8b93f8e558d511a5d5e0b54.png",
"uuid": "c58ce0c9-1540-4595-b22a-64f6e48d913a",
"ext": ".png"
},
{
"name": "body_normal_upper_right_leg",
"url": "//yun.duiba.com.cn/aurora/assets/a459a6ea09d0b69b5f85df504df34457b1ec8760.png",
"uuid": "fe81c45d-a4ea-4f11-aa0c-5afa5c1a24dc",
"ext": ".png"
},
{
"name": "head_0",
"url": "//yun.duiba.com.cn/aurora/assets/54f4cabcad3c0d297c1786ea74529cce274bfdce.png",
"uuid": "88bdda7e-9af3-4e98-ae7f-da4d53ab42d2",
"ext": ".png"
},
{
"name": "head_1",
"url": "//yun.duiba.com.cn/aurora/assets/abfe9be652673e7c0bc761b36775e6b3d0c66aff.png",
"uuid": "e7beb90a-13d2-4504-a88b-5aa6c53f5c9b",
"ext": ".png"
},
{
"name": "head_2",
"url": "//yun.duiba.com.cn/aurora/assets/5ea8fe57ab6d1ff0a796431550b49bce3ddd41d2.png",
"uuid": "4975457c-12c2-49c2-893d-fdf40c1fef94",
"ext": ".png"
},
{
"name": "head_3",
"url": "//yun.duiba.com.cn/aurora/assets/0f0850f184c6ca6f7e7add61d43b8adf16dd43f4.png",
"uuid": "47db2073-4f14-43ee-afca-1e98188cd169",
"ext": ".png"
},
{
"name": "head_4",
"url": "//yun.duiba.com.cn/aurora/assets/426a5773e6781c3f287bb0a01561014848055602.png",
"uuid": "7d7dea57-26ee-488e-b928-78c0e4f21baf",
"ext": ".png"
},
{
"name": "head_bird",
"url": "//yun.duiba.com.cn/aurora/assets/022f41d77464df1edeca7fcc4c235ec8c8081743.png",
"uuid": "4d8b2438-0d62-47fd-9971-7766e63a9283",
"ext": ".png"
},
{
"name": "head_heart",
"url": "//yun.duiba.com.cn/aurora/assets/29f401553ae6a1cac70e3eb9f2ced4af4563e6d9.png",
"uuid": "b7918a78-18ee-4a98-8fd2-c5ea1d74f80b",
"ext": ".png"
},
{
"name": "head_smoke",
"url": "//yun.duiba.com.cn/aurora/assets/562d44364589ea6cd6354d15a7ad5e19bf9229e2.png",
"uuid": "8921ea9f-f618-45d2-b2ce-99540a9455f4",
"ext": ".png"
},
{
"name": "dialog_0",
"url": "//yun.duiba.com.cn/aurora/assets/f742f6a3ecd6664059e37aa6ae901b059a6da2b0.png",
"uuid": "5f6ef454-634e-4663-8591-de8a383f629e",
"ext": ".png"
},
{
"name": "dialog_1",
"url": "//yun.duiba.com.cn/aurora/assets/ca5d41083614b91f0a3b0d140ec247f4c7121f1d.png",
"uuid": "c64a2e5a-197c-486a-8d7a-245cf3f3d0c9",
"ext": ".png"
},
{
"name": "body_gray_body",
"url": "//yun.duiba.com.cn/aurora/assets/1a68b3195fd3568d9b31e3ff87a3721c321a0d74.png",
"uuid": "1ad192ec-0412-4120-af19-015134a5dbf1",
"ext": ".png"
},
{
"name": "body_gray_foot",
"url": "//yun.duiba.com.cn/aurora/assets/c4c3584c49d77878fd76b357d9b11aac9a1377e8.png",
"uuid": "2af600c6-4bfb-4870-89b5-27d1cb25088d",
"ext": ".png"
},
{
"name": "body_gray_lower_left_arm",
"url": "//yun.duiba.com.cn/aurora/assets/f188548ec71fc93b62c39d53d374c518b97c4f33.png",
"uuid": "c591459e-781f-4114-b020-66678eb572fe",
"ext": ".png"
},
{
"name": "body_gray_lower_left_leg",
"url": "//yun.duiba.com.cn/aurora/assets/fb085cf0df30bbaa4f615a438a1099fcf8c9e301.png",
"uuid": "1c2153bb-3639-4d89-8cf3-0a88656bf23a",
"ext": ".png"
},
{
"name": "body_gray_lower_right_arm",
"url": "//yun.duiba.com.cn/aurora/assets/4af5042462d46a168704614cd3a4f3b171fc15a3.png",
"uuid": "7c838ff5-d21f-4f10-9967-1d361c6755e0",
"ext": ".png"
},
{
"name": "body_gray_lower_right_leg",
"url": "//yun.duiba.com.cn/aurora/assets/da576541165b14d775f115db3c280737ee9ecf0a.png",
"uuid": "71bf4fb3-6ca0-4738-85f0-4662ea99aa05",
"ext": ".png"
},
{
"name": "body_gray_upper_left_arm",
"url": "//yun.duiba.com.cn/aurora/assets/6680f484a38c27f88978c08c868f400ba9649402.png",
"uuid": "109aedfe-5b12-43ec-b6c8-272f0ad68454",
"ext": ".png"
},
{
"name": "body_gray_upper_left_leg",
"url": "//yun.duiba.com.cn/aurora/assets/29037e47c3d44e656dcb89cca718e91f9689324d.png",
"uuid": "6f8ac4a2-323e-4c8f-98b0-a85ea1c6f3e1",
"ext": ".png"
},
{
"name": "body_gray_upper_right_arm",
"url": "//yun.duiba.com.cn/aurora/assets/ac396f21c9a494e5ed6a5c57417674bd5504ef71.png",
"uuid": "842bd78c-93bb-4500-9445-a55bfe00ae30",
"ext": ".png"
},
{
"name": "body_gray_upper_right_leg",
"url": "//yun.duiba.com.cn/aurora/assets/44ec8f17ec1470d13e78c132e6c5f790d59c93ae.png",
"uuid": "3cc57fd8-bf90-42e9-9149-3b7f5e6bceda",
"ext": ".png"
}
],
"events": {
"in": {
"walking-cat-start": {
"alias": "开始"
},
"walking-cat-revive": {
"alias": "复活"
}
},
"out": {
"walking-cat-game-end": {
"alias": "游戏结束",
"data": {
}
},
"walking-cat-game-changScore": {
"alias": "游戏分数改变",
"data": {
}
}
}
}
}
\ No newline at end of file
import {getTextureByName} from "./utils";
import {LoopComponent} from "./LoopComponent";
import {getStage} from "./utils";
import {props} from "../props";
export class Background extends engine.Container {
//static stageWidth = engine.gameStage.stage.width;
partRes = ['bg_far', 'bg_mid', 'bg_near'];
speeds = [0.05, 0.5, 1];
setup() {
let bottomBg = new engine.Rect();
bottomBg.x = 0;
bottomBg.y = 0;
bottomBg.width = getStage().width;
bottomBg.height = 0;
bottomBg.fillColor = 0x75c9f5;
this.addChild(bottomBg);
const parts = [];
for(let i = 0; i < 3; i++){
let part = new LoopComponent();
part.setupLoop([
this.partRes[i],
this.partRes[i],
]);
parts.push(part);
this.addChild(part);
}
const {height} = getStage();
parts[0].y = (height - parts[0].height) / 2 - 400;
parts[1].y = (height - parts[1].height) / 2 - 120;
parts[2].y = (height - parts[2].height) / 2 + 300;
bottomBg.y = parts[2].y;
bottomBg.height = height - parts[2].y;
const moon = new engine.Sprite(getTextureByName('moon'));
moon.x = 100;
moon.y = 100;
this.addChild(moon);
}
setViewport(pos) {
for (let i = 0; i < 3; i++) {
const part = <LoopComponent>this.getChildAt(i + 1);
const speed = this.speeds[i];
part.setViewport(pos * speed)
}
}
reset(revive = false){
}
}
/**
* 障碍物
*/
import {getStage, getTextureByName} from "./utils";
export class Block extends engine.Container {
static configs = [
{ratio: 0.6, width: 15, off: 32, effect: '', effect_offset: {x: 0, y: 0}},
{ratio: 0.1, width: 10, off: 18, effect: '', effect_offset: {x: 0, y: 0}},
{ratio: 0.15, width: 30, off: 32, effect: '', effect_offset: {x: 0, y: 0}},
{ratio: 0.1, width: 86, off: 28, effect: '', effect_offset: {x: 0, y: 0}},
{ratio: 0.5, width: 70, off: 20, effect: '', effect_offset: {x: 0, y: -20}},
{ratio: 0, width: 0, off: 0, effect: '', effect_offset: {x: 0, y: 0}},
{ratio: 0, width: 0, off: 0, effect: '', effect_offset: {x: 0, y: 0}},
{ratio: 0, width: 0, off: 0, effect: '', effect_offset: {x: 0, y: 0}},
{ratio: 0, width: 0, off: 0, effect: '', effect_offset: {x: 0, y: 0}},
{ratio: 0, width: 0, off: 0, effect: '', effect_offset: {x: 0, y: 0}},
{ratio: 0, width: 123, off: 23, effect: '', effect_offset: {x: 0, y: 0}},
];
type;
bmp;
//effectMC: engine.MovieClip;
effectResolve;
constructor() {
super();
this.bmp = new engine.Sprite();
this.addChild(this.bmp = new engine.Sprite());
}
//
reset({type,}) {
this.type = type;
let bmp = this.bmp;
bmp.alpha = 1;
bmp.texture = this.getBlock();
const {width, off} = Block.configs[type];
bmp.x = -(off + width / 2);
bmp.y = -(bmp.height / 2);
}
getBlock(){
return getTextureByName('block_' + this.type);
}
playEffect() {
//const {effect, effect_offset} = Block.configs[this.type];
// if (effect) {
// if (!this.effectMC) {
// const mc = this.effectMC = Effects.instance.makeMovieClip(effect);
// const {x, y} = effect_offset;
// mc.x = x;
// mc.y = y;
// this.addChild(mc);
// mc.addEventListener(egret.Event.COMPLETE, this.onEffectComplete, this);
// }
// this.effectMC.gotoAndPlay(0, 1);
// return new Promise(resolve => {
// this.effectResolve = resolve;
// })
// } else {
// return Promise.resolve();
// }
}
playFadeOut() {
return this.getTweenPromise(
engine.Tween.get(this.bmp)
.to({alpha: 0}, 100)
.to({alpha: 1}, 100)
.to({alpha: 0}, 100)
)
}
private onEffectComplete(event) {
this.effectResolve && this.effectResolve();
this.effectResolve = null;
}
getTweenPromise(tween: engine.Tween): Promise<any> {
return new Promise((resolve) => {
tween.call(resolve);
});
}
}
import { PlayGame } from './PlayGame';
import { Background } from "./Background";
import {Road} from './Road'
import {Player} from "./player/Player";
import {getStage,getfactor} from "./utils";
import {Block} from "./Block";
import ObjectPool = engine.ObjectPool;
export const PoolName: string = 'block';
ObjectPool.registerPool(PoolName, function () {
return new Block();
}, function (item: Block, data) {
item.reset(data);
});
export default class GameView extends engine.Container {
private static _instance: GameView;
public static get instance(): GameView {
if (this._instance == undefined) {
this._instance = new GameView();
}
return this._instance;
}
offset = {x: -100, y: 320};
background: Background;
road: Road;
playGame:PlayGame;
world: p2.World;
player: Player;
revivePos;
playing;
lock;
worldFPS = 60;
private _block:Block;
_touchEnabled;
_viewport: any = {
x: 0,
y: 0,
};
constructor() {
super();
}
hasPreSetup;
eventStart() {
if(this.hasPreSetup){
return;
}
this.hasPreSetup = true;
let background = this.background = new Background();
background.setup();
this.addChild(background);
let road = this.road = new Road();
road.y = getStage().height / 2 + 310;
this.addChild(road);
this.road.preSetup();
this.setupWorld();
this.player.fade(0, false);
this.viewport = 0;
this.startWorld();
this.reset();
this.setup();
const playHint = new engine.Label();
playHint.fillColor = 'block';
playHint.size = 30;
playHint.text = '注意不要踩到线和陷阱哦,后果很严重哦~';
playHint.x = (getStage().width-playHint.width)/2;
playHint.y = getStage().height / 2 + 500;
this.addChild(playHint);
this.playGame = new PlayGame();
setTimeout(() => {
this.playGame.GameView = this;
this.addChild(this.playGame);
this.start();
}, 500);
}
hasSetup;
setup() {
if(this.hasSetup){
return;
}
this.hasSetup = true;
this.road.setup();
}
setupWorld() {
let OTHER = Math.pow(2, 1),
BODYPARTS = Math.pow(2, 2),
GROUND = Math.pow(2, 3);
const world = this.world = new p2.World({
//gravity: [0, 0],
});
world.sleepMode = p2.World.BODY_SLEEPING;
let planeShape = new p2.Plane();
let ground = new p2.Body({
position: [0, 0],
});
ground.addShape(planeShape);
planeShape.collisionGroup = GROUND;
planeShape.collisionMask = BODYPARTS | OTHER;
world.addBody(ground);
let player = this.player = new Player();
player.setup({
collisionGroup: BODYPARTS,
collisionMask: GROUND | OTHER,
world,
ground,
});
player.addEventListener('move', this.onMove, this);
player.addEventListener('foot_down', this.onFootDown, this);
}
onTicker(dt: number): boolean {
const world = this.world;
this.world.step(this.worldFPS / 1000);
let l = world.bodies.length;
for (let i: number = 0; i < l; i++) {
let body: p2.Body = world.bodies[i];
let display: any = body.displays ? body.displays[0] : null;
if (display) {
if (!this.contains(display)) {
this.addChild(display);
}
display.localUpdate(
body.position[0] * getfactor() + getStage().width / 2 + this.offset.x - this.viewport,
getStage().height / 2 - body.position[1] * getfactor() + this.offset.y,
360 - (body.angle + body.shapes[0].angle) * 180 / Math.PI,
body.sleepState == p2.Body.SLEEPING
)
}
}
return false;
}
reset(revive = false) {
this.background.reset(revive);
this.road.reset(revive);
this.player.reset(revive);
this.player.fade(0);
// if(!revive){
// this.score = 0;
// }
this.viewport = revive ? this.revivePos : 0;
}
start(revive = false){
this.road.start(revive);
this.player.fade(1);
this.playGame.start(revive);
}
startWorld() {
if(this.playing){
return;
}
this.playing = true;
//engine.startTick(this.onTicker, this);
engine.gameStage.addEventListener(engine.Event.ENTER_FRAME,this.onTicker,this)
}
stopWorld() {
if(!this.playing){
return;
}
this.playing = false;
//egret.stopTick(this.onTicker, this);
engine.gameStage.removeEventListener(engine.Event.ENTER_FRAME,this.onTicker,this)
}
get viewport() {
return this._viewport.x;
}
set viewport(v) {
this._viewport.x = v;
this.updateViewport();
}
updateViewport() {
const {x, y} = this._viewport;
const pos = Math.max(0, x);
this.background.setViewport(pos);
this.road.setViewport(pos);
}
private onMove(event) {
const {pos, bodyPos} = event.data;
this.viewport = pos;
if(this.road.hitReward(bodyPos)){
this.dispatchEvent('scoreChange', {
rewardScore: 100,
passType: 10,
}, true);
}
}
down() {
if(this.lock){
return;
}
this.player.down();
}
up() {
if(this.lock){
return;
}
this.player.up();
}
private onFootDown(event){
const {mileage, pos} = event.data;
this.revivePos = pos;
const {target, lastTarget} = this.road.hitBlock(pos);
this.road.playDust(pos);
if(target){
this.lock = true;
this.stopWorld();
this.dispatchEvent(engine.Event.COMPLETE,null,true);
target.playFadeOut();
target.playEffect();
if(target.type == 4){ //explosion
this.player.setSkin('gray');
}
this.road.removeBlock(target);
this.player.switchFace(target.type);
if(target.type == 0){
this.player.fall();
}
this.lock = false;
this.startWorld();
}else{
this.player.switchFace('normal');
const score = Math.floor(mileage / 50 * 5);
this.dispatchEvent('scoreChange', {
score,
passType: lastTarget ? lastTarget.type : -1,
}, true);
}
}
setWitchFace(type){
this.player.switchFace(type);
// setTimeout(() => {
// }, );
}
}
import { props } from './../props';
/**
* Created by rockyl on 2020-01-09.
*/
import GameView from "./GameView";
import {injectProps} from "../props";
import { PlayGame } from './PlayGame';
export class GameWrapper extends engine.Container {
private _gameView: GameView;
constructor() {
super();
engine.globalEvent.addEventListener('walking-cat-start', this.start, this);
engine.globalEvent.addEventListener('walking-cat-revive', this.revive, this);
engine.globalEvent.addEventListener('walking-cat-showScore', this.revive, this);
let gameView = this._gameView = new GameView();
this.addChild(gameView);
//this.once(engine.Event.ADDED_TO_STAGE, this.start, this);
}
start(event: engine.Event) {
injectProps(event.data);
this._gameView.eventStart();
}
revive() {
console.log('复活');
this._gameView.reset(true);
this._gameView.start(true);
}
}
import {getTextureByName} from "./utils";
export class LoopComponent extends engine.Container{
parts: any[];
onceInfo: any = {width: 0, height: 0, count: 0};
loopInfo: any = {width: 0, height: 0, count: 0};
constructor() {
super();
this.parts = [];
}
private setup(parts, info) {
parts.forEach((item, index) => {
let part;
if(typeof item == 'string'){
part = new engine.Sprite(getTextureByName(item));
}else if(item instanceof engine.Texture){
part = new engine.Sprite(item);
}else {
part = item;
}
this.addChild(part);
this.parts.push(part);
if (index == 0) {
info.width = part.width;
info.height = part.height;
}
});
info.count = parts.length;
this.setViewport(0, 0)
}
setupOnce(resArr) {
this.setup(resArr, this.onceInfo);
}
setupLoop(resArr) {
this.setup(resArr, this.loopInfo);
}
setViewport(x, y = 0) {
const sizeField = y == 0 ? 'width' : 'height';
const posField = y == 0 ? 'x' : 'y';
const pos = y == 0 ? x : y;
let index;
const onceSize = this.onceInfo[sizeField];
const onceCount = this.onceInfo.count;
const loopCount = this.loopInfo.count;
const loopSize = this.loopInfo[sizeField];
index = onceSize == 0 ? -1 : Math.floor(pos / onceSize);
if (index < 0 || index >= onceCount) {
const loopIndex = Math.floor((pos - onceCount * onceSize) / this.loopInfo[sizeField]);
index = onceCount + loopIndex;
}
let formerIndex = index < onceCount ? index : (index) % loopCount + onceCount;
let latterIndex = index < onceCount ? index + 1 : (index - onceCount + 1) % loopCount + onceCount;
let former = this.parts[formerIndex];
let latter = this.parts[latterIndex];
if(!former || !latter){
console.log(formerIndex, latterIndex);
}
former[posField] = -(pos - loopSize * (index < onceCount ? index : index - onceCount) - (index < onceCount ? 0 : onceCount * onceSize));
latter[posField] = former.x + (index < onceCount ? onceSize : loopSize);
}
}
\ No newline at end of file
import GameView from "./GameView";
import { getStage ,getTextureByName} from "./utils";
import { props } from "../props";
import { ScoreLabel } from "./ScoreLabel";
export class PlayGame extends engine.Container{
touchLayer: engine.Rect;
public GameView:GameView;
private addlabelScore: engine.Label = null;
public labScore: ScoreLabel;
private dialog:engine.Image;
normalScore;
rewardScore;
lastDialogTs;
private static _instance: PlayGame;
public static get instance(): PlayGame {
if (this._instance == undefined) {
this._instance = new PlayGame();
}
return this._instance;
}
public start(revive = false) {
if(!revive){
this.normalScore = 0;
this.rewardScore = 0;
this.lastDialogTs = 0;
this.initTouch();
this.initLabScore();
this.initAddlabel();
this.initDialog();
}
this.registerEvent();
}
registerEvent(){
this.touchLayer.addEventListener(engine.MouseEvent.MOUSE_DOWN,this.onMouseDown,this);
this.touchLayer.addEventListener(engine.MouseEvent.MOUSE_UP,this.onMouseUp,this);
this.GameView.addEventListener(engine.Event.COMPLETE, this.onGameComplete, this);
this.GameView.addEventListener('scoreChange', this.onScoreChange, this);
}
initTouch(){
this.touchLayer = new engine.Rect();
this.addChild(this.touchLayer);
this.touchLayer.width = getStage().width;
this.touchLayer.height = getStage().height;
this.touchLayer.x = 0;
this.touchLayer.y = 0;
this.touchLayer.alpha = 0;
}
removeListener(){
this.touchLayer.removeEventListener(engine.MouseEvent.MOUSE_DOWN,this.onMouseDown,this);
this.touchLayer.removeEventListener(engine.MouseEvent.MOUSE_UP,this.onMouseUp,this);
this.GameView.removeEventListener(engine.Event.COMPLETE, this.onGameComplete, this);
this.GameView.removeEventListener('scoreChange', this.onScoreChange, this);
}
initLabScore(){
this.labScore = new ScoreLabel();
this.labScore.visible = props.showScore;
this.labScore.updateScore(0, this.formatScore, false);
this.labScore.fillColor = 'yellow';
this.labScore.size = 46;
this.labScore.x = 610;
engine.Tween.get(this.labScore,{loop:false})
.set({y:-100})
.wait(300)
.to({y:40},200,engine.Ease.backOut)
this.addChild(this.labScore);
}
initAddlabel(){
this.addlabelScore = new engine.Label();
this.addlabelScore.fillColor = 'yellow';
this.addlabelScore.size = 40;
this.addlabelScore.text = '';
this.addlabelScore.x = 378;
this.addlabelScore.y = 582;
this.addlabelScore.visible = false;
this.addChild(this.addlabelScore);
}
initDialog(){
this.dialog = new engine.Image();
this.dialog.x = 390;
this.dialog.y = 323;
this.addChild(this.dialog);
}
onMouseDown(){
this.GameView.down();
}
onMouseUp(){
this.GameView.up();
}
onGameComplete(){
console.log('死亡');
this.removeListener();
let score = this.getScore();
engine.globalEvent.dispatchEvent('walking-cat-game-end',{score:score});
}
getScore(round = false) {
let score = (this.normalScore + this.rewardScore) / 10;
score *= (props.scoreTimes || 1);
if (round) {
return Math.round(score);
}
return score;
}
onScoreChange(event){
const {score, passType, rewardScore} = event.data;
let scoreAdd;
if (rewardScore) {
this.rewardScore += rewardScore;
scoreAdd = rewardScore;
} else {
scoreAdd = score - this.normalScore;
this.normalScore = score;
}
let curScore = this.getScore();
this.labScore.updateScore(curScore, this.formatScore);
if (passType > 0 && passType <= 4) {
const now = Date.now();
if (now - this.lastDialogTs > 15000) {
this.play(1);
this.lastDialogTs = now;
}
} else if (passType == 10) {
this.play(0);
this.lastDialogTs = Date.now();
this.GameView.setWitchFace('happy');
}
if (scoreAdd > 0) {
const labScoreAdd = this.addlabelScore;
labScoreAdd.visible = props.showScore;
labScoreAdd.alpha = 0;
labScoreAdd.verticalCenter = 0;
labScoreAdd.text = '+' + (scoreAdd / 10 * (props.scoreTimes || 1));
engine.Tween.get(labScoreAdd, null, null, true)
.to({verticalCenter: -50, alpha: 1,}, 200, engine.Ease.cubicIn)
.wait(300)
.to({verticalCenter: -100, alpha: 0,}, 100, engine.Ease.cubicOut)
.call(function () {
labScoreAdd.visible = false;
}, this);
}
engine.globalEvent.dispatchEvent('walking-cat-game-changScore',{score:curScore});
}
formatScore = (s) => {
let t = (Math.ceil(s * 10) / 10).toString();
t += t.indexOf('.') < 0 ? '.0' : '';
return t;
};
play(id){
const img = this.dialog;
img.texture = getTextureByName('dialog_'+id);
img.scaleX = img.scaleY = 0;
img.alpha = 1;
img.visible = true;
engine.Tween.get(img, null, null, true)
.to({
scaleX: 1, scaleY: 1
}, 500, engine.Ease.backOut)
.wait(500)
.to({
alpha: 0,
}, 300)
.call(()=>{
img.visible = false;
});
}
private revive() {
this.GameView.reset(true);
this.GameView.start(true);
}
}
\ No newline at end of file
import { localWave } from './../localWave';
import ObjectPool = engine.ObjectPool;
import {getStage} from "./utils";
import {getTextureByName} from "./utils";
import {props} from "../props";
import { Block } from "./Block";
export class Road extends engine.Container{
container: engine.Container;
dustEffect:[];
dustNode:engine.Container;
dustSprite:engine.Sprite;
dustIndex:number = 0;
flag: engine.Sprite;
reward;
index = 0;
minDistance = parseInt(props.blockMinDistance) || 100;
maxDistance = parseInt(props.blockMaxDistance) || 300;
basePos = getStage().width / 2 - 100;
padding = 500;
lastPos;
rewardIndex;
aniReward:any;
tweenReward;
lastBlockType;
preSetup() {
this.addChild(this.container = new engine.Container());
const flag = this.flag = new engine.Sprite(getTextureByName('flag_record'));
this.anchorRate(flag, 0.5, 1);
flag.y = -230;
flag.x = this.transScoreToFlagPos();
flag.visible = flag.x > 0;
this.addChild(flag);
}
setup(){
this.dustNode = new engine.Container();
this.dustSprite = new engine.Sprite();
this.dustSprite.visible = false;
this.dustNode.y = -1000;
this.dustNode.x = -450;
this.dustNode.addChild(this.dustSprite);
this.addChild(this.dustNode)
const reward = this.reward = new engine.Sprite();
reward.visible = false;
reward.y = -500;
this.addChild(reward);
this.aniReward = new localWave();
this.aniReward.init(reward, 2000, localWave.sin.bind(null, 10));
}
start(revive = false) {
if(revive){
}else{
this.rewardIndex = 0;
this.showReward();
}
}
reset(revive = false) {
if (!revive)
{
this.index = 0;
this.lastPos = 0;
this.clear();
this.fill();
this.flag.x = this.transScoreToFlagPos();
this.flag.visible = this.flag.x > 0;
}
}
anchorRate(target: any, rx: number, ry: number, width: number = 0, height: number = 0, resetPos = true): void {
if (width == 0) {
width = target.width;
}
if (height == 0) {
height = target.height;
}
if (resetPos) {
if (rx == 0) {
target.x -= target.anchorOffsetX;
}
if (ry == 0) {
target.y -= target.anchorOffsetY;
}
}
target.anchorOffsetX = width * rx;
target.anchorOffsetY = height * ry;
if (resetPos) {
if (rx > 0) {
target.x += target.anchorOffsetX;
}
if (ry > 0) {
target.y += target.anchorOffsetY;
}
}
}
transScoreToFlagPos(){
//const maxScore = props.maxScore;
//maxScore * 100
return -1;
}
clear() {
while (this.container.children.length > 0) {
this.removeBlockAt(0);
}
}
//添加障碍
addBlock() {
let type = 0, v;
if (this.index > 10) {
do {
const rv = Math.random();
v = 0;
for (let i = 0; i < 5; i++) {
v += Block.configs[i].ratio;
if (rv < v) {
type = i;
break;
}
}
} while (this.lastBlockType == type);
this.lastBlockType = type;
}
const block: Block = ObjectPool.getObject('block', {type});
const {width} = Block.configs[type];
const distance = this.index == 0 ?
this.maxDistance :
this.makeRandomFloat(this.maxDistance, this.minDistance);
const pos = this.lastPos + distance;
block.x = pos;
this.container.addChild(block);
this.lastPos = pos + width;
this.index++;
}
removeBlockAt(index){
const block = this.container.removeChildAt(index);
ObjectPool.recycleObject('block', block);
}
removeBlock(block) {
this.container.removeChild(block);
ObjectPool.recycleObject('block', block);
}
fill() {
if (isNaN(this.lastPos)) {
return;
}
while (true) {
if (this.lastPos + this.x > getStage().width + this.padding) {
break;
}
this.addBlock();
}
}
makeRandomFloat(max: number, min: number = 0): number {
return Math.random() * (max - min) + min;
}
setViewport(pos) {
this.x = this.basePos - pos;
while (this.container.children.length > 0) {
if (this.container.getChildAt(0).x >= pos - this.padding) {
break;
}
this.removeBlockAt(0);
}
this.fill();
}
showReward(type = 10) {
this.rewardIndex++;
const pos = this.rewardIndex * getStage().width * 3;
const reward = this.reward;
reward.visible = true;
reward.alpha = 1;
reward.texture = getTextureByName('menu_block_10');
reward.x = pos;
this.aniReward.updateRegisterPos();
}
hideReward() {
const reward = this.reward;
this.tweenReward = engine.Tween.get(reward)
.to({alpha: 0}, 200)
.call(() => {
this.tweenReward = null;
this.showReward();
})
}
hitReward(pos) {
if (this.reward.visible && pos >= this.reward.x && !this.tweenReward) {
this.hideReward();
return true;
}
}
playDust(pos) {
this.dustSprite.x = pos;
//播放序列帧
this.dustSprite.visible = true;
this.addEventListener(engine.Event.ENTER_FRAME,this.onEnterFrame,this);
}
onEnterFrame(){
if(this.dustIndex < 12){
this.dustSprite.texture = getTextureByName('dust_'+this.dustIndex);
this.dustIndex ++;
}else{
this.dustIndex = 0;
this.dustSprite.visible = false;
this.removeEventListener(engine.Event.ENTER_FRAME,this.onEnterFrame,this);
}
}
hitBlock(pos) {
let target, lastTarget;
//console.log('*******************');
let foot = {a: pos - 84 / 2, b: pos + 84 / 2};
//console.log(foot);
this.container.children.some((block: Block, i) => {
const {width} = Block.configs[block.type];
const line = {a: block.x - width / 2, b: block.x + width / 2};
//console.log(i, line);
if (this.lineHitTest(foot, line)) {
target = block;
return true;
}
});
//console.log(target ? 'hit on' : 'safe');
if (!target) {
for (let i = this.container.children.length; i > 0; i--) {
const block = this.container.getChildAt(i - 1);
if (block.x < pos) {
lastTarget = block;
break;
}
}
}
return {
target,
lastTarget,
};
}
lineHitTest(l0, l1) {
return l0.a < l1.b && l0.b > l1.a;
}
}
\ No newline at end of file
/**
* Created by rockyl on 2018/9/10.
*
* 分数标签
*/
export class ScoreLabel extends engine.Label {
formatFun: Function;
_value;
_temp;
updateScore(score, formatFun = null, animation = true) {
this.formatFun = formatFun;
this._value = score;
if (animation) {
engine.Tween.get(this, null, null, true)
.to({temp: score}, 300);
} else {
this.updateLocal(score);
}
}
get score() {
return this._value;
}
private get temp() {
return this._temp;
}
private set temp(v) {
this._temp = v;
this.updateLocal(v);
}
updateLocal(v) {
this.text = this.formatFun && this.formatFun(v) || v;
}
}
/**
* Created by rockyl on 2020-02-03.
*/
import {Block} from "./Block";
import ObjectPool = engine.ObjectPool;
export const PoolName: string = 'block';
ObjectPool.registerPool(PoolName, function () {
return new Block();
}, function (item: Block, data) {
item.reset(data);
});
/**
* 头部
*/
import {getTextureByName} from "../utils";
const factor = 10;
export class Head extends engine.Container implements IPlayerPart{
imgFace:engine.Sprite;
_headType;
constructor(){
super();
this.imgFace = new engine.Sprite(getTextureByName('head_0'));
this.addChild(this.imgFace);
this.imgFace.anchorTexture.set(107/this.imgFace.width,155/this.imgFace.height);
this.imgFace.y = 65;
this._headType = '';
}
localUpdate(x, y, rotation, sleeping){
this.x = x;
this.y = y;
this.rotation = rotation;
//this.alpha = sleeping ? 0.8 : 1;
}
get fWidth(){
return this.width / factor;
}
get fHeight(){
return this.height / factor;
}
switchFace(type, playAni){
if(type == this._headType){
return;
}
let headName = ''
if(type == 'normal'){
headName = 'head_0';
}else if(type == 'happy'){
headName = 'head_1'
}else if(type == 1 || type == 0 || type == 2){
headName = 'head_2';
}else if(type == 3){
headName = 'head_3';
}else if(type == 4){
headName = 'head_4';
}
this._headType = type;
this.imgFace.texture = getTextureByName(headName);
// this.currentState = 'face_' + type;
// const ani: egret.tween.TweenGroup = this['ani_face_' + type];
// if(playAni && ani){
// ani.play(0);
// }
}
}
interface IPlayerPart {
localUpdate(x, y, rotation, sleeping);
}
import { Head } from "./Head";
import { PlayerPart } from "./PlayerPart";
import {getfactor} from "../utils"
enum PlayerStat {
RELEASE,
RISING,
FALL,
}
const debug = false;
export class Player extends engine.EventDispatcher{
partMass = 0.1;
footMass = 0.1;
shouldersDistance = 50 / getfactor();
speed = 30;
skin = '';
world: p2.World;
originPos: any = {};
leftFoot: p2.Body;
lowerLeftLeg: p2.Body;
upperLeftLeg: p2.Body;
rightFoot: p2.Body;
lowerRightLeg: p2.Body;
upperRightLeg: p2.Body;
body: p2.Body;
head: p2.Body;
upperLeftArm: p2.Body;
lowerLeftArm: p2.Body;
upperRightArm: p2.Body;
lowerRightArm: p2.Body;
leftFootGroundCons: p2.RevoluteConstraint;
rightFootGroundCons: p2.RevoluteConstraint;
foots: p2.Body[];
lowerLegs: p2.Body[];
upperLegs: p2.Body[];
footGroundCons: p2.RevoluteConstraint[];
state: PlayerStat;
step;
safePos = 0;
setup(options) {
const {collisionGroup, collisionMask, world, ground} = options;
this.world = world;
world.on('postStep', this.onPostStep);
const bodyPartShapes = [];
const leftFootDisplay = this.createDisplay('foot');
const lowerLeftLegDisplay = this.createDisplay('lower_left_leg');
const upperLeftLegDisplay = this.createDisplay('upper_left_leg');
const rightFootDisplay = this.createDisplay('foot');
const lowerRightLegDisplay = this.createDisplay('lower_right_leg');
const upperRightLegDisplay = this.createDisplay('upper_right_leg');
const bodyDisplay = this.createDisplay('body', {x:50, y: 0});
const headDisplay = new Head();
const upperLeftArmDisplay = this.createDisplay('upper_left_arm');
const lowerLeftArmDisplay = this.createDisplay('lower_left_arm', {x: -20, y: 0});
const upperRightArmDisplay = this.createDisplay('upper_right_arm');
const lowerRightArmDisplay = this.createDisplay('lower_right_arm', {x: -39, y: 0});
//left leg
const leftFootShape = new p2.Box(leftFootDisplay.fSize);
bodyPartShapes.push(leftFootShape);
this.originPos['leftFoot'] = [
-this.shouldersDistance / 2,
leftFootDisplay.fHeight / 2
];
const leftFoot = this.leftFoot = new p2.Body({
allowSleep: false,
mass: this.footMass,
position: this.originPos['leftFoot'],
});
if (!debug) leftFoot.displays = [leftFootDisplay];
leftFoot.addShape(leftFootShape);
const lowerLeftLegShape = new p2.Box(lowerLeftLegDisplay.fSize);
bodyPartShapes.push(lowerLeftLegShape);
this.originPos['lowerLeftLeg'] = [
-this.shouldersDistance / 2,
leftFoot.position[1] + lowerLeftLegDisplay.fHeight / 2 + 5 / getfactor()
];
const lowerLeftLeg = this.lowerLeftLeg = new p2.Body({
allowSleep: false,
mass: this.partMass,
position: this.originPos['lowerLeftLeg'],
});
if (!debug) lowerLeftLeg.displays = [lowerLeftLegDisplay];
lowerLeftLeg.addShape(lowerLeftLegShape);
const leftAnkleJoint = new p2.RevoluteConstraint(lowerLeftLeg, leftFoot, {
localPivotA: [0, -lowerLeftLegDisplay.fHeight / 2 + 5 / getfactor()],
localPivotB: [-leftFootDisplay.fWidth / 2 + 18 / getfactor(), 0],
});
leftAnkleJoint.setLimits(-Math.PI / 3, Math.PI / 3);
const leftFootGroundCons = this.leftFootGroundCons = new p2.RevoluteConstraint(leftFoot, ground, {
localPivotA: [0, -leftFootDisplay.fHeight / 2],
localPivotB: [leftFoot.position[0], 0],
});
leftFootGroundCons.setLimits(0, 0);
const upperLeftLegShape = new p2.Box(upperLeftLegDisplay.fSize);
bodyPartShapes.push(upperLeftLegShape);
this.originPos['upperLeftLeg'] = [
-this.shouldersDistance / 2,
lowerLeftLeg.position[1] + lowerLeftLegDisplay.fHeight / 2 + upperLeftLegDisplay.fHeight / 2 - 40 / getfactor()
];
const upperLeftLeg = this.upperLeftLeg = new p2.Body({
allowSleep: false,
mass: this.partMass,
position: this.originPos['upperLeftLeg'],
});
if (!debug) upperLeftLeg.displays = [upperLeftLegDisplay];
upperLeftLeg.addShape(upperLeftLegShape);
const leftKneeJoint = new p2.RevoluteConstraint(upperLeftLeg, lowerLeftLeg, {
localPivotA: [0, -upperLeftLegDisplay.fHeight / 2 + 20 / getfactor()],
localPivotB: [0, lowerLeftLegDisplay.fHeight / 2 - 20 / getfactor()],
});
leftKneeJoint.setLimits(-Math.PI, 0);
//right leg
const rightFootShape = new p2.Box(rightFootDisplay.fSize);
bodyPartShapes.push(rightFootShape);
this.originPos['rightFoot'] = [
this.shouldersDistance / 2,
rightFootDisplay.fHeight / 2
];
const rightFoot = this.rightFoot = new p2.Body({
allowSleep: false,
mass: this.footMass,
position: this.originPos['rightFoot'],
});
if (!debug) rightFoot.displays = [rightFootDisplay];
rightFoot.addShape(rightFootShape);
const lowerRightLegShape = new p2.Box(lowerRightLegDisplay.fSize);
bodyPartShapes.push(lowerRightLegShape);
this.originPos['lowerRightLeg'] = [
this.shouldersDistance / 2,
rightFoot.position[1] + lowerRightLegDisplay.fHeight / 2 + 5 / getfactor()
];
const lowerRightLeg = this.lowerRightLeg = new p2.Body({
allowSleep: false,
mass: this.partMass,
position: this.originPos['lowerRightLeg'],
});
if (!debug) lowerRightLeg.displays = [lowerRightLegDisplay];
lowerRightLeg.addShape(lowerRightLegShape);
const rightAnkleJoint = new p2.RevoluteConstraint(lowerRightLeg, rightFoot, {
localPivotA: [0, -lowerRightLegDisplay.fHeight / 2 + 5 / getfactor()],
localPivotB: [-rightFootDisplay.fWidth / 2 + 18 / getfactor(), 0],
});
rightAnkleJoint.setLimits(-Math.PI / 3, Math.PI / 3);
const rightFootGroundCons = this.rightFootGroundCons = new p2.RevoluteConstraint(rightFoot, ground, {
localPivotA: [0, -rightFootDisplay.fHeight / 2],
localPivotB: [rightFoot.position[0], 0],
});
rightFootGroundCons.setLimits(0, 0);
const upperRightLegShape = new p2.Box(upperRightLegDisplay.fSize);
bodyPartShapes.push(upperRightLegShape);
this.originPos['upperRightLeg'] = [
this.shouldersDistance / 2,
lowerRightLeg.position[1] + lowerRightLegDisplay.fHeight / 2 + upperRightLegDisplay.fHeight / 2 - 40 / getfactor()
];
const upperRightLeg = this.upperRightLeg = new p2.Body({
allowSleep: false,
mass: this.partMass,
position: this.originPos['upperRightLeg'],
});
if (!debug) upperRightLeg.displays = [upperRightLegDisplay];
upperRightLeg.addShape(upperRightLegShape);
const rightKneeJoint = new p2.RevoluteConstraint(upperRightLeg, lowerRightLeg, {
localPivotA: [0, -upperRightLegDisplay.fHeight / 2 + 20 / getfactor()],
localPivotB: [0, lowerRightLegDisplay.fHeight / 2 - 20 / getfactor()],
});
rightKneeJoint.setLimits(-Math.PI, 0);
//body
var bodyWidth = 120 / getfactor();
var bodyHeight = 250 / getfactor();
const bodyShape = new p2.Box({width: bodyWidth, height: bodyHeight});
bodyPartShapes.push(bodyShape);
this.originPos['body'] = [
0,
upperRightLeg.position[1] + upperRightLegDisplay.fHeight / 2 + bodyHeight / 2 - 60 / getfactor()
];
const body = this.body = new p2.Body({
allowSleep: false,
mass: this.partMass,
position: this.originPos['body'],
});
if (!debug) body.displays = [bodyDisplay];
body.addShape(bodyShape);
const leftHipJoint = new p2.RevoluteConstraint(body, upperLeftLeg, {
localPivotA: [-20 / getfactor(), -bodyHeight / 2 + 30 / getfactor()],
localPivotB: [0, upperLeftLegDisplay.fHeight / 2 - 30 / getfactor()],
});
leftHipJoint.setLimits(-Math.PI / 6 * 2, Math.PI / 6 * 2);
const rightHipJoint = new p2.RevoluteConstraint(body, upperRightLeg, {
localPivotA: [-20 / getfactor(), -bodyHeight / 2 + 30 / getfactor()],
localPivotB: [0, upperRightLegDisplay.fHeight / 2 - 30 / getfactor()],
});
rightHipJoint.setLimits(-Math.PI / 6 * 2, Math.PI / 6 * 2);
//head
const headShape = new p2.Circle({radius: 85 / getfactor()});
bodyPartShapes.push(headShape);
//
this.originPos['head'] = [
0,
body.position[1] + bodyHeight / 2 + 85 / getfactor()
];
const head = this.head = new p2.Body({
allowSleep: false,
mass: this.partMass,
position: this.originPos['head'],
});
head.addShape(headShape);
if (!debug) head.displays = [headDisplay];
const headJoint = new p2.RevoluteConstraint(body, head, {
localPivotA: [0, bodyHeight / 2 - 10 / getfactor()],
localPivotB: [0, (-85 + 10) / getfactor()],
});
headJoint.setLimits(-Math.PI / 6 * 2, Math.PI / 6 * 2);
//left arm
const upperLeftArmShape = new p2.Box(upperLeftArmDisplay.fSize);
bodyPartShapes.push(upperLeftArmShape);
this.originPos['upperLeftArm'] = [
-this.shouldersDistance / 2 - 10 / getfactor(),
body.position[1] + bodyHeight / 2 - upperLeftArmDisplay.fHeight / 2
];
const upperLeftArm = this.upperLeftArm = new p2.Body({
allowSleep: false,
mass: this.partMass,
position: this.originPos['upperLeftArm'],
});
if (!debug) upperLeftArm.displays = [upperLeftArmDisplay];
upperLeftArm.addShape(upperLeftArmShape);
const leftShoulderJoint = new p2.RevoluteConstraint(body, upperLeftArm, {
localPivotA: [-this.shouldersDistance / 2 + 10 / getfactor(), bodyHeight / 2],
localPivotB: [0, upperLeftArmDisplay.fHeight / 2],
});
leftShoulderJoint.setLimits(-Math.PI / 2, 0);
var width = 50 / getfactor();
const lowerLeftArmShape = new p2.Box({width, height: lowerLeftArmDisplay.fHeight});
bodyPartShapes.push(lowerLeftArmShape);
this.originPos['lowerLeftArm'] = [
-this.shouldersDistance / 2 - 10 / getfactor() + 10 / getfactor(),
upperLeftArm.position[1] - upperLeftArmDisplay.fHeight / 2 - lowerLeftArmDisplay.fHeight / 2 + 20 / getfactor()
];
const lowerLeftArm = this.lowerLeftArm = new p2.Body({
allowSleep: false,
mass: this.partMass,
position: this.originPos['lowerLeftArm'],
});
if (!debug) lowerLeftArm.displays = [lowerLeftArmDisplay];
lowerLeftArm.addShape(lowerLeftArmShape);
const leftElbowJoint = new p2.RevoluteConstraint(upperLeftArm, lowerLeftArm, {
localPivotA: [0, -upperLeftArmDisplay.fHeight / 2 + 10 / getfactor()],
localPivotB: [-10 / getfactor(), lowerLeftLegDisplay.fHeight / 2 - 10 / getfactor()],
});
leftElbowJoint.setLimits(0, Math.PI * 2 / 3);
//right arm
const upperRightArmShape = new p2.Box(upperRightArmDisplay.fSize);
bodyPartShapes.push(upperRightArmShape);
this.originPos['upperRightArm'] = [
this.shouldersDistance / 2,
body.position[1] + bodyHeight / 2 - upperRightArmDisplay.fHeight / 2
];
const upperRightArm = this.upperRightArm = new p2.Body({
allowSleep: false,
mass: this.partMass,
position: this.originPos['upperRightArm'],
});
if (!debug) upperRightArm.displays = [upperRightArmDisplay];
upperRightArm.addShape(upperRightArmShape);
const rightShoulderJoint = new p2.RevoluteConstraint(body, upperRightArm, {
localPivotA: [this.shouldersDistance / 2 + 10 / getfactor(), bodyHeight / 2],
localPivotB: [0, upperRightArmDisplay.fHeight / 2],
});
rightShoulderJoint.setLimits(-Math.PI / 2, 0);
var width = 30 / getfactor();
const lowerRightArmShape = new p2.Box({width, height: lowerRightArmDisplay.fHeight});
bodyPartShapes.push(lowerRightArmShape);
this.originPos['lowerRightArm'] = [
this.shouldersDistance / 2,
upperRightArm.position[1] - upperRightArmDisplay.fHeight / 2 - lowerRightArmDisplay.fHeight / 2 + 40 / getfactor()
];
const lowerRightArm = this.lowerRightArm = new p2.Body({
allowSleep: false,
mass: this.partMass,
position: this.originPos['lowerRightArm'],
});
if (!debug) lowerRightArm.displays = [lowerRightArmDisplay];
lowerRightArm.addShape(lowerRightArmShape);
const rightElbowJoint = new p2.RevoluteConstraint(upperRightArm, lowerRightArm, {
localPivotA: [0, -upperRightArmDisplay.fHeight / 2 + 20 / getfactor()],
localPivotB: [0, lowerRightLegDisplay.fHeight / 2 - 20 / getfactor()],
});
rightElbowJoint.setLimits(0, Math.PI * 2 / 3);
const bodies = [
lowerRightArm, upperRightArm,
lowerRightLeg, upperRightLeg, rightFoot,
body,
lowerLeftLeg, upperLeftLeg, leftFoot,
lowerLeftArm, upperLeftArm,
head,
];
bodies.forEach(body => {
world.addBody(body);
});
const joints = [
leftAnkleJoint,
leftKneeJoint,
rightAnkleJoint,
rightKneeJoint,
headJoint,
leftHipJoint,
rightHipJoint,
leftShoulderJoint,
leftElbowJoint,
rightShoulderJoint,
rightElbowJoint,
leftFootGroundCons,
rightFootGroundCons,
];
joints.forEach(joint => {
world.addConstraint(joint);
});
for (let i = 0; i < bodyPartShapes.length; i++) {
let s = bodyPartShapes[i];
s.collisionGroup = collisionGroup;
s.collisionMask = collisionMask;
}
this.foots = [leftFoot, rightFoot];
this.lowerLegs = [lowerLeftLeg, lowerRightLeg];
this.upperLegs = [upperLeftLeg, upperRightLeg];
this.footGroundCons = [leftFootGroundCons, rightFootGroundCons];
//this.addEventListener('move',this.moveTest,this);
}
// moveTest(){
// console.log('移动');
// }
reset(revive = false) {
if (revive) {
} else {
this.step = -1;
this.safePos = 0;
[
'lowerLeftLeg',
'upperLeftLeg',
'lowerRightLeg',
'upperRightLeg',
'body',
'head',
'upperLeftArm',
'lowerLeftArm',
'upperRightArm',
'lowerRightArm',
].forEach(partName => {
const part = this[partName];
part.position[0] = this.safePos + this.originPos[partName][0];
})
}
for (let i = 0; i < 2; i++) {
let cons = this.footGroundCons[i];
cons.pivotB[0] = this.foots[i].position[0] = this.safePos + (i == 0 ? -1 : 1) * this.shouldersDistance / 2;
if (this.state == PlayerStat.FALL) {
this.world.addConstraint(cons);
}
}
this.switchFace('normal', false);
this.setSkin('normal');
this.state = PlayerStat.RELEASE;
}
createDisplay(resName, offset = null) {
let bmp = new PlayerPart(resName);
let anchorX = bmp.width / 2 + (offset ? offset.x : 0);
let anchorY = bmp.height / 2 + (offset ? offset.y : 0);
bmp.anchorTexture.set(anchorX/bmp.width,anchorY/bmp.height);
return bmp;
}
get currentSide() {
return this.step % 2;
}
get anotherSide() {
return (this.step + 1) % 2;
}
onPostStep = (e = null) => {
const side = this.currentSide;
let footHang = this.foots[this.currentSide];
let footFall = this.foots[this.anotherSide];
switch (this.state) {
case PlayerStat.FALL:
break;
case PlayerStat.RISING:
let footOffset = footHang.position[0] - footFall.position[0];
let speed = this.speed;
this.upperLegs[side].angularVelocity = 10;
this.upperLegs[side].velocity = [
footOffset < 0 ? speed - 10 : speed,
0
];
this.lowerLegs[side].velocity = [
footOffset < 0 ? speed - 10 : speed,
footOffset < 0 ? 3 : 2
];
this.head.velocity = [speed * 0.5, 20];
this.dispatchEvent('move', {
pos: (this.leftFoot.position[0] + this.rightFoot.position[0]) / 2 * getfactor(),
bodyPos: this.body.position[0] * getfactor(),
},true);
if (footOffset > 50) {
this.up();
}
break;
case PlayerStat.RELEASE:
this.head.velocity = [0, 30];
break;
}
};
onFootDown = () => {
const pos = this.foots[this.currentSide].position[0] * getfactor();
const mileage = Math.max(this.foots[0].position[0], this.foots[1].position[0]) * getfactor();
this.safePos = this.foots[this.currentSide].position[0];
this.dispatchEvent('foot_down', {
mileage,
pos,
//revivePos: this.safePos * factor,
}, true)
};
down() {
if (this.state == PlayerStat.RISING) {
return;
}
this.step++;
const cons = this.footGroundCons[this.currentSide];
this.world.removeConstraint(cons);
this.state = PlayerStat.RISING;
}
up() {
if (this.state == PlayerStat.RELEASE) {
return;
}
const side = this.currentSide;
this.foots[side].velocity = [0, 0];
this.body.velocity = [0, 0];
const currentFoot = this.foots[side];
const cons = this.footGroundCons[side];
cons.pivotB[0] = currentFoot.position[0];
this.world.addConstraint(cons);
this.state = PlayerStat.RELEASE;
setTimeout(this.onFootDown, 200);
}
fall() {
this.body.velocity = [0, -30];
this.head.velocity = [-50, -50];
this.world.removeConstraint(this.footGroundCons[0]);
this.world.removeConstraint(this.footGroundCons[1]);
this.foots[this.currentSide].velocity[0] = 60;
this.foots[this.anotherSide].velocity[0] = 70;
this.state = PlayerStat.FALL;
}
switchFace(type, playAni = true) {
const headDisplay: Head = <Head>this.head.displays[0];
headDisplay.switchFace(type, playAni);
}
setSkin(name) {
if (this.skin == name) {
return;
}
this.skin = name;
[
'leftFoot',
'lowerLeftLeg',
'upperLeftLeg',
'rightFoot',
'lowerRightLeg',
'upperRightLeg',
'body',
'upperLeftArm',
'lowerLeftArm',
'upperRightArm',
'lowerRightArm',
].forEach(partName => {
const part = this[partName];
part.displays[0].setSkin(name);
})
}
fade(alpha, animation = true){
[
'leftFoot',
'lowerLeftLeg',
'upperLeftLeg',
'rightFoot',
'lowerRightLeg',
'upperRightLeg',
'body',
'head',
'upperLeftArm',
'lowerLeftArm',
'upperRightArm',
'lowerRightArm',
].forEach(partName => {
const display = this[partName].displays[0];
if(animation){
engine.Tween.get(display, null, null, true)
.to({alpha}, 200);
}else{
display.alpha = alpha;
}
})
}
}
\ No newline at end of file
/**
* 玩家部件
*/
import {getTextureByName, getfactor} from "../utils";
export class PlayerPart extends engine.Sprite implements IPlayerPart {
constructor(name) {
super();
this.changeRes(name)
}
changeRes(name) {
this.name = name;
this.texture = getTextureByName('body_normal_'+name)
};
setSkin(name) {
this.texture = getTextureByName('body_' + name + '_' + this.name);
}
// update(x, y, rotation, sleeping) {
// this.x = x;
// this.y = y;
// this.rotation = rotation;
// //this.alpha = sleeping ? 0.5 : 1;
// }
localUpdate(x, y, rotation, sleeping){
this.x = x;
this.y = y;
this.rotation = rotation;
//this.alpha = sleeping ? 0.5 : 1;
}
get fSize() {
return {width: this.fWidth, height: this.fHeight}
}
get fWidth() {
return this.width / getfactor();
}
get fHeight() {
return this.height / getfactor();
}
reset() {
}
}
/**
* 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 getStage(){
return engine.gameStage.stage;
}
export function getfactor(){
return 10;
}
/**
* 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 16/3/9.
*/
export class localWave {
static round:Function = function (h:number, t:number):any {
return {x: Math.cos(t) * h, y: Math.sin(t) * h};
};
static cos:Function = function (h:number, t:number):any {
return {x: Math.cos(t) * h, y: 0};
};
static sin:Function = function (h:number, t:number):any {
h = h || 1;
return {x: 0, y: Math.sin(t) * h};
};
static rotate:Function = function (t:number):any {
return {r: 360 * t / Math.PI / 2};
};
static shake:Function = function(angle:number, count:number, t:number):any{
return { r: Math.sin(t * count) * angle };
};
static breath:Function = function(scale:number, t:number):any{
return {sx: Math.sin(t) * scale + 1, sy: -Math.sin(t + Math.PI / 4) * scale + 1};
};
static zoom:Function = function(scale:number, t:number):any{
scale = scale || 0.1;
return {sx: Math.sin(t) * scale + 1, sy: Math.sin(t) * scale + 1};
};
static fade:Function = function (base, t:number):any {
return {alpha: (Math.sin(t) + 1) * 0.5 + base};
};
_tween:engine.Tween;
target:any;
duration:number;
delay:number;
offset:number;
loop:number;
reverse:boolean;
private _calProps;
private _oldProperties:any = {};
private _count;
init(target:any, duration:number, calProps:Function = null, loop:number = 0, autoPlay:boolean = true, reverse:boolean = false, delay:number = 0, offset:number = 0) {
this.target = target;
this._calProps = calProps ? calProps : localWave.round;
this.duration = duration;
this.loop = loop;
this.reverse = reverse;
this.delay = delay;
this.offset = offset;
this.updateRegisterPos();
if (autoPlay) {
this.play();
}
}
updateRegisterPos():void{
this._oldProperties.x = this.target.x;
this._oldProperties.y = this.target.y;
this._oldProperties.scaleX = this.target.scaleX;
this._oldProperties.scaleY = this.target.scaleY;
this._oldProperties.skewX = this.target.skewX;
this._oldProperties.skewY = this.target.skewY;
this._oldProperties.rotation = this.target.rotation;
this._oldProperties.alpha = this.target.alpha;
}
play() {
if(this._tween){
return this._tween;
}
this._count = 0;
return this._playStep();
}
_playStep(){
if(this.loop > 0 && this._count >= this.loop){
this.stop();
return;
}
this._count ++;
this.t = this.reverse ? Math.PI * 2 : 0;
this._tween = engine.Tween.get(this);
this._tween.wait(this.delay).to({t: this.reverse ? 0 : Math.PI * 2}, this.duration).call(this._playStep, this);
return this._tween;
}
private _t:number = 0;
private get t():number {
return this._t;
}
private set t(value:number) {
if(!this.target.stage){
return;
}
this._t = value;
let props:any = this._calProps.call(this, this._t + this.offset);
if(props.hasOwnProperty('x')){
this.target.x = (props.x || 0) + this._oldProperties.x;
}
if(props.hasOwnProperty('y')){
this.target.y = (props.y || 0) + this._oldProperties.y;
}
if(props.hasOwnProperty('sx')){
this.target.scaleX = props.sx;
}
if(props.hasOwnProperty('sy')){
this.target.scaleY = props.sy;
}
if(props.hasOwnProperty('skewX')){
this.target.skewX = props.skewX;
}
if(props.hasOwnProperty('skewY')){
this.target.skewY = props.skewY;
}
if(props.hasOwnProperty('r')){
this.target.rotation = props.r;
}
if(props.hasOwnProperty('alpha')){
this.target.alpha = props.alpha;
}
}
stop(recovery:boolean = false, animation:boolean = false, duration:number = 1000):void {
if(!this._tween){
return ;
}
engine.Tween.removeTweens(this);
if(recovery){
engine.Tween.get(this.target).to(this._oldProperties, duration);
}
this._tween = null;
}
get playing():boolean{
return this._tween != null;
}
}
//////////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2014-present, Egret Technology.
// All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of the Egret nor the
// names of its contributors may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////////////
declare module p2 {
export class AABB {
upperBound: number[];
lowerBound: number[];
constructor(options?: {
upperBound?: number[];
lowerBound?: number[];
});
containsPoint(point: number[]): boolean;
setFromPoints(points: number[][], position: number[], angle: number, skinSize: number): void;
copy(aabb: AABB): void;
extend(aabb: AABB): void;
overlaps(aabb: AABB): boolean;
overlapsRay(ray:Ray): number;
}
export class Broadphase {
static AABB: number;
static BOUNDING_CIRCLE: number;
static boundingRadiusCheck(bodyA: Body, bodyB: Body): boolean;
static aabbCheck(bodyA: Body, bodyB: Body): boolean;
static canCollide(bodyA: Body, bodyB: Body): boolean;
constructor(type: number);
result: Body[];
world: World;
boundingVolumeType: number;
setWorld(world: World): void;
getCollisionPairs(world: World): Body[];
boundingVolumeCheck(bodyA: Body, bodyB: Body): boolean;
}
export class NaiveBroadphase extends Broadphase {
aabbQuery(world: World, aabb: AABB, result: Body[]): Body[];
}
export class Narrowphase {
static findSeparatingAxis(c1:Convex, offset1:number[], angle1:number, c2:Convex, offset2:number[], angle2:number, sepAxis:number[]): boolean;
static getClosestEdge(c:Convex, angle:number, axis:number[], flip:boolean): number;
static projectConvexOntoAxis(convexShape:Convex, convexOffset:number[], convexAngle:number, worldAxis:number[], result:number[]): void;
contactEquationPool: ContactEquationPool;
contactEquations: ContactEquation[];
contactSkinSize: number;
enabledEquations: boolean;
enableFriction: boolean;
frictionCoefficient: number;
frictionEquationPool: FrictionEquationPool;
frictionEquations: FrictionEquation[];
frictionRelaxation: number;
frictionStiffness: number;
restitution: number;
slipForce: number;
stiffness: number;
surfaceVelocity: number;
//官方不赞成使用的属性
enableFrictionReduction: boolean;
bodiesOverlap(bodyA: Body, bodyB: Body): boolean;
capsuleCapsule(bi: Body, si: Capsule, xi: number[], ai: number, bj: Body, sj: Capsule, xj: number[], aj: number): void;
circleCapsule(bi: Body, si: Circle, xi: number[], ai: number, bj: Body, sj: Line, xj: number[], aj: number): void;
circleCircle(bodyA: Body, shapeA: Circle, offsetA: number[], angleA: number, bodyB: Body, shapeB: Circle, offsetB: number[], angleB: number, justTest: boolean, radiusA?:number, radiusB?:number): void;
circleConvex(circleBody:Body, circleShape:Circle, circleOffset:number[], circleAngle:number, convexBody:Body, convexShape:Convex, convexOffset:number[], convexAngle:number, justTest:boolean, circleRadius:number): void;
circleHeightfield(bi:Body, si:Circle, xi:number[], bj:Body, sj:Heightfield, xj:number[], aj:number): void;
circleLine(circleBody:Body, circleShape:Circle, circleOffset:number[], circleAngle:number, lineBody:Body, lineShape:Line, lineOffset:number[], lineAngle:number, justTest:boolean, lineRadius:number, circleRadius:number): void;
circleParticle(circleBody:Body, circleShape:Circle, circleOffset:number[], circleAngle:number, particleBody:Body, particleShape:Particle, particleOffset:number[], particleAngle:number, justTest:boolean): void;
circlePlane(bi:Body, si:Circle, xi:number[], bj:Body, sj:Plane, xj:number[], aj:number): void;
collidedLastStep(bodyA: Body, bodyB: Body): boolean;
convexCapsule(convexBody:Body, convexShape:Convex, convexPosition:number[], convexAngle:number, capsuleBody:Body, capsuleShape:Capsule, capsulePosition:number[], capsuleAngle:number): void;
convexConvex(bi:Body, si:Convex, xi:number[], ai:number, bj:Body, sj:Convex, xj:number[], aj:number): void;
convexLine(convexBody:Body, convexShape:Convex, convexOffset:number[], convexAngle:number, lineBody:Body, lineShape:Line, lineOffset:number[], lineAngle:number, justTest:boolean): void;
createContactEquation(bodyA: Body, bodyB: Body): ContactEquation;
createFrictionEquation(bodyA: Body,bodyB: Body): FrictionEquation;
createFrictionFromContact(contactEquation: ContactEquation): FrictionEquation;
lineBox(lineBody:Body, lineShape:Line, lineOffset:number[], lineAngle:number, boxBody:Body, boxShape:Box, boxOffset:number[], boxAngle:number, justTest:boolean): void;
lineCapsule(lineBody:Body, lineShape:Line, linePosition:number[], lineAngle:number, capsuleBody:Body, capsuleShape:Capsule, capsulePosition:number[], capsuleAngle:number): void;
lineLine(bodyA:Body, shapeA:Line, positionA:number[], angleA:number, bodyB:Body, shapeB:Line, positionB:number[], angleB:number): void;
particleConvex(particleBody:Body, particleShape:Particle, particleOffset:number[], particleAngle:number, convexBody:Body, convexShape:Convex, convexOffset:number[], convexAngle:number, justTest:boolean): void;
particlePlane(particleBody:Body, particleShape:Particle, particleOffset:number[], particleAngle:number, planeBody:Body, planeShape:Plane, planeOffset:number[], planeAngle:number, justTest:boolean): void;
planeCapsule(planeBody:Body, planeShape:Circle, planeOffset:number[], planeAngle:number, capsuleBody:Body, capsuleShape:Particle, capsuleOffset:number[], capsuleAngle:number, justTest:boolean): void;
planeConvex(planeBody:Body, planeShape:Plane, planeOffset:number[], planeAngle:number, convexBody:Body, convexShape:Convex, convexOffset:number[], convexAngle:number, justTest:boolean): void;
planeLine(planeBody:Body, planeShape:Plane, planeOffset:number[], planeAngle:number, lineBody:Body, lineShape:Line, lineOffset:number[], lineAngle:number): void;
reset(): void;
}
export class SAPBroadphase extends Broadphase {
axisIndex: number;
axisList: Body[];
aabbQuery(world: World, aabb: AABB, result: Body[]): Body[];
sortAxisList(a: Body[], axisIndex: number): Body[];
}
export class Constraint {
static DISTANCE: number;
static GEAR: number;
static LOCK: number;
static PRISMATIC: number;
static REVOLUTE: number;
constructor(bodyA: Body, bodyB: Body, type: number, options?: {
collideConnected?: boolean;
});
type: number;
equations: Equation[];
bodyA: Body;
bodyB: Body;
collideConnected: boolean;
update(): void;
setStiffness(stiffness: number): void;
setRelaxation(relaxation: number): void;
}
export class DistanceConstraint extends Constraint {
constructor(bodyA: Body, bodyB: Body, options?: {
distance?: number;
localAnchorA?: number[];
localAnchorB?: number[];
maxForce?: number;
});
localAnchorA: number[];
localAnchorB: number[];
distance: number;
maxForce: number;
upperLimitEnabled: boolean;
upperLimit: number;
lowerLimitEnabled: boolean;
lowerLimit: number;
position: number;
setMaxForce(maxForce: number): void;
getMaxForce(): number;
}
export class GearConstraint extends Constraint {
constructor(bodyA: Body, bodyB: Body, options?: {
angle?: number;
ratio?: number;
maxTorque?: number;
});
ratio: number;
angle: number;
setMaxTorque(torque: number): void;
getMaxTorque(): number;
}
export class LockConstraint extends Constraint {
constructor(bodyA: Body, bodyB: Body, options?: {
localOffsetB?: number[];
localAngleB?: number;
maxForce?: number;
collideConnected?: boolean;
});
localAngleB: number;
localOffsetB: number[];
setMaxForce(force: number): void;
getMaxForce(): number;
}
export class PrismaticConstraint extends Constraint {
constructor(bodyA: Body, bodyB: Body, options?: {
maxForce?: number;
localAnchorA?: number[];
localAnchorB?: number[];
localAxisA?: number[];
disableRotationalLock?: boolean;
upperLimit?: number;
lowerLimit?: number;
collideConnected?: boolean;
});
localAnchorA: number[];
localAnchorB: number[];
localAxisA: number[];
lowerLimit: number;
lowerLimitEnabled: boolean;
motorEnabled: boolean;
motorEquation: Equation;
motorSpeed: number;
position: number;
upperLimit: number;
upperLimitEnabled: boolean;
disableMotor(): void;
enableMotor(): void;
setLimits(lower: number, upper: number): void;
}
export class RevoluteConstraint extends Constraint {
constructor(bodyA: Body, bodyB: Body, options?: {
worldPivot?: number[];
localPivotA?: number[];
localPivotB?: number[];
maxForce?: number;
collideConnected?: boolean;
});
angle: number;
lowerLimit: number;
lowerLimitEnabled: boolean;
motorEnabled: boolean;
pivotA: number[];
pivotB: number[];
upperLimit: number;
upperLimitEnabled: boolean;
disableMotor(): void;
enableMotor(): void;
getMotorSpeed(): number;
//官方不赞成使用了
motorIsEnabled(): boolean;
setLimits(lower: number, upper: number): void;
setMotorSpeed(speed: number): void;
}
export class AngleLockEquation extends Equation {
constructor(bodyA: Body, bodyB: Body, options?: {
angle?: number;
ratio?: number;
});
computeGq(): number;
setRatio(ratio: number): number;
setMaxTorque(torque: number): number;
}
export class ContactEquation extends Equation {
constructor(bodyA: Body, bodyB: Body);
contactPointA: number[];
contactPointB: number[];
normalA: number[];
restitution: number;
firstImpact: boolean;
shapeA: Shape;
shapeB: Shape;
}
export class Equation {
static DEFAULT_STIFFNESS: number;
static DEFAULT_RELAXATION: number;
constructor(bodyA: Body, bodyB: Body, minForce?: number, maxForce?: number);
minForce: number;
maxForce: number;
bodyA: Body;
bodyB: Body;
stiffness: number;
relaxation: number;
G: number[];
needsUpdate: boolean;
multiplier: number;
relativeVelocity: number;
enabled: boolean;
gmult(): number;
computeB(): number;
computeGq(): number;
computeGW(): number;
computeGWlambda(): number;
computeGiMf(): number;
computeGiMGt(): number;
addToWlambda(deltalambda: number): void;
computeInvC(eps: number): number;
update(): void;
}
export class FrictionEquation extends Equation {
constructor(bodyA: Body, bodyB: Body, slipForce: number);
contactEquations: ContactEquation;
contactPointA: number[];
contactPointB: number[];
t: number[];
shapeA: Shape;
shapeB: Shape;
frictionCoefficient: number;
setSlipForce(slipForce: number): void;
getSlipForce(): number;
}
export class RotationalLockEquation extends Equation {
constructor(bodyA: Body, bodyB: Body, options?: {
angle?: number;
});
angle: number;
}
export class RotationalVelocityEquation extends Equation {
constructor(bodyA: Body, bodyB: Body);
}
export class EventEmitter {
on(type: string, listener: Function, context?: any): EventEmitter;
has(type: string, listener: Function): boolean;
off(type: string, listener: Function): EventEmitter;
emit(event: any): EventEmitter;
}
export class ContactMaterialOptions {
friction?: number;
restitution?: number;
stiffness?: number;
relaxation?: number;
frictionStiffness?: number;
frictionRelaxation?: number;
surfaceVelocity?: number;
}
export class ContactMaterial {
constructor(materialA: Material, materialB: Material, options?: ContactMaterialOptions);
id: number;
materialA: Material;
materialB: Material;
friction: number;
restitution: number;
stiffness: number;
relaxation: number;
frictionStuffness: number;
frictionRelaxation: number;
surfaceVelocity: number;
contactSkinSize: number;
}
export class Material {
constructor(id: number);
id: number;
}
export class vec2 {
static add(out: number[], a: number[], b: number[]): number[];
static centroid(out: number[], a: number[], b: number[], c: number[]): number[];
static clone(a: number[]): number[];
static copy(out: number[], a: number[]): number[];
static create(): number[];
static crossLength(a: number[], b: number[]): number;
static crossVZ(out: number[], vec: number[], zcomp: number): number;
static crossZV(out: number[], zcomp: number, vec: number[]): number;
static dist(a: number[], b: number[]): number;
static distance(a: number[], b: number[]): number;
static div(out: number[], a: number[], b: number[]): number[];
static divide(out: number[], a: number[], b: number[]): number[];
static dot(a: number[], b: number[]): number;
static fromValues(x: number, y: number): number[];
static getLineSegmentsIntersection(out: number[], p0: number[], p1: number[], p2: number[], p3: number[]): boolean;
static getLineSegmentsIntersectionFraction(p0: number[], p1: number[], p2: number[], p3: number[]): number;
static len(a: number[]): number;
static length(a: number[]): number;
static lerp(out: number[], a: number[], b: number[], t: number): void;
static mul(out: number[], a: number[], b: number[]): number[];
static multiply(out: number[], a: number[], b: number[]): number[];
static negate(out: number[], a: number[]): number[];
static normalize(out: number[], a: number[]): number[];
static reflect(out: number[], vector: number[], normal: number[]): void;
static rotate(out: number[], a: number[], angle: number): void;
static rotate90cw(out: number[], a: number[]): void;
static scale(out: number[], a: number[], b: number): number[];
static set(out: number[], x: number, y: number): number[];
static sqrDist(a: number[], b: number[]): number;
static squaredDistance(a: number[], b: number[]): number;
static sqrLen(a: number[]): number;
static squaredLength(a: number[]): number;
static str(vec: number[]): string;
static sub(out: number[], a: number[], b: number[]): number[];
static subtract(out: number[], a: number[], b: number[]): number[];
static toGlobalFrame(out: number[], localPoint: number[], framePosition: number[], frameAngle: number): void;
static toLocalFrame(out: number[], worldPoint: number[], framePosition: number[], frameAngle: number): void;
static vectorToLocalFrame(out: number[], worldVector: number[], frameAngle: number): void;
}
// export class BodyOptions {
//
// mass: number;
// position: number[];
// velocity: number[];
// angle: number;
// angularVelocity: number;
// force: number[];
// angularForce: number;
// fixedRotation: number;
//
// }
/**
* 刚体。有质量、位置、速度等属性以及一组被用于碰撞的形状
*
* @class Body
* @constructor
* @extends EventEmitter
* @param {Array} [options.force]
* @param {Array} [options.position]
* @param {Array} [options.velocity]
* @param {Boolean} [options.allowSleep]
* @param {Boolean} [options.collisionResponse]
* @param {Number} [options.angle=0]
* @param {Number} [options.angularForce=0]
* @param {Number} [options.angularVelocity=0]
* @param {Number} [options.ccdIterations=10]
* @param {Number} [options.ccdSpeedThreshold=-1]
* @param {Number} [options.fixedRotation=false]
* @param {Number} [options.gravityScale]
* @param {Number} [options.id]
* @param {Number} [options.mass=0] 一个大于0的数字。如果设置成0,其type属性将被设置为 Body.STATIC.
* @param {Number} [options.sleepSpeedLimit]
* @param {Number} [options.sleepTimeLimit]
* @param {Object} [options]
*
* @example
* // 创建一个刚体
* var body = new Body({
* mass: 1,
* position: [0, 0],
* angle: 0,
* velocity: [0, 0],
* angularVelocity: 0
* });
*
* // 将一个圆形形状添加到刚体
* body.addShape(new Circle({ radius: 1 }));
*
* // 将刚体加入 world
* world.addBody(body);
*/
export class Body extends EventEmitter {
sleepyEvent: {
type: string;
};
sleepEvent: {
type: string;
};
wakeUpEvent: {
type: string;
};
static DYNAMIC: number;
static STATIC: number;
static KINEMATIC: number;
static AWAKE: number;
static SLEEPY: number;
static SLEEPING: number;
constructor(options?);
/**
* 刚体id
* @property id
* @type {Number}
*/
id: number;
/**
* 刚体被添加到的 world。如果没有被添加到 world 该属性将被设置为 null
* @property world
* @type {World}
*/
world: World;
/**
* 刚体的碰撞形状
*
* @property shapes
* @type {Array}
*/
shapes: Shape[];
/**
* 质量
* @property mass
* @type {number}
*/
mass: number;
/**
* 惯性
* @property inertia
* @type {number}
*/
inertia: number;
/**
* 是否固定旋转
* @property fixedRotation
* @type {Boolean}
*/
fixedRotation: boolean;
/**
* 位置
* @property position
* @type {Array}
*/
position: number[];
/**
* 位置插值
* @property interpolatedPosition
* @type {Array}
*/
interpolatedPosition: number[];
/**
* 角度插值
* @property interpolatedAngle
* @type {Number}
*/
interpolatedAngle: number;
/**
* 速度
* @property velocity
* @type {Array}
*/
velocity: number[];
/**
* 角度
* @property angle
* @type {number}
*/
angle: number;
/**
* 力
* @property force
* @type {Array}
*/
force: number[];
/**
* 角力
* @property angularForce
* @type {number}
*/
angularForce: number;
/**
* 限行阻尼。取值区间[0,1]
* @property damping
* @type {Number}
* @default 0.1
*/
damping: number;
/**
* 角阻尼。取值区间[0,1]
* @property angularDamping
* @type {Number}
* @default 0.1
*/
angularDamping: number;
/**
* 运动类型。 应该是Body.STATIC,Body.DYNAMIC,Body.KINEMATIC之一
*
* * Static 刚体不会动,不响应力或者碰撞
* * Dynamic 刚体会动,响应力和碰撞
* * Kinematic 刚体仅根据自身属性运动,不响应力或者碰撞
*
* @property type
* @type {number}
*
* @example
* // 默认值是STATIC
* var body = new Body();
* console.log(body.type == Body.STATIC); // true
*
* @example
* // 将质量设置为非0的值,会变为DYNAMIC
* var dynamicBody = new Body({
* mass : 1
* });
* console.log(dynamicBody.type == Body.DYNAMIC); // true
*
* @example
* // KINEMATIC刚体只会运动,如果你改变它的速度
* var kinematicBody = new Body({
* type: Body.KINEMATIC
* });
*/
type: number;
/**
* 边界圆半径
* @property boundingRadius
* @type {Number}
*/
boundingRadius: number;
/**
* 边框
* @property aabb
* @type {AABB}
*/
aabb: AABB;
/**
* 设置AABB是否会更新。通过调用 updateAABB 方法更新它
* @property aabbNeedsUpdate
* @type {Boolean}
* @see updateAABB
*
* @example
* body.aabbNeedsUpdate = true;
* body.updateAABB();
* console.log(body.aabbNeedsUpdate); // false
*/
aabbNeedsUpdate: boolean;
/**
* 设置为true,刚体会自动进入睡眠。需要在 World 中允许刚体睡眠
* @property allowSleep
* @type {Boolean}
* @default true
*/
allowSleep: boolean;
/**
* Body.AWAKE,Body.SLEEPY,Body.SLEEPING之一
*
* 默认值是 Body.AWAKE。如果刚体速度低于 sleepSpeedLimit,该属性将变为 Body.SLEEPY。如果持续 Body.SLEEPY 状态 sleepTimeLimit 秒,该属性将变为 Body.SLEEPY。
*
* @property sleepState
* @type {Number}
* @default Body.AWAKE
*/
sleepState: number;
/**
* 如果速度小于该值,sleepState 将变为 Body.SLEEPY 状态
* @property sleepSpeedLimit
* @type {Number}
* @default 0.2
*/
sleepSpeedLimit: number;
/**
* 如果持续 Body.SLEEPY 状态 sleepTimeLimit 秒,sleepState 将变为 Body.SLEEPING
* @property sleepTimeLimit
* @type {Number}
* @default 1
*/
sleepTimeLimit: number;
/**
* 重力缩放因子。如果你想忽略刚体重心,设置为零。如果你想反转重力,将其设置为-1。
* @property {Number} gravityScale
* @default 1
*/
gravityScale: number;
/**
* The angular velocity of the body, in radians per second.
* @property angularVelocity
* @type {number}
*/
angularVelocity: number;
/**
* The inverse inertia of the body.
* @property invInertia
* @type {number}
*/
invInertia: number;
/**
* The inverse mass of the body.
* @property invMass
* @type {number}
*/
invMass: number;
/**
* The previous angle of the body.
* @property previousAngle
* @type {number}
*/
previousAngle: number;
/**
* The previous position of the body.
* @property previousPosition
* @type {Array}
*/
previousPosition: number[];
/**
* Constraint velocity that was added to the body during the last step.
* @property vlambda
* @type {Array}
*/
vlambda: number[];
/**
* Angular constraint velocity that was added to the body during last step.
* @property wlambda
* @type {Array}
*/
wlambda: number[];
/**
* The number of iterations that should be used when searching for the time of impact during CCD. A larger number will assure that there's a small penetration on CCD collision, but a small number will give more performance.
* @property {Number} ccdIterations
* @default 10
*/
ccdIterations: number;
/**
* If the body speed exceeds this threshold, CCD (continuous collision detection) will be enabled. Set it to a negative number to disable CCD completely for this body.
* @property {Number} ccdSpeedThreshold
* @default -1
*/
ccdSpeedThreshold: number;
/**
* Whether to produce contact forces when in contact with other bodies. Note that contacts will be generated, but they will be disabled. That means that this body will move through other bodies, but it will still trigger contact events, etc.
* @property collisionResponse
* @type {Boolean}
*/
collisionResponse: boolean;
/**
* Set to true if you want to fix the body movement along the X axis. The body will still be able to move along Y.
* @property fixedX
* @type {Boolean}
*/
fixedX: boolean;
/**
* Set to true if you want to fix the body movement along the Y axis. The body will still be able to move along X.
* @property fixedY
* @type {Boolean}
*/
fixedY: boolean;
/**
* How long the body has been sleeping.
* @property idleTime
* @type {Number}
*/
idleTime: number;
/**
* 与每个形状对应的显示对象
*/
displays: engine.DisplayObject[];
/**
* 设置刚体总密度
* @method setDensity
*/
setDensity(density: number): void;
/**
* 得到所有形状的总面积
* @method getArea
* @return {Number}
*/
getArea(): number;
/**
* 获得AABB
* @method getAABB
*/
getAABB(): AABB;
/**
* 更新AABB
* @method updateAABB
*/
updateAABB(): void;
/**
* 更新外边界
* @method updateBoundingRadius
*/
updateBoundingRadius(): void;
/**
* 添加一个形状
*
* @method addShape
* @param {Shape} shape 形状
* @param {Array} [offset] 偏移
* @param {Number} [angle] 角度
*
* @example
* var body = new Body(),
* shape = new Circle();
*
* // 位于中心
* body.addShape(shape);
*
* // 偏移量为x轴一个单位
* body.addShape(shape,[1,0]);
*
* // 偏移量为y轴一个单位,同时逆时针旋转90度
* body.addShape(shape,[0,1],Math.PI/2);
*/
addShape(shape: Shape, offset?: number[], angle?: number): void;
/**
* 移除形状
* @method removeShape
* @param {Shape} shape
* @return {Boolean}
*/
removeShape(shape: Shape): boolean;
/**
* 更新属性,结构或者质量改变时会被调用
*
* @method updateMassProperties
*
* @example
* body.mass += 1;
* body.updateMassProperties();
*/
updateMassProperties(): void;
/**
* 相对于 world 中的一个点施加力
* @method applyForce
* @param {Array} force 力
* @param {Array} relativePoint 以物体中心点为基准的点
*/
applyForce(force: number[], relativePoint: number[]): void;
/**
* Wake the body up. Normally you should not need this, as the body is automatically awoken at events such as collisions.
* Sets the sleepState to {{#crossLink "Body/AWAKE:property"}}Body.AWAKE{{/crossLink}} and emits the wakeUp event if the body wasn't awake before.
* @method wakeUp
*/
wakeUp(): void;
/**
* Force body sleep
* @method sleep
*/
sleep(): void;
/**
* Called every timestep to update internal sleep timer and change sleep state if needed.
* @method sleepTick
* @param {number} time The world time in seconds
* @param {boolean} dontSleep
* @param {number} dt
*/
sleepTick(time: number, dontSleep: boolean, dt: number): void;
/**
* Check if the body is overlapping another body. Note that this method only works if the body was added to a World and if at least one step was taken.
* @method overlaps
* @param {Body} body
* @return {boolean}
*/
overlaps(body: Body): boolean;
/**
* Moves the shape offsets so their center of mass becomes the body center of mass.
* @method adjustCenterOfMass
*/
adjustCenterOfMass(): void;
/**
* Apply damping.
* @method applyDamping
* @param {number} dt Current time step
*/
applyDamping(dt: number): void;
/**
* Reads a polygon shape path, and assembles convex shapes from that and puts them at proper offset points.
* @method fromPolygon
* @param {Array} path An array of 2d vectors, e.g. [[0,0],[0,1],...] that resembles a concave or convex polygon. The shape must be simple and without holes.
* @param {Object} [options]
* @param {Boolean} [options.optimalDecomp=false] Set to true if you need optimal decomposition. Warning: very slow for polygons with more than 10 vertices.
* @param {Boolean} [options.skipSimpleCheck=false] Set to true if you already know that the path is not intersecting itself.
* @param {Boolean|Number} [options.removeCollinearPoints=false] Set to a number (angle threshold value) to remove collinear points, or false to keep all points.
* @return {Boolean} True on success, else false.
*/
fromPolygon(path:number[][], options?: {
optimalDecomp?: boolean;
skipSimpleCheck?: boolean;
removeCollinearPoints?: boolean; // Boolean | Number
}): boolean;
/**
* Sets the force on the body to zero.
* @method setZeroForce
*/
setZeroForce(): void;
/**
* Transform a world point to local body frame.
* @method toLocalFrame
* @param {Array} out The vector to store the result in
* @param {Array} worldPoint The input world point
*/
toLocalFrame(out: number[], worldPoint: number[]): void;
/**
* Transform a local point to world frame.
* @method toWorldFrame
* @param {Array} out The vector to store the result in
* @param {Array} localPoint The input local point
*/
toWorldFrame(out: number[], localPoint: number[]): void;
/**
* Apply force to a body-local point.
* @method applyForceLocal
* @param {Array} localForce The force vector to add, oriented in local body space.
* @param {Array} localPoint A point relative to the body in world space. If not given, it is set to zero and all of the impulse will be excerted on the center of mass.
*/
applyForceLocal(localForce: number[], localPoint: number[]): void;
/**
* Apply impulse to a point relative to the body. This could for example be a point on the Body surface. An impulse is a force added to a body during a short period of time (impulse = force * time). Impulses will be added to Body.velocity and Body.angularVelocity.
* @method applyImpulse
* @param {Array} impulse The impulse vector to add, oriented in world space.
* @param {Array} relativePoint A point relative to the body in world space. If not given, it is set to zero and all of the impulse will be excerted on the center of mass.
*/
applyImpulse(impulse: number[], relativePoint: number[]): void;
/**
* Apply impulse to a point relative to the body. This could for example be a point on the Body surface. An impulse is a force added to a body during a short period of time (impulse = force * time). Impulses will be added to Body.velocity and Body.angularVelocity.
* @method applyImpulseLocal
* @param {Array} impulse The impulse vector to add, oriented in world space.
* @param {Array} relativePoint A point relative to the body in world space. If not given, it is set to zero and all of the impulse will be excerted on the center of mass.
*/
applyImpulseLocal(impulse: number[], relativePoint: number[]): void;
/**
* Get velocity of a point in the body.
* @method getVelocityAtPoint
* @param {Array} result A vector to store the result in
* @param {Array} relativePoint A world oriented vector, indicating the position of the point to get the velocity from
* @return {Array}
*/
getVelocityAtPoint(result: number[], relativePoint: number[]): number[];
/**
* Move the body forward in time given its current velocity.
* @method integrate
* @param {number} dt
*/
integrate(dt: number): void;
/**
* Transform a world point to local body frame.
* @method vectorToLocalFrame
* @param {Array} out The vector to store the result in
* @param {Array} worldVector The input world vector
*/
vectorToLocalFrame(out: number[], worldVector: number[]): void;
/**
* Transform a local point to world frame.
* @method vectorToWorldFrame
* @param {Array} out The vector to store the result in
* @param {Array} localVector The input local vector
*/
vectorToWorldFrame(out: number[], localVector: number[]): void;
}
/**
* Box shape class.
*
* @class Box
* @constructor
* @extends Convex
* @param {Object} [options] (Note that this options object will be passed on to the Shape constructor.)
* @param {Number} [options.width=1] Total width of the box
* @param {Number} [options.height=1] Total height of the box
*/
export class Box extends Convex {
constructor(options?: Object);
width: number;
height: number;
}
export class Pool {
objects: any[];
get(): Object;
release(object: Object): Pool;
resize(size: number): Pool;
}
export class OverlapKeeperRecordPool extends Pool {
}
export class IslandPool extends Pool {
}
export class IslandNodePool extends Pool {
}
export class ContactEquationPool extends Pool {
}
export class FrictionEquationPool extends Pool {
}
export class Ray {
static ALL: number;
static ANY: number;
static CLOSEST: number;
constructor(options?: {
from?: number[];
to?: number[];
checkCollisionResponse?: boolean;
skipBackfaces?: boolean;
collisionMask?: number;
collisionGroup?: number;
mode?: number;
callback?: number;
});
callback: Function;
checkCollisionResponse: boolean;
collisionGroup: number;
collisionMask: number;
direction: number[];
from: number[];
length: number;
mode: number;
skipBackfaces: boolean;
to: number[];
getAABB(aabb: AABB): void;
intersectBodies(bodies: Body[]): void;
update(): void;
}
export class RaycastResult {
body: Body;
faceIndex: number;
fraction: number;
isStopped: boolean;
normal: number[];
shape: Shape;
getHitDistance(ray: Ray): void;
getHitPoint(out:number[], ray: Ray): void;
hasHit():boolean;
reset(): void;
stop(): void;
}
export class TopDownVehicle {
constructor(chassisBody: Body, options?: Object);
chassisBody: Body;
wheels: WheelConstraint[];
addToWorld(world: World): void;
addWheel(wheelOptions?: Object): WheelConstraint;
removeFromWorld(world: World): void;
update(): void;
}
export class WheelConstraint extends Constraint {
constructor(vehicle: TopDownVehicle, options?: {
localForwardVector?: number[];
localPosition?: number[];
sideFriction?: number;
});
engineForce: number;
localForwardVector: number[];
localPosition: number[];
steerValue: number;
getSpeed(): number;
update(): void;
}
export class Spring {
constructor(bodyA: Body, bodyB: Body, options?: {
stiffness?: number;
damping?: number;
localAnchorA?: number[];
localAnchorB?: number[];
worldAnchorA?: number[];
worldAnchorB?: number[];
});
bodyA: Body;
bodyB: Body;
damping: number;
stiffness: number;
applyForce(): void;
}
export class LinearSpring extends Spring {
constructor(bodyA: Body, bodyB: Body, options?: {
restLength?: number;
stiffness?: number;
damping?: number;
worldAnchorA?: number[];
worldAnchorB?: number[];
localAnchorA?: number[];
localAnchorB?: number[];
});
localAnchorA: number[];
localAnchorB: number[];
restLength: number;
setWorldAnchorA(worldAnchorA: number[]): void;
setWorldAnchorB(worldAnchorB: number[]): void;
getWorldAnchorA(result: number[]): void;
getWorldAnchorB(result: number[]): void;
}
export class RotationalSpring extends Spring {
constructor(bodyA: Body, bodyB: Body, options?: {
restAngle?: number;
stiffness?: number;
damping?: number;
});
restAngle: number;
}
/**
* Capsule shape class.
*
* @class Capsule
* @constructor
* @extends Shape
* @param {Object} [options] (Note that this options object will be passed on to the Shape constructor.)
* @param {Number} [options.length=1] The distance between the end points
* @param {Number} [options.radius=1] Radius of the capsule
*/
export class Capsule extends Shape {
constructor(options?: Object);
length: number;
radius: number;
conputeMomentOfInertia(mass: number): number;
}
/**
* Circle shape class.
*
* @class Circle
* @constructor
* @extends Shape
* @param {Object} [options] (Note that this options object will be passed on to the Shape constructor.)
* @param {Number} [options.radius=1] The radius of this circle
* @example
* var circleShape = new Circle({ radius: 1 });
* body.addShape(circleShape);
*/
export class Circle extends Shape {
constructor(options?: Object);
/**
* 半径
* @property radius
* @type {number}
*/
radius: number;
}
/**
* Convex shape class.
*
* @class Convex
* @constructor
* @extends Shape
* @param {Object} [options] (Note that this options object will be passed on to the Shape constructor.)
* @param {Array} [options.vertices] An array of vertices that span this shape. Vertices are given in counter-clockwise (CCW) direction.
* @param {Array} [options.axes] An array of unit length vectors, representing the symmetry axes in the convex.
* @example
* var vertices = [[-1,-1], [1,-1], [1,1], [-1,1]];
* var convexShape = new Convex({ vertices: vertices });
* body.addShape(convexShape);
*/
export class Convex extends Shape {
static projectOntoAxis(offset: number[], localAxis: number[], result: number[]): void;
static triangleArea(a: number[], b: number[], c: number[]): number;
constructor(options?: Object);
vertices: number[][];
axes: number[];
centerOfMass: number[];
triangles: number[];
updateCenterOfMass(): void;
updateTriangles(): void;
}
export class Heightfield extends Shape {
constructor(options?: {
heights?: number[];
minValue?: number;
maxValue?: number;
elementWidth?: number;
});
heights: number[];
maxValue: number;
minValue: number;
elementWidth: number;
getLineSegment(start:number[], end:number[], i:number): void;
updateMaxMinValues(): void;
}
export class Shape {
static BOX: number;
static CAPSULE: number;
static CIRCLE: number;
static CONVEX: number;
static HEIGHTFIELD: number;
static LINE: number;
static PARTICLE: number;
static PLANE: number;
constructor(options?: {
position?: number[];
angle?: number;
collisionGroup?: number;
collisionMask?: number;
sensor?: boolean;
collisionResponse?: boolean;
type?: number;
});
angle: number;
area: number;
body: Body;
boundingRadius: number;
collisionGroup: number;
collisionMask: number;
collisionResponse: boolean;
id: number;
material: Material;
position: number[];
sensor: boolean;
type: number;
computeAABB(out: AABB, position: number[], angle: number): void;
computeMomentOfInertia(mass: number): number;
raycast(result: RaycastResult, ray: Ray, position: number[], angle: number): void;
updateArea(): void;
updateBoundingRadius(): number;
}
export class Line extends Shape {
constructor(options?: {
length?: number;
});
length: number;
}
export class Particle extends Shape {
}
export class Plane extends Shape {
}
export class Solver extends EventEmitter {
constructor();
equations: Equation[];
equationSortFunction: Function; //Function | boolean
addEquation(eq: Equation): void;
addEquations(eqs: Equation[]): void;
removeAllEquations(): void;
removeEquation(eq: Equation): void;
solve(dt: number, world: World): void;
solveIsland(dt: number, island: Island): void;
sortEquations(): void;
}
export class GSSolver extends Solver {
constructor(options?: {
iterations?: number;
tolerance?: number;
});
iterations: number;
tolerance: number;
useZeroRHS: boolean;
frictionIterations: number;
usedIterations: number;
solve(h: number, world: World): void;
}
export class OverlapKeeper {
constructor();
recordPool: OverlapKeeperRecordPool;
tick(): void;
setOverlapping(bodyA: Body, shapeA: Body, bodyB: Body, shapeB: Body): void;
bodiesAreOverlapping(bodyA: Body, bodyB: Body): boolean;
}
export class OverlapKeeperRecord {
constructor(bodyA: Body, shapeA: Shape, bodyB: Body, shapeB: Shape);
bodyA: Body;
bodyB: Body;
shapeA: Shape;
shapeB: Shape;
set(bodyA: Body, shapeA: Shape, bodyB: Body, shapeB: Shape): void;
}
export class TupleDictionary {
data: Object;
keys: number[];
copy(dict: TupleDictionary): void;
get(i: number, j: number): number;
getByKey(key: number): Object;
getKey(i: number, j: number): string;
reset(): void;
set(i: number, j: number, value: number): void;
}
export class Utils {
static appendArray<T>(a: Array<T>, b: Array<T>): Array<T>;
static splice<T>(array: Array<T>, index: number, howMany: number): void;
static extend(a: any, b: any): void;
static defaults(options: any, defaults: any): any;
}
export class Island {
equations: Equation[];
bodies: Body[];
reset(): void;
getBodies(): Body[];
wantsToSleep(): boolean;
sleep(): void;
}
export class IslandManager extends Solver {
static getUnvisitedNode(nodes: Node[]): IslandNode; // IslandNode | boolean
constructor(options?: Object);
islands: Island[];
nodes: IslandNode[];
islandPool: IslandPool;
nodePool: IslandNodePool;
visit(node: IslandNode, bds: Body[], eqs: Equation[]): void;
bfs(root: IslandNode, bds: Body[], eqs: Equation[]): void;
split(world: World): Island[];
}
export class IslandNode {
constructor(body: Body);
body: Body;
neighbors: IslandNode[];
equations: Equation[];
visited: boolean;
reset(): void;
}
/**
* world,包含所有刚体
*
* @class World
* @constructor
* @param {Object} [options]
* @param {Solver} [options.solver] 默认值 GSSolver.
* @param {Array} [options.gravity] 默认值 [0,-9.78]
* @param {Broadphase} [options.broadphase] 默认值 NaiveBroadphase
* @param {Boolean} [options.islandSplit=false]
* @param {Boolean} [options.doProfiling=false]
* @extends EventEmitter
*
* @example
* var world = new World({
* gravity: [0, -9.81],
* broadphase: new SAPBroadphase()
* });
*/
export class World extends EventEmitter {
/**
* step() 执行之后调用
* @event postStep
*/
postStepEvent: {
type: string;
};
/**
* Body 加入时调用
* @event addBody
* @param {Body} body
*/
addBodyEvent: {
type: string;
body: Body;
};
/**
* Body移除时调用
* @event removeBody
* @param {Body} body
*/
removeBodyEvent: {
type: string;
body: Body;
};
/**
* Spring 加入时调用
* @event addSpring
* @param {Spring} spring
*/
addSpringEvent: {
type: string;
spring: Spring;
};
/**
* 当两个刚体第一次碰撞时调用。调用时碰撞步骤已经完成
* @event impact
* @param {Body} bodyA
* @param {Body} bodyB
*/
impactEvent: {
type: string;
bodyA: Body;
bodyB: Body;
shapeA: Shape;
shapeB: Shape;
contactEquation: ContactEquation;
};
/**
* 当 Broadphase 手机对碰之后被调用
* @event postBroadphase
* @param {Array} 对碰数组
*/
postBroadphaseEvent: {
type: string;
pairs: Body[];
};
/**
* 当两个形状重叠时调用
* @event beginContact
* @param {Shape} shapeA
* @param {Shape} shapeB
* @param {Body} bodyA
* @param {Body} bodyB
* @param {Array} contactEquations
*/
beginContactEvent: {
type: string;
shapeA: Shape;
shapeB: Shape;
bodyA: Body;
bodyB: Body;
contactEquations: ContactEquation[];
};
/**
* 当两个形状停止重叠时调用
* @event endContact
* @param {Shape} shapeA
* @param {Shape} shapeB
* @param {Body} bodyA
* @param {Body} bodyB
*/
endContactEvent: {
type: string;
shapeA: Shape;
shapeB: Shape;
bodyA: Body;
bodyB: Body;
};
/**
* Fired just before equations are added to the solver to be solved. Can be used to control what equations goes into the solver.
* @event preSolve
* @param {Array} contactEquations An array of contacts to be solved.
* @param {Array} frictionEquations An array of friction equations to be solved.
*/
preSolveEvent: {
type: string;
contactEquations: ContactEquation[];
frictionEquations: FrictionEquation[];
};
/**
* 从不让刚体睡眠
* @static
* @property {number} NO_SLEEPING
*/
static NO_SLEEPING: number;
/**
* 刚体睡眠
* @static
* @property {number} BODY_SLEEPING
*/
static BODY_SLEEPING: number;
/**
* 取消激活在接触中的刚体,如果所有刚体都接近睡眠。必须设置 World.islandSplit
* @static
* @property {number} ISLAND_SLEEPING
*/
static ISLAND_SLEEPING: number;
constructor(options?: {
solver?: Solver;
gravity?: number[];
broadphase?: Broadphase;
islandSplit?: boolean;
});
/**
* For keeping track of what time step size we used last step
* @property lastTimeStep
* @type {number}
*/
lastTimeStep: number;
overlapKeeper: OverlapKeeper;
/**
* If the length of .gravity is zero, and .useWorldGravityAsFrictionGravity=true, then switch to using .frictionGravity for friction instead. This fallback is useful for gravityless games.
* @property {boolean} useFrictionGravityOnZeroGravity
* @default true
*/
useFrictionGravityOnZeroGravity: boolean;
/**
* 所有 Spring
* @property springs
* @type {Array}
*/
springs: Spring[];
/**
* 所有 Body
* @property {Array} bodies
*/
bodies: Body[];
/**
* 所使用的求解器,以满足约束条件和接触。 默认值是 GSSolver
* @property {Solver} solver
*/
solver: Solver;
/**
* @property narrowphase
* @type {Narrowphase}
*/
narrowphase: Narrowphase;
/**
* The island manager of this world.
* @property {IslandManager} islandManager
*/
islandManager: IslandManager;
/**
* 重力。在每个 step() 开始对所有刚体生效
*
* @property gravity
* @type {Array}
*/
gravity: number[];
/**
* 重力摩擦
* @property {Number} frictionGravity
*/
frictionGravity: number;
/**
* 设置为true,frictionGravity 会被自动设置为 gravity 长度.
* @property {Boolean} useWorldGravityAsFrictionGravity
*/
useWorldGravityAsFrictionGravity: boolean;
/**
* @property broadphase
* @type {Broadphase}
*/
broadphase: Broadphase;
/**
* 用户添加限制
*
* @property constraints
* @type {Array}
*/
constraints: Constraint[];
/**
* 默认材料,defaultContactMaterial 时使用
* @property {Material} defaultMaterial
*/
defaultMaterial: Material;
/**
* 使用的默认接触材料,如果没有接触材料被设置为碰撞的材料
* @property {ContactMaterial} defaultContactMaterial
*/
defaultContactMaterial: ContactMaterial;
/**
* 设置自动使用弹簧力
* @property applySpringForces
* @type {Boolean}
*/
applySpringForces: boolean;
/**
* 设置自动使用阻尼
* @property applyDamping
* @type {Boolean}
*/
applyDamping: boolean;
/**
* 设置自动使用重力
* @property applyGravity
* @type {Boolean}
*/
applyGravity: boolean;
/**
* 使用约束求解
* @property solveConstraints
* @type {Boolean}
*/
solveConstraints: boolean;
/**
* 接触材料
* @property contactMaterials
* @type {Array}
*/
contactMaterials: ContactMaterial[];
/**
* 世界时间
* @property time
* @type {Number}
*/
time: number;
/**
* 是否正在 step 阶段
* @property {Boolean} stepping
*/
stepping: boolean;
/**
* 是否启用岛内分裂
* @property {Boolean} islandSplit
*/
islandSplit: boolean;
/**
* 设置为true,world会派发 impact 事件,关闭可以提高性能
* @property emitImpactEvent
* @type {Boolean}
*/
emitImpactEvent: boolean;
/**
* 刚体睡眠策略。取值是 World.NO_SLEEPING,World.BODY_SLEEPING,World.ISLAND_SLEEPING 之一
* @property sleepMode
* @type {number}
* @default World.NO_SLEEPING
*/
sleepMode: number;
/**
* 添加约束
* @method addConstraint
* @param {Constraint} constraint
*/
addConstraint(constraint: Constraint): void;
/**
* 添加触点材料
* @method addContactMaterial
* @param {ContactMaterial} contactMaterial
*/
addContactMaterial(contactMaterial: ContactMaterial): void;
/**
* 移除触点材料
* @method removeContactMaterial
* @param {ContactMaterial} cm
*/
removeContactMaterial(cm: ContactMaterial): void;
/**
* 通过2个材料获得触点材料
* @method getContactMaterial
* @param {Material} materialA
* @param {Material} materialB
* @return {ContactMaterial} 获得的触点材料或者false
*/
getContactMaterial(materialA: Material, materialB: Material): ContactMaterial;
/**
* 移除约束
* @method removeConstraint
* @param {Constraint} constraint
*/
removeConstraint(constraint: Constraint): void;
/**
* 使物理系统向前经过一定时间
*
* @method step
* @param {Number} dt 时长
* @param {Number} [timeSinceLastCalled=0]
* @param {Number} [maxSubSteps=10]
*
* @example
* var world = new World();
* world.step(0.01);
*/
step(dt: number, timeSinceLastCalled?: number, maxSubSteps?: number): void;
/**
* 添加一个 Spring
*
* @method addSpring
* @param {Spring} spring
*/
addSpring(spring: Spring): void;
/**
* 移除一个 Spring
*
* @method removeSpring
* @param {Spring} spring
*/
removeSpring(spring: Spring): void;
/**
* 添加一个 Body
*
* @method addBody
* @param {Body} body
*
* @example
* var world = new World(),
* body = new Body();
* world.addBody(body);
*/
addBody(body: Body): void;
/**
* 移除一个 Body。如果在 step()阶段调用,将会在阶段之后移除
*
* @method removeBody
* @param {Body} body
*/
removeBody(body: Body): void;
/**
* 通过id获取一个 Body
* @method getBodyById
* @return {Body|Boolean} 得到的刚体或者false
*/
getBodyByID(id: number): Body;
/**
* 两个刚体之间禁用碰撞
* @method disableBodyCollision
* @param {Body} bodyA
* @param {Body} bodyB
*/
disableBodyCollision(bodyA: Body, bodyB: Body): void;
/**
* 两个刚体之间启用碰撞
* @method enableBodyCollision
* @param {Body} bodyA
* @param {Body} bodyB
*/
enableBodyCollision(bodyA: Body, bodyB: Body): void;
/**
* 重置 world
* @method clear
*/
clear(): void;
/**
* Test if a world point overlaps bodies
* @method hitTest
* @param {Array} worldPoint Point to use for intersection tests
* @param {Array} bodies A list of objects to check for intersection
* @param {number} precision Used for matching against particles and lines. Adds some margin to these infinitesimal objects.
* @return {Array} Array of bodies that overlap the point
*/
hitTest(worldPoint: number[], bodies: Body[], precision: number): Body[];
/**
* Ray cast against all bodies in the world.
* @method raycast
* @param {RaycastResult} result
* @param {Ray} ray
* @return {boolean} True if any body was hit.
*/
raycast(result: RaycastResult, ray: Ray): boolean;
/**
* Runs narrowphase for the shape pair i and j.
* @method runNarrowphase
* @param {Narrowphase} np
* @param {Body} bi
* @param {Shape} si
* @param {Array} xi
* @param {number} ai
* @param {Body} bj
* @param {Shape} sj
* @param {Array} xj
* @param {number} aj
* @param {number} mu
*/
runNarrowphase(np:Narrowphase, bi:Body, si:Shape, xi:number[], ai:number, bj:Body, sj:Shape, xj:number[], aj:number, mu:number): void;
/**
* Set the relaxation for all equations and contact materials.
* @method setGlobalRelaxation
* @param {number} relaxation
*/
setGlobalRelaxation(relaxation: number): void;
/**
* Set the stiffness for all equations and contact materials.
* @method setGlobalStiffness
* @param {Number} stiffness
*/
setGlobalStiffness(stiffness: number): void;
}
}
\ No newline at end of file
/**
* 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