Commit 5e9c78f6 authored by zjz1994's avatar zjz1994

代码暂存

parent 81e5868b
{
"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": "#ffffff"
},
"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": "bg1",
"url": "//yun.duiba.com.cn/aurora/assets/b2c76b2a753317e5ea935bab22097a43a4c9f7cb.png",
"uuid": "bg1",
"ext": ".png"
},
{
"name": "bg2",
"url": "//yun.duiba.com.cn/aurora/assets/7f8261a9dd7b83cdc3b95b6f3f385e7a91e49682.png",
"uuid": "bg2",
"ext": ".png"
},
{
"name": "bg3",
"url": "//yun.duiba.com.cn/aurora/assets/872c688f9c2f495fe234277256923804df2ab75e.png",
"uuid": "bg3",
"ext": ".png"
},
{
"name": "car1",
"url": "//yun.duiba.com.cn/aurora/assets/c1e80aee4eee3665e0f0bce08233b05be4b4ee9c.png",
"uuid": "car1",
"ext": ".png"
},
{
"name": "yindao1",
"url": "//yun.duiba.com.cn/aurora/assets/a0409ec24b35198e990c61bc7f5dc66b15a5213a.png",
"uuid": "yindao1",
"ext": ".png"
},
{
"name": "yindao2",
"url": "//yun.duiba.com.cn/aurora/assets/7ece2d8c438ec06004f7f40d9798ab72f0e6a244.png",
"uuid": "yindao2",
"ext": ".png"
},
{
"name": "shouzhi",
"url": "//yun.duiba.com.cn/aurora/assets/fd62b438bfd67345fe441f5e68e4394d650fac8d.png",
"uuid": "shouzhi",
"ext": ".png"
},
{
"name": "zhuzi1",
"url": "//yun.duiba.com.cn/aurora/assets/cb779c9ebf4bfbd5bec1d817a6ef824d4ae5d751.png",
"uuid": "zhuzi1",
"ext": ".png"
},
{
"name": "zhuzi2",
"url": "//yun.duiba.com.cn/aurora/assets/c5187595bec08c211c8e45bf5f163ff02fd659ab.png",
"uuid": "zhuzi2",
"ext": ".png"
},
{
"name": "zhuzi3",
"url": "//yun.duiba.com.cn/aurora/assets/08dc255864c2af52dac7a993a4c62b1970dd6db4.png",
"uuid": "zhuzi3",
"ext": ".png"
},
{
"name": "person",
"url": "//yun.duiba.com.cn/aurora/assets/094526243496c8ebf1002f73f3cbbf3c9e12892a.png",
"uuid": "person",
"ext": ".png"
},
{
"name": "gold",
"url": "//yun.duiba.com.cn/aurora/assets/ae210ad26cee13f8fb6e69be62f7f5498be50a5b.png",
"uuid": "7f4e19f2-c80f-4a65-bec2-1f3c3dc6d210",
"ext": ".png"
},
{
"name": "walk",
"url": "//yun.duiba.com.cn/aurora/assets/a4ab1e1a2b49d140db4a0806562098a8b1619b06.svga",
"uuid": "10cd1fdd-4fd8-43cf-a1c7-6ff5846d8a91",
"ext": ".svga"
}
],
"events": {
"in": {
"bjxd-game-start": {
"alias": "开始",
"data": {}
},
"bjxd-game-revive": {
"alias": "复活",
"data": {}
},
"bjxd-game-change": {
"alias": "替换显示",
"data": {
"index": 1
}
}
},
"out": {
"bjxd-game-over": {
"alias": "游戏结束",
"data": {
"score": 0
}
},
"bjxd-game-score": {
"alias": "分数",
"data": {
"score": 0
}
}
}
},
"id": "bjxd-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['bjxd-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}\r\n\t//# sourceMappingURL=props.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 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 pier.changeBg();\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.changeBg = function () {\r\n\t var nume = this.children.length;\r\n\t for (var i = 0; i < nume; i++) {\r\n\t var ipier = this.getChildAt(i);\r\n\t ipier.changeBg();\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 pier.changeBg();\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));\r\n\t//# sourceMappingURL=Road.js.map\n\n\tfunction getTexture(uuid) {\r\n\t return engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n\t}\r\n\tfunction getTextureByName(name) {\r\n\t return getTexture(engine.getAssetByName(name).uuid);\r\n\t}\r\n\tfunction 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}\r\n\t//# sourceMappingURL=utils.js.map\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.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 var _a = this.stage, width = _a.width, height = _a.height;\r\n\t this.guideMask = new engine.Container();\r\n\t this.addChild(this.guideMask);\r\n\t this.guideImg = new engine.Image();\r\n\t this.guideMask.addChild(this.guideImg);\r\n\t this.shouzhi = new engine.Image(getTextureByName(\"shouzhi\"));\r\n\t this.guideMask.addChild(this.shouzhi);\r\n\t }\r\n\t this.guideImg.texture = getTextureByName(\"yindao\" + id);\r\n\t this.guideStep(id);\r\n\t this.once(engine.MouseEvent.CLICK, function () {\r\n\t this.visible = false;\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.guideStep = function (id) {\r\n\t if (id == 1) {\r\n\t this.shouzhi.x = 244;\r\n\t this.shouzhi.y = 812;\r\n\t }\r\n\t if (id == 2) {\r\n\t this.shouzhi.x = 346;\r\n\t this.shouzhi.y = 1108;\r\n\t }\r\n\t };\r\n\t return GuideLayer;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=GuideLayer.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 if (item.length > 0) {\r\n\t part = new engine.Sprite(getTextureByName(item));\r\n\t }\r\n\t else {\r\n\t part = new engine.Sprite();\r\n\t }\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 if (changName && changName.length > 0) {\r\n\t item.texture = getTextureByName(changName);\r\n\t }\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));\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.partResHHL = ['bg1', ''];\r\n\t _this.partResHB = ['bg2', ''];\r\n\t _this.partResWH = ['bg3', ''];\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 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 };\r\n\t return Background;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=Background.js.map\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.part1tex = \"zhuzi1\";\r\n\t _this.part2tex = \"zhuzi2\";\r\n\t _this.part3tex = \"zhuzi3\";\r\n\t _this.texname = \"\";\r\n\t _this.zhuy = 1006;\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 this.changeBg();\r\n\t bmp.x = 0;\r\n\t bmp.y = this.zhuy;\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.changeBg = function () {\r\n\t var texstr;\r\n\t if (GameView.bgIndex == 0) {\r\n\t texstr = this.part1tex;\r\n\t }\r\n\t else if (GameView.bgIndex == 1) {\r\n\t texstr = this.part2tex;\r\n\t }\r\n\t else {\r\n\t texstr = this.part3tex;\r\n\t }\r\n\t if (this.texname != texstr) {\r\n\t this.texname = texstr;\r\n\t this.bmp.texture = getTextureByName(texstr);\r\n\t }\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 = this.zhuy - 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));\r\n\t//# sourceMappingURL=Pier.js.map\n\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.playery = 845;\r\n\t return _this;\r\n\t }\r\n\t Player.prototype.initPlayer = function (pierWidth) {\r\n\t this.pierWidth = 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 = this.playery;\r\n\t this.playerNode.x = pierWidth / 2 - 80;\r\n\t this.playerNode.play();\r\n\t };\r\n\t Player.prototype.revive = function () {\r\n\t this._container.x = 0;\r\n\t this._container.y = 0;\r\n\t this.playerNode.x = this.pierWidth / 2 - 80;\r\n\t this.playerNode.y = this.playery;\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));\r\n\t//# sourceMappingURL=Player.js.map\n\n\tvar Strut = (function (_super) {\r\n\t tslib.__extends(Strut, _super);\r\n\t function Strut() {\r\n\t var _this = _super !== null && _super.apply(this, arguments) || this;\r\n\t _this.gany = 1005;\r\n\t return _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 = this.gany;\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 var paddingx = 20;\r\n\t if (GameView.bgIndex == 0) {\r\n\t paddingx = 20;\r\n\t }\r\n\t else if (GameView.bgIndex == 1) {\r\n\t paddingx = 30;\r\n\t }\r\n\t else if (GameView.bgIndex == 2) {\r\n\t paddingx = 20;\r\n\t }\r\n\t this._strut.x = pierWidth - paddingx;\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 var paddingx = 20;\r\n\t var chax = 20;\r\n\t if (GameView.bgIndex == 0) {\r\n\t paddingx = 20;\r\n\t chax = 20;\r\n\t }\r\n\t else if (GameView.bgIndex == 1) {\r\n\t paddingx = 30;\r\n\t chax = 60;\r\n\t }\r\n\t else if (GameView.bgIndex == 2) {\r\n\t paddingx = 20;\r\n\t chax = 20;\r\n\t }\r\n\t if (this._distance[0] - this._distance[1] + chax <= this._strut.height && this._strut.height <= this._distance[0] + paddingx) {\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 = this.gany;\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));\r\n\t//# sourceMappingURL=Strut.js.map\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 };\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.revive = function () {\r\n\t console.log(\"复活---------\");\r\n\t this._player.revive();\r\n\t this._isTouchLayer = true;\r\n\t this.closeStrut();\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 };\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('bjxd-game-over', { 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 console.log(\"新分数\", this._sumScore);\r\n\t engine.globalEvent.dispatchEvent('bjxd-game-score', { score: 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 (GameView.bgIndex != index) {\r\n\t GameView.bgIndex = index;\r\n\t this._backgroud.changeBg(index);\r\n\t this._road.changeBg();\r\n\t }\r\n\t };\r\n\t GameView.bgIndex = 0;\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('bjxd-game-start', _this.start, _this);\r\n\t engine.globalEvent.addEventListener('bjxd-game-revive', _this.revive, _this);\r\n\t engine.globalEvent.addEventListener('bjxd-game-change', _this.change, _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 GameWrapper.prototype.revive = function () {\r\n\t this._gameView.revive();\r\n\t };\r\n\t GameWrapper.prototype.change = function (event) {\r\n\t this._gameView.changeBg(event.data.index);\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"
}
...@@ -194,5 +194,5 @@ ...@@ -194,5 +194,5 @@
} }
}, },
"id": "dxbcyj-game", "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" "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.pierWidth = 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.revive = function () {\r\n\t this._container.x = 0;\r\n\t this._container.y = 0;\r\n\t this.playerNode.x = this.pierWidth / 2 - 80;\r\n\t this.playerNode.y = 675;\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.revive = function () {\r\n\t console.log(\"复活---------\");\r\n\t this._player.revive();\r\n\t this._isTouchLayer = true;\r\n\t this.closeStrut();\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 this.testrevive = new engine.Label();\r\n\t this.addChild(this.testrevive);\r\n\t this.testrevive.size = 55;\r\n\t this.testrevive.text = \"复活\";\r\n\t this.testrevive.width = 500;\r\n\t this.testrevive.height = 200;\r\n\t this.testrevive.mouseEnabled = true;\r\n\t this.testrevive.addEventListener(engine.MouseEvent.CLICK, this.revive, this);\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 engine.globalEvent.addEventListener('dxbcyj-game-revive', _this.revive);\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 GameWrapper.prototype.revive = function () {\r\n\t this._gameView.revive();\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"
} }
...@@ -65,15 +65,28 @@ ...@@ -65,15 +65,28 @@
], ],
"events": { "events": {
"in": { "in": {
"pictures-initgame": {
"alias": "初始化",
"data": {
"gameUrls": [
"https://yun.duiba.com.cn/aurora/assets/1456b2a9d72e56f075abb29df99052d87a0f1e48.jpg",
"https://yun.duiba.com.cn/aurora/assets/61fd0754d7924305fd2851be86a480d71d2c2981.jpg",
"https://yun.duiba.com.cn/aurora/assets/6b70d7ec626f35f21347bf5bc3e61bedc44167be.jpg"
]
}
},
"pictures-start": { "pictures-start": {
"alias": "开始", "alias": "开始",
"data": { "data": {
"actidx": 1,
"rows": 3, "rows": 3,
"cols": 3, "cols": 3,
"picUrl": "图片",
"gametime": 30 "gametime": 30
} }
}, },
"pictures-luanxu": {
"alias": "乱序"
},
"pictures-pause": { "pictures-pause": {
"alias": "停止" "alias": "停止"
}, },
...@@ -97,5 +110,5 @@ ...@@ -97,5 +110,5 @@
} }
}, },
"id": "pintu", "id": "pintu",
"code": "(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :\n\ttypeof define === 'function' && define.amd ? define(['tslib'], factory) :\n\t(global = global || self, global.pintu = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n\tvar props = {};\r\n\tfunction prepareProps() {\r\n\t var metaProps = getProps();\r\n\t engine.injectProp(props, metaProps);\r\n\t}\r\n\tfunction injectProps(p) {\r\n\t engine.injectProp(props, p);\r\n\t}\r\n\t//# sourceMappingURL=props.js.map\n\n\tfunction getTexture(uuid) {\r\n\t return engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n\t}\r\n\tfunction getTextureByName(name) {\r\n\t return getTexture(engine.getAssetByName(name).uuid);\r\n\t}\r\n\tfunction loadImageByUrl(url) {\r\n\t return new Promise(function (resolve) {\r\n\t if (engine.TextureCache[url]) {\r\n\t resolve(engine.TextureCache[url]);\r\n\t }\r\n\t else {\r\n\t var t = engine.Texture.from(url);\r\n\t t.addEventListener(\"loaded\", function () { resolve(t); });\r\n\t }\r\n\t });\r\n\t}\r\n\t//# sourceMappingURL=utils.js.map\n\n\tvar qietu = (function (url, rows, cols, parent) { return tslib.__awaiter(void 0, void 0, void 0, function () {\r\n\t var t, mwid, mhei, picarr, picnames, r, startx, endx, c, starty, endy, uvs, itexture, itexname, e_1;\r\n\t return tslib.__generator(this, function (_a) {\r\n\t switch (_a.label) {\r\n\t case 0:\r\n\t _a.trys.push([0, 2, , 3]);\r\n\t return [4, loadImageByUrl(url)];\r\n\t case 1:\r\n\t t = _a.sent();\r\n\t mwid = t.width / rows;\r\n\t mhei = t.height / cols;\r\n\t picarr = {};\r\n\t picnames = [];\r\n\t for (r = 0; r < rows; r++) {\r\n\t startx = r / rows;\r\n\t endx = (r + 1) / rows;\r\n\t for (c = 0; c < cols; c++) {\r\n\t starty = c / cols;\r\n\t endy = (c + 1) / cols;\r\n\t uvs = new Float32Array([\r\n\t starty,\r\n\t startx,\r\n\t endy,\r\n\t startx,\r\n\t endy,\r\n\t endx,\r\n\t starty,\r\n\t endx\r\n\t ]);\r\n\t itexture = new engine.Sprite(t);\r\n\t itexture.uvs = uvs;\r\n\t itexture.width = mwid;\r\n\t itexture.height = mhei;\r\n\t itexname = \"pic_\" + c + \"_\" + r;\r\n\t itexture.name = itexname;\r\n\t picarr[itexname] = itexture;\r\n\t picnames.push(itexname);\r\n\t }\r\n\t }\r\n\t return [2, {\r\n\t res: true,\r\n\t picarr: picarr,\r\n\t mwid: mwid,\r\n\t mhei: mhei,\r\n\t picnames: picnames\r\n\t }];\r\n\t case 2:\r\n\t e_1 = _a.sent();\r\n\t console.error(\"图片加载失败\", e_1);\r\n\t console.log(url, rows, cols);\r\n\t return [2, {\r\n\t res: false\r\n\t }];\r\n\t case 3: return [2];\r\n\t }\r\n\t });\r\n\t}); });\r\n\t//# sourceMappingURL=qietu.js.map\n\n\tvar GameView = (function (_super) {\r\n\t tslib.__extends(GameView, _super);\r\n\t function GameView() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.ingame = false;\r\n\t _this.selectImgArr = [];\r\n\t _this.sucposData = {};\r\n\t _this.once(engine.Event.ADDED_TO_STAGE, _this.initScene, _this);\r\n\t return _this;\r\n\t }\r\n\t GameView.prototype.initScene = function () {\r\n\t this.lineShape = new engine.Shape();\r\n\t this.selectimg3 = new engine.Image(getTextureByName(\"框3\"));\r\n\t this.selectimg4 = new engine.Image(getTextureByName(\"框4\"));\r\n\t this.dicont = new engine.Container();\r\n\t this.linecont = new engine.Container();\r\n\t this.blockcont = new engine.Container();\r\n\t this.addChild(this.dicont);\r\n\t this.addChild(this.linecont);\r\n\t this.addChild(this.blockcont);\r\n\t this.linecont.addChild(this.lineShape);\r\n\t };\r\n\t GameView.prototype.start = function () {\r\n\t return tslib.__awaiter(this, void 0, void 0, function () {\r\n\t var picUrl, result, res, picarr, mwid, mhei, picnames, gap, r, c, ipicx, ipicy, npicname, selidx, ipicname, ipic, rl, cl;\r\n\t return tslib.__generator(this, function (_a) {\r\n\t switch (_a.label) {\r\n\t case 0:\r\n\t this.dicont.removeChildren();\r\n\t picUrl = props.picUrl;\r\n\t this.gametime = props.gametime;\r\n\t this.showtime = props.gametime;\r\n\t this.rows = props.rows;\r\n\t this.cols = props.cols;\r\n\t this.nselectimg = null;\r\n\t if (this.rows == 3) {\r\n\t this.nselectimg = this.selectimg3;\r\n\t }\r\n\t if (this.rows == 4) {\r\n\t this.nselectimg = this.selectimg4;\r\n\t }\r\n\t this.passtime = 0;\r\n\t this.selectImgArr = new Array();\r\n\t this.sucposData = {};\r\n\t return [4, qietu(picUrl, this.rows, this.cols, this.dicont)];\r\n\t case 1:\r\n\t result = _a.sent();\r\n\t res = result.res;\r\n\t if (res) {\r\n\t picarr = result.picarr;\r\n\t mwid = result.mwid;\r\n\t mhei = result.mhei;\r\n\t picnames = result.picnames;\r\n\t gap = 2;\r\n\t for (r = 0; r < this.rows; r++) {\r\n\t for (c = 0; c < this.cols; c++) {\r\n\t ipicx = mwid * c + gap;\r\n\t ipicy = mhei * r + gap;\r\n\t npicname = \"pic_\" + c + \"_\" + r;\r\n\t this.sucposData[npicname] = r + \"_\" + c;\r\n\t selidx = Math.floor(Math.random() * picnames.length);\r\n\t ipicname = picnames[selidx];\r\n\t if (r == c && r != this.rows - 1) {\r\n\t while (ipicname == npicname) {\r\n\t selidx = Math.floor(Math.random() * picnames.length);\r\n\t ipicname = picnames[selidx];\r\n\t }\r\n\t }\r\n\t ipic = picarr[ipicname];\r\n\t picnames.splice(selidx, 1);\r\n\t this.dicont.addChild(ipic);\r\n\t ipic.x = ipicx;\r\n\t ipic.y = ipicy;\r\n\t ipic[\"postr\"] = r + \"_\" + c;\r\n\t ipic.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.touchPic, this);\r\n\t }\r\n\t }\r\n\t this.lineShape.clear();\r\n\t this.lineShape.beginStroke(0x0069df, 4, engine.LINE_CAP.BUTT, engine.LINE_JOIN.BEVEL, 100);\r\n\t this.lineShape.moveTo(0 + gap, 0 + gap);\r\n\t this.lineShape.lineTo(mhei * this.cols + gap, 0 + gap);\r\n\t this.lineShape.lineTo(mhei * this.cols + gap, mwid * this.rows + gap);\r\n\t this.lineShape.lineTo(0 + gap, mwid * this.rows + gap);\r\n\t this.lineShape.lineTo(0 + gap, 0 + gap);\r\n\t for (rl = 1; rl < this.rows; rl++) {\r\n\t this.lineShape.moveTo(0 + gap, rl * mhei + gap);\r\n\t this.lineShape.lineTo(mwid * this.cols + gap, rl * mhei + gap);\r\n\t }\r\n\t for (cl = 1; cl < this.cols; cl++) {\r\n\t this.lineShape.moveTo(cl * mwid + gap, 0 + gap);\r\n\t this.lineShape.lineTo(cl * mwid + gap, this.rows * mhei + gap);\r\n\t }\r\n\t this.lineShape.endStroke();\r\n\t this.ticker = setInterval(this.update, 30);\r\n\t }\r\n\t else {\r\n\t console.error(\"图片处理失败\");\r\n\t }\r\n\t return [2];\r\n\t }\r\n\t });\r\n\t });\r\n\t };\r\n\t GameView.prototype.pause = function () {\r\n\t this.ingame = false;\r\n\t };\r\n\t GameView.prototype.resume = function () {\r\n\t this.ingame = true;\r\n\t };\r\n\t GameView.prototype.update = function () {\r\n\t var ntime = Date.now();\r\n\t if (!this.lastframetime) {\r\n\t this.lastframetime = ntime;\r\n\t return;\r\n\t }\r\n\t if (this.ingame) {\r\n\t var passtime = (ntime - this.lastframetime) / 1000;\r\n\t this.passtime += passtime;\r\n\t var showtime1 = Math.round(this.gametime - this.passtime);\r\n\t if (this.showtime != showtime1) {\r\n\t this.showtime = showtime1;\r\n\t if (this.showtime <= 0) {\r\n\t this.showtime = 0;\r\n\t this.gameover(2);\r\n\t }\r\n\t engine.globalEvent.dispatchEvent(\"pictures-time-update\", {\r\n\t time: this.showtime\r\n\t });\r\n\t }\r\n\t }\r\n\t this.lastframetime = ntime;\r\n\t };\r\n\t GameView.prototype.touchPic = function (e) {\r\n\t if (!this.ingame) {\r\n\t return;\r\n\t }\r\n\t var selectname = e.target.name;\r\n\t var spx = e.target.x;\r\n\t var spy = e.target.y;\r\n\t var gap = 2;\r\n\t if (this.selectImgArr.length == 0) {\r\n\t if (this.nselectimg) {\r\n\t this.blockcont.addChild(this.nselectimg);\r\n\t this.nselectimg.x = spx - gap;\r\n\t this.nselectimg.y = spy - gap;\r\n\t }\r\n\t this.selectImgArr.push(selectname);\r\n\t }\r\n\t else if (this.selectImgArr.length == 1) {\r\n\t if (selectname == this.selectImgArr[0]) {\r\n\t return;\r\n\t }\r\n\t else {\r\n\t this.selectImgArr.push(selectname);\r\n\t this.changeImgPos();\r\n\t }\r\n\t }\r\n\t };\r\n\t GameView.prototype.changeImgPos = function () {\r\n\t var img1name = this.selectImgArr[0];\r\n\t var img2name = this.selectImgArr[1];\r\n\t var img1 = this.dicont.getChildByName(img1name);\r\n\t var img2 = this.dicont.getChildByName(img2name);\r\n\t var imgpos1x = img1.x;\r\n\t var imgpos1y = img1.y;\r\n\t var imgpos2x = img2.x;\r\n\t var imgpos2y = img2.y;\r\n\t var imgpostr1 = img1.postr;\r\n\t var imgpostr2 = img2.postr;\r\n\t img1.x = imgpos2x;\r\n\t img1.y = imgpos2y;\r\n\t img1.postr = imgpostr2;\r\n\t img2.x = imgpos1x;\r\n\t img2.y = imgpos1y;\r\n\t img2.postr = imgpostr1;\r\n\t this.selectImgArr = new Array();\r\n\t if (this.nselectimg) {\r\n\t this.blockcont.removeChild(this.nselectimg);\r\n\t }\r\n\t var isuc = this.checkSuccess();\r\n\t if (isuc) {\r\n\t console.error(\"成功过关\");\r\n\t this.gameover(1);\r\n\t }\r\n\t };\r\n\t GameView.prototype.checkSuccess = function () {\r\n\t var isuc = true;\r\n\t for (var r = 0; r < this.rows; r++) {\r\n\t for (var c = 0; c < this.cols; c++) {\r\n\t var ipicname = \"pic_\" + c + \"_\" + r;\r\n\t var npicstr = r + \"_\" + c;\r\n\t var ipic = this.dicont.getChildByName(ipicname);\r\n\t var ipostr = ipic.postr;\r\n\t if (npicstr != ipostr) {\r\n\t isuc = false;\r\n\t break;\r\n\t }\r\n\t }\r\n\t }\r\n\t return isuc;\r\n\t };\r\n\t GameView.prototype.gameover = function (reason) {\r\n\t this.ingame = false;\r\n\t this.ticker && clearInterval(this.ticker);\r\n\t engine.globalEvent.dispatchEvent('pictures-game-over', {\r\n\t reason: reason,\r\n\t time: this.passtime\r\n\t });\r\n\t };\r\n\t return GameView;\r\n\t}(engine.Container));\n\n\tvar GameWrapper = (function (_super) {\r\n\t tslib.__extends(GameWrapper, _super);\r\n\t function GameWrapper() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this._gameView = new GameView();\r\n\t _this.addChild(_this._gameView);\r\n\t engine.globalEvent.addEventListener('pictures-start', _this.start, _this);\r\n\t engine.globalEvent.addEventListener('pictures-pause', _this.pause, _this);\r\n\t engine.globalEvent.addEventListener('pictures-resume', _this.resume, _this);\r\n\t return _this;\r\n\t }\r\n\t GameWrapper.prototype.start = function (event) {\r\n\t injectProps(event.data);\r\n\t this._gameView.start();\r\n\t };\r\n\t GameWrapper.prototype.pause = function (event) {\r\n\t this._gameView.pause();\r\n\t };\r\n\t GameWrapper.prototype.resume = function (event) {\r\n\t this._gameView.resume();\r\n\t };\r\n\t return GameWrapper;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=GameWrapper.js.map\n\n\tfunction index (props) {\r\n\t prepareProps();\r\n\t injectProps(props);\r\n\t var instance = new GameWrapper();\r\n\t return instance;\r\n\t}\r\n\t//# sourceMappingURL=index.js.map\n\n\treturn index;\n\n})));\n" "code": "(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :\n\ttypeof define === 'function' && define.amd ? define(['tslib'], factory) :\n\t(global = global || self, global.pintu = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n\tvar props = {};\r\n\tfunction prepareProps() {\r\n\t var metaProps = getProps();\r\n\t engine.injectProp(props, metaProps);\r\n\t}\r\n\tfunction injectProps(p) {\r\n\t engine.injectProp(props, p);\r\n\t}\r\n\t//# sourceMappingURL=props.js.map\n\n\tfunction getTexture(uuid) {\r\n\t return engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n\t}\r\n\tfunction getTextureByName(name) {\r\n\t return getTexture(engine.getAssetByName(name).uuid);\r\n\t}\r\n\tfunction loadImageByUrl(url) {\r\n\t console.log('loadImageByUrl----------:', url);\r\n\t return new Promise(function (resolve) {\r\n\t if (engine.TextureCache[url]) {\r\n\t resolve(engine.TextureCache[url]);\r\n\t }\r\n\t else {\r\n\t var t = engine.Texture.from(url);\r\n\t t.addEventListener(\"loaded\", function () { resolve(t); });\r\n\t }\r\n\t });\r\n\t}\r\n\t//# sourceMappingURL=utils.js.map\n\n\tvar qietu = (function (url, type1, rows, cols, parent) { return tslib.__awaiter(void 0, void 0, void 0, function () {\r\n\t var t, setimgwid, mwid1, mhei1, mwid, mhei, picarr, picnames, chax, chay, startlix, addlix, startliy, addliy, r, startx, endx, c, starty, endy, uvs, isprite, ispritename, e_1;\r\n\t return tslib.__generator(this, function (_a) {\r\n\t switch (_a.label) {\r\n\t case 0:\r\n\t _a.trys.push([0, 4, , 5]);\r\n\t t = void 0;\r\n\t if (!(type1 == 1)) return [3, 1];\r\n\t console.log(\"直接使用已加载的tex\");\r\n\t t = url;\r\n\t return [3, 3];\r\n\t case 1: return [4, loadImageByUrl(url)];\r\n\t case 2:\r\n\t t = (_a.sent());\r\n\t _a.label = 3;\r\n\t case 3:\r\n\t setimgwid = 612;\r\n\t mwid1 = setimgwid / rows;\r\n\t mhei1 = setimgwid / cols;\r\n\t mwid = t.width;\r\n\t mhei = t.height;\r\n\t picarr = {};\r\n\t picnames = [];\r\n\t chax = void 0;\r\n\t chay = void 0;\r\n\t startlix = void 0;\r\n\t addlix = void 0;\r\n\t startliy = void 0;\r\n\t addliy = void 0;\r\n\t if (mwid > mhei) {\r\n\t chax = (mwid - mhei) / 2;\r\n\t startlix = chax / mwid;\r\n\t addlix = (mhei / cols) / mwid;\r\n\t startliy = 0;\r\n\t addliy = 1 / rows;\r\n\t }\r\n\t else {\r\n\t startlix = 0;\r\n\t addlix = 1 / cols;\r\n\t chay = (mhei - mwid) / 2;\r\n\t startliy = chay / mhei;\r\n\t addliy = (mwid / rows) / mhei;\r\n\t }\r\n\t for (r = 0; r < rows; r++) {\r\n\t startx = startlix + addlix * r;\r\n\t endx = startx + addlix;\r\n\t for (c = 0; c < cols; c++) {\r\n\t starty = startliy + addliy * c;\r\n\t endy = starty + addliy;\r\n\t uvs = new Float32Array([\r\n\t starty,\r\n\t startx,\r\n\t endy,\r\n\t startx,\r\n\t endy,\r\n\t endx,\r\n\t starty,\r\n\t endx\r\n\t ]);\r\n\t isprite = new engine.Sprite(t);\r\n\t isprite.uvs = uvs;\r\n\t isprite.width = mwid1;\r\n\t isprite.height = mhei1;\r\n\t ispritename = \"pic_\" + c + \"_\" + r;\r\n\t isprite.name = ispritename;\r\n\t picarr[ispritename] = isprite;\r\n\t picnames.push(ispritename);\r\n\t }\r\n\t }\r\n\t return [2, {\r\n\t res: true,\r\n\t picarr: picarr,\r\n\t mwid: mwid1,\r\n\t mhei: mhei1,\r\n\t picnames: picnames\r\n\t }];\r\n\t case 4:\r\n\t e_1 = _a.sent();\r\n\t console.error(\"图片加载失败\", e_1);\r\n\t console.log(url, rows, cols);\r\n\t return [2, {\r\n\t res: false\r\n\t }];\r\n\t case 5: return [2];\r\n\t }\r\n\t });\r\n\t}); });\r\n\t//# sourceMappingURL=qietu.js.map\n\n\tvar GameView = (function (_super) {\r\n\t tslib.__extends(GameView, _super);\r\n\t function GameView() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.ingame = false;\r\n\t _this.selectImgArr = [];\r\n\t _this.sucposData = {};\r\n\t _this.gameUrls = [];\r\n\t _this.onegamePics = [];\r\n\t _this.once(engine.Event.ADDED_TO_STAGE, _this.initScene, _this);\r\n\t return _this;\r\n\t }\r\n\t GameView.prototype.initScene = function () {\r\n\t this.lineShape = new engine.Shape();\r\n\t this.selectimg3 = new engine.Image(getTextureByName(\"框3\"));\r\n\t this.selectimg4 = new engine.Image(getTextureByName(\"框4\"));\r\n\t this.dicont = new engine.Container();\r\n\t this.linecont = new engine.Container();\r\n\t this.blockcont = new engine.Container();\r\n\t this.addChild(this.dicont);\r\n\t this.addChild(this.linecont);\r\n\t this.addChild(this.blockcont);\r\n\t this.linecont.addChild(this.lineShape);\r\n\t };\r\n\t GameView.prototype.initgame = function () {\r\n\t return tslib.__awaiter(this, void 0, void 0, function () {\r\n\t var l, lurl, lt;\r\n\t return tslib.__generator(this, function (_a) {\r\n\t switch (_a.label) {\r\n\t case 0:\r\n\t console.log(\"initgame---------\");\r\n\t this.gameUrls = props.gameUrls;\r\n\t this.onegamePics = new Array();\r\n\t l = 0;\r\n\t _a.label = 1;\r\n\t case 1:\r\n\t if (!(l < this.gameUrls.length)) return [3, 4];\r\n\t lurl = this.gameUrls[l];\r\n\t return [4, loadImageByUrl(lurl)];\r\n\t case 2:\r\n\t lt = _a.sent();\r\n\t this.onegamePics.push(lt);\r\n\t _a.label = 3;\r\n\t case 3:\r\n\t l++;\r\n\t return [3, 1];\r\n\t case 4: return [2];\r\n\t }\r\n\t });\r\n\t });\r\n\t };\r\n\t GameView.prototype.start = function () {\r\n\t return tslib.__awaiter(this, void 0, void 0, function () {\r\n\t var actidx, tex, type1, result, res, picarr, mwid, mhei, picnames, gap, r, c, ipicx, ipicy, npicname, ipic, rl, cl;\r\n\t return tslib.__generator(this, function (_a) {\r\n\t switch (_a.label) {\r\n\t case 0:\r\n\t this.dicont.removeChildren();\r\n\t actidx = props.actidx;\r\n\t this.gametime = props.gametime;\r\n\t this.showtime = props.gametime;\r\n\t console.log(\"start-----------------\", actidx);\r\n\t this.rows = props.rows;\r\n\t this.cols = props.cols;\r\n\t this.nselectimg = null;\r\n\t if (this.rows == 3) {\r\n\t this.nselectimg = this.selectimg3;\r\n\t }\r\n\t if (this.rows == 4) {\r\n\t this.nselectimg = this.selectimg4;\r\n\t }\r\n\t this.passtime = 0;\r\n\t this.selectImgArr = new Array();\r\n\t this.sucposData = {};\r\n\t tex = this.onegamePics[actidx];\r\n\t type1 = 1;\r\n\t if (!tex) {\r\n\t tex = this.gameUrls[actidx];\r\n\t type1 = 2;\r\n\t }\r\n\t return [4, qietu(tex, type1, this.rows, this.cols, this.dicont)];\r\n\t case 1:\r\n\t result = _a.sent();\r\n\t res = result.res;\r\n\t if (res) {\r\n\t picarr = result.picarr;\r\n\t mwid = result.mwid;\r\n\t mhei = result.mhei;\r\n\t picnames = result.picnames;\r\n\t this.mwid = mwid;\r\n\t this.mhei = mhei;\r\n\t this.picarr = picarr;\r\n\t this.picnames = picnames;\r\n\t gap = 2;\r\n\t for (r = 0; r < this.rows; r++) {\r\n\t for (c = 0; c < this.cols; c++) {\r\n\t ipicx = mwid * c + gap;\r\n\t ipicy = mhei * r + gap;\r\n\t npicname = \"pic_\" + c + \"_\" + r;\r\n\t ipic = picarr[npicname];\r\n\t this.dicont.addChild(ipic);\r\n\t ipic.x = ipicx;\r\n\t ipic.y = ipicy;\r\n\t }\r\n\t }\r\n\t this.lineShape.clear();\r\n\t this.lineShape.beginStroke(0x0069df, 4, engine.LINE_CAP.BUTT, engine.LINE_JOIN.BEVEL, 100);\r\n\t this.lineShape.moveTo(0 + gap, 0 + gap);\r\n\t this.lineShape.lineTo(mhei * this.cols + gap, 0 + gap);\r\n\t this.lineShape.lineTo(mhei * this.cols + gap, mwid * this.rows + gap);\r\n\t this.lineShape.lineTo(0 + gap, mwid * this.rows + gap);\r\n\t this.lineShape.lineTo(0 + gap, 0 + gap);\r\n\t for (rl = 1; rl < this.rows; rl++) {\r\n\t this.lineShape.moveTo(0 + gap, rl * mhei + gap);\r\n\t this.lineShape.lineTo(mwid * this.cols + gap, rl * mhei + gap);\r\n\t }\r\n\t for (cl = 1; cl < this.cols; cl++) {\r\n\t this.lineShape.moveTo(cl * mwid + gap, 0 + gap);\r\n\t this.lineShape.lineTo(cl * mwid + gap, this.rows * mhei + gap);\r\n\t }\r\n\t this.lineShape.endStroke();\r\n\t this.ticker = setInterval(this.update, 20);\r\n\t }\r\n\t else {\r\n\t console.error(\"图片处理失败\");\r\n\t }\r\n\t return [2];\r\n\t }\r\n\t });\r\n\t });\r\n\t };\r\n\t GameView.prototype.luanxu = function () {\r\n\t var gap = 2;\r\n\t for (var r = 0; r < this.rows; r++) {\r\n\t for (var c = 0; c < this.cols; c++) {\r\n\t var ipicx = this.mwid * c + gap;\r\n\t var ipicy = this.mhei * r + gap;\r\n\t var npicname = \"pic_\" + c + \"_\" + r;\r\n\t this.sucposData[npicname] = r + \"_\" + c;\r\n\t var selidx = Math.floor(Math.random() * this.picnames.length);\r\n\t var ipicname = this.picnames[selidx];\r\n\t if (r == c && r != this.rows - 1) {\r\n\t while (ipicname == npicname) {\r\n\t selidx = Math.floor(Math.random() * this.picnames.length);\r\n\t ipicname = this.picnames[selidx];\r\n\t }\r\n\t }\r\n\t var ipic = this.picarr[ipicname];\r\n\t this.picnames.splice(selidx, 1);\r\n\t ipic.x = ipicx;\r\n\t ipic.y = ipicy;\r\n\t ipic[\"postr\"] = r + \"_\" + c;\r\n\t ipic.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.touchPic, this);\r\n\t }\r\n\t }\r\n\t };\r\n\t GameView.prototype.pause = function () {\r\n\t this.ingame = false;\r\n\t };\r\n\t GameView.prototype.resume = function () {\r\n\t this.ingame = true;\r\n\t };\r\n\t GameView.prototype.update = function () {\r\n\t var ntime = Date.now();\r\n\t if (!this.lastframetime) {\r\n\t this.lastframetime = ntime;\r\n\t return;\r\n\t }\r\n\t if (this.ingame) {\r\n\t var passtime = (ntime - this.lastframetime) / 1000;\r\n\t this.passtime += passtime;\r\n\t var showtime1 = Math.round(this.gametime - this.passtime);\r\n\t if (this.showtime != showtime1) {\r\n\t this.showtime = showtime1;\r\n\t if (this.showtime <= 0) {\r\n\t this.showtime = 0;\r\n\t this.gameover(2);\r\n\t }\r\n\t engine.globalEvent.dispatchEvent(\"pictures-time-update\", {\r\n\t time: this.showtime\r\n\t });\r\n\t }\r\n\t }\r\n\t this.lastframetime = ntime;\r\n\t };\r\n\t GameView.prototype.touchPic = function (e) {\r\n\t if (!this.ingame) {\r\n\t return;\r\n\t }\r\n\t var selectname = e.target.name;\r\n\t var spx = e.target.x;\r\n\t var spy = e.target.y;\r\n\t var gap = 2;\r\n\t if (this.selectImgArr.length == 0) {\r\n\t if (this.nselectimg) {\r\n\t this.blockcont.addChild(this.nselectimg);\r\n\t this.nselectimg.x = spx - gap;\r\n\t this.nselectimg.y = spy - gap;\r\n\t }\r\n\t this.selectImgArr.push(selectname);\r\n\t }\r\n\t else if (this.selectImgArr.length == 1) {\r\n\t if (selectname == this.selectImgArr[0]) {\r\n\t return;\r\n\t }\r\n\t else {\r\n\t this.selectImgArr.push(selectname);\r\n\t this.changeImgPos();\r\n\t }\r\n\t }\r\n\t };\r\n\t GameView.prototype.changeImgPos = function () {\r\n\t var img1name = this.selectImgArr[0];\r\n\t var img2name = this.selectImgArr[1];\r\n\t var img1 = this.dicont.getChildByName(img1name);\r\n\t var img2 = this.dicont.getChildByName(img2name);\r\n\t var imgpos1x = img1.x;\r\n\t var imgpos1y = img1.y;\r\n\t var imgpos2x = img2.x;\r\n\t var imgpos2y = img2.y;\r\n\t var imgpostr1 = img1.postr;\r\n\t var imgpostr2 = img2.postr;\r\n\t img1.x = imgpos2x;\r\n\t img1.y = imgpos2y;\r\n\t img1.postr = imgpostr2;\r\n\t img2.x = imgpos1x;\r\n\t img2.y = imgpos1y;\r\n\t img2.postr = imgpostr1;\r\n\t this.selectImgArr = new Array();\r\n\t if (this.nselectimg) {\r\n\t this.blockcont.removeChild(this.nselectimg);\r\n\t }\r\n\t var isuc = this.checkSuccess();\r\n\t if (isuc) {\r\n\t console.error(\"成功过关\");\r\n\t this.gameover(1);\r\n\t }\r\n\t };\r\n\t GameView.prototype.checkSuccess = function () {\r\n\t var isuc = true;\r\n\t for (var r = 0; r < this.rows; r++) {\r\n\t for (var c = 0; c < this.cols; c++) {\r\n\t var ipicname = \"pic_\" + c + \"_\" + r;\r\n\t var npicstr = r + \"_\" + c;\r\n\t var ipic = this.dicont.getChildByName(ipicname);\r\n\t var ipostr = ipic.postr;\r\n\t if (npicstr != ipostr) {\r\n\t isuc = false;\r\n\t break;\r\n\t }\r\n\t }\r\n\t }\r\n\t return isuc;\r\n\t };\r\n\t GameView.prototype.gameover = function (reason) {\r\n\t this.ingame = false;\r\n\t this.ticker && clearInterval(this.ticker);\r\n\t engine.globalEvent.dispatchEvent('pictures-game-over', {\r\n\t reason: reason,\r\n\t time: this.passtime\r\n\t });\r\n\t };\r\n\t return GameView;\r\n\t}(engine.Container));\n\n\tvar GameWrapper = (function (_super) {\r\n\t tslib.__extends(GameWrapper, _super);\r\n\t function GameWrapper() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this._gameView = new GameView();\r\n\t _this.addChild(_this._gameView);\r\n\t engine.globalEvent.addEventListener('pictures-initgame', _this.initgame, _this);\r\n\t engine.globalEvent.addEventListener('pictures-start', _this.start, _this);\r\n\t engine.globalEvent.addEventListener('pictures-luanxu', _this.luanxu, _this);\r\n\t engine.globalEvent.addEventListener('pictures-pause', _this.pause, _this);\r\n\t engine.globalEvent.addEventListener('pictures-resume', _this.resume, _this);\r\n\t return _this;\r\n\t }\r\n\t GameWrapper.prototype.initgame = function (event) {\r\n\t injectProps(event.data);\r\n\t this._gameView.initgame();\r\n\t };\r\n\t GameWrapper.prototype.start = function (event) {\r\n\t injectProps(event.data);\r\n\t this._gameView.start();\r\n\t };\r\n\t GameWrapper.prototype.luanxu = function () {\r\n\t this._gameView.luanxu();\r\n\t };\r\n\t GameWrapper.prototype.pause = function (event) {\r\n\t this._gameView.pause();\r\n\t };\r\n\t GameWrapper.prototype.resume = function (event) {\r\n\t this._gameView.resume();\r\n\t };\r\n\t return GameWrapper;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=GameWrapper.js.map\n\n\tfunction index (props) {\r\n\t prepareProps();\r\n\t injectProps(props);\r\n\t var instance = new GameWrapper();\r\n\t return instance;\r\n\t}\r\n\t//# sourceMappingURL=index.js.map\n\n\treturn index;\n\n})));\n"
} }
/**
* Created by rockyl on 2019-12-16.
*/
const customId = 'bjxd-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('bjxd-game-start', {guide: 2});
}, 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['bjxd-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);
}
//# sourceMappingURL=props.js.map
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);
pier.changeBg();
if (childrenNum == 0) {
pier.x = 0;
}
else {
pier.x = this.lastPos + randomPos;
}
this.lastPos = pier.x;
}
};
Road.prototype.changeBg = function () {
var nume = this.children.length;
for (var i = 0; i < nume; i++) {
var ipier = this.getChildAt(i);
ipier.changeBg();
}
};
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);
pier.changeBg();
};
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));
//# sourceMappingURL=Road.js.map
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;
}
//# sourceMappingURL=utils.js.map
var GuideLayer = (function (_super) {
tslib.__extends(GuideLayer, _super);
function GuideLayer() {
var _this = _super.call(this) || this;
_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) {
var _a = this.stage, width = _a.width, height = _a.height;
this.guideMask = new engine.Container();
this.addChild(this.guideMask);
this.guideImg = new engine.Image();
this.guideMask.addChild(this.guideImg);
this.shouzhi = new engine.Image(getTextureByName("shouzhi"));
this.guideMask.addChild(this.shouzhi);
}
this.guideImg.texture = getTextureByName("yindao" + id);
this.guideStep(id);
this.once(engine.MouseEvent.CLICK, function () {
this.visible = false;
if (this._callBack) {
this._callBack();
}
}, this);
};
GuideLayer.prototype.guideStep = function (id) {
if (id == 1) {
this.shouzhi.x = 244;
this.shouzhi.y = 812;
}
if (id == 2) {
this.shouzhi.x = 346;
this.shouzhi.y = 1108;
}
};
return GuideLayer;
}(engine.Container));
//# sourceMappingURL=GuideLayer.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') {
if (item.length > 0) {
part = new engine.Sprite(getTextureByName(item));
}
else {
part = new engine.Sprite();
}
}
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) {
if (changName && changName.length > 0) {
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));
//# sourceMappingURL=LoopComponent.js.map
var Background = (function (_super) {
tslib.__extends(Background, _super);
function Background() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.partResHHL = ['bg1', ''];
_this.partResHB = ['bg2', ''];
_this.partResWH = ['bg3', ''];
_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);
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;
}
}
};
return Background;
}(engine.Container));
//# sourceMappingURL=Background.js.map
var Pier = (function (_super) {
tslib.__extends(Pier, _super);
function Pier() {
var _this = _super.call(this) || this;
_this.part1tex = "zhuzi1";
_this.part2tex = "zhuzi2";
_this.part3tex = "zhuzi3";
_this.texname = "";
_this.zhuy = 1006;
_this.bmp = new engine.Sprite();
_this.addChild(_this.bmp);
return _this;
}
Pier.prototype.init = function () {
var bmp = this.bmp;
bmp.alpha = 1;
this.changeBg();
bmp.x = 0;
bmp.y = this.zhuy;
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.changeBg = function () {
var texstr;
if (GameView.bgIndex == 0) {
texstr = this.part1tex;
}
else if (GameView.bgIndex == 1) {
texstr = this.part2tex;
}
else {
texstr = this.part3tex;
}
if (this.texname != texstr) {
this.texname = texstr;
this.bmp.texture = getTextureByName(texstr);
}
};
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 = this.zhuy - 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));
//# sourceMappingURL=Pier.js.map
var Player = (function (_super) {
tslib.__extends(Player, _super);
function Player() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.playery = 845;
return _this;
}
Player.prototype.initPlayer = function (pierWidth) {
this.pierWidth = pierWidth;
this._container = new engine.Container();
this.addChild(this._container);
this.playerNode = createSvga('walk');
this._container.addChild(this.playerNode);
this.playerNode.y = this.playery;
this.playerNode.x = pierWidth / 2 - 80;
this.playerNode.play();
};
Player.prototype.revive = function () {
this._container.x = 0;
this._container.y = 0;
this.playerNode.x = this.pierWidth / 2 - 80;
this.playerNode.y = this.playery;
};
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));
//# sourceMappingURL=Player.js.map
var Strut = (function (_super) {
tslib.__extends(Strut, _super);
function Strut() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.gany = 1005;
return _this;
}
Strut.prototype.init = function () {
this._strut = new engine.Rect();
this.addChild(this._strut);
this._strut.width = props.strutWidth;
this._strut.y = this.gany;
this._strut.fillColor = props.strutColor;
this._strut.rotation = 180;
};
Strut.prototype.onMouseDown = function (pierWidth, distance, callBack) {
var paddingx = 20;
if (GameView.bgIndex == 0) {
paddingx = 20;
}
else if (GameView.bgIndex == 1) {
paddingx = 30;
}
else if (GameView.bgIndex == 2) {
paddingx = 20;
}
this._strut.x = pierWidth - paddingx;
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;
var paddingx = 20;
var chax = 20;
if (GameView.bgIndex == 0) {
paddingx = 20;
chax = 20;
}
else if (GameView.bgIndex == 1) {
paddingx = 30;
chax = 60;
}
else if (GameView.bgIndex == 2) {
paddingx = 20;
chax = 20;
}
if (this._distance[0] - this._distance[1] + chax <= this._strut.height && this._strut.height <= this._distance[0] + paddingx) {
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 = this.gany;
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));
//# sourceMappingURL=Strut.js.map
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();
};
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.revive = function () {
console.log("复活---------");
this._player.revive();
this._isTouchLayer = true;
this.closeStrut();
};
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 () {
};
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('bjxd-game-over', { 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;
console.log("新分数", this._sumScore);
engine.globalEvent.dispatchEvent('bjxd-game-score', { score: this._sumScore });
};
GameView.prototype.getScore = function () {
return this._sumScore;
};
GameView.prototype.changeBg = function (index) {
if (GameView.bgIndex != index) {
GameView.bgIndex = index;
this._backgroud.changeBg(index);
this._road.changeBg();
}
};
GameView.bgIndex = 0;
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('bjxd-game-start', _this.start, _this);
engine.globalEvent.addEventListener('bjxd-game-revive', _this.revive, _this);
engine.globalEvent.addEventListener('bjxd-game-change', _this.change, _this);
var gameView = _this._gameView = new GameView();
_this.addChild(gameView);
return _this;
}
GameWrapper.prototype.start = function (event) {
this._gameView.start(event.data.guide);
};
GameWrapper.prototype.revive = function () {
this._gameView.revive();
};
GameWrapper.prototype.change = function (event) {
this._gameView.changeBg(event.data.index);
};
return GameWrapper;
}(engine.Container));
//# sourceMappingURL=GameWrapper.js.map
function index (props) {
prepareProps();
injectProps(props);
var instance = new GameWrapper();
return instance;
}
//# sourceMappingURL=index.js.map
return index;
})));
//# sourceMappingURL=main.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sources":["src/custom/bjxd-game/src/props.ts","src/custom/bjxd-game/src/game/Road.ts","src/custom/bjxd-game/src/game/utils.ts","src/custom/bjxd-game/src/game/GuideLayer.ts","src/custom/bjxd-game/src/game/LoopComponent.ts","src/custom/bjxd-game/src/game/Background.ts","src/custom/bjxd-game/src/game/Pier.ts","src/custom/bjxd-game/src/game/Player.ts","src/custom/bjxd-game/src/game/Strut.ts","src/custom/bjxd-game/src/game/GameView.ts","src/custom/bjxd-game/src/game/GameWrapper.ts","src/custom/bjxd-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 {getTextureByName,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 pier.changeBg();\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 changeBg(){\r\n let nume = this.children.length;\r\n\r\n for(let i=0;i<nume;i++){\r\n let ipier = this.getChildAt(i) as Pier;\r\n ipier.changeBg();\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 pier.changeBg();\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\t// console.log(\"资源加载\",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\tguideImg:engine.Image;\r\n\tshouzhi:engine.Image;\r\n\t_options;\r\n\t_callBack;\r\n\r\n\tconstructor() {\r\n\t\tsuper();\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\r\n\t\tif (!this.guideMask) {\r\n\t\t\tconst {width, height} = this.stage;\r\n\t\t\tthis.guideMask = new engine.Container();\r\n\t\t\tthis.addChild(this.guideMask);\r\n\r\n\t\t\tthis.guideImg = new engine.Image();\r\n\t\t\tthis.guideMask.addChild(this.guideImg);\r\n\r\n\t\t\tthis.shouzhi = new engine.Image(getTextureByName(\"shouzhi\"));\r\n\t\t\tthis.guideMask.addChild(this.shouzhi);\r\n\t\t}\r\n\t\tthis.guideImg.texture = getTextureByName(\"yindao\"+id);\r\n\t\tthis.guideStep(id);\r\n\t\t\r\n\t\tthis.once(engine.MouseEvent.CLICK, function(){\r\n\t\t\tthis.visible = false;\r\n\t\t\tif(this._callBack){\r\n\t\t\t\tthis._callBack();\r\n\t\t\t}\r\n\t\t}, this);\r\n\t}\r\n\tguideStep(id){\r\n\t\tif(id == 1){\r\n\t\t\tthis.shouzhi.x = 244;\r\n\t\t\tthis.shouzhi.y = 812;\r\n\t\t}\r\n\t\tif(id == 2){\r\n\t\t\tthis.shouzhi.x = 346;\r\n\t\t\tthis.shouzhi.y = 1108;\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\tif(item.length>0){\r\n\t\t\t\t\tpart = new engine.Sprite(getTextureByName(item));\r\n\t\t\t\t}else{\r\n\t\t\t\t\tpart = new engine.Sprite();\r\n\t\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\tif(changName&&changName.length>0){\r\n\t\t\t\titem.texture = getTextureByName(changName)\r\n\t\t\t}\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 = ['bg1',''];\r\n partResHB = ['bg2',''];\r\n partResWH = ['bg3',''];\r\n speeds = [];\r\n resArray=[];\r\n frameMovePos = 0;\r\n frameIndex;\r\n sumMovePos;\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 \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 }\r\n}","import { props } from './../props';\r\nimport {getTextureByName,getStage} from \"./utils\";\r\nimport GameView from './GameView';\r\nexport class Pier extends engine.Container {\r\n bmp:engine.Sprite;\r\n public haveGold;\r\n part1tex = \"zhuzi1\";\r\n part2tex = \"zhuzi2\";\r\n part3tex = \"zhuzi3\";\r\n\r\n texname:string = \"\";\r\n constructor() {\r\n\t\tsuper();\r\n this.bmp = new engine.Sprite();\r\n this.addChild(this.bmp);\r\n }\r\n zhuy:number = 1006;\r\n init(){\r\n\t\tconst bmp = this.bmp;\r\n bmp.alpha = 1;\r\n this.changeBg();\r\n\r\n\t\tbmp.x = 0;\r\n bmp.y = this.zhuy;\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 changeBg(){\r\n let texstr;\r\n if(GameView.bgIndex==0){\r\n texstr = this.part1tex;\r\n }else if(GameView.bgIndex==1){\r\n texstr = this.part2tex;\r\n }else{\r\n texstr = this.part3tex;\r\n }\r\n if(this.texname!=texstr){\r\n this.texname = texstr;\r\n\t\t this.bmp.texture = getTextureByName(texstr);\r\n }\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 = this.zhuy - 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 pierWidth\r\n playery:number = 845;\r\n initPlayer(pierWidth){\r\n this.pierWidth = pierWidth;\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 = this.playery;\r\n this.playerNode.x = pierWidth/2 - 80;\r\n this.playerNode.play();\r\n }\r\n revive(){\r\n this._container.x = 0;\r\n this._container.y = 0;\r\n this.playerNode.x = this.pierWidth/2 - 80;\r\n this.playerNode.y = this.playery;\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\nimport GameView from \"./GameView\";\r\n\r\nexport class Strut extends engine.Container{\r\n _strut: engine.Rect;\r\n _distance;\r\n _callBack;\r\n gany = 1005;\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 = this.gany;\r\n this._strut.fillColor = props.strutColor;\r\n this._strut.rotation = 180;\r\n }\r\n onMouseDown(pierWidth,distance,callBack){\r\n let paddingx = 20;\r\n if(GameView.bgIndex==0){\r\n paddingx = 20;\r\n }else if(GameView.bgIndex==1){\r\n paddingx = 30;\r\n }else if(GameView.bgIndex==2){\r\n paddingx = 20;\r\n }\r\n this._strut.x = pierWidth - paddingx;\r\n\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\r\n let paddingx = 20;\r\n let chax = 20;\r\n if(GameView.bgIndex==0){\r\n paddingx = 20;\r\n chax = 20;\r\n }else if(GameView.bgIndex==1){\r\n paddingx = 30;\r\n chax = 60;\r\n }else if(GameView.bgIndex==2){\r\n paddingx = 20;\r\n chax = 20;\r\n }\r\n\r\n if(this._distance[0] - this._distance[1] + chax <= this._strut.height && this._strut.height <= this._distance[0] + paddingx){\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 = this.gany;\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\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\t// labScore:ScoreLabel;\r\n\t_sumScore;\r\n\t_isMouseDown;\r\n\r\n\t_guide;\r\n\r\n\ttestrevive:engine.Label;\r\n\ttestchange:engine.Label;\r\n\r\n\tstatic bgIndex:number = 0;\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\t// this._scoreContainer = new engine.Container();\r\n\t\t// this.addChild(this._scoreContainer);\r\n\t\t// this.initLabScore();\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\trevive(){\r\n\t\tconsole.log(\"复活---------\");\r\n\t\tthis._player.revive();\r\n\t\tthis._isTouchLayer = true;\r\n\t\tthis.closeStrut();\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\r\n\t\t// this.labScore = new ScoreLabel();\r\n // this.labScore.fillColor = 0xff7646;\r\n\t\t// this.labScore.size = 70;\r\n\t\t// this.labScore.width = getStage().width;\r\n\t\t// this.labScore.textAlign = engine.TEXT_ALIGN.CENTER;\r\n\t\t// this.labScore.x = 0;\r\n\t\t// this._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\t\tthis._touchLayer.alpha = 0;\r\n\r\n\r\n\t\t// this.testrevive = new engine.Label();\r\n\t\t// this.addChild(this.testrevive);\r\n\t\t// this.testrevive.size = 55;\r\n\t\t// this.testrevive.text = \"复活\";\r\n\t\t// this.testrevive.width = 500;\r\n\t\t// this.testrevive.height = 200;\r\n\t\t// this.testrevive.mouseEnabled = true;\r\n\t\t// this.testrevive.addEventListener(engine.MouseEvent.CLICK,this.revive,this);\r\n\t\r\n\t\t// this.testchange = new engine.Label();\r\n\t\t// this.addChild(this.testchange);\r\n\t\t// this.testchange.size = 55;\r\n\t\t// this.testchange.text = \"复活\";\r\n\t\t\r\n\t\t// this.testchange.width = 500;\r\n\t\t// this.testchange.height = 200;\r\n\t\t// this.testchange.mouseEnabled = true;\r\n\t\t// this.testchange.addEventListener(engine.MouseEvent.CLICK,this.changeBg,this);\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('bjxd-game-over',{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\t// if(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\t// this.labScore.updateScore(this._sumScore);\r\n\t\tconsole.log(\"新分数\",this._sumScore);\r\n\t\tengine.globalEvent.dispatchEvent('bjxd-game-score',{score: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\t// index = (GameView.bgIndex +1)%3;\r\n\t\t// console.log(\"切换图片\",index);\r\n\t\tif(GameView.bgIndex != index){\r\n\t\t\tGameView.bgIndex = index;\r\n\t\t\tthis._backgroud.changeBg(index);\r\n\t\t\tthis._road.changeBg();\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('bjxd-game-start', this.start, this);\r\n\t\tengine.globalEvent.addEventListener('bjxd-game-revive',this.revive,this);\r\n\t\tengine.globalEvent.addEventListener('bjxd-game-change',this.change,this);\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\trevive(){\r\n\t\tthis._gameView.revive();\r\n\t}\r\n\tchange(event:engine.Event){\r\n\t\t// console.log(\"切换图片显示\");\r\n\t\tthis._gameView.changeBg(event.data.index);\r\n\t}\r\n}\r\n","/**\r\n * Created by rockyl on 2019-11-20.\r\n */\r\n\r\nimport {GameWrapper} from \"./game/GameWrapper\";\r\nimport {injectProps, prepareProps} from \"./props\";\r\n\r\nexport default function (props) {\r\n\tprepareProps();\r\n\tinjectProps(props);\r\n\r\n\tlet instance = new GameWrapper();\r\n\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;;MAuGC;KApGG,oBAAK,GAAL;SAGI,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;SACjB,IAAI,CAAC,OAAO,EAAE,CAAC;MAElB;KACD,2BAAY,GAAZ;SACI,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;MACnC;KACD,0BAAW,GAAX;SAC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AI,CAAC,MAAM,EAAC,KAAI,CAAC,CAAC;SACzE,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;KACD,4BAAM,GAAN;SACC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;MACxB;KACD,4BAAM,GAAN,UAAO,KAAkB;SAExB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;MAC1C;KACF,kBAAC;CAAD,CAAC,CAzBgC,MAAM,CAAC,SAAS,GAyBhD;;;iBC1BwB,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": "#ffffff"
},
"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": "bg1",
"url": "//yun.duiba.com.cn/aurora/assets/b2c76b2a753317e5ea935bab22097a43a4c9f7cb.png",
"uuid": "bg1",
"ext": ".png"
},
{
"name": "bg2",
"url": "//yun.duiba.com.cn/aurora/assets/7f8261a9dd7b83cdc3b95b6f3f385e7a91e49682.png",
"uuid": "bg2",
"ext": ".png"
},
{
"name": "bg3",
"url": "//yun.duiba.com.cn/aurora/assets/872c688f9c2f495fe234277256923804df2ab75e.png",
"uuid": "bg3",
"ext": ".png"
},
{
"name": "car1",
"url": "//yun.duiba.com.cn/aurora/assets/c1e80aee4eee3665e0f0bce08233b05be4b4ee9c.png",
"uuid": "car1",
"ext": ".png"
},
{
"name": "yindao1",
"url": "//yun.duiba.com.cn/aurora/assets/a0409ec24b35198e990c61bc7f5dc66b15a5213a.png",
"uuid": "yindao1",
"ext": ".png"
},
{
"name": "yindao2",
"url": "//yun.duiba.com.cn/aurora/assets/7ece2d8c438ec06004f7f40d9798ab72f0e6a244.png",
"uuid": "yindao2",
"ext": ".png"
},
{
"name": "shouzhi",
"url": "//yun.duiba.com.cn/aurora/assets/fd62b438bfd67345fe441f5e68e4394d650fac8d.png",
"uuid": "shouzhi",
"ext": ".png"
},
{
"name": "zhuzi1",
"url": "//yun.duiba.com.cn/aurora/assets/cb779c9ebf4bfbd5bec1d817a6ef824d4ae5d751.png",
"uuid": "zhuzi1",
"ext": ".png"
},
{
"name": "zhuzi2",
"url": "//yun.duiba.com.cn/aurora/assets/c5187595bec08c211c8e45bf5f163ff02fd659ab.png",
"uuid": "zhuzi2",
"ext": ".png"
},
{
"name": "zhuzi3",
"url": "//yun.duiba.com.cn/aurora/assets/08dc255864c2af52dac7a993a4c62b1970dd6db4.png",
"uuid": "zhuzi3",
"ext": ".png"
},
{
"name": "person",
"url": "//yun.duiba.com.cn/aurora/assets/094526243496c8ebf1002f73f3cbbf3c9e12892a.png",
"uuid": "person",
"ext": ".png"
},
{
"name": "gold",
"url": "//yun.duiba.com.cn/aurora/assets/ae210ad26cee13f8fb6e69be62f7f5498be50a5b.png",
"uuid": "7f4e19f2-c80f-4a65-bec2-1f3c3dc6d210",
"ext": ".png"
},
{
"name": "walk",
"url": "//yun.duiba.com.cn/aurora/assets/a4ab1e1a2b49d140db4a0806562098a8b1619b06.svga",
"uuid": "10cd1fdd-4fd8-43cf-a1c7-6ff5846d8a91",
"ext": ".svga"
}
],
"events": {
"in": {
"bjxd-game-start": {
"alias": "开始",
"data": {
}
},
"bjxd-game-revive": {
"alias": "复活",
"data": {
}
},
"bjxd-game-reset": {
"alias": "重置",
"data": {
}
},
"bjxd-game-change": {
"alias": "替换显示",
"data": {
"index":1
}
}
},
"out": {
"bjxd-game-over": {
"alias": "游戏结束",
"data": {
"score":0
}
},
"bjxd-game-score": {
"alias": "分数",
"data": {
"score":0
}
}
}
}
}
\ 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 = ['bg1',''];
partResHB = ['bg2',''];
partResWH = ['bg3',''];
speeds = [];
resArray=[];
frameMovePos = 0;
frameIndex;
sumMovePos;
//需要的总帧数
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)
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;
}
}
}
}
\ 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;
testrevive:engine.Label;
testchange:engine.Label;
static bgIndex:number = 0;
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();
}
}
//复活
revive(){
console.log("复活---------");
this._player.revive();
this._isTouchLayer = true;
this.closeStrut();
}
//新手引导
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(){
// this.labScore = new ScoreLabel();
// this.labScore.fillColor = 0xff7646;
// this.labScore.size = 70;
// this.labScore.width = getStage().width;
// this.labScore.textAlign = engine.TEXT_ALIGN.CENTER;
// this.labScore.x = 0;
// 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;
// this.testrevive = new engine.Label();
// this.addChild(this.testrevive);
// this.testrevive.size = 55;
// this.testrevive.text = "复活";
// this.testrevive.width = 500;
// this.testrevive.height = 200;
// this.testrevive.mouseEnabled = true;
// this.testrevive.addEventListener(engine.MouseEvent.CLICK,this.revive,this);
// this.testchange = new engine.Label();
// this.addChild(this.testchange);
// this.testchange.size = 55;
// this.testchange.text = "复活";
// this.testchange.width = 500;
// this.testchange.height = 200;
// this.testchange.mouseEnabled = true;
// this.testchange.addEventListener(engine.MouseEvent.CLICK,this.changeBg,this);
}
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('bjxd-game-over',{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);
console.log("新分数",this._sumScore);
engine.globalEvent.dispatchEvent('bjxd-game-score',{score:this._sumScore});
}
getScore(){
return this._sumScore;
}
changeBg(index){
// index = (GameView.bgIndex +1)%3;
// console.log("切换图片",index);
if(GameView.bgIndex != index){
GameView.bgIndex = index;
this._backgroud.changeBg(index);
this._road.changeBg();
}
}
}
/**
* 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('bjxd-game-start', this.start, this);
engine.globalEvent.addEventListener('bjxd-game-revive',this.revive,this);
engine.globalEvent.addEventListener('bjxd-game-change',this.change,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);
}
revive(){
this._gameView.revive();
}
change(event:engine.Event){
// console.log("切换图片显示");
this._gameView.changeBg(event.data.index);
}
}
/**
* 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;
guideImg:engine.Image;
shouzhi:engine.Image;
_options;
_callBack;
constructor() {
super();
this.setup();
}
private setup() {
}
show(id, options,callback?) {
this.visible = true;
this._callBack = callback?callback:null;
if (!this.guideMask) {
const {width, height} = this.stage;
this.guideMask = new engine.Container();
this.addChild(this.guideMask);
this.guideImg = new engine.Image();
this.guideMask.addChild(this.guideImg);
this.shouzhi = new engine.Image(getTextureByName("shouzhi"));
this.guideMask.addChild(this.shouzhi);
}
this.guideImg.texture = getTextureByName("yindao"+id);
this.guideStep(id);
this.once(engine.MouseEvent.CLICK, function(){
this.visible = false;
if(this._callBack){
this._callBack();
}
}, this);
}
guideStep(id){
if(id == 1){
this.shouzhi.x = 244;
this.shouzhi.y = 812;
}
if(id == 2){
this.shouzhi.x = 346;
this.shouzhi.y = 1108;
}
}
}
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'){
if(item.length>0){
part = new engine.Sprite(getTextureByName(item));
}else{
part = new engine.Sprite();
}
}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) => {
if(changName&&changName.length>0){
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";
import GameView from './GameView';
export class Pier extends engine.Container {
bmp:engine.Sprite;
public haveGold;
part1tex = "zhuzi1";
part2tex = "zhuzi2";
part3tex = "zhuzi3";
texname:string = "";
constructor() {
super();
this.bmp = new engine.Sprite();
this.addChild(this.bmp);
}
zhuy:number = 1006;
init(){
const bmp = this.bmp;
bmp.alpha = 1;
this.changeBg();
bmp.x = 0;
bmp.y = this.zhuy;
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();
}
changeBg(){
let texstr;
if(GameView.bgIndex==0){
texstr = this.part1tex;
}else if(GameView.bgIndex==1){
texstr = this.part2tex;
}else{
texstr = this.part3tex;
}
if(this.texname!=texstr){
this.texname = texstr;
this.bmp.texture = getTextureByName(texstr);
}
}
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 = this.zhuy - 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;
pierWidth
playery:number = 845;
initPlayer(pierWidth){
this.pierWidth = pierWidth;
this._container = new engine.Container();
this.addChild(this._container);
this.playerNode = createSvga('walk');
this._container.addChild(this.playerNode);
this.playerNode.y = this.playery;
this.playerNode.x = pierWidth/2 - 80;
this.playerNode.play();
}
revive(){
this._container.x = 0;
this._container.y = 0;
this.playerNode.x = this.pierWidth/2 - 80;
this.playerNode.y = this.playery;
}
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 {getTextureByName,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);
pier.changeBg();
if(childrenNum == 0){
pier.x = 0;
}else{
pier.x = this.lastPos + randomPos;
}
this.lastPos = pier.x;
}
}
changeBg(){
let nume = this.children.length;
for(let i=0;i<nume;i++){
let ipier = this.getChildAt(i) as Pier;
ipier.changeBg();
}
}
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);
pier.changeBg();
}
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";
import GameView from "./GameView";
export class Strut extends engine.Container{
_strut: engine.Rect;
_distance;
_callBack;
gany = 1005;
init(){
this._strut = new engine.Rect();
this.addChild(this._strut);
this._strut.width = props.strutWidth;
this._strut.y = this.gany;
this._strut.fillColor = props.strutColor;
this._strut.rotation = 180;
}
onMouseDown(pierWidth,distance,callBack){
let paddingx = 20;
if(GameView.bgIndex==0){
paddingx = 20;
}else if(GameView.bgIndex==1){
paddingx = 30;
}else if(GameView.bgIndex==2){
paddingx = 20;
}
this._strut.x = pierWidth - paddingx;
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;
let paddingx = 20;
let chax = 20;
if(GameView.bgIndex==0){
paddingx = 20;
chax = 20;
}else if(GameView.bgIndex==1){
paddingx = 30;
chax = 60;
}else if(GameView.bgIndex==2){
paddingx = 20;
chax = 20;
}
if(this._distance[0] - this._distance[1] + chax <= this._strut.height && this._strut.height <= this._distance[0] + paddingx){
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 = this.gany;
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) {
// console.log("资源加载",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);
}
...@@ -45,7 +45,7 @@ function launchWithCustomModule(customModule) { ...@@ -45,7 +45,7 @@ function launchWithCustomModule(customModule) {
}, 100); }, 100);
setTimeout(() => { setTimeout(() => {
//engine.globalEvent.dispatchEvent('dxbcyj-game-start', {guide: 0}); engine.globalEvent.dispatchEvent('dxbcyj-game-start', {guide: 1});
}, 500); }, 500);
}); });
......
...@@ -420,6 +420,7 @@ ...@@ -420,6 +420,7 @@
return _super !== null && _super.apply(this, arguments) || this; return _super !== null && _super.apply(this, arguments) || this;
} }
Player.prototype.initPlayer = function (pierWidth) { Player.prototype.initPlayer = function (pierWidth) {
this.pierWidth = pierWidth;
this._container = new engine.Container(); this._container = new engine.Container();
this.addChild(this._container); this.addChild(this._container);
this.playerNode = createSvga('walk'); this.playerNode = createSvga('walk');
...@@ -428,6 +429,12 @@ ...@@ -428,6 +429,12 @@
this.playerNode.x = pierWidth / 2 - 80; this.playerNode.x = pierWidth / 2 - 80;
this.playerNode.play(); this.playerNode.play();
}; };
Player.prototype.revive = function () {
this._container.x = 0;
this._container.y = 0;
this.playerNode.x = this.pierWidth / 2 - 80;
this.playerNode.y = 675;
};
Player.prototype.setViewport = function (pos, callBack, pierWidth) { Player.prototype.setViewport = function (pos, callBack, pierWidth) {
var tmpPos = 0; var tmpPos = 0;
var isSuccess = false; var isSuccess = false;
...@@ -639,6 +646,12 @@ ...@@ -639,6 +646,12 @@
}); });
}); });
}; };
GameView.prototype.revive = function () {
console.log("复活---------");
this._player.revive();
this._isTouchLayer = true;
this.closeStrut();
};
GameView.prototype.setGuide = function () { GameView.prototype.setGuide = function () {
var _this = this; var _this = this;
this._road.setGuide(); this._road.setGuide();
...@@ -686,6 +699,14 @@ ...@@ -686,6 +699,14 @@
this._touchLayer.x = 0; this._touchLayer.x = 0;
this._touchLayer.y = 0; this._touchLayer.y = 0;
this._touchLayer.alpha = 0; this._touchLayer.alpha = 0;
this.testrevive = new engine.Label();
this.addChild(this.testrevive);
this.testrevive.size = 55;
this.testrevive.text = "复活";
this.testrevive.width = 500;
this.testrevive.height = 200;
this.testrevive.mouseEnabled = true;
this.testrevive.addEventListener(engine.MouseEvent.CLICK, this.revive, this);
}; };
GameView.prototype.setScoreShow = function () { GameView.prototype.setScoreShow = function () {
}; };
...@@ -766,6 +787,7 @@ ...@@ -766,6 +787,7 @@
function GameWrapper() { function GameWrapper() {
var _this = _super.call(this) || this; var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('dxbcyj-game-start', _this.start, _this); engine.globalEvent.addEventListener('dxbcyj-game-start', _this.start, _this);
engine.globalEvent.addEventListener('dxbcyj-game-revive', _this.revive);
var gameView = _this._gameView = new GameView(); var gameView = _this._gameView = new GameView();
_this.addChild(gameView); _this.addChild(gameView);
return _this; return _this;
...@@ -773,6 +795,9 @@ ...@@ -773,6 +795,9 @@
GameWrapper.prototype.start = function (event) { GameWrapper.prototype.start = function (event) {
this._gameView.start(event.data.guide); this._gameView.start(event.data.guide);
}; };
GameWrapper.prototype.revive = function () {
this._gameView.revive();
};
return GameWrapper; return GameWrapper;
}(engine.Container)); }(engine.Container));
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -39,6 +39,8 @@ export default class GameView extends engine.Container { ...@@ -39,6 +39,8 @@ export default class GameView extends engine.Container {
_isMouseDown; _isMouseDown;
_guide; _guide;
testrevive:engine.Label;
constructor() { constructor() {
super(); super();
this.once(engine.Event.ADDED_TO_STAGE, this.setup, this); this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);
...@@ -70,6 +72,7 @@ export default class GameView extends engine.Container { ...@@ -70,6 +72,7 @@ export default class GameView extends engine.Container {
this.addChild(this._scoreContainer); this.addChild(this._scoreContainer);
this.initLabScore(); this.initLabScore();
} }
async start(guide) { async start(guide) {
this._isTouchLayer = true; this._isTouchLayer = true;
...@@ -88,6 +91,13 @@ export default class GameView extends engine.Container { ...@@ -88,6 +91,13 @@ export default class GameView extends engine.Container {
this.registerEvent(); this.registerEvent();
} }
} }
//复活
revive(){
console.log("复活---------");
this._player.revive();
this._isTouchLayer = true;
this.closeStrut();
}
//新手引导 //新手引导
setGuide(){ setGuide(){
this._road.setGuide(); this._road.setGuide();
...@@ -140,6 +150,16 @@ export default class GameView extends engine.Container { ...@@ -140,6 +150,16 @@ export default class GameView extends engine.Container {
this._touchLayer.x = 0; this._touchLayer.x = 0;
this._touchLayer.y = 0; this._touchLayer.y = 0;
this._touchLayer.alpha = 0; this._touchLayer.alpha = 0;
this.testrevive = new engine.Label();
this.addChild(this.testrevive);
this.testrevive.size = 55;
this.testrevive.text = "复活";
this.testrevive.width = 500;
this.testrevive.height = 200;
this.testrevive.mouseEnabled = true;
this.testrevive.addEventListener(engine.MouseEvent.CLICK,this.revive,this);
} }
setScoreShow(){ setScoreShow(){
......
...@@ -13,7 +13,7 @@ export class GameWrapper extends engine.Container { ...@@ -13,7 +13,7 @@ export class GameWrapper extends engine.Container {
super(); super();
engine.globalEvent.addEventListener('dxbcyj-game-start', this.start, this); engine.globalEvent.addEventListener('dxbcyj-game-start', this.start, this);
engine.globalEvent.addEventListener('dxbcyj-game-revive',this.revive);
let gameView = this._gameView = new GameView(); let gameView = this._gameView = new GameView();
this.addChild(gameView); this.addChild(gameView);
...@@ -23,5 +23,7 @@ export class GameWrapper extends engine.Container { ...@@ -23,5 +23,7 @@ export class GameWrapper extends engine.Container {
start(event: engine.Event) { start(event: engine.Event) {
this._gameView.start(event.data.guide); this._gameView.start(event.data.guide);
} }
revive(){
this._gameView.revive();
}
} }
...@@ -4,8 +4,9 @@ export class Player extends engine.Container{ ...@@ -4,8 +4,9 @@ export class Player extends engine.Container{
_container; _container;
private playerNode: svga.Svga; private playerNode: svga.Svga;
pierWidth
initPlayer(pierWidth){ initPlayer(pierWidth){
this.pierWidth = pierWidth;
this._container = new engine.Container(); this._container = new engine.Container();
this.addChild(this._container); this.addChild(this._container);
...@@ -16,6 +17,12 @@ export class Player extends engine.Container{ ...@@ -16,6 +17,12 @@ export class Player extends engine.Container{
this.playerNode.x = pierWidth/2 - 80; this.playerNode.x = pierWidth/2 - 80;
this.playerNode.play(); this.playerNode.play();
} }
revive(){
this._container.x = 0;
this._container.y = 0;
this.playerNode.x = this.pierWidth/2 - 80;
this.playerNode.y = 675;
}
setViewport(pos,callBack,pierWidth?){ setViewport(pos,callBack,pierWidth?){
let tmpPos = 0; let tmpPos = 0;
let isSuccess = false; let isSuccess = false;
......
...@@ -45,18 +45,28 @@ function launchWithCustomModule(customModule) { ...@@ -45,18 +45,28 @@ function launchWithCustomModule(customModule) {
engine.addCustomModule(customId, engine.gameStage.sceneContainer.getChildAt(0)); engine.addCustomModule(customId, engine.gameStage.sceneContainer.getChildAt(0));
}, 100); }, 100);
setTimeout(()=>{
engine.globalEvent.dispatchEvent('pictures-initgame', {
gameUrls:[
"https://yun.duiba.com.cn/aurora/assets/1456b2a9d72e56f075abb29df99052d87a0f1e48.jpg",
"https://yun.duiba.com.cn/aurora/assets/61fd0754d7924305fd2851be86a480d71d2c2981.jpg",
"https://yun.duiba.com.cn/aurora/assets/6b70d7ec626f35f21347bf5bc3e61bedc44167be.jpg"
]
})
},1000);
setTimeout(() => { setTimeout(() => {
engine.globalEvent.dispatchEvent('pictures-start', { engine.globalEvent.dispatchEvent('pictures-start', {
picUrl: "//yun.duiba.com.cn/aurora/assets/eb952d8bfd900cb9367368ddf8048d66c44a52a0.png", actidx:0,
rows:3, rows:3,
cols:3, cols:3,
gametime:30 gametime:30000
}); });
// const d = engine.gameStage.sceneContainer.getChildAt(0); // const d = engine.gameStage.sceneContainer.getChildAt(0);
// engine.gameStage.sceneContainer.getChildAt(0).x = (d.stage.width-props.W)/2; // engine.gameStage.sceneContainer.getChildAt(0).x = (d.stage.width-props.W)/2;
// engine.gameStage.sceneContainer.getChildAt(0).y = (d.stage.height-props.H)/2; // engine.gameStage.sceneContainer.getChildAt(0).y = (d.stage.height-props.H)/2;
}, 1000); }, 3000);
// setTimeout(() => { // setTimeout(() => {
// engine.globalEvent.dispatchEvent('pictures-start', { // engine.globalEvent.dispatchEvent('pictures-start', {
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
return getTexture(engine.getAssetByName(name).uuid); return getTexture(engine.getAssetByName(name).uuid);
} }
function loadImageByUrl(url) { function loadImageByUrl(url) {
console.log('loadImageByUrl----------:', url);
return new Promise(function (resolve) { return new Promise(function (resolve) {
if (engine.TextureCache[url]) { if (engine.TextureCache[url]) {
resolve(engine.TextureCache[url]); resolve(engine.TextureCache[url]);
...@@ -33,25 +34,55 @@ ...@@ -33,25 +34,55 @@
} }
//# sourceMappingURL=utils.js.map //# sourceMappingURL=utils.js.map
var qietu = (function (url, rows, cols, parent) { return tslib.__awaiter(void 0, void 0, void 0, function () { var qietu = (function (url, type1, rows, cols, parent) { return tslib.__awaiter(void 0, void 0, void 0, function () {
var t, mwid, mhei, picarr, picnames, r, startx, endx, c, starty, endy, uvs, itexture, itexname, e_1; var t, setimgwid, mwid1, mhei1, mwid, mhei, picarr, picnames, chax, chay, startlix, addlix, startliy, addliy, r, startx, endx, c, starty, endy, uvs, isprite, ispritename, e_1;
return tslib.__generator(this, function (_a) { return tslib.__generator(this, function (_a) {
switch (_a.label) { switch (_a.label) {
case 0: case 0:
_a.trys.push([0, 2, , 3]); _a.trys.push([0, 4, , 5]);
return [4, loadImageByUrl(url)]; t = void 0;
case 1: if (!(type1 == 1)) return [3, 1];
t = _a.sent(); console.log("直接使用已加载的tex");
mwid = t.width / rows; t = url;
mhei = t.height / cols; return [3, 3];
case 1: return [4, loadImageByUrl(url)];
case 2:
t = (_a.sent());
_a.label = 3;
case 3:
setimgwid = 612;
mwid1 = setimgwid / rows;
mhei1 = setimgwid / cols;
mwid = t.width;
mhei = t.height;
picarr = {}; picarr = {};
picnames = []; picnames = [];
chax = void 0;
chay = void 0;
startlix = void 0;
addlix = void 0;
startliy = void 0;
addliy = void 0;
if (mwid > mhei) {
chax = (mwid - mhei) / 2;
startlix = chax / mwid;
addlix = (mhei / cols) / mwid;
startliy = 0;
addliy = 1 / rows;
}
else {
startlix = 0;
addlix = 1 / cols;
chay = (mhei - mwid) / 2;
startliy = chay / mhei;
addliy = (mwid / rows) / mhei;
}
for (r = 0; r < rows; r++) { for (r = 0; r < rows; r++) {
startx = r / rows; startx = startlix + addlix * r;
endx = (r + 1) / rows; endx = startx + addlix;
for (c = 0; c < cols; c++) { for (c = 0; c < cols; c++) {
starty = c / cols; starty = startliy + addliy * c;
endy = (c + 1) / cols; endy = starty + addliy;
uvs = new Float32Array([ uvs = new Float32Array([
starty, starty,
startx, startx,
...@@ -62,31 +93,31 @@ ...@@ -62,31 +93,31 @@
starty, starty,
endx endx
]); ]);
itexture = new engine.Sprite(t); isprite = new engine.Sprite(t);
itexture.uvs = uvs; isprite.uvs = uvs;
itexture.width = mwid; isprite.width = mwid1;
itexture.height = mhei; isprite.height = mhei1;
itexname = "pic_" + c + "_" + r; ispritename = "pic_" + c + "_" + r;
itexture.name = itexname; isprite.name = ispritename;
picarr[itexname] = itexture; picarr[ispritename] = isprite;
picnames.push(itexname); picnames.push(ispritename);
} }
} }
return [2, { return [2, {
res: true, res: true,
picarr: picarr, picarr: picarr,
mwid: mwid, mwid: mwid1,
mhei: mhei, mhei: mhei1,
picnames: picnames picnames: picnames
}]; }];
case 2: case 4:
e_1 = _a.sent(); e_1 = _a.sent();
console.error("图片加载失败", e_1); console.error("图片加载失败", e_1);
console.log(url, rows, cols); console.log(url, rows, cols);
return [2, { return [2, {
res: false res: false
}]; }];
case 3: return [2]; case 5: return [2];
} }
}); });
}); }); }); });
...@@ -99,6 +130,8 @@ ...@@ -99,6 +130,8 @@
_this.ingame = false; _this.ingame = false;
_this.selectImgArr = []; _this.selectImgArr = [];
_this.sucposData = {}; _this.sucposData = {};
_this.gameUrls = [];
_this.onegamePics = [];
_this.once(engine.Event.ADDED_TO_STAGE, _this.initScene, _this); _this.once(engine.Event.ADDED_TO_STAGE, _this.initScene, _this);
return _this; return _this;
} }
...@@ -114,16 +147,44 @@ ...@@ -114,16 +147,44 @@
this.addChild(this.blockcont); this.addChild(this.blockcont);
this.linecont.addChild(this.lineShape); this.linecont.addChild(this.lineShape);
}; };
GameView.prototype.initgame = function () {
return tslib.__awaiter(this, void 0, void 0, function () {
var l, lurl, lt;
return tslib.__generator(this, function (_a) {
switch (_a.label) {
case 0:
console.log("initgame---------");
this.gameUrls = props.gameUrls;
this.onegamePics = new Array();
l = 0;
_a.label = 1;
case 1:
if (!(l < this.gameUrls.length)) return [3, 4];
lurl = this.gameUrls[l];
return [4, loadImageByUrl(lurl)];
case 2:
lt = _a.sent();
this.onegamePics.push(lt);
_a.label = 3;
case 3:
l++;
return [3, 1];
case 4: return [2];
}
});
});
};
GameView.prototype.start = function () { GameView.prototype.start = function () {
return tslib.__awaiter(this, void 0, void 0, function () { return tslib.__awaiter(this, void 0, void 0, function () {
var picUrl, result, res, picarr, mwid, mhei, picnames, gap, r, c, ipicx, ipicy, npicname, selidx, ipicname, ipic, rl, cl; var actidx, tex, type1, result, res, picarr, mwid, mhei, picnames, gap, r, c, ipicx, ipicy, npicname, ipic, rl, cl;
return tslib.__generator(this, function (_a) { return tslib.__generator(this, function (_a) {
switch (_a.label) { switch (_a.label) {
case 0: case 0:
this.dicont.removeChildren(); this.dicont.removeChildren();
picUrl = props.picUrl; actidx = props.actidx;
this.gametime = props.gametime; this.gametime = props.gametime;
this.showtime = props.gametime; this.showtime = props.gametime;
console.log("start-----------------", actidx);
this.rows = props.rows; this.rows = props.rows;
this.cols = props.cols; this.cols = props.cols;
this.nselectimg = null; this.nselectimg = null;
...@@ -136,7 +197,13 @@ ...@@ -136,7 +197,13 @@
this.passtime = 0; this.passtime = 0;
this.selectImgArr = new Array(); this.selectImgArr = new Array();
this.sucposData = {}; this.sucposData = {};
return [4, qietu(picUrl, this.rows, this.cols, this.dicont)]; tex = this.onegamePics[actidx];
type1 = 1;
if (!tex) {
tex = this.gameUrls[actidx];
type1 = 2;
}
return [4, qietu(tex, type1, this.rows, this.cols, this.dicont)];
case 1: case 1:
result = _a.sent(); result = _a.sent();
res = result.res; res = result.res;
...@@ -145,28 +212,20 @@ ...@@ -145,28 +212,20 @@
mwid = result.mwid; mwid = result.mwid;
mhei = result.mhei; mhei = result.mhei;
picnames = result.picnames; picnames = result.picnames;
this.mwid = mwid;
this.mhei = mhei;
this.picarr = picarr;
this.picnames = picnames;
gap = 2; gap = 2;
for (r = 0; r < this.rows; r++) { for (r = 0; r < this.rows; r++) {
for (c = 0; c < this.cols; c++) { for (c = 0; c < this.cols; c++) {
ipicx = mwid * c + gap; ipicx = mwid * c + gap;
ipicy = mhei * r + gap; ipicy = mhei * r + gap;
npicname = "pic_" + c + "_" + r; npicname = "pic_" + c + "_" + r;
this.sucposData[npicname] = r + "_" + c; ipic = picarr[npicname];
selidx = Math.floor(Math.random() * picnames.length);
ipicname = picnames[selidx];
if (r == c && r != this.rows - 1) {
while (ipicname == npicname) {
selidx = Math.floor(Math.random() * picnames.length);
ipicname = picnames[selidx];
}
}
ipic = picarr[ipicname];
picnames.splice(selidx, 1);
this.dicont.addChild(ipic); this.dicont.addChild(ipic);
ipic.x = ipicx; ipic.x = ipicx;
ipic.y = ipicy; ipic.y = ipicy;
ipic["postr"] = r + "_" + c;
ipic.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.touchPic, this);
} }
} }
this.lineShape.clear(); this.lineShape.clear();
...@@ -185,7 +244,7 @@ ...@@ -185,7 +244,7 @@
this.lineShape.lineTo(cl * mwid + gap, this.rows * mhei + gap); this.lineShape.lineTo(cl * mwid + gap, this.rows * mhei + gap);
} }
this.lineShape.endStroke(); this.lineShape.endStroke();
this.ticker = setInterval(this.update, 30); this.ticker = setInterval(this.update, 20);
} }
else { else {
console.error("图片处理失败"); console.error("图片处理失败");
...@@ -195,6 +254,31 @@ ...@@ -195,6 +254,31 @@
}); });
}); });
}; };
GameView.prototype.luanxu = function () {
var gap = 2;
for (var r = 0; r < this.rows; r++) {
for (var c = 0; c < this.cols; c++) {
var ipicx = this.mwid * c + gap;
var ipicy = this.mhei * r + gap;
var npicname = "pic_" + c + "_" + r;
this.sucposData[npicname] = r + "_" + c;
var selidx = Math.floor(Math.random() * this.picnames.length);
var ipicname = this.picnames[selidx];
if (r == c && r != this.rows - 1) {
while (ipicname == npicname) {
selidx = Math.floor(Math.random() * this.picnames.length);
ipicname = this.picnames[selidx];
}
}
var ipic = this.picarr[ipicname];
this.picnames.splice(selidx, 1);
ipic.x = ipicx;
ipic.y = ipicy;
ipic["postr"] = r + "_" + c;
ipic.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.touchPic, this);
}
}
};
GameView.prototype.pause = function () { GameView.prototype.pause = function () {
this.ingame = false; this.ingame = false;
}; };
...@@ -310,15 +394,24 @@ ...@@ -310,15 +394,24 @@
var _this = _super.call(this) || this; var _this = _super.call(this) || this;
_this._gameView = new GameView(); _this._gameView = new GameView();
_this.addChild(_this._gameView); _this.addChild(_this._gameView);
engine.globalEvent.addEventListener('pictures-initgame', _this.initgame, _this);
engine.globalEvent.addEventListener('pictures-start', _this.start, _this); engine.globalEvent.addEventListener('pictures-start', _this.start, _this);
engine.globalEvent.addEventListener('pictures-luanxu', _this.luanxu, _this);
engine.globalEvent.addEventListener('pictures-pause', _this.pause, _this); engine.globalEvent.addEventListener('pictures-pause', _this.pause, _this);
engine.globalEvent.addEventListener('pictures-resume', _this.resume, _this); engine.globalEvent.addEventListener('pictures-resume', _this.resume, _this);
return _this; return _this;
} }
GameWrapper.prototype.initgame = function (event) {
injectProps(event.data);
this._gameView.initgame();
};
GameWrapper.prototype.start = function (event) { GameWrapper.prototype.start = function (event) {
injectProps(event.data); injectProps(event.data);
this._gameView.start(); this._gameView.start();
}; };
GameWrapper.prototype.luanxu = function () {
this._gameView.luanxu();
};
GameWrapper.prototype.pause = function (event) { GameWrapper.prototype.pause = function (event) {
this._gameView.pause(); this._gameView.pause();
}; };
......
{"version":3,"file":"index.js","sources":["src/custom/pintu/src/props.ts","src/custom/pintu/src/game/utils.ts","src/custom/pintu/src/game/qietu.ts","src/custom/pintu/src/game/GameView.ts","src/custom/pintu/src/game/GameWrapper.ts","src/custom/pintu/src/index.ts"],"sourcesContent":["/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\n\r\nexport let props: any = {};\r\n\r\nexport function prepareProps() {\r\n\tlet metaProps = getProps();\r\n\r\n\tengine.injectProp(props, metaProps);\r\n}\r\n\r\nexport function injectProps(p) {\r\n\tengine.injectProp(props, p);\r\n}\r\n","/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\n\r\nexport function getTexture(uuid) {\r\n\treturn engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n}\r\n\r\nexport function getTextureByName(name) {\r\n\treturn getTexture(engine.getAssetByName(name).uuid);\r\n}\r\n\r\nexport function playSound(name) {\r\n\tengine.playSound(engine.getAssetByName(name).uuid, {keep: true});\r\n}\r\nexport function createSvga(name, anchorName?) {\r\n\tlet inst = new svga.Svga();\r\n\tinst.source = 'asset://' + engine.getAssetByName(name).uuid;\r\n\treturn inst;\r\n}\r\n\r\nexport function loadImageByUrl(url){\r\n\treturn new Promise((resolve) => {\r\n\t\tif (engine.TextureCache[url]) {\r\n\t\t\tresolve(engine.TextureCache[url])\r\n\t\t} else {\r\n\t\t\tvar t = engine.Texture.from(url);\r\n\t\t\tt.addEventListener(\"loaded\", () => { resolve(t) })\r\n\t\t}\r\n\t})\r\n}","import { props } from \"../props\";\r\nimport { loadImageByUrl } from \"./utils\";\r\nconst urls = [];\r\nconst picMap = {};\r\nconst posMap = {};\r\nexport default async(url:string, rows:number, cols:number,parent:engine.Container) => {\r\n try{\r\n let t:engine.Texture = await loadImageByUrl(url) as engine.Texture;\r\n \r\n let mwid = t.width/rows;\r\n let mhei = t.height/cols;\r\n\r\n let picarr = {};\r\n let picnames = [];\r\n for(let r=0;r<rows;r++){\r\n let startx = r/rows;\r\n let endx = (r+1)/rows;\r\n // linedraw.moveTo()\r\n for(let c=0;c<cols;c++){\r\n let starty = c/cols;\r\n let endy = (c+1)/cols;\r\n\r\n let uvs = new Float32Array([\r\n starty,\r\n startx,\r\n endy,\r\n startx,\r\n endy,\r\n endx,\r\n starty,\r\n endx\r\n ]);\r\n\r\n let itexture = new engine.Sprite(t);\r\n itexture.uvs = uvs;\r\n\r\n itexture.width = mwid;\r\n itexture.height = mhei;\r\n let itexname = \"pic_\"+c+\"_\"+r;\r\n itexture.name = itexname;\r\n picarr[itexname] = itexture;\r\n picnames.push(itexname);\r\n }\r\n }\r\n return {\r\n res:true,\r\n picarr:picarr,\r\n mwid:mwid,\r\n mhei:mhei,\r\n picnames:picnames\r\n };\r\n }catch(e){\r\n console.error(\"图片加载失败\",e);\r\n console.log(url,rows,cols);\r\n return {\r\n res:false\r\n };\r\n }\r\n};\r\n","/**\r\n * Created by rockyl on 2018/8/16.\r\n */\r\n\r\nimport { props } from \"../props\";\r\nimport qietu from \"./qietu\";\r\nimport { getTexture, loadImageByUrl,getTextureByName } from \"./utils\";\r\nimport ObjectPool = engine.ObjectPool;\r\n\r\nexport default class GameView extends engine.Container {\r\n rows:number;\r\n cols:number;\r\n\r\n passtime:number;\r\n gametime:number;\r\n showtime:number;\r\n\r\n lastframetime:number;\r\n\r\n ingame:boolean = false;\r\n\r\n ticker;\r\n\r\n selectimg3:engine.Image;\r\n selectimg4:engine.Image;\r\n nselectimg:engine.Image;\r\n\r\n selectImgArr:Array<string> = [];\r\n sucposData:Object = {};\r\n\r\n dicont:engine.Container;\r\n linecont:engine.Container;\r\n blockcont:engine.Container;\r\n\r\n lineShape:engine.Shape;\r\n constructor() {\r\n super();\r\n this.once(engine.Event.ADDED_TO_STAGE, this.initScene, this);\r\n }\r\n initScene(){\r\n this.lineShape = new engine.Shape();\r\n this.selectimg3 = new engine.Image(getTextureByName(\"框3\"));\r\n this.selectimg4 = new engine.Image(getTextureByName(\"框4\"));\r\n //底图\r\n this.dicont = new engine.Container();\r\n //线\r\n this.linecont = new engine.Container();\r\n //亮片\r\n this.blockcont = new engine.Container();\r\n\r\n this.addChild(this.dicont);\r\n this.addChild(this.linecont);\r\n this.addChild(this.blockcont);\r\n \r\n this.linecont.addChild(this.lineShape);\r\n }\r\n async start() {\r\n this.dicont.removeChildren();\r\n\r\n let picUrl = props.picUrl;\r\n this.gametime = props.gametime;\r\n this.showtime = props.gametime;\r\n\r\n this.rows = props.rows;\r\n this.cols = props.cols;\r\n\r\n this.nselectimg = null;\r\n if(this.rows==3){\r\n this.nselectimg = this.selectimg3;\r\n }\r\n if(this.rows==4){\r\n this.nselectimg = this.selectimg4;\r\n }\r\n\r\n this.passtime = 0;\r\n \r\n this.selectImgArr = new Array();\r\n this.sucposData = {};\r\n let result = await qietu(picUrl,this.rows,this.cols,this.dicont);\r\n let res = result.res;\r\n if(res){\r\n let picarr = result.picarr;\r\n let mwid = result.mwid;\r\n let mhei = result.mhei;\r\n let picnames = result.picnames;\r\n let gap = 2;\r\n for(let r=0;r<this.rows;r++){\r\n for(let c=0;c<this.cols;c++){\r\n let ipicx = mwid*c+gap;\r\n let ipicy = mhei*r+gap;\r\n let npicname = \"pic_\"+c+\"_\"+r;\r\n\r\n this.sucposData[npicname] = r+\"_\"+c;\r\n\r\n let selidx = Math.floor(Math.random()*picnames.length);\r\n let ipicname:string = picnames[selidx];\r\n if(r==c&&r!=this.rows-1){\r\n while(ipicname==npicname){\r\n selidx = Math.floor(Math.random()*picnames.length);\r\n ipicname = picnames[selidx];\r\n }\r\n }\r\n let ipic = picarr[ipicname];\r\n picnames.splice(selidx,1);\r\n this.dicont.addChild(ipic);\r\n ipic.x = ipicx;\r\n ipic.y = ipicy;\r\n ipic[\"postr\"] = r+\"_\"+c;\r\n\r\n ipic.addEventListener(engine.MouseEvent.MOUSE_DOWN,\r\n this.touchPic,this);\r\n }\r\n }\r\n //框线\r\n this.lineShape.clear();\r\n this.lineShape.beginStroke(0x0069df,4,engine.LINE_CAP.BUTT,engine.LINE_JOIN.BEVEL,100);\r\n\r\n this.lineShape.moveTo(0+gap,0+gap);\r\n this.lineShape.lineTo(mhei*this.cols+gap,0+gap);\r\n this.lineShape.lineTo(mhei*this.cols+gap,mwid*this.rows+gap);\r\n this.lineShape.lineTo(0+gap,mwid*this.rows+gap);\r\n this.lineShape.lineTo(0+gap,0+gap);\r\n\r\n for(let rl=1;rl<this.rows;rl++){\r\n this.lineShape.moveTo(0+gap,rl*mhei+gap);\r\n this.lineShape.lineTo(mwid*this.cols+gap,rl*mhei+gap);\r\n }\r\n for(let cl=1;cl<this.cols;cl++){\r\n this.lineShape.moveTo(cl*mwid+gap,0+gap);\r\n this.lineShape.lineTo(cl*mwid+gap,this.rows*mhei+gap);\r\n }\r\n this.lineShape.endStroke();\r\n \r\n\r\n this.ticker = setInterval(this.update, 30);\r\n }else{\r\n console.error(\"图片处理失败\");\r\n }\r\n }\r\n pause(){\r\n this.ingame = false;\r\n }\r\n resume(){\r\n this.ingame = true;\r\n }\r\n\r\n\r\n update() {\r\n let ntime = Date.now();\r\n if(!this.lastframetime){\r\n this.lastframetime = ntime;\r\n return;\r\n }\r\n if(this.ingame){\r\n let passtime = (ntime - this.lastframetime)/1000;\r\n this.passtime += passtime;\r\n let showtime1 = Math.round(this.gametime - this.passtime);\r\n // console.log(passtime,this.passtime,this.gametime,this.showtime);\r\n if(this.showtime!=showtime1){\r\n this.showtime = showtime1;\r\n if(this.showtime<=0){\r\n this.showtime = 0;\r\n this.gameover(2);\r\n }\r\n // console.log(\"倒计时\",this.showtime);\r\n engine.globalEvent.dispatchEvent(\"pictures-time-update\",{\r\n time:this.showtime\r\n });\r\n }\r\n }\r\n this.lastframetime = ntime;\r\n }\r\n\r\n touchPic(e:engine.MouseEvent){\r\n if(!this.ingame){\r\n return;\r\n }\r\n // console.log(e.target.name);\r\n let selectname = e.target.name;\r\n let spx = e.target.x;\r\n let spy = e.target.y;\r\n let gap = 2;\r\n if(this.selectImgArr.length==0){\r\n if(this.nselectimg){\r\n this.blockcont.addChild(this.nselectimg);\r\n this.nselectimg.x = spx-gap;\r\n this.nselectimg.y = spy-gap;\r\n }\r\n this.selectImgArr.push(selectname);\r\n }else if(this.selectImgArr.length==1){\r\n if(selectname==this.selectImgArr[0]){\r\n return;\r\n }else{\r\n this.selectImgArr.push(selectname);\r\n this.changeImgPos();\r\n }\r\n }\r\n }\r\n changeImgPos(){\r\n let img1name = this.selectImgArr[0];\r\n let img2name = this.selectImgArr[1];\r\n\r\n let img1 = this.dicont.getChildByName(img1name);\r\n let img2 = this.dicont.getChildByName(img2name);\r\n\r\n let imgpos1x = img1.x;\r\n let imgpos1y = img1.y;\r\n let imgpos2x = img2.x;\r\n let imgpos2y = img2.y;\r\n\r\n let imgpostr1 = img1.postr;\r\n let imgpostr2 = img2.postr;\r\n\r\n img1.x = imgpos2x;\r\n img1.y = imgpos2y;\r\n img1.postr = imgpostr2;\r\n\r\n img2.x = imgpos1x;\r\n img2.y = imgpos1y;\r\n img2.postr = imgpostr1;\r\n\r\n this.selectImgArr = new Array();\r\n \r\n if(this.nselectimg){\r\n this.blockcont.removeChild(this.nselectimg);\r\n }\r\n let isuc = this.checkSuccess();\r\n if(isuc){\r\n console.error(\"成功过关\");\r\n this.gameover(1);\r\n }\r\n }\r\n checkSuccess(){\r\n let isuc:boolean = true;\r\n for(let r=0;r<this.rows;r++){\r\n for(let c=0;c<this.cols;c++){\r\n let ipicname = \"pic_\"+c+\"_\"+r;\r\n let npicstr = r+\"_\"+c;\r\n let ipic = this.dicont.getChildByName(ipicname);\r\n let ipostr = ipic.postr;\r\n if(npicstr!=ipostr){\r\n isuc = false;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n return isuc;\r\n\r\n }\r\n /**\r\n * \r\n * @param reason 1成功,2失败\r\n */\r\n private gameover(reason:number) {\r\n this.ingame = false;\r\n this.ticker&&clearInterval(this.ticker);\r\n engine.globalEvent.dispatchEvent('pictures-game-over', {\r\n reason:reason,\r\n time: this.passtime \r\n });\r\n }\r\n\r\n}\r\n","/**\r\n * Created by rockyl on 2020-01-09.\r\n */\r\n\r\nimport GameView from \"./GameView\";\r\nimport { injectProps } from \"../props\";\r\n\r\n\r\nexport class GameWrapper extends engine.Container {\r\n\t// private _status;\r\n\tprivate _gameView: GameView;\r\n\r\n\r\n\r\n\r\n\r\n\tconstructor() {\r\n\t\tsuper();\r\n\r\n\t\t//创建实例\r\n\t\tthis._gameView = new GameView();\r\n\t\tthis.addChild(this._gameView);\r\n\r\n\t\tengine.globalEvent.addEventListener('pictures-start', this.start, this);\r\n\t\tengine.globalEvent.addEventListener('pictures-pause', this.pause, this);\r\n\t\tengine.globalEvent.addEventListener('pictures-resume', this.resume, this);\r\n\t}\r\n\r\n\tstart(event: engine.Event) {\r\n\t\tinjectProps(event.data);\r\n\r\n\t\t// this._status = 1;\r\n\r\n\t\tthis._gameView.start();\r\n\t}\r\n\tpause(event: engine.Event) {\r\n\t\t\r\n\t\tthis._gameView.pause();\r\n\t}\r\n\tresume(event:engine.Event){\r\n\t\tthis._gameView.resume();\r\n\t}\r\n}\r\n","/**\r\n * Created by rockyl on 2019-11-20.\r\n */\r\n\r\nimport {GameWrapper} from \"./game/GameWrapper\";\r\nimport {injectProps, prepareProps} from \"./props\";\r\n\r\nexport default function (props) {\r\n\tprepareProps();\r\n\tinjectProps(props);\r\n\r\n\tlet instance = new GameWrapper();\r\n\t\r\n\treturn instance;\r\n}\r\n"],"names":["__extends"],"mappings":";;;;;;CAIO,IAAI,KAAK,GAAQ,EAAE,CAAC;AAE3B,UAAgB,YAAY;KAC3B,IAAI,SAAS,GAAG,QAAQ,EAAE,CAAC;KAE3B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;CACrC,CAAC;AAED,UAAgB,WAAW,CAAC,CAAC;KAC5B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;CAC7B,CAAC;;;UCVe,UAAU,CAAC,IAAI;KAC9B,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;CACvD,CAAC;AAED,UAAgB,gBAAgB,CAAC,IAAI;KACpC,OAAO,UAAU,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;CACrD,CAAC;AAED,UASgB,cAAc,CAAC,GAAG;KACjC,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO;SAC1B,IAAI,MAAM,CAAC,YAA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AI,QAAQ,GAAG,IAAI,WAAW,EAAE,CAAC;KAEjC,OAAO,QAAQ,CAAC;CACjB,CAAC;;;;;;;;;"} {"version":3,"file":"index.js","sources":["src/custom/pintu/src/props.ts","src/custom/pintu/src/game/utils.ts","src/custom/pintu/src/game/qietu.ts","src/custom/pintu/src/game/GameView.ts","src/custom/pintu/src/game/GameWrapper.ts","src/custom/pintu/src/index.ts"],"sourcesContent":["/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\n\r\nexport let props: any = {};\r\n\r\nexport function prepareProps() {\r\n\tlet metaProps = getProps();\r\n\r\n\tengine.injectProp(props, metaProps);\r\n}\r\n\r\nexport function injectProps(p) {\r\n\tengine.injectProp(props, p);\r\n}\r\n","/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\n\r\nexport function getTexture(uuid) {\r\n\treturn engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n}\r\n\r\nexport function getTextureByName(name) {\r\n\treturn getTexture(engine.getAssetByName(name).uuid);\r\n}\r\n\r\nexport function playSound(name) {\r\n\tengine.playSound(engine.getAssetByName(name).uuid, {keep: true});\r\n}\r\nexport function createSvga(name, anchorName?) {\r\n\tlet inst = new svga.Svga();\r\n\tinst.source = 'asset://' + engine.getAssetByName(name).uuid;\r\n\treturn inst;\r\n}\r\n\r\nexport function loadImageByUrl(url){\r\n\tconsole.log('loadImageByUrl----------:',url);\r\n\treturn new Promise((resolve) => {\r\n\t\tif (engine.TextureCache[url]) {\r\n\t\t\tresolve(engine.TextureCache[url])\r\n\t\t} else {\r\n\t\t\tvar t = engine.Texture.from(url);\r\n\t\t\tt.addEventListener(\"loaded\", () => { resolve(t) })\r\n\t\t}\r\n\t})\r\n}","import { props } from \"../props\";\r\nimport { loadImageByUrl } from \"./utils\";\r\nconst urls = [];\r\nconst picMap = {};\r\nconst posMap = {};\r\nexport default async(url:any,type1:number, rows:number, cols:number,parent:engine.Container) => {\r\n try{\r\n let t:engine.Texture;\r\n if(type1==1){\r\n console.log(\"直接使用已加载的tex\");\r\n t = url;\r\n }else{\r\n t = await loadImageByUrl(url) as engine.Texture;\r\n }\r\n \r\n let setimgwid = 612;\r\n let mwid1 = setimgwid/rows;\r\n let mhei1 = setimgwid/cols;\r\n\r\n let mwid = t.width;\r\n let mhei = t.height;\r\n\r\n let picarr = {};\r\n let picnames = [];\r\n\r\n let chax;\r\n let chay;\r\n let startlix;\r\n let addlix;\r\n let startliy;\r\n let addliy;\r\n if(mwid>mhei){\r\n chax = (mwid-mhei)/2;\r\n startlix = chax/mwid;\r\n addlix = (mhei/cols)/mwid;\r\n\r\n startliy = 0;\r\n addliy = 1/rows;\r\n }else{\r\n startlix = 0;\r\n addlix = 1/cols;\r\n\r\n chay = (mhei-mwid)/2;\r\n startliy = chay/mhei;\r\n addliy = (mwid/rows)/mhei;\r\n }\r\n for(let r=0;r<rows;r++){\r\n let startx = startlix+addlix*r;\r\n let endx = startx + addlix;\r\n for(let c=0;c<cols;c++){\r\n let starty = startliy+addliy*c;\r\n let endy = starty+addliy;\r\n\r\n let uvs = new Float32Array([\r\n starty,\r\n startx,\r\n endy,\r\n startx,\r\n endy,\r\n endx,\r\n starty,\r\n endx\r\n ])\r\n let isprite = new engine.Sprite(t);\r\n isprite.uvs = uvs;\r\n\r\n isprite.width = mwid1;\r\n isprite.height = mhei1;\r\n\r\n let ispritename = \"pic_\"+c+\"_\"+r;\r\n isprite.name = ispritename;\r\n picarr[ispritename] = isprite;\r\n picnames.push(ispritename);\r\n }\r\n }\r\n return {\r\n res:true,\r\n picarr:picarr,\r\n mwid:mwid1,\r\n mhei:mhei1,\r\n picnames:picnames\r\n };\r\n }catch(e){\r\n console.error(\"图片加载失败\",e);\r\n console.log(url,rows,cols);\r\n return {\r\n res:false\r\n };\r\n }\r\n};\r\n","/**\r\n * Created by rockyl on 2018/8/16.\r\n */\r\n\r\nimport { props } from \"../props\";\r\nimport qietu from \"./qietu\";\r\nimport { getTexture, loadImageByUrl,getTextureByName } from \"./utils\";\r\nimport ObjectPool = engine.ObjectPool;\r\n\r\nexport default class GameView extends engine.Container {\r\n rows:number;\r\n cols:number;\r\n\r\n passtime:number;\r\n gametime:number;\r\n showtime:number;\r\n\r\n lastframetime:number;\r\n\r\n ingame:boolean = false;\r\n\r\n ticker;\r\n\r\n selectimg3:engine.Image;\r\n selectimg4:engine.Image;\r\n nselectimg:engine.Image;\r\n\r\n selectImgArr:Array<string> = [];\r\n sucposData:Object = {};\r\n\r\n dicont:engine.Container;\r\n linecont:engine.Container;\r\n blockcont:engine.Container;\r\n\r\n lineShape:engine.Shape;\r\n\r\n mwid:number;\r\n mhei:number;\r\n picnames:Array<string>;\r\n picarr;\r\n\r\n gameUrls:Array<string> = [];\r\n onegamePics:Array<engine.Texture> = [];\r\n constructor() {\r\n super();\r\n this.once(engine.Event.ADDED_TO_STAGE, this.initScene, this);\r\n }\r\n initScene(){\r\n this.lineShape = new engine.Shape();\r\n this.selectimg3 = new engine.Image(getTextureByName(\"框3\"));\r\n this.selectimg4 = new engine.Image(getTextureByName(\"框4\"));\r\n //底图\r\n this.dicont = new engine.Container();\r\n //线\r\n this.linecont = new engine.Container();\r\n //亮片\r\n this.blockcont = new engine.Container();\r\n\r\n this.addChild(this.dicont);\r\n this.addChild(this.linecont);\r\n this.addChild(this.blockcont);\r\n \r\n this.linecont.addChild(this.lineShape);\r\n }\r\n async initgame(){\r\n console.log(\"initgame---------\");\r\n this.gameUrls = props.gameUrls;\r\n \r\n this.onegamePics = new Array();\r\n for(let l=0;l<this.gameUrls.length;l++){\r\n let lurl = this.gameUrls[l];\r\n let lt = await loadImageByUrl(lurl) as engine.Texture;\r\n this.onegamePics.push(lt);\r\n }\r\n }\r\n async start() {\r\n \r\n this.dicont.removeChildren();\r\n\r\n let actidx = props.actidx;\r\n this.gametime = props.gametime;\r\n this.showtime = props.gametime;\r\n console.log(\"start-----------------\",actidx);\r\n this.rows = props.rows;\r\n this.cols = props.cols;\r\n\r\n this.nselectimg = null;\r\n if(this.rows==3){\r\n this.nselectimg = this.selectimg3;\r\n }\r\n if(this.rows==4){\r\n this.nselectimg = this.selectimg4;\r\n }\r\n\r\n this.passtime = 0;\r\n \r\n this.selectImgArr = new Array();\r\n this.sucposData = {};\r\n\r\n let tex:any = this.onegamePics[actidx];\r\n let type1 = 1;\r\n if(!tex){\r\n tex = this.gameUrls[actidx];\r\n type1 = 2;\r\n }\r\n let result = await qietu(tex,type1,this.rows,this.cols,this.dicont);\r\n let res = result.res;\r\n if(res){\r\n let picarr = result.picarr;\r\n let mwid = result.mwid;\r\n let mhei = result.mhei;\r\n let picnames = result.picnames;\r\n\r\n this.mwid = mwid;\r\n this.mhei = mhei;\r\n this.picarr = picarr;\r\n this.picnames = picnames;\r\n\r\n let gap = 2;\r\n for(let r=0;r<this.rows;r++){\r\n for(let c=0;c<this.cols;c++){\r\n let ipicx = mwid*c+gap;\r\n let ipicy = mhei*r+gap;\r\n let npicname = \"pic_\"+c+\"_\"+r;\r\n\r\n // this.sucposData[npicname] = r+\"_\"+c;\r\n\r\n // let selidx = Math.floor(Math.random()*picnames.length);\r\n // let ipicname:string = picnames[selidx];\r\n // if(r==c&&r!=this.rows-1){\r\n // while(ipicname==npicname){\r\n // selidx = Math.floor(Math.random()*picnames.length);\r\n // ipicname = picnames[selidx];\r\n // }\r\n // }\r\n let ipic = picarr[npicname];\r\n // picnames.splice(selidx,1);\r\n this.dicont.addChild(ipic);\r\n ipic.x = ipicx;\r\n ipic.y = ipicy;\r\n // ipic[\"postr\"] = r+\"_\"+c;\r\n\r\n // ipic.addEventListener(engine.MouseEvent.MOUSE_DOWN,\r\n // this.touchPic,this);\r\n }\r\n }\r\n //框线\r\n this.lineShape.clear();\r\n this.lineShape.beginStroke(0x0069df,4,engine.LINE_CAP.BUTT,engine.LINE_JOIN.BEVEL,100);\r\n\r\n this.lineShape.moveTo(0+gap,0+gap);\r\n this.lineShape.lineTo(mhei*this.cols+gap,0+gap);\r\n this.lineShape.lineTo(mhei*this.cols+gap,mwid*this.rows+gap);\r\n this.lineShape.lineTo(0+gap,mwid*this.rows+gap);\r\n this.lineShape.lineTo(0+gap,0+gap);\r\n\r\n for(let rl=1;rl<this.rows;rl++){\r\n this.lineShape.moveTo(0+gap,rl*mhei+gap);\r\n this.lineShape.lineTo(mwid*this.cols+gap,rl*mhei+gap);\r\n }\r\n for(let cl=1;cl<this.cols;cl++){\r\n this.lineShape.moveTo(cl*mwid+gap,0+gap);\r\n this.lineShape.lineTo(cl*mwid+gap,this.rows*mhei+gap);\r\n }\r\n this.lineShape.endStroke();\r\n \r\n\r\n this.ticker = setInterval(this.update, 20);\r\n }else{\r\n console.error(\"图片处理失败\");\r\n }\r\n }\r\n luanxu(){\r\n let gap = 2;\r\n for(let r=0;r<this.rows;r++){\r\n for(let c=0;c<this.cols;c++){\r\n let ipicx = this.mwid*c+gap;\r\n let ipicy = this.mhei*r+gap;\r\n let npicname = \"pic_\"+c+\"_\"+r;\r\n\r\n this.sucposData[npicname] = r+\"_\"+c;\r\n\r\n let selidx = Math.floor(Math.random()*this.picnames.length);\r\n let ipicname:string = this.picnames[selidx];\r\n if(r==c&&r!=this.rows-1){\r\n while(ipicname==npicname){\r\n selidx = Math.floor(Math.random()*this.picnames.length);\r\n ipicname = this.picnames[selidx];\r\n }\r\n }\r\n let ipic = this.picarr[ipicname];\r\n this.picnames.splice(selidx,1);\r\n ipic.x = ipicx;\r\n ipic.y = ipicy;\r\n ipic[\"postr\"] = r+\"_\"+c;\r\n\r\n ipic.addEventListener(engine.MouseEvent.MOUSE_DOWN,\r\n this.touchPic,this);\r\n }\r\n }\r\n }\r\n pause(){\r\n this.ingame = false;\r\n }\r\n resume(){\r\n this.ingame = true;\r\n }\r\n\r\n\r\n update() {\r\n let ntime = Date.now();\r\n if(!this.lastframetime){\r\n this.lastframetime = ntime;\r\n return;\r\n }\r\n if(this.ingame){\r\n let passtime = (ntime - this.lastframetime)/1000;\r\n this.passtime += passtime;\r\n let showtime1 = Math.round(this.gametime - this.passtime);\r\n // console.log(passtime,this.passtime,this.gametime,this.showtime);\r\n if(this.showtime!=showtime1){\r\n this.showtime = showtime1;\r\n if(this.showtime<=0){\r\n this.showtime = 0;\r\n this.gameover(2);\r\n }\r\n // console.log(\"倒计时\",this.showtime);\r\n engine.globalEvent.dispatchEvent(\"pictures-time-update\",{\r\n time:this.showtime\r\n });\r\n }\r\n }\r\n this.lastframetime = ntime;\r\n }\r\n\r\n touchPic(e:engine.MouseEvent){\r\n if(!this.ingame){\r\n return;\r\n }\r\n // console.log(e.target.name);\r\n let selectname = e.target.name;\r\n let spx = e.target.x;\r\n let spy = e.target.y;\r\n let gap = 2;\r\n if(this.selectImgArr.length==0){\r\n if(this.nselectimg){\r\n this.blockcont.addChild(this.nselectimg);\r\n this.nselectimg.x = spx-gap;\r\n this.nselectimg.y = spy-gap;\r\n }\r\n this.selectImgArr.push(selectname);\r\n }else if(this.selectImgArr.length==1){\r\n if(selectname==this.selectImgArr[0]){\r\n return;\r\n }else{\r\n this.selectImgArr.push(selectname);\r\n this.changeImgPos();\r\n }\r\n }\r\n }\r\n changeImgPos(){\r\n let img1name = this.selectImgArr[0];\r\n let img2name = this.selectImgArr[1];\r\n\r\n let img1 = this.dicont.getChildByName(img1name);\r\n let img2 = this.dicont.getChildByName(img2name);\r\n\r\n let imgpos1x = img1.x;\r\n let imgpos1y = img1.y;\r\n let imgpos2x = img2.x;\r\n let imgpos2y = img2.y;\r\n\r\n let imgpostr1 = img1.postr;\r\n let imgpostr2 = img2.postr;\r\n\r\n img1.x = imgpos2x;\r\n img1.y = imgpos2y;\r\n img1.postr = imgpostr2;\r\n\r\n img2.x = imgpos1x;\r\n img2.y = imgpos1y;\r\n img2.postr = imgpostr1;\r\n\r\n this.selectImgArr = new Array();\r\n \r\n if(this.nselectimg){\r\n this.blockcont.removeChild(this.nselectimg);\r\n }\r\n let isuc = this.checkSuccess();\r\n if(isuc){\r\n console.error(\"成功过关\");\r\n this.gameover(1);\r\n }\r\n }\r\n checkSuccess(){\r\n let isuc:boolean = true;\r\n for(let r=0;r<this.rows;r++){\r\n for(let c=0;c<this.cols;c++){\r\n let ipicname = \"pic_\"+c+\"_\"+r;\r\n let npicstr = r+\"_\"+c;\r\n let ipic = this.dicont.getChildByName(ipicname);\r\n let ipostr = ipic.postr;\r\n if(npicstr!=ipostr){\r\n isuc = false;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n return isuc;\r\n\r\n }\r\n /**\r\n * \r\n * @param reason 1成功,2失败\r\n */\r\n private gameover(reason:number) {\r\n this.ingame = false;\r\n this.ticker&&clearInterval(this.ticker);\r\n engine.globalEvent.dispatchEvent('pictures-game-over', {\r\n reason:reason,\r\n time: this.passtime \r\n });\r\n }\r\n\r\n}\r\n","/**\r\n * Created by rockyl on 2020-01-09.\r\n */\r\n\r\nimport GameView from \"./GameView\";\r\nimport { injectProps } from \"../props\";\r\n\r\n\r\nexport class GameWrapper extends engine.Container {\r\n\t// private _status;\r\n\tprivate _gameView: GameView;\r\n\r\n\r\n\r\n\r\n\r\n\tconstructor() {\r\n\t\tsuper();\r\n\r\n\t\t//创建实例\r\n\t\tthis._gameView = new GameView();\r\n\t\tthis.addChild(this._gameView);\r\n\r\n\t\tengine.globalEvent.addEventListener('pictures-initgame', this.initgame, this);\r\n\t\tengine.globalEvent.addEventListener('pictures-start', this.start, this);\r\n\t\tengine.globalEvent.addEventListener('pictures-luanxu', this.luanxu, this);\r\n\t\tengine.globalEvent.addEventListener('pictures-pause', this.pause, this);\r\n\t\tengine.globalEvent.addEventListener('pictures-resume', this.resume, this);\r\n\t}\r\n\tinitgame(event: engine.Event) {\r\n\t\tinjectProps(event.data);\r\n\r\n\t\t// this._status = 1;\r\n\r\n\t\tthis._gameView.initgame();\r\n\t}\r\n\tstart(event: engine.Event) {\r\n\t\tinjectProps(event.data);\r\n\r\n\t\t// this._status = 1;\r\n\r\n\t\tthis._gameView.start();\r\n\t}\r\n\tluanxu(){\r\n\t\tthis._gameView.luanxu();\r\n\t}\r\n\tpause(event: engine.Event) {\r\n\t\t\r\n\t\tthis._gameView.pause();\r\n\t}\r\n\tresume(event:engine.Event){\r\n\t\tthis._gameView.resume();\r\n\t}\r\n}\r\n","/**\r\n * Created by rockyl on 2019-11-20.\r\n */\r\n\r\nimport {GameWrapper} from \"./game/GameWrapper\";\r\nimport {injectProps, prepareProps} from \"./props\";\r\n\r\nexport default function (props) {\r\n\tprepareProps();\r\n\tinjectProps(props);\r\n\r\n\tlet instance = new GameWrapper();\r\n\t\r\n\treturn instance;\r\n}\r\n"],"names":["__extends"],"mappings":";;;;;;CAIO,IAAI,KAAK,GAAQ,EAAE,CAAC;AAE3B,UAAgB,YAAY;KAC3B,IAAI,SAAS,GAAG,QAAQ,EAAE,CAAC;KAE3B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;CACrC,CAAC;AAED,UAAgB,WAAW,CAAC,CAAC;KAC5B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;CAC7B,CAAC;;;UCVe,UAAU,CAAC,IAAI;KAC9B,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;CACvD,CAAC;AAED,UAAgB,gBAAgB,CAAC,IAAI;KACpC,OAAO,UAAU,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;CACrD,CAAC;AAED,UASgB,cAAc,CAAC,GAAG;KACjC,OAAO,CAAC,GAAG,CAAC,2BAA2B,EAAC,GAAG,CAAC,CAAC;KAC7C,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO;SAC1B,IAAI,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE;aAC7B,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAA;UACjC;cAAM;aACN,IAAI,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;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B,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SAIxB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;MACvB;KACD,4BAAM,GAAN;SACC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;MACxB;KACD,2BAAK,GAAL,UAAM,KAAmB;SAExB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;MACvB;KACD,4BAAM,GAAN,UAAO,KAAkB;SACxB,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;MACxB;KACF,kBAAC;CAAD,CAAC,CA7CgC,MAAM,CAAC,SAAS,GA6ChD;;;iBC9CwB,KAAK;KAC7B,YAAY,EAAE,CAAC;KACf,WAAW,CAAC,KAAK,CAAC,CAAC;KAEnB,IAAI,QAAQ,GAAG,IAAI,WAAW,EAAE,CAAC;KAEjC,OAAO,QAAQ,CAAC;CACjB,CAAC;;;;;;;;;"}
\ No newline at end of file \ No newline at end of file
...@@ -65,15 +65,28 @@ ...@@ -65,15 +65,28 @@
], ],
"events": { "events": {
"in": { "in": {
"pictures-initgame": {
"alias": "初始化",
"data":{
"gameUrls":[
"https://yun.duiba.com.cn/aurora/assets/1456b2a9d72e56f075abb29df99052d87a0f1e48.jpg",
"https://yun.duiba.com.cn/aurora/assets/61fd0754d7924305fd2851be86a480d71d2c2981.jpg",
"https://yun.duiba.com.cn/aurora/assets/6b70d7ec626f35f21347bf5bc3e61bedc44167be.jpg"
]
}
},
"pictures-start": { "pictures-start": {
"alias": "开始", "alias": "开始",
"data": { "data": {
"actidx":1,
"rows":3, "rows":3,
"cols":3, "cols":3,
"picUrl":"图片",
"gametime":30 "gametime":30
} }
}, },
"pictures-luanxu": {
"alias": "乱序"
},
"pictures-pause": { "pictures-pause": {
"alias": "停止" "alias": "停止"
}, },
......
...@@ -33,6 +33,14 @@ export default class GameView extends engine.Container { ...@@ -33,6 +33,14 @@ export default class GameView extends engine.Container {
blockcont:engine.Container; blockcont:engine.Container;
lineShape:engine.Shape; lineShape:engine.Shape;
mwid:number;
mhei:number;
picnames:Array<string>;
picarr;
gameUrls:Array<string> = [];
onegamePics:Array<engine.Texture> = [];
constructor() { constructor() {
super(); super();
this.once(engine.Event.ADDED_TO_STAGE, this.initScene, this); this.once(engine.Event.ADDED_TO_STAGE, this.initScene, this);
...@@ -54,13 +62,25 @@ export default class GameView extends engine.Container { ...@@ -54,13 +62,25 @@ export default class GameView extends engine.Container {
this.linecont.addChild(this.lineShape); this.linecont.addChild(this.lineShape);
} }
async initgame(){
console.log("initgame---------");
this.gameUrls = props.gameUrls;
this.onegamePics = new Array();
for(let l=0;l<this.gameUrls.length;l++){
let lurl = this.gameUrls[l];
let lt = await loadImageByUrl(lurl) as engine.Texture;
this.onegamePics.push(lt);
}
}
async start() { async start() {
this.dicont.removeChildren(); this.dicont.removeChildren();
let picUrl = props.picUrl; let actidx = props.actidx;
this.gametime = props.gametime; this.gametime = props.gametime;
this.showtime = props.gametime; this.showtime = props.gametime;
console.log("start-----------------",actidx);
this.rows = props.rows; this.rows = props.rows;
this.cols = props.cols; this.cols = props.cols;
...@@ -76,13 +96,26 @@ export default class GameView extends engine.Container { ...@@ -76,13 +96,26 @@ export default class GameView extends engine.Container {
this.selectImgArr = new Array(); this.selectImgArr = new Array();
this.sucposData = {}; this.sucposData = {};
let result = await qietu(picUrl,this.rows,this.cols,this.dicont);
let tex:any = this.onegamePics[actidx];
let type1 = 1;
if(!tex){
tex = this.gameUrls[actidx];
type1 = 2;
}
let result = await qietu(tex,type1,this.rows,this.cols,this.dicont);
let res = result.res; let res = result.res;
if(res){ if(res){
let picarr = result.picarr; let picarr = result.picarr;
let mwid = result.mwid; let mwid = result.mwid;
let mhei = result.mhei; let mhei = result.mhei;
let picnames = result.picnames; let picnames = result.picnames;
this.mwid = mwid;
this.mhei = mhei;
this.picarr = picarr;
this.picnames = picnames;
let gap = 2; let gap = 2;
for(let r=0;r<this.rows;r++){ for(let r=0;r<this.rows;r++){
for(let c=0;c<this.cols;c++){ for(let c=0;c<this.cols;c++){
...@@ -90,25 +123,25 @@ export default class GameView extends engine.Container { ...@@ -90,25 +123,25 @@ export default class GameView extends engine.Container {
let ipicy = mhei*r+gap; let ipicy = mhei*r+gap;
let npicname = "pic_"+c+"_"+r; let npicname = "pic_"+c+"_"+r;
this.sucposData[npicname] = r+"_"+c; // this.sucposData[npicname] = r+"_"+c;
let selidx = Math.floor(Math.random()*picnames.length); // let selidx = Math.floor(Math.random()*picnames.length);
let ipicname:string = picnames[selidx]; // let ipicname:string = picnames[selidx];
if(r==c&&r!=this.rows-1){ // if(r==c&&r!=this.rows-1){
while(ipicname==npicname){ // while(ipicname==npicname){
selidx = Math.floor(Math.random()*picnames.length); // selidx = Math.floor(Math.random()*picnames.length);
ipicname = picnames[selidx]; // ipicname = picnames[selidx];
} // }
} // }
let ipic = picarr[ipicname]; let ipic = picarr[npicname];
picnames.splice(selidx,1); // picnames.splice(selidx,1);
this.dicont.addChild(ipic); this.dicont.addChild(ipic);
ipic.x = ipicx; ipic.x = ipicx;
ipic.y = ipicy; ipic.y = ipicy;
ipic["postr"] = r+"_"+c; // ipic["postr"] = r+"_"+c;
ipic.addEventListener(engine.MouseEvent.MOUSE_DOWN, // ipic.addEventListener(engine.MouseEvent.MOUSE_DOWN,
this.touchPic,this); // this.touchPic,this);
} }
} }
//框线 //框线
...@@ -132,11 +165,40 @@ export default class GameView extends engine.Container { ...@@ -132,11 +165,40 @@ export default class GameView extends engine.Container {
this.lineShape.endStroke(); this.lineShape.endStroke();
this.ticker = setInterval(this.update, 30); this.ticker = setInterval(this.update, 20);
}else{ }else{
console.error("图片处理失败"); console.error("图片处理失败");
} }
} }
luanxu(){
let gap = 2;
for(let r=0;r<this.rows;r++){
for(let c=0;c<this.cols;c++){
let ipicx = this.mwid*c+gap;
let ipicy = this.mhei*r+gap;
let npicname = "pic_"+c+"_"+r;
this.sucposData[npicname] = r+"_"+c;
let selidx = Math.floor(Math.random()*this.picnames.length);
let ipicname:string = this.picnames[selidx];
if(r==c&&r!=this.rows-1){
while(ipicname==npicname){
selidx = Math.floor(Math.random()*this.picnames.length);
ipicname = this.picnames[selidx];
}
}
let ipic = this.picarr[ipicname];
this.picnames.splice(selidx,1);
ipic.x = ipicx;
ipic.y = ipicy;
ipic["postr"] = r+"_"+c;
ipic.addEventListener(engine.MouseEvent.MOUSE_DOWN,
this.touchPic,this);
}
}
}
pause(){ pause(){
this.ingame = false; this.ingame = false;
} }
......
...@@ -21,11 +21,19 @@ export class GameWrapper extends engine.Container { ...@@ -21,11 +21,19 @@ export class GameWrapper extends engine.Container {
this._gameView = new GameView(); this._gameView = new GameView();
this.addChild(this._gameView); this.addChild(this._gameView);
engine.globalEvent.addEventListener('pictures-initgame', this.initgame, this);
engine.globalEvent.addEventListener('pictures-start', this.start, this); engine.globalEvent.addEventListener('pictures-start', this.start, this);
engine.globalEvent.addEventListener('pictures-luanxu', this.luanxu, this);
engine.globalEvent.addEventListener('pictures-pause', this.pause, this); engine.globalEvent.addEventListener('pictures-pause', this.pause, this);
engine.globalEvent.addEventListener('pictures-resume', this.resume, this); engine.globalEvent.addEventListener('pictures-resume', this.resume, this);
} }
initgame(event: engine.Event) {
injectProps(event.data);
// this._status = 1;
this._gameView.initgame();
}
start(event: engine.Event) { start(event: engine.Event) {
injectProps(event.data); injectProps(event.data);
...@@ -33,6 +41,9 @@ export class GameWrapper extends engine.Container { ...@@ -33,6 +41,9 @@ export class GameWrapper extends engine.Container {
this._gameView.start(); this._gameView.start();
} }
luanxu(){
this._gameView.luanxu();
}
pause(event: engine.Event) { pause(event: engine.Event) {
this._gameView.pause(); this._gameView.pause();
......
...@@ -3,22 +3,53 @@ import { loadImageByUrl } from "./utils"; ...@@ -3,22 +3,53 @@ import { loadImageByUrl } from "./utils";
const urls = []; const urls = [];
const picMap = {}; const picMap = {};
const posMap = {}; const posMap = {};
export default async(url:string, rows:number, cols:number,parent:engine.Container) => { export default async(url:any,type1:number, rows:number, cols:number,parent:engine.Container) => {
try{ try{
let t:engine.Texture = await loadImageByUrl(url) as engine.Texture; let t:engine.Texture;
if(type1==1){
console.log("直接使用已加载的tex");
t = url;
}else{
t = await loadImageByUrl(url) as engine.Texture;
}
let setimgwid = 612;
let mwid1 = setimgwid/rows;
let mhei1 = setimgwid/cols;
let mwid = t.width/rows; let mwid = t.width;
let mhei = t.height/cols; let mhei = t.height;
let picarr = {}; let picarr = {};
let picnames = []; let picnames = [];
let chax;
let chay;
let startlix;
let addlix;
let startliy;
let addliy;
if(mwid>mhei){
chax = (mwid-mhei)/2;
startlix = chax/mwid;
addlix = (mhei/cols)/mwid;
startliy = 0;
addliy = 1/rows;
}else{
startlix = 0;
addlix = 1/cols;
chay = (mhei-mwid)/2;
startliy = chay/mhei;
addliy = (mwid/rows)/mhei;
}
for(let r=0;r<rows;r++){ for(let r=0;r<rows;r++){
let startx = r/rows; let startx = startlix+addlix*r;
let endx = (r+1)/rows; let endx = startx + addlix;
// linedraw.moveTo()
for(let c=0;c<cols;c++){ for(let c=0;c<cols;c++){
let starty = c/cols; let starty = startliy+addliy*c;
let endy = (c+1)/cols; let endy = starty+addliy;
let uvs = new Float32Array([ let uvs = new Float32Array([
starty, starty,
...@@ -29,24 +60,24 @@ export default async(url:string, rows:number, cols:number,parent:engine.Containe ...@@ -29,24 +60,24 @@ export default async(url:string, rows:number, cols:number,parent:engine.Containe
endx, endx,
starty, starty,
endx endx
]); ])
let isprite = new engine.Sprite(t);
isprite.uvs = uvs;
let itexture = new engine.Sprite(t); isprite.width = mwid1;
itexture.uvs = uvs; isprite.height = mhei1;
itexture.width = mwid; let ispritename = "pic_"+c+"_"+r;
itexture.height = mhei; isprite.name = ispritename;
let itexname = "pic_"+c+"_"+r; picarr[ispritename] = isprite;
itexture.name = itexname; picnames.push(ispritename);
picarr[itexname] = itexture;
picnames.push(itexname);
} }
} }
return { return {
res:true, res:true,
picarr:picarr, picarr:picarr,
mwid:mwid, mwid:mwid1,
mhei:mhei, mhei:mhei1,
picnames:picnames picnames:picnames
}; };
}catch(e){ }catch(e){
......
...@@ -20,6 +20,7 @@ export function createSvga(name, anchorName?) { ...@@ -20,6 +20,7 @@ export function createSvga(name, anchorName?) {
} }
export function loadImageByUrl(url){ export function loadImageByUrl(url){
console.log('loadImageByUrl----------:',url);
return new Promise((resolve) => { return new Promise((resolve) => {
if (engine.TextureCache[url]) { if (engine.TextureCache[url]) {
resolve(engine.TextureCache[url]) resolve(engine.TextureCache[url])
......
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