Commit b5274699 authored by lujinlei's avatar lujinlei

1

parent 72c4b76a
{
"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
},
"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-13b139664ab1",
"ext": ".png"
},
{
"name": "frontbox_4",
"url": "//yun.duiba.com.cn/aurora/assets/fde8c60981791e5136c7914274c2a2d0936626cd.png",
"uuid": "aa30ee7c-a6ad-4e10-9b6a-13b139664ab2",
"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
}
}
},
"id": "doll-machine2",
"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"
}
{
"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": {
"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) {
GameView.prototype.playShake = function () {
var _this = this;
var _a = this.frontContainer, x = _a.x, y = _a.y;
let a = '';
a.substr
return new Promise(function (resolve) {
var shakeOffset = 7;
var duration = 30;
......
/**
* 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;;CCXD,IAAO,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;CAKtC;KAA0BA,8BAAgB;KAA1C;;MA6FC;KA1FG,oBAAK,G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AAK;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);
}
......@@ -20,6 +20,7 @@ class AnimationPool extends Pool<PoolFrameAnimation> {
} else {
let anim = new PoolFrameAnimation(key);
this.layer.addChild(anim);
return anim;
}
}
......
/**
* 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