Commit d0b28e59 authored by zjz1994's avatar zjz1994

北京现代过桥墩,拼图

parent 5e9c78f6
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
"strutUpSpeed": { "strutUpSpeed": {
"alias": "撑杆上升速度(每帧上升增量,一秒60帧)", "alias": "撑杆上升速度(每帧上升增量,一秒60帧)",
"type": "number", "type": "number",
"default": 10 "default": 30
}, },
"strutWidth": { "strutWidth": {
"alias": "撑杆宽度", "alias": "撑杆宽度",
...@@ -120,7 +120,7 @@ ...@@ -120,7 +120,7 @@
}, },
{ {
"name": "yindao1", "name": "yindao1",
"url": "//yun.duiba.com.cn/aurora/assets/a0409ec24b35198e990c61bc7f5dc66b15a5213a.png", "url": "//yun.duiba.com.cn/aurora/assets/f21d5429dbd947e66613bd6c5d864fdcfd104bd4.png",
"uuid": "yindao1", "uuid": "yindao1",
"ext": ".png" "ext": ".png"
}, },
...@@ -168,9 +168,15 @@ ...@@ -168,9 +168,15 @@
}, },
{ {
"name": "walk", "name": "walk",
"url": "//yun.duiba.com.cn/aurora/assets/a4ab1e1a2b49d140db4a0806562098a8b1619b06.svga", "url": "//yun.duiba.com.cn/aurora/assets/5b31481f8d5669213da518b156aac7cadf5d9374",
"uuid": "10cd1fdd-4fd8-43cf-a1c7-6ff5846d8a91", "uuid": "10cd1fdd-4fd8-43cf-a1c7-6ff5846d8a91",
"ext": ".svga" "ext": ".svga"
},
{
"name": "xiache",
"url": "//yun.duiba.com.cn/aurora/assets/57ad75aa036c04e13abcf32c464ff5ae37419495",
"uuid": "xiache",
"ext": ".svga"
} }
], ],
"events": { "events": {
...@@ -183,11 +189,21 @@ ...@@ -183,11 +189,21 @@
"alias": "复活", "alias": "复活",
"data": {} "data": {}
}, },
"bjxd-game-reset": {
"alias": "重置",
"data": {}
},
"bjxd-game-change": { "bjxd-game-change": {
"alias": "替换显示", "alias": "替换显示",
"data": { "data": {
"index": 1 "index": 1
} }
},
"bjxd-game-speed": {
"alias": "修改速度",
"data": {
"speed": 10
}
} }
}, },
"out": { "out": {
...@@ -206,5 +222,5 @@ ...@@ -206,5 +222,5 @@
} }
}, },
"id": "bjxd-game", "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" "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}\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));\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.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));\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));\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));\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 };\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));\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 = 878;\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 - 50;\r\n\t this.playerNode.play();\r\n\t this._container.visible = false;\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 - 50;\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));\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 = 3;\r\n\t chax = 39;\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 var mindis = this._distance[0] - this._distance[1] + chax;\r\n\t var maxdis = this._distance[0] + paddingx;\r\n\t if (mindis <= this._strut.height && this._strut.height <= maxdis) {\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 var maxdis = 700;\r\n\t if (this._strut.height < maxdis) {\r\n\t if (this._strut.height + GameView.speed > maxdis) {\r\n\t this._strut.height = maxdis;\r\n\t }\r\n\t else {\r\n\t this._strut.height += GameView.speed;\r\n\t }\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));\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.playery = 878;\r\n\t _this.inani = true;\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 this.pierWidth = pierWidth;\r\n\t this.xiacheNode = createSvga(\"xiache\");\r\n\t this.addChild(this.xiacheNode);\r\n\t this.xiacheNode.y = this.playery - 35;\r\n\t this.xiacheNode.x = this.pierWidth / 2 - 100;\r\n\t this.xiacheNode.stop();\r\n\t this.xiacheNode.name = \"xiacheanm\";\r\n\t console.log(\"下车动画帧数\", this.xiacheNode.totalFrames, this.xiacheNode);\r\n\t this.xiacheNode.visible = false;\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.playComp = function () {\r\n\t var curframe = this.xiacheNode.currentFrame;\r\n\t if (curframe == this.xiacheNode.totalFrames) {\r\n\t this.inani = false;\r\n\t this.xiacheNode.stop();\r\n\t this.xiacheNode.removeEventListener(engine.Event.ENTER_FRAME, this.playComp, this);\r\n\t for (var i = 0; i < 15; i++) {\r\n\t if (i < 12) {\r\n\t this.xiacheNode.getChildAt(i).visible = false;\r\n\t }\r\n\t }\r\n\t this._player._container.visible = true;\r\n\t }\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 this._player.revive();\r\n\t this.closeStrut();\r\n\t initScore = 0;\r\n\t this.updateScore(initScore);\r\n\t if (this.xiacheNode.x < this.pierWidth / 2 - 105) {\r\n\t this.startAnm();\r\n\t }\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.startAnm = function () {\r\n\t this.inani = true;\r\n\t this.xiacheNode.visible = true;\r\n\t for (var i = 0; i < 15; i++) {\r\n\t if (i < 12) {\r\n\t this.xiacheNode.getChildAt(i).visible = true;\r\n\t }\r\n\t }\r\n\t this.xiacheNode.x = this.pierWidth / 2 - 100;\r\n\t this._player._container.visible = false;\r\n\t this.xiacheNode.gotoAndPlay(1);\r\n\t this.xiacheNode.addEventListener(engine.Event.ENTER_FRAME, this.playComp, this);\r\n\t };\r\n\t GameView.prototype.reset = function () {\r\n\t this._sumScore = 0;\r\n\t engine.globalEvent.dispatchEvent('bjxd-game-score', { score: this._sumScore });\r\n\t this._player.revive();\r\n\t this.closeStrut();\r\n\t this.changeBg(GameView.bgIndex);\r\n\t this.startAnm();\r\n\t };\r\n\t GameView.prototype.revive = function () {\r\n\t this._player.revive();\r\n\t this.startAnm();\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 && !this.inani) {\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 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 this._player.setViewport(this._strut.getStrutHeight(), function () {\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 var carx = this.xiacheNode.x;\r\n\t if (carx > -200) {\r\n\t carx -= movePos;\r\n\t engine.Tween.get(this.xiacheNode, { loop: false })\r\n\t .to({\r\n\t x: carx\r\n\t }, props.pierMoveTime);\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 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.prototype.changeSpeed = function (speed) {\r\n\t if (GameView.speed != speed) {\r\n\t GameView.speed = speed;\r\n\t }\r\n\t };\r\n\t GameView.bgIndex = 0;\r\n\t GameView.speed = 10;\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('bjxd-game-start', _this.start, _this);\r\n\t engine.globalEvent.addEventListener('bjxd-game-reset', _this.reset, _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 engine.globalEvent.addEventListener('bjxd-game-speed', _this.speed, _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.reset = function () {\r\n\t this._gameView.reset();\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 GameWrapper.prototype.speed = function (event) {\r\n\t this._gameView.changeSpeed(event.data.speed);\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"
} }
...@@ -106,9 +106,27 @@ ...@@ -106,9 +106,27 @@
"data": { "data": {
"reason": "结束(1:成功,2失败)" "reason": "结束(1:成功,2失败)"
} }
},
"pictures-load-complete": {
"alias": "图片加载完毕",
"data": {
"reason": "结束(1:成功,2失败)"
}
},
"pictures-time-passtime": {
"alias": "倒计时进度条",
"data": {
"passtime": 0
}
},
"pictures-time-initcomp": {
"alias": "倒计时进度条",
"data": {
"passtime": 0
}
} }
} }
}, },
"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 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" "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}\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 tslib.__awaiter(this, void 0, void 0, function () {\r\n\t return tslib.__generator(this, function (_a) {\r\n\t console.log('loadImageByUrl----------:', url);\r\n\t return [2, 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 });\r\n\t}\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, 6, , 7]);\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 if (!(mwid < 10 || mhei < 10)) return [3, 5];\r\n\t console.log(\"调整222222222222\");\r\n\t return [4, new Promise(function (res) {\r\n\t setTimeout(function () {\r\n\t res();\r\n\t }, 200);\r\n\t })];\r\n\t case 4:\r\n\t _a.sent();\r\n\t return [2, qietu(t, 1, rows, cols)];\r\n\t case 5:\r\n\t console.log('图片', t);\r\n\t console.log(\"图片获取尺寸\", mwid, mhei);\r\n\t if (mwid > mhei) {\r\n\t if (mhei < setimgwid) {\r\n\t mwid = mwid * setimgwid / mhei;\r\n\t mhei = setimgwid;\r\n\t }\r\n\t }\r\n\t else {\r\n\t if (mwid < setimgwid) {\r\n\t mhei = mhei * setimgwid / mwid;\r\n\t mwid = setimgwid;\r\n\t }\r\n\t }\r\n\t console.log(\"适配后的图片尺寸\", mwid, mhei);\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 6:\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 7: return [2];\r\n\t }\r\n\t });\r\n\t}); });\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.gameTimes = [];\r\n\t _this.onegamePics = [];\r\n\t _this.movesteps = 0;\r\n\t _this.startime = 0;\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.selectimg3.mouseEnabled = false;\r\n\t this.selectimg4.mouseEnabled = false;\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 console.log(\"拼图初始化完毕--------------\");\r\n\t engine.globalEvent.dispatchEvent(\"pictures-time-initcomp\", {});\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.gameTimes = props.gameTimes;\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 if (this.onegamePics.length == 1) {\r\n\t this.startfirst();\r\n\t }\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.startfirst = 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 this.movesteps = 0;\r\n\t this.startime = Date.now();\r\n\t actidx = 0;\r\n\t this.gametime = this.gameTimes[actidx];\r\n\t this.showtime = this.gameTimes[actidx];\r\n\t this.passtime = 0;\r\n\t engine.globalEvent.dispatchEvent(\"pictures-time-update\", {\r\n\t time: this.showtime,\r\n\t });\r\n\t engine.globalEvent.dispatchEvent(\"pictures-time-passtime\", {\r\n\t passtime: this.passtime\r\n\t });\r\n\t console.log(\"start-----------------\", actidx);\r\n\t this.rows = 3;\r\n\t this.cols = 3;\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.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 engine.globalEvent.dispatchEvent(\"pictures-load-complete\");\r\n\t this.ticker && clearInterval(this.ticker);\r\n\t this.ticker = setInterval(this.update, 10);\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.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 this.movesteps = 0;\r\n\t this.startime = Date.now();\r\n\t actidx = props.actidx;\r\n\t this.gametime = this.gameTimes[actidx];\r\n\t this.showtime = this.gameTimes[actidx];\r\n\t this.passtime = 0;\r\n\t engine.globalEvent.dispatchEvent(\"pictures-time-update\", {\r\n\t time: this.showtime,\r\n\t });\r\n\t engine.globalEvent.dispatchEvent(\"pictures-time-passtime\", {\r\n\t passtime: this.passtime\r\n\t });\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.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 && clearInterval(this.ticker);\r\n\t this.ticker = setInterval(this.update, 10);\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 console.error(\"拼图暂停\");\r\n\t };\r\n\t GameView.prototype.resume = function () {\r\n\t this.lastframetime = Date.now();\r\n\t this.ingame = true;\r\n\t console.error(\"拼图继续\");\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 engine.globalEvent.dispatchEvent(\"pictures-time-passtime\", {\r\n\t passtime: this.passtime\r\n\t });\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 if (this.nselectimg) {\r\n\t this.blockcont.removeChild(this.nselectimg);\r\n\t }\r\n\t this.selectImgArr = new Array();\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 this.movesteps += 1;\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 var ntime = Date.now();\r\n\t var gametime = ntime - this.startime;\r\n\t engine.globalEvent.dispatchEvent('pictures-game-over', {\r\n\t reason: reason,\r\n\t time: this.passtime,\r\n\t number: this.movesteps,\r\n\t gametime: gametime\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));\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"
} }
...@@ -45,8 +45,11 @@ function launchWithCustomModule(customModule) { ...@@ -45,8 +45,11 @@ function launchWithCustomModule(customModule) {
}, 100); }, 100);
setTimeout(() => { setTimeout(() => {
engine.globalEvent.dispatchEvent('bjxd-game-start', {guide: 2}); engine.globalEvent.dispatchEvent('bjxd-game-start', {guide: 1});
}, 500); }, 500);
setTimeout(() => {
engine.globalEvent.dispatchEvent('bjxd-game-reset', {guide: 2});
}, 600);
}); });
engine.globalEvent.addEventListener('dxbcyj-game-result', (e) => { engine.globalEvent.addEventListener('dxbcyj-game-result', (e) => {
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
function injectProps(p) { function injectProps(p) {
engine.injectProp(props, p); engine.injectProp(props, p);
} }
//# sourceMappingURL=props.js.map
var ObjectPool = engine.ObjectPool; var ObjectPool = engine.ObjectPool;
var Road = (function (_super) { var Road = (function (_super) {
...@@ -118,7 +117,6 @@ ...@@ -118,7 +117,6 @@
}; };
return Road; return Road;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=Road.js.map
function getTexture(uuid) { function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid); return engine.Texture.from(getAssetByUUID(uuid).uuid);
...@@ -134,7 +132,6 @@ ...@@ -134,7 +132,6 @@
inst.source = engine.getAssetByName(name).uuid; inst.source = engine.getAssetByName(name).uuid;
return inst; return inst;
} }
//# sourceMappingURL=utils.js.map
var GuideLayer = (function (_super) { var GuideLayer = (function (_super) {
tslib.__extends(GuideLayer, _super); tslib.__extends(GuideLayer, _super);
...@@ -178,7 +175,6 @@ ...@@ -178,7 +175,6 @@
}; };
return GuideLayer; return GuideLayer;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=GuideLayer.js.map
var LoopComponent = (function (_super) { var LoopComponent = (function (_super) {
tslib.__extends(LoopComponent, _super); tslib.__extends(LoopComponent, _super);
...@@ -254,7 +250,6 @@ ...@@ -254,7 +250,6 @@
}; };
return LoopComponent; return LoopComponent;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=LoopComponent.js.map
var Background = (function (_super) { var Background = (function (_super) {
tslib.__extends(Background, _super); tslib.__extends(Background, _super);
...@@ -330,7 +325,6 @@ ...@@ -330,7 +325,6 @@
}; };
return Background; return Background;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=Background.js.map
var Pier = (function (_super) { var Pier = (function (_super) {
tslib.__extends(Pier, _super); tslib.__extends(Pier, _super);
...@@ -351,14 +345,6 @@ ...@@ -351,14 +345,6 @@
this.changeBg(); this.changeBg();
bmp.x = 0; bmp.x = 0;
bmp.y = this.zhuy; 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 () { Pier.prototype.changeBg = function () {
var texstr; var texstr;
...@@ -409,13 +395,12 @@ ...@@ -409,13 +395,12 @@
}; };
return Pier; return Pier;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=Pier.js.map
var Player = (function (_super) { var Player = (function (_super) {
tslib.__extends(Player, _super); tslib.__extends(Player, _super);
function Player() { function Player() {
var _this = _super !== null && _super.apply(this, arguments) || this; var _this = _super !== null && _super.apply(this, arguments) || this;
_this.playery = 845; _this.playery = 878;
return _this; return _this;
} }
Player.prototype.initPlayer = function (pierWidth) { Player.prototype.initPlayer = function (pierWidth) {
...@@ -425,13 +410,14 @@ ...@@ -425,13 +410,14 @@
this.playerNode = createSvga('walk'); this.playerNode = createSvga('walk');
this._container.addChild(this.playerNode); this._container.addChild(this.playerNode);
this.playerNode.y = this.playery; this.playerNode.y = this.playery;
this.playerNode.x = pierWidth / 2 - 80; this.playerNode.x = pierWidth / 2 - 50;
this.playerNode.play(); this.playerNode.play();
this._container.visible = false;
}; };
Player.prototype.revive = function () { Player.prototype.revive = function () {
this._container.x = 0; this._container.x = 0;
this._container.y = 0; this._container.y = 0;
this.playerNode.x = this.pierWidth / 2 - 80; this.playerNode.x = this.pierWidth / 2 - 50;
this.playerNode.y = this.playery; this.playerNode.y = this.playery;
}; };
Player.prototype.setViewport = function (pos, callBack, pierWidth) { Player.prototype.setViewport = function (pos, callBack, pierWidth) {
...@@ -486,7 +472,6 @@ ...@@ -486,7 +472,6 @@
}; };
return Player; return Player;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=Player.js.map
var Strut = (function (_super) { var Strut = (function (_super) {
tslib.__extends(Strut, _super); tslib.__extends(Strut, _super);
...@@ -545,14 +530,16 @@ ...@@ -545,14 +530,16 @@
chax = 20; chax = 20;
} }
else if (GameView.bgIndex == 1) { else if (GameView.bgIndex == 1) {
paddingx = 30; paddingx = 3;
chax = 60; chax = 39;
} }
else if (GameView.bgIndex == 2) { else if (GameView.bgIndex == 2) {
paddingx = 20; paddingx = 20;
chax = 20; chax = 20;
} }
if (this._distance[0] - this._distance[1] + chax <= this._strut.height && this._strut.height <= this._distance[0] + paddingx) { var mindis = this._distance[0] - this._distance[1] + chax;
var maxdis = this._distance[0] + paddingx;
if (mindis <= this._strut.height && this._strut.height <= maxdis) {
isSuccess = true; isSuccess = true;
} }
if (this._callBack) { if (this._callBack) {
...@@ -560,8 +547,14 @@ ...@@ -560,8 +547,14 @@
} }
}; };
Strut.prototype.frameStrut = function () { Strut.prototype.frameStrut = function () {
if (this._strut.height < 1000) { var maxdis = 700;
this._strut.height += props.strutUpSpeed; if (this._strut.height < maxdis) {
if (this._strut.height + GameView.speed > maxdis) {
this._strut.height = maxdis;
}
else {
this._strut.height += GameView.speed;
}
} }
}; };
Strut.prototype.rest = function () { Strut.prototype.rest = function () {
...@@ -578,7 +571,6 @@ ...@@ -578,7 +571,6 @@
}; };
return Strut; return Strut;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=Strut.js.map
var ObjectPool$1 = engine.ObjectPool; var ObjectPool$1 = engine.ObjectPool;
var PoolName = 'pier'; var PoolName = 'pier';
...@@ -592,6 +584,8 @@ ...@@ -592,6 +584,8 @@
function GameView() { function GameView() {
var _this = _super.call(this) || this; var _this = _super.call(this) || this;
_this.moveX = 0; _this.moveX = 0;
_this.playery = 878;
_this.inani = true;
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this); _this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
return _this; return _this;
} }
...@@ -610,10 +604,33 @@ ...@@ -610,10 +604,33 @@
var player = this._player = new Player(); var player = this._player = new Player();
this.addChild(player); this.addChild(player);
player.initPlayer(pierWidth); player.initPlayer(pierWidth);
this.pierWidth = pierWidth;
this.xiacheNode = createSvga("xiache");
this.addChild(this.xiacheNode);
this.xiacheNode.y = this.playery - 35;
this.xiacheNode.x = this.pierWidth / 2 - 100;
this.xiacheNode.stop();
this.xiacheNode.name = "xiacheanm";
console.log("下车动画帧数", this.xiacheNode.totalFrames, this.xiacheNode);
this.xiacheNode.visible = false;
var strut = this._strut = new Strut(); var strut = this._strut = new Strut();
this.addChild(strut); this.addChild(strut);
strut.init(); strut.init();
}; };
GameView.prototype.playComp = function () {
var curframe = this.xiacheNode.currentFrame;
if (curframe == this.xiacheNode.totalFrames) {
this.inani = false;
this.xiacheNode.stop();
this.xiacheNode.removeEventListener(engine.Event.ENTER_FRAME, this.playComp, this);
for (var i = 0; i < 15; i++) {
if (i < 12) {
this.xiacheNode.getChildAt(i).visible = false;
}
}
this._player._container.visible = true;
}
};
GameView.prototype.start = function (guide) { GameView.prototype.start = function (guide) {
return tslib.__awaiter(this, void 0, void 0, function () { return tslib.__awaiter(this, void 0, void 0, function () {
var initScore; var initScore;
...@@ -622,8 +639,13 @@ ...@@ -622,8 +639,13 @@
this._sumScore = 0; this._sumScore = 0;
this._isMouseDown = false; this._isMouseDown = false;
this._guide = guide; this._guide = guide;
initScore = this._road.getStartGold(0) ? props.goldScore : 0; this._player.revive();
this.closeStrut();
initScore = 0;
this.updateScore(initScore); this.updateScore(initScore);
if (this.xiacheNode.x < this.pierWidth / 2 - 105) {
this.startAnm();
}
if (this._guide == '1') { if (this._guide == '1') {
this.setGuide(); this.setGuide();
} }
...@@ -635,9 +657,30 @@ ...@@ -635,9 +657,30 @@
}); });
}); });
}; };
GameView.prototype.startAnm = function () {
this.inani = true;
this.xiacheNode.visible = true;
for (var i = 0; i < 15; i++) {
if (i < 12) {
this.xiacheNode.getChildAt(i).visible = true;
}
}
this.xiacheNode.x = this.pierWidth / 2 - 100;
this._player._container.visible = false;
this.xiacheNode.gotoAndPlay(1);
this.xiacheNode.addEventListener(engine.Event.ENTER_FRAME, this.playComp, this);
};
GameView.prototype.reset = function () {
this._sumScore = 0;
engine.globalEvent.dispatchEvent('bjxd-game-score', { score: this._sumScore });
this._player.revive();
this.closeStrut();
this.changeBg(GameView.bgIndex);
this.startAnm();
};
GameView.prototype.revive = function () { GameView.prototype.revive = function () {
console.log("复活---------");
this._player.revive(); this._player.revive();
this.startAnm();
this._isTouchLayer = true; this._isTouchLayer = true;
this.closeStrut(); this.closeStrut();
}; };
...@@ -676,7 +719,7 @@ ...@@ -676,7 +719,7 @@
GameView.prototype.setScoreShow = function () { GameView.prototype.setScoreShow = function () {
}; };
GameView.prototype.onMouseDown = function () { GameView.prototype.onMouseDown = function () {
if (this._isTouchLayer) { if (this._isTouchLayer && !this.inani) {
this._isMouseDown = true; this._isMouseDown = true;
this._strut.onMouseDown(this._road.getFristPier(), this._road.getDistance(), this.goCallBcak.bind(this)); this._strut.onMouseDown(this._road.getFristPier(), this._road.getDistance(), this.goCallBcak.bind(this));
} }
...@@ -691,7 +734,6 @@ ...@@ -691,7 +734,6 @@
GameView.prototype.goCallBcak = function (isSuccess) { GameView.prototype.goCallBcak = function (isSuccess) {
var _this = this; var _this = this;
if (isSuccess) { if (isSuccess) {
console.log('成功了');
var movePos = this._road.getMovePos(); var movePos = this._road.getMovePos();
if (this._road.getStartGold(1, false)) { if (this._road.getStartGold(1, false)) {
this.updateScore(props.singleScore + props.goldScore); this.updateScore(props.singleScore + props.goldScore);
...@@ -702,9 +744,7 @@ ...@@ -702,9 +744,7 @@
this._player.setViewport(movePos, this.complete.bind(this)); this._player.setViewport(movePos, this.complete.bind(this));
} }
else { else {
console.log('失败了');
this._player.setViewport(this._strut.getStrutHeight(), function () { this._player.setViewport(this._strut.getStrutHeight(), function () {
console.log('掉下去了');
engine.globalEvent.dispatchEvent('bjxd-game-over', { score: _this._sumScore }); engine.globalEvent.dispatchEvent('bjxd-game-over', { score: _this._sumScore });
}, this._road.getFristPier()); }, this._road.getFristPier());
} }
...@@ -718,6 +758,14 @@ ...@@ -718,6 +758,14 @@
this._player.setBackViewport(function () { this._player.setBackViewport(function () {
_this._isTouchLayer = true; _this._isTouchLayer = true;
}); });
var carx = this.xiacheNode.x;
if (carx > -200) {
carx -= movePos;
engine.Tween.get(this.xiacheNode, { loop: false })
.to({
x: carx
}, props.pierMoveTime);
}
this.closeStrut(); this.closeStrut();
}; };
GameView.prototype.closeStrut = function () { GameView.prototype.closeStrut = function () {
...@@ -725,7 +773,6 @@ ...@@ -725,7 +773,6 @@
}; };
GameView.prototype.updateScore = function (score) { GameView.prototype.updateScore = function (score) {
this._sumScore += score; this._sumScore += score;
console.log("新分数", this._sumScore);
engine.globalEvent.dispatchEvent('bjxd-game-score', { score: this._sumScore }); engine.globalEvent.dispatchEvent('bjxd-game-score', { score: this._sumScore });
}; };
GameView.prototype.getScore = function () { GameView.prototype.getScore = function () {
...@@ -738,18 +785,25 @@ ...@@ -738,18 +785,25 @@
this._road.changeBg(); this._road.changeBg();
} }
}; };
GameView.prototype.changeSpeed = function (speed) {
if (GameView.speed != speed) {
GameView.speed = speed;
}
};
GameView.bgIndex = 0; GameView.bgIndex = 0;
GameView.speed = 10;
return GameView; return GameView;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=GameView.js.map
var GameWrapper = (function (_super) { var GameWrapper = (function (_super) {
tslib.__extends(GameWrapper, _super); tslib.__extends(GameWrapper, _super);
function GameWrapper() { function GameWrapper() {
var _this = _super.call(this) || this; var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('bjxd-game-start', _this.start, _this); engine.globalEvent.addEventListener('bjxd-game-start', _this.start, _this);
engine.globalEvent.addEventListener('bjxd-game-reset', _this.reset, _this);
engine.globalEvent.addEventListener('bjxd-game-revive', _this.revive, _this); engine.globalEvent.addEventListener('bjxd-game-revive', _this.revive, _this);
engine.globalEvent.addEventListener('bjxd-game-change', _this.change, _this); engine.globalEvent.addEventListener('bjxd-game-change', _this.change, _this);
engine.globalEvent.addEventListener('bjxd-game-speed', _this.speed, _this);
var gameView = _this._gameView = new GameView(); var gameView = _this._gameView = new GameView();
_this.addChild(gameView); _this.addChild(gameView);
return _this; return _this;
...@@ -757,15 +811,20 @@ ...@@ -757,15 +811,20 @@
GameWrapper.prototype.start = function (event) { GameWrapper.prototype.start = function (event) {
this._gameView.start(event.data.guide); this._gameView.start(event.data.guide);
}; };
GameWrapper.prototype.reset = function () {
this._gameView.reset();
};
GameWrapper.prototype.revive = function () { GameWrapper.prototype.revive = function () {
this._gameView.revive(); this._gameView.revive();
}; };
GameWrapper.prototype.change = function (event) { GameWrapper.prototype.change = function (event) {
this._gameView.changeBg(event.data.index); this._gameView.changeBg(event.data.index);
}; };
GameWrapper.prototype.speed = function (event) {
this._gameView.changeSpeed(event.data.speed);
};
return GameWrapper; return GameWrapper;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=GameWrapper.js.map
function index (props) { function index (props) {
prepareProps(); prepareProps();
...@@ -773,7 +832,6 @@ ...@@ -773,7 +832,6 @@
var instance = new GameWrapper(); var instance = new GameWrapper();
return instance; return instance;
} }
//# sourceMappingURL=index.js.map
return index; return index;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
"strutUpSpeed": { "strutUpSpeed": {
"alias": "撑杆上升速度(每帧上升增量,一秒60帧)", "alias": "撑杆上升速度(每帧上升增量,一秒60帧)",
"type": "number", "type": "number",
"default": 10 "default": 30
}, },
"strutWidth": { "strutWidth": {
"alias": "撑杆宽度", "alias": "撑杆宽度",
...@@ -121,7 +121,7 @@ ...@@ -121,7 +121,7 @@
}, },
{ {
"name": "yindao1", "name": "yindao1",
"url": "//yun.duiba.com.cn/aurora/assets/a0409ec24b35198e990c61bc7f5dc66b15a5213a.png", "url": "//yun.duiba.com.cn/aurora/assets/f21d5429dbd947e66613bd6c5d864fdcfd104bd4.png",
"uuid": "yindao1", "uuid": "yindao1",
"ext": ".png" "ext": ".png"
}, },
...@@ -169,9 +169,15 @@ ...@@ -169,9 +169,15 @@
}, },
{ {
"name": "walk", "name": "walk",
"url": "//yun.duiba.com.cn/aurora/assets/a4ab1e1a2b49d140db4a0806562098a8b1619b06.svga", "url": "//yun.duiba.com.cn/aurora/assets/5b31481f8d5669213da518b156aac7cadf5d9374",
"uuid": "10cd1fdd-4fd8-43cf-a1c7-6ff5846d8a91", "uuid": "10cd1fdd-4fd8-43cf-a1c7-6ff5846d8a91",
"ext": ".svga" "ext": ".svga"
},
{
"name": "xiache",
"url": "//yun.duiba.com.cn/aurora/assets/57ad75aa036c04e13abcf32c464ff5ae37419495",
"uuid": "xiache",
"ext": ".svga"
} }
], ],
"events": { "events": {
...@@ -196,6 +202,12 @@ ...@@ -196,6 +202,12 @@
"data": { "data": {
"index":1 "index":1
} }
},
"bjxd-game-speed": {
"alias": "修改速度",
"data": {
"speed":10
}
} }
}, },
"out": { "out": {
......
...@@ -5,7 +5,7 @@ import { Road } from './Road'; ...@@ -5,7 +5,7 @@ import { Road } from './Road';
*/ */
import {props} from "../props"; import {props} from "../props";
import {getStage,getTextureByName} from "./utils"; import {getStage,getTextureByName,createSvga} from "./utils";
import {GuideLayer} from "./GuideLayer"; import {GuideLayer} from "./GuideLayer";
import { Background } from "./Background"; import { Background } from "./Background";
import ObjectPool = engine.ObjectPool; import ObjectPool = engine.ObjectPool;
...@@ -29,6 +29,7 @@ export default class GameView extends engine.Container { ...@@ -29,6 +29,7 @@ export default class GameView extends engine.Container {
_backgroud:Background; _backgroud:Background;
_road:Road; _road:Road;
_player:Player; _player:Player;
_strut:Strut; _strut:Strut;
_touchLayer: engine.Rect; _touchLayer: engine.Rect;
_isTouchLayer; _isTouchLayer;
...@@ -44,6 +45,13 @@ export default class GameView extends engine.Container { ...@@ -44,6 +45,13 @@ export default class GameView extends engine.Container {
testchange:engine.Label; testchange:engine.Label;
static bgIndex:number = 0; static bgIndex:number = 0;
private xiacheNode:svga.Svga;
playery:number = 878;
inani:boolean = true;
pierWidth;
constructor() { constructor() {
super(); super();
this.once(engine.Event.ADDED_TO_STAGE, this.setup, this); this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);
...@@ -67,23 +75,55 @@ export default class GameView extends engine.Container { ...@@ -67,23 +75,55 @@ export default class GameView extends engine.Container {
this.addChild(player); this.addChild(player);
player.initPlayer(pierWidth); player.initPlayer(pierWidth);
this.pierWidth = pierWidth;
this.xiacheNode = createSvga("xiache");
this.addChild(this.xiacheNode);
this.xiacheNode.y = this.playery-35;
this.xiacheNode.x = this.pierWidth/2 - 100;
this.xiacheNode.stop();
this.xiacheNode.name = "xiacheanm";
console.log("下车动画帧数",this.xiacheNode.totalFrames,this.xiacheNode);
// this.xiacheNode.addEventListener(engine.Event.ENTER_FRAME,this.playComp,this);
this.xiacheNode.visible = false;
const strut = this._strut = new Strut(); const strut = this._strut = new Strut();
this.addChild(strut); this.addChild(strut);
strut.init(); strut.init();
// this.startAnm();
// this._scoreContainer = new engine.Container(); // this._scoreContainer = new engine.Container();
// this.addChild(this._scoreContainer); // this.addChild(this._scoreContainer);
// this.initLabScore(); // this.initLabScore();
} }
playComp(){
let curframe = this.xiacheNode.currentFrame;
if(curframe==this.xiacheNode.totalFrames){
this.inani = false;
// console.log("下车动画播放完毕",curframe,this.xiacheNode);
this.xiacheNode.stop();
this.xiacheNode.removeEventListener(engine.Event.ENTER_FRAME,this.playComp,this);
for(let i=0;i<15;i++){
if(i<12){
this.xiacheNode.getChildAt(i).visible = false;
}
}
this._player._container.visible = true;
}
}
async start(guide) { async start(guide) {
this._isTouchLayer = true; this._isTouchLayer = true;
this._sumScore = 0; this._sumScore = 0;
this._isMouseDown = false; this._isMouseDown = false;
this._guide = guide; this._guide = guide;
this._player.revive();
this.closeStrut();
let initScore = this._road.getStartGold(0) ? props.goldScore : 0; let initScore = 0;//this._road.getStartGold(0) ? props.goldScore : 0;
this.updateScore(initScore); this.updateScore(initScore);
if(this.xiacheNode.x<this.pierWidth/2-105){
this.startAnm();
}
//是否是新手 //是否是新手
if(this._guide == '1'){ if(this._guide == '1'){
this.setGuide(); this.setGuide();
...@@ -92,10 +132,33 @@ export default class GameView extends engine.Container { ...@@ -92,10 +132,33 @@ export default class GameView extends engine.Container {
this.registerEvent(); this.registerEvent();
} }
} }
startAnm(){
this.inani = true;
this.xiacheNode.visible = true;
for(let i=0;i<15;i++){
if(i<12){
this.xiacheNode.getChildAt(i).visible = true;
}
}
this.xiacheNode.x = this.pierWidth/2 - 100;
this._player._container.visible = false;
this.xiacheNode.gotoAndPlay(1);
this.xiacheNode.addEventListener(engine.Event.ENTER_FRAME,this.playComp,this);
}
//重置
reset(){
this._sumScore = 0;
engine.globalEvent.dispatchEvent('bjxd-game-score',{score:this._sumScore});
this._player.revive();
this.closeStrut();
this.changeBg(GameView.bgIndex);
this.startAnm();
}
//复活 //复活
revive(){ revive(){
console.log("复活---------"); // console.log("复活---------");
this._player.revive(); this._player.revive();
this.startAnm();
this._isTouchLayer = true; this._isTouchLayer = true;
this.closeStrut(); this.closeStrut();
} }
...@@ -166,7 +229,7 @@ export default class GameView extends engine.Container { ...@@ -166,7 +229,7 @@ export default class GameView extends engine.Container {
} }
//鼠标事件 //鼠标事件
onMouseDown(){ onMouseDown(){
if(this._isTouchLayer){ if(this._isTouchLayer&&!this.inani){
this._isMouseDown = true; this._isMouseDown = true;
this._strut.onMouseDown(this._road.getFristPier(),this._road.getDistance(),this.goCallBcak.bind(this)); this._strut.onMouseDown(this._road.getFristPier(),this._road.getDistance(),this.goCallBcak.bind(this));
} }
...@@ -181,7 +244,7 @@ export default class GameView extends engine.Container { ...@@ -181,7 +244,7 @@ export default class GameView extends engine.Container {
//撑杆回调 //撑杆回调
goCallBcak(isSuccess){ goCallBcak(isSuccess){
if(isSuccess){ if(isSuccess){
console.log('成功了'); // console.log('成功了');
let movePos = this._road.getMovePos(); let movePos = this._road.getMovePos();
if(this._road.getStartGold(1,false)){ if(this._road.getStartGold(1,false)){
this.updateScore(props.singleScore + props.goldScore); this.updateScore(props.singleScore + props.goldScore);
...@@ -192,9 +255,9 @@ export default class GameView extends engine.Container { ...@@ -192,9 +255,9 @@ export default class GameView extends engine.Container {
this._player.setViewport(movePos,this.complete.bind(this)); this._player.setViewport(movePos,this.complete.bind(this));
}else{ }else{
console.log('失败了'); // console.log('失败了');
this._player.setViewport(this._strut.getStrutHeight(),()=>{ this._player.setViewport(this._strut.getStrutHeight(),()=>{
console.log('掉下去了'); // console.log('掉下去了');
engine.globalEvent.dispatchEvent('bjxd-game-over',{score:this._sumScore}); engine.globalEvent.dispatchEvent('bjxd-game-over',{score:this._sumScore});
},this._road.getFristPier()) },this._road.getFristPier())
} }
...@@ -211,6 +274,17 @@ export default class GameView extends engine.Container { ...@@ -211,6 +274,17 @@ export default class GameView extends engine.Container {
this._player.setBackViewport(()=>{ this._player.setBackViewport(()=>{
this._isTouchLayer = true; this._isTouchLayer = true;
}); });
let carx = this.xiacheNode.x;
if(carx>-200){
carx -= movePos;
engine.Tween.get(this.xiacheNode,{loop:false})
.to({
x:carx
},props.pierMoveTime);
}
this.closeStrut(); this.closeStrut();
} }
//重置撑杆 //重置撑杆
...@@ -228,7 +302,7 @@ export default class GameView extends engine.Container { ...@@ -228,7 +302,7 @@ export default class GameView extends engine.Container {
// this.changeBg(2); // this.changeBg(2);
// } // }
// this.labScore.updateScore(this._sumScore); // this.labScore.updateScore(this._sumScore);
console.log("新分数",this._sumScore); // console.log("新分数",this._sumScore);
engine.globalEvent.dispatchEvent('bjxd-game-score',{score:this._sumScore}); engine.globalEvent.dispatchEvent('bjxd-game-score',{score:this._sumScore});
} }
getScore(){ getScore(){
...@@ -244,4 +318,10 @@ export default class GameView extends engine.Container { ...@@ -244,4 +318,10 @@ export default class GameView extends engine.Container {
this._road.changeBg(); this._road.changeBg();
} }
} }
static speed = 10;
changeSpeed(speed){
if(GameView.speed!=speed){
GameView.speed = speed;
}
}
} }
...@@ -13,8 +13,10 @@ export class GameWrapper extends engine.Container { ...@@ -13,8 +13,10 @@ export class GameWrapper extends engine.Container {
super(); super();
engine.globalEvent.addEventListener('bjxd-game-start', this.start, this); engine.globalEvent.addEventListener('bjxd-game-start', this.start, this);
engine.globalEvent.addEventListener('bjxd-game-reset', this.reset, this);
engine.globalEvent.addEventListener('bjxd-game-revive',this.revive,this); engine.globalEvent.addEventListener('bjxd-game-revive',this.revive,this);
engine.globalEvent.addEventListener('bjxd-game-change',this.change,this); engine.globalEvent.addEventListener('bjxd-game-change',this.change,this);
engine.globalEvent.addEventListener('bjxd-game-speed',this.speed,this);
let gameView = this._gameView = new GameView(); let gameView = this._gameView = new GameView();
this.addChild(gameView); this.addChild(gameView);
...@@ -24,6 +26,9 @@ export class GameWrapper extends engine.Container { ...@@ -24,6 +26,9 @@ 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);
} }
reset(){
this._gameView.reset();
}
revive(){ revive(){
this._gameView.revive(); this._gameView.revive();
} }
...@@ -31,4 +36,7 @@ export class GameWrapper extends engine.Container { ...@@ -31,4 +36,7 @@ export class GameWrapper extends engine.Container {
// console.log("切换图片显示"); // console.log("切换图片显示");
this._gameView.changeBg(event.data.index); this._gameView.changeBg(event.data.index);
} }
speed(event:engine.Event){
this._gameView.changeSpeed(event.data.speed);
}
} }
...@@ -22,14 +22,14 @@ export class Pier extends engine.Container { ...@@ -22,14 +22,14 @@ export class Pier extends engine.Container {
bmp.x = 0; bmp.x = 0;
bmp.y = this.zhuy; bmp.y = this.zhuy;
if(this.children.length < 2){ // if(this.children.length < 2){
const gold = new engine.Sprite(); // const gold = new engine.Sprite();
gold.texture = getTextureByName('gold'); // gold.texture = getTextureByName('gold');
gold.name = 'gold'; // gold.name = 'gold';
this.addChild(gold); // this.addChild(gold);
} // }
this.setGoldPosX(bmp); // this.setGoldPosX(bmp);
this.setShowGold(); // this.setShowGold();
} }
changeBg(){ changeBg(){
let texstr; let texstr;
......
...@@ -5,7 +5,7 @@ export class Player extends engine.Container{ ...@@ -5,7 +5,7 @@ export class Player extends engine.Container{
private playerNode: svga.Svga; private playerNode: svga.Svga;
pierWidth pierWidth
playery:number = 845; playery:number = 878;
initPlayer(pierWidth){ initPlayer(pierWidth){
this.pierWidth = pierWidth; this.pierWidth = pierWidth;
this._container = new engine.Container(); this._container = new engine.Container();
...@@ -15,13 +15,15 @@ export class Player extends engine.Container{ ...@@ -15,13 +15,15 @@ export class Player extends engine.Container{
this.playerNode = createSvga('walk'); this.playerNode = createSvga('walk');
this._container.addChild(this.playerNode); this._container.addChild(this.playerNode);
this.playerNode.y = this.playery; this.playerNode.y = this.playery;
this.playerNode.x = pierWidth/2 - 80; this.playerNode.x = pierWidth/2 - 50;
this.playerNode.play(); this.playerNode.play();
this._container.visible = false;
} }
revive(){ revive(){
this._container.x = 0; this._container.x = 0;
this._container.y = 0; this._container.y = 0;
this.playerNode.x = this.pierWidth/2 - 80; this.playerNode.x = this.pierWidth/2 - 50;
this.playerNode.y = this.playery; this.playerNode.y = this.playery;
} }
setViewport(pos,callBack,pierWidth?){ setViewport(pos,callBack,pierWidth?){
......
...@@ -53,14 +53,17 @@ export class Strut extends engine.Container{ ...@@ -53,14 +53,17 @@ export class Strut extends engine.Container{
paddingx = 20; paddingx = 20;
chax = 20; chax = 20;
}else if(GameView.bgIndex==1){ }else if(GameView.bgIndex==1){
paddingx = 30; paddingx = 3;
chax = 60; chax = 39;
}else if(GameView.bgIndex==2){ }else if(GameView.bgIndex==2){
paddingx = 20; paddingx = 20;
chax = 20; chax = 20;
} }
if(this._distance[0] - this._distance[1] + chax <= this._strut.height && this._strut.height <= this._distance[0] + paddingx){ let mindis = this._distance[0] - this._distance[1] + chax;
let maxdis = this._distance[0] + paddingx;
// console.log("成功失败判断",mindis,this._strut.height,maxdis);
if(mindis <= this._strut.height && this._strut.height <= maxdis){
isSuccess = true; isSuccess = true;
} }
if(this._callBack){ if(this._callBack){
...@@ -68,8 +71,31 @@ export class Strut extends engine.Container{ ...@@ -68,8 +71,31 @@ export class Strut extends engine.Container{
} }
} }
frameStrut(){ frameStrut(){
if(this._strut.height < 1000){ // let paddingx = 20;
this._strut.height += props.strutUpSpeed; // let chax = 20;
// if(GameView.bgIndex==0){
// paddingx = 20;
// chax = 20;
// }else if(GameView.bgIndex==1){
// paddingx = 3;
// chax = 39;
// }else if(GameView.bgIndex==2){
// paddingx = 20;
// chax = 20;
// }
// let tmindis = this._distance[0] - this._distance[1] + chax;
// let tmaxdis = this._distance[0] + paddingx;
let maxdis = 700;
// maxdis = 700;
// console.log("测试杆长",maxdis);
if(this._strut.height < maxdis){
if(this._strut.height+GameView.speed>maxdis){
this._strut.height = maxdis
}else{
this._strut.height += GameView.speed;
}
} }
} }
rest(){ rest(){
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
"strutUpSpeed": { "strutUpSpeed": {
"alias": "撑杆上升速度(每帧上升增量,一秒60帧)", "alias": "撑杆上升速度(每帧上升增量,一秒60帧)",
"type": "number", "type": "number",
"default": 10 "default": 30
}, },
"strutWidth": { "strutWidth": {
"alias": "撑杆宽度", "alias": "撑杆宽度",
......
...@@ -48,7 +48,7 @@ function launchWithCustomModule(customModule) { ...@@ -48,7 +48,7 @@ function launchWithCustomModule(customModule) {
setTimeout(()=>{ setTimeout(()=>{
engine.globalEvent.dispatchEvent('pictures-initgame', { engine.globalEvent.dispatchEvent('pictures-initgame', {
gameUrls:[ gameUrls:[
"https://yun.duiba.com.cn/aurora/assets/1456b2a9d72e56f075abb29df99052d87a0f1e48.jpg", "https://yun.duiba.com.cn/aurora/assets/7a9960acd582bb0b41bcfcdb24da68f354ccb1ff.jpg",
"https://yun.duiba.com.cn/aurora/assets/61fd0754d7924305fd2851be86a480d71d2c2981.jpg", "https://yun.duiba.com.cn/aurora/assets/61fd0754d7924305fd2851be86a480d71d2c2981.jpg",
"https://yun.duiba.com.cn/aurora/assets/6b70d7ec626f35f21347bf5bc3e61bedc44167be.jpg" "https://yun.duiba.com.cn/aurora/assets/6b70d7ec626f35f21347bf5bc3e61bedc44167be.jpg"
] ]
...@@ -56,12 +56,12 @@ function launchWithCustomModule(customModule) { ...@@ -56,12 +56,12 @@ function launchWithCustomModule(customModule) {
},1000); },1000);
setTimeout(() => { setTimeout(() => {
engine.globalEvent.dispatchEvent('pictures-start', { // engine.globalEvent.dispatchEvent('pictures-start', {
actidx:0, // actidx:0,
rows:3, // rows:3,
cols:3, // cols:3,
gametime:30000 // 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;
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
function injectProps(p) { function injectProps(p) {
engine.injectProp(props, p); engine.injectProp(props, p);
} }
//# sourceMappingURL=props.js.map
function getTexture(uuid) { function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid); return engine.Texture.from(getAssetByUUID(uuid).uuid);
...@@ -21,25 +20,28 @@ ...@@ -21,25 +20,28 @@
return getTexture(engine.getAssetByName(name).uuid); return getTexture(engine.getAssetByName(name).uuid);
} }
function loadImageByUrl(url) { function loadImageByUrl(url) {
console.log('loadImageByUrl----------:', url); return tslib.__awaiter(this, void 0, void 0, function () {
return new Promise(function (resolve) { return tslib.__generator(this, function (_a) {
if (engine.TextureCache[url]) { console.log('loadImageByUrl----------:', url);
resolve(engine.TextureCache[url]); return [2, new Promise(function (resolve) {
} if (engine.TextureCache[url]) {
else { resolve(engine.TextureCache[url]);
var t = engine.Texture.from(url); }
t.addEventListener("loaded", function () { resolve(t); }); else {
} var t = engine.Texture.from(url);
t.addEventListener("loaded", function () { resolve(t); });
}
})];
});
}); });
} }
//# sourceMappingURL=utils.js.map
var qietu = (function (url, type1, 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, setimgwid, mwid1, mhei1, mwid, mhei, picarr, picnames, chax, chay, startlix, addlix, startliy, addliy, r, startx, endx, c, starty, endy, uvs, isprite, ispritename, 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, 4, , 5]); _a.trys.push([0, 6, , 7]);
t = void 0; t = void 0;
if (!(type1 == 1)) return [3, 1]; if (!(type1 == 1)) return [3, 1];
console.log("直接使用已加载的tex"); console.log("直接使用已加载的tex");
...@@ -55,6 +57,32 @@ ...@@ -55,6 +57,32 @@
mhei1 = setimgwid / cols; mhei1 = setimgwid / cols;
mwid = t.width; mwid = t.width;
mhei = t.height; mhei = t.height;
if (!(mwid < 10 || mhei < 10)) return [3, 5];
console.log("调整222222222222");
return [4, new Promise(function (res) {
setTimeout(function () {
res();
}, 200);
})];
case 4:
_a.sent();
return [2, qietu(t, 1, rows, cols)];
case 5:
console.log('图片', t);
console.log("图片获取尺寸", mwid, mhei);
if (mwid > mhei) {
if (mhei < setimgwid) {
mwid = mwid * setimgwid / mhei;
mhei = setimgwid;
}
}
else {
if (mwid < setimgwid) {
mhei = mhei * setimgwid / mwid;
mwid = setimgwid;
}
}
console.log("适配后的图片尺寸", mwid, mhei);
picarr = {}; picarr = {};
picnames = []; picnames = [];
chax = void 0; chax = void 0;
...@@ -110,18 +138,17 @@ ...@@ -110,18 +138,17 @@
mhei: mhei1, mhei: mhei1,
picnames: picnames picnames: picnames
}]; }];
case 4: case 6:
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 5: return [2]; case 7: return [2];
} }
}); });
}); }); }); });
//# sourceMappingURL=qietu.js.map
var GameView = (function (_super) { var GameView = (function (_super) {
tslib.__extends(GameView, _super); tslib.__extends(GameView, _super);
...@@ -131,7 +158,10 @@ ...@@ -131,7 +158,10 @@
_this.selectImgArr = []; _this.selectImgArr = [];
_this.sucposData = {}; _this.sucposData = {};
_this.gameUrls = []; _this.gameUrls = [];
_this.gameTimes = [];
_this.onegamePics = []; _this.onegamePics = [];
_this.movesteps = 0;
_this.startime = 0;
_this.once(engine.Event.ADDED_TO_STAGE, _this.initScene, _this); _this.once(engine.Event.ADDED_TO_STAGE, _this.initScene, _this);
return _this; return _this;
} }
...@@ -139,6 +169,8 @@ ...@@ -139,6 +169,8 @@
this.lineShape = new engine.Shape(); this.lineShape = new engine.Shape();
this.selectimg3 = new engine.Image(getTextureByName("框3")); this.selectimg3 = new engine.Image(getTextureByName("框3"));
this.selectimg4 = new engine.Image(getTextureByName("框4")); this.selectimg4 = new engine.Image(getTextureByName("框4"));
this.selectimg3.mouseEnabled = false;
this.selectimg4.mouseEnabled = false;
this.dicont = new engine.Container(); this.dicont = new engine.Container();
this.linecont = new engine.Container(); this.linecont = new engine.Container();
this.blockcont = new engine.Container(); this.blockcont = new engine.Container();
...@@ -146,6 +178,8 @@ ...@@ -146,6 +178,8 @@
this.addChild(this.linecont); this.addChild(this.linecont);
this.addChild(this.blockcont); this.addChild(this.blockcont);
this.linecont.addChild(this.lineShape); this.linecont.addChild(this.lineShape);
console.log("拼图初始化完毕--------------");
engine.globalEvent.dispatchEvent("pictures-time-initcomp", {});
}; };
GameView.prototype.initgame = function () { GameView.prototype.initgame = function () {
return tslib.__awaiter(this, void 0, void 0, function () { return tslib.__awaiter(this, void 0, void 0, function () {
...@@ -155,6 +189,7 @@ ...@@ -155,6 +189,7 @@
case 0: case 0:
console.log("initgame---------"); console.log("initgame---------");
this.gameUrls = props.gameUrls; this.gameUrls = props.gameUrls;
this.gameTimes = props.gameTimes;
this.onegamePics = new Array(); this.onegamePics = new Array();
l = 0; l = 0;
_a.label = 1; _a.label = 1;
...@@ -165,6 +200,9 @@ ...@@ -165,6 +200,9 @@
case 2: case 2:
lt = _a.sent(); lt = _a.sent();
this.onegamePics.push(lt); this.onegamePics.push(lt);
if (this.onegamePics.length == 1) {
this.startfirst();
}
_a.label = 3; _a.label = 3;
case 3: case 3:
l++; l++;
...@@ -174,6 +212,96 @@ ...@@ -174,6 +212,96 @@
}); });
}); });
}; };
GameView.prototype.startfirst = function () {
return tslib.__awaiter(this, void 0, void 0, function () {
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) {
switch (_a.label) {
case 0:
this.dicont.removeChildren();
this.movesteps = 0;
this.startime = Date.now();
actidx = 0;
this.gametime = this.gameTimes[actidx];
this.showtime = this.gameTimes[actidx];
this.passtime = 0;
engine.globalEvent.dispatchEvent("pictures-time-update", {
time: this.showtime,
});
engine.globalEvent.dispatchEvent("pictures-time-passtime", {
passtime: this.passtime
});
console.log("start-----------------", actidx);
this.rows = 3;
this.cols = 3;
this.nselectimg = null;
if (this.rows == 3) {
this.nselectimg = this.selectimg3;
}
if (this.rows == 4) {
this.nselectimg = this.selectimg4;
}
this.selectImgArr = new Array();
this.sucposData = {};
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:
result = _a.sent();
res = result.res;
if (res) {
picarr = result.picarr;
mwid = result.mwid;
mhei = result.mhei;
picnames = result.picnames;
this.mwid = mwid;
this.mhei = mhei;
this.picarr = picarr;
this.picnames = picnames;
gap = 2;
for (r = 0; r < this.rows; r++) {
for (c = 0; c < this.cols; c++) {
ipicx = mwid * c + gap;
ipicy = mhei * r + gap;
npicname = "pic_" + c + "_" + r;
ipic = picarr[npicname];
this.dicont.addChild(ipic);
ipic.x = ipicx;
ipic.y = ipicy;
}
}
this.lineShape.clear();
this.lineShape.beginStroke(0x0069df, 4, engine.LINE_CAP.BUTT, engine.LINE_JOIN.BEVEL, 100);
this.lineShape.moveTo(0 + gap, 0 + gap);
this.lineShape.lineTo(mhei * this.cols + gap, 0 + gap);
this.lineShape.lineTo(mhei * this.cols + gap, mwid * this.rows + gap);
this.lineShape.lineTo(0 + gap, mwid * this.rows + gap);
this.lineShape.lineTo(0 + gap, 0 + gap);
for (rl = 1; rl < this.rows; rl++) {
this.lineShape.moveTo(0 + gap, rl * mhei + gap);
this.lineShape.lineTo(mwid * this.cols + gap, rl * mhei + gap);
}
for (cl = 1; cl < this.cols; cl++) {
this.lineShape.moveTo(cl * mwid + gap, 0 + gap);
this.lineShape.lineTo(cl * mwid + gap, this.rows * mhei + gap);
}
this.lineShape.endStroke();
engine.globalEvent.dispatchEvent("pictures-load-complete");
this.ticker && clearInterval(this.ticker);
this.ticker = setInterval(this.update, 10);
}
else {
console.error("图片处理失败");
}
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 actidx, tex, type1, result, res, picarr, mwid, mhei, picnames, gap, r, c, ipicx, ipicy, npicname, ipic, rl, cl; var actidx, tex, type1, result, res, picarr, mwid, mhei, picnames, gap, r, c, ipicx, ipicy, npicname, ipic, rl, cl;
...@@ -181,9 +309,18 @@ ...@@ -181,9 +309,18 @@
switch (_a.label) { switch (_a.label) {
case 0: case 0:
this.dicont.removeChildren(); this.dicont.removeChildren();
this.movesteps = 0;
this.startime = Date.now();
actidx = props.actidx; actidx = props.actidx;
this.gametime = props.gametime; this.gametime = this.gameTimes[actidx];
this.showtime = props.gametime; this.showtime = this.gameTimes[actidx];
this.passtime = 0;
engine.globalEvent.dispatchEvent("pictures-time-update", {
time: this.showtime,
});
engine.globalEvent.dispatchEvent("pictures-time-passtime", {
passtime: this.passtime
});
console.log("start-----------------", actidx); console.log("start-----------------", actidx);
this.rows = props.rows; this.rows = props.rows;
this.cols = props.cols; this.cols = props.cols;
...@@ -194,7 +331,6 @@ ...@@ -194,7 +331,6 @@
if (this.rows == 4) { if (this.rows == 4) {
this.nselectimg = this.selectimg4; this.nselectimg = this.selectimg4;
} }
this.passtime = 0;
this.selectImgArr = new Array(); this.selectImgArr = new Array();
this.sucposData = {}; this.sucposData = {};
tex = this.onegamePics[actidx]; tex = this.onegamePics[actidx];
...@@ -244,7 +380,8 @@ ...@@ -244,7 +380,8 @@
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, 20); this.ticker && clearInterval(this.ticker);
this.ticker = setInterval(this.update, 10);
} }
else { else {
console.error("图片处理失败"); console.error("图片处理失败");
...@@ -281,9 +418,12 @@ ...@@ -281,9 +418,12 @@
}; };
GameView.prototype.pause = function () { GameView.prototype.pause = function () {
this.ingame = false; this.ingame = false;
console.error("拼图暂停");
}; };
GameView.prototype.resume = function () { GameView.prototype.resume = function () {
this.lastframetime = Date.now();
this.ingame = true; this.ingame = true;
console.error("拼图继续");
}; };
GameView.prototype.update = function () { GameView.prototype.update = function () {
var ntime = Date.now(); var ntime = Date.now();
...@@ -294,6 +434,9 @@ ...@@ -294,6 +434,9 @@
if (this.ingame) { if (this.ingame) {
var passtime = (ntime - this.lastframetime) / 1000; var passtime = (ntime - this.lastframetime) / 1000;
this.passtime += passtime; this.passtime += passtime;
engine.globalEvent.dispatchEvent("pictures-time-passtime", {
passtime: this.passtime
});
var showtime1 = Math.round(this.gametime - this.passtime); var showtime1 = Math.round(this.gametime - this.passtime);
if (this.showtime != showtime1) { if (this.showtime != showtime1) {
this.showtime = showtime1; this.showtime = showtime1;
...@@ -326,6 +469,10 @@ ...@@ -326,6 +469,10 @@
} }
else if (this.selectImgArr.length == 1) { else if (this.selectImgArr.length == 1) {
if (selectname == this.selectImgArr[0]) { if (selectname == this.selectImgArr[0]) {
if (this.nselectimg) {
this.blockcont.removeChild(this.nselectimg);
}
this.selectImgArr = new Array();
return; return;
} }
else { else {
...@@ -352,6 +499,7 @@ ...@@ -352,6 +499,7 @@
img2.y = imgpos1y; img2.y = imgpos1y;
img2.postr = imgpostr1; img2.postr = imgpostr1;
this.selectImgArr = new Array(); this.selectImgArr = new Array();
this.movesteps += 1;
if (this.nselectimg) { if (this.nselectimg) {
this.blockcont.removeChild(this.nselectimg); this.blockcont.removeChild(this.nselectimg);
} }
...@@ -380,9 +528,13 @@ ...@@ -380,9 +528,13 @@
GameView.prototype.gameover = function (reason) { GameView.prototype.gameover = function (reason) {
this.ingame = false; this.ingame = false;
this.ticker && clearInterval(this.ticker); this.ticker && clearInterval(this.ticker);
var ntime = Date.now();
var gametime = ntime - this.startime;
engine.globalEvent.dispatchEvent('pictures-game-over', { engine.globalEvent.dispatchEvent('pictures-game-over', {
reason: reason, reason: reason,
time: this.passtime time: this.passtime,
number: this.movesteps,
gametime: gametime
}); });
}; };
return GameView; return GameView;
...@@ -420,7 +572,6 @@ ...@@ -420,7 +572,6 @@
}; };
return GameWrapper; return GameWrapper;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=GameWrapper.js.map
function index (props) { function index (props) {
prepareProps(); prepareProps();
...@@ -428,7 +579,6 @@ ...@@ -428,7 +579,6 @@
var instance = new GameWrapper(); var instance = new GameWrapper();
return instance; return instance;
} }
//# sourceMappingURL=index.js.map
return index; return index;
......
{"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;aACjC,CAAC,CAAC,gBAAgB,CAAC,QAAQ,EAAE,c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IxB,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;;;;;;;;;"} {"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 async 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\nimport qietu from \"./qietu\";\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 if(mwid<10||mhei<10){\r\n console.log(\"调整222222222222\");\r\n await new Promise(res=>{\r\n setTimeout(function(){\r\n res();\r\n },200);\r\n })\r\n return qietu(t,1,rows,cols,parent);\r\n }\r\n console.log('图片',t);\r\n console.log(\"图片获取尺寸\",mwid,mhei);\r\n if(mwid>mhei){\r\n if(mhei<setimgwid){\r\n mwid = mwid*setimgwid/mhei;\r\n mhei = setimgwid;\r\n }\r\n }else{\r\n if(mwid<setimgwid){\r\n mhei = mhei*setimgwid/mwid;\r\n mwid = setimgwid;\r\n }\r\n }\r\n console.log(\"适配后的图片尺寸\",mwid,mhei);\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 gameTimes:Array<number> = [];\r\n onegamePics:Array<engine.Texture> = [];\r\n movesteps:number = 0;\r\n startime:number = 0;\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 this.selectimg3.mouseEnabled = false;\r\n this.selectimg4.mouseEnabled = false;\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 console.log(\"拼图初始化完毕--------------\");\r\n engine.globalEvent.dispatchEvent(\"pictures-time-initcomp\",{});\r\n }\r\n async initgame(){\r\n console.log(\"initgame---------\");\r\n this.gameUrls = props.gameUrls;\r\n this.gameTimes = props.gameTimes;\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 if(this.onegamePics.length==1){//第一张图加载完毕,自动填充\r\n this.startfirst();\r\n\r\n }\r\n }\r\n }\r\n async startfirst(){\r\n this.dicont.removeChildren();\r\n this.movesteps = 0;\r\n this.startime = Date.now();\r\n\r\n let actidx = 0;\r\n this.gametime = this.gameTimes[actidx];\r\n this.showtime = this.gameTimes[actidx];\r\n this.passtime = 0;\r\n engine.globalEvent.dispatchEvent(\"pictures-time-update\",{\r\n time:this.showtime,\r\n });\r\n engine.globalEvent.dispatchEvent(\"pictures-time-passtime\",{\r\n passtime:this.passtime\r\n });\r\n console.log(\"start-----------------\",actidx);\r\n this.rows = 3;\r\n this.cols = 3;\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 \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 let ipic = picarr[npicname];\r\n this.dicont.addChild(ipic);\r\n ipic.x = ipicx;\r\n ipic.y = ipicy;\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 engine.globalEvent.dispatchEvent(\"pictures-load-complete\");\r\n this.ticker&&clearInterval(this.ticker);\r\n this.ticker = setInterval(this.update, 10);\r\n }else{\r\n console.error(\"图片处理失败\");\r\n }\r\n }\r\n async start() {\r\n \r\n this.dicont.removeChildren();\r\n this.movesteps = 0;\r\n this.startime = Date.now();\r\n\r\n let actidx = props.actidx;\r\n this.gametime = this.gameTimes[actidx];\r\n this.showtime = this.gameTimes[actidx];\r\n this.passtime = 0;\r\n engine.globalEvent.dispatchEvent(\"pictures-time-update\",{\r\n time:this.showtime,\r\n });\r\n engine.globalEvent.dispatchEvent(\"pictures-time-passtime\",{\r\n passtime:this.passtime\r\n });\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 \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 this.ticker&&clearInterval(this.ticker);\r\n this.ticker = setInterval(this.update, 10);\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 console.error(\"拼图暂停\");\r\n }\r\n resume(){\r\n this.lastframetime = Date.now();\r\n this.ingame = true;\r\n console.error(\"拼图继续\");\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 engine.globalEvent.dispatchEvent(\"pictures-time-passtime\",{\r\n passtime:this.passtime\r\n });\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 if(this.nselectimg){\r\n this.blockcont.removeChild(this.nselectimg);\r\n }\r\n this.selectImgArr = new Array();\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 this.movesteps += 1;\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\r\n let ntime = Date.now();\r\n let gametime = ntime - this.startime;\r\n engine.globalEvent.dispatchEvent('pictures-game-over', {\r\n reason:reason,\r\n time: this.passtime,\r\n number:this.movesteps,\r\n gametime:gametime\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,I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AC1E,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,gBAAgB,EAAE,KAAI,CAAC,KAAK,EAAE,KAAI,CAAC,CAAC;SACxE,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,iBAAiB,EAAE,KAAI,CAAC,MAAM,EAAE,KAAI,CAAC,CAAC;;MAC1E;KACD,8BAAQ,GAAR,UAAS,KAAmB;SAC3B,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SAIxB,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;MAC1B;KACD,2BAAK,GAAL,UAAM,KAAmB;SACxB,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
...@@ -106,6 +106,24 @@ ...@@ -106,6 +106,24 @@
"data": { "data": {
"reason": "结束(1:成功,2失败)" "reason": "结束(1:成功,2失败)"
} }
},
"pictures-load-complete": {
"alias": "图片加载完毕",
"data": {
"reason": "结束(1:成功,2失败)"
}
},
"pictures-time-passtime": {
"alias": "倒计时进度条",
"data": {
"passtime": 0
}
},
"pictures-time-initcomp": {
"alias": "倒计时进度条",
"data": {
"passtime": 0
}
} }
} }
} }
......
...@@ -40,7 +40,10 @@ export default class GameView extends engine.Container { ...@@ -40,7 +40,10 @@ export default class GameView extends engine.Container {
picarr; picarr;
gameUrls:Array<string> = []; gameUrls:Array<string> = [];
gameTimes:Array<number> = [];
onegamePics:Array<engine.Texture> = []; onegamePics:Array<engine.Texture> = [];
movesteps:number = 0;
startime:number = 0;
constructor() { constructor() {
super(); super();
this.once(engine.Event.ADDED_TO_STAGE, this.initScene, this); this.once(engine.Event.ADDED_TO_STAGE, this.initScene, this);
...@@ -49,6 +52,8 @@ export default class GameView extends engine.Container { ...@@ -49,6 +52,8 @@ export default class GameView extends engine.Container {
this.lineShape = new engine.Shape(); this.lineShape = new engine.Shape();
this.selectimg3 = new engine.Image(getTextureByName("框3")); this.selectimg3 = new engine.Image(getTextureByName("框3"));
this.selectimg4 = new engine.Image(getTextureByName("框4")); this.selectimg4 = new engine.Image(getTextureByName("框4"));
this.selectimg3.mouseEnabled = false;
this.selectimg4.mouseEnabled = false;
//底图 //底图
this.dicont = new engine.Container(); this.dicont = new engine.Container();
//线 //线
...@@ -61,25 +66,132 @@ export default class GameView extends engine.Container { ...@@ -61,25 +66,132 @@ export default class GameView extends engine.Container {
this.addChild(this.blockcont); this.addChild(this.blockcont);
this.linecont.addChild(this.lineShape); this.linecont.addChild(this.lineShape);
console.log("拼图初始化完毕--------------");
engine.globalEvent.dispatchEvent("pictures-time-initcomp",{});
} }
async initgame(){ async initgame(){
console.log("initgame---------"); console.log("initgame---------");
this.gameUrls = props.gameUrls; this.gameUrls = props.gameUrls;
this.gameTimes = props.gameTimes;
this.onegamePics = new Array(); this.onegamePics = new Array();
for(let l=0;l<this.gameUrls.length;l++){ for(let l=0;l<this.gameUrls.length;l++){
let lurl = this.gameUrls[l]; let lurl = this.gameUrls[l];
let lt = await loadImageByUrl(lurl) as engine.Texture; let lt = await loadImageByUrl(lurl) as engine.Texture;
this.onegamePics.push(lt); this.onegamePics.push(lt);
if(this.onegamePics.length==1){//第一张图加载完毕,自动填充
this.startfirst();
}
}
}
async startfirst(){
this.dicont.removeChildren();
this.movesteps = 0;
this.startime = Date.now();
let actidx = 0;
this.gametime = this.gameTimes[actidx];
this.showtime = this.gameTimes[actidx];
this.passtime = 0;
engine.globalEvent.dispatchEvent("pictures-time-update",{
time:this.showtime,
});
engine.globalEvent.dispatchEvent("pictures-time-passtime",{
passtime:this.passtime
});
console.log("start-----------------",actidx);
this.rows = 3;
this.cols = 3;
this.nselectimg = null;
if(this.rows==3){
this.nselectimg = this.selectimg3;
}
if(this.rows==4){
this.nselectimg = this.selectimg4;
}
this.selectImgArr = new Array();
this.sucposData = {};
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;
if(res){
let picarr = result.picarr;
let mwid = result.mwid;
let mhei = result.mhei;
let picnames = result.picnames;
this.mwid = mwid;
this.mhei = mhei;
this.picarr = picarr;
this.picnames = picnames;
let gap = 2;
for(let r=0;r<this.rows;r++){
for(let c=0;c<this.cols;c++){
let ipicx = mwid*c+gap;
let ipicy = mhei*r+gap;
let npicname = "pic_"+c+"_"+r;
let ipic = picarr[npicname];
this.dicont.addChild(ipic);
ipic.x = ipicx;
ipic.y = ipicy;
}
}
//框线
this.lineShape.clear();
this.lineShape.beginStroke(0x0069df,4,engine.LINE_CAP.BUTT,engine.LINE_JOIN.BEVEL,100);
this.lineShape.moveTo(0+gap,0+gap);
this.lineShape.lineTo(mhei*this.cols+gap,0+gap);
this.lineShape.lineTo(mhei*this.cols+gap,mwid*this.rows+gap);
this.lineShape.lineTo(0+gap,mwid*this.rows+gap);
this.lineShape.lineTo(0+gap,0+gap);
for(let rl=1;rl<this.rows;rl++){
this.lineShape.moveTo(0+gap,rl*mhei+gap);
this.lineShape.lineTo(mwid*this.cols+gap,rl*mhei+gap);
}
for(let cl=1;cl<this.cols;cl++){
this.lineShape.moveTo(cl*mwid+gap,0+gap);
this.lineShape.lineTo(cl*mwid+gap,this.rows*mhei+gap);
}
this.lineShape.endStroke();
engine.globalEvent.dispatchEvent("pictures-load-complete");
this.ticker&&clearInterval(this.ticker);
this.ticker = setInterval(this.update, 10);
}else{
console.error("图片处理失败");
} }
} }
async start() { async start() {
this.dicont.removeChildren(); this.dicont.removeChildren();
this.movesteps = 0;
this.startime = Date.now();
let actidx = props.actidx; let actidx = props.actidx;
this.gametime = props.gametime; this.gametime = this.gameTimes[actidx];
this.showtime = props.gametime; this.showtime = this.gameTimes[actidx];
this.passtime = 0;
engine.globalEvent.dispatchEvent("pictures-time-update",{
time:this.showtime,
});
engine.globalEvent.dispatchEvent("pictures-time-passtime",{
passtime:this.passtime
});
console.log("start-----------------",actidx); console.log("start-----------------",actidx);
this.rows = props.rows; this.rows = props.rows;
this.cols = props.cols; this.cols = props.cols;
...@@ -92,7 +204,7 @@ export default class GameView extends engine.Container { ...@@ -92,7 +204,7 @@ export default class GameView extends engine.Container {
this.nselectimg = this.selectimg4; this.nselectimg = this.selectimg4;
} }
this.passtime = 0;
this.selectImgArr = new Array(); this.selectImgArr = new Array();
this.sucposData = {}; this.sucposData = {};
...@@ -164,8 +276,8 @@ export default class GameView extends engine.Container { ...@@ -164,8 +276,8 @@ export default class GameView extends engine.Container {
} }
this.lineShape.endStroke(); this.lineShape.endStroke();
this.ticker&&clearInterval(this.ticker);
this.ticker = setInterval(this.update, 20); this.ticker = setInterval(this.update, 10);
}else{ }else{
console.error("图片处理失败"); console.error("图片处理失败");
} }
...@@ -201,9 +313,12 @@ export default class GameView extends engine.Container { ...@@ -201,9 +313,12 @@ export default class GameView extends engine.Container {
} }
pause(){ pause(){
this.ingame = false; this.ingame = false;
console.error("拼图暂停");
} }
resume(){ resume(){
this.lastframetime = Date.now();
this.ingame = true; this.ingame = true;
console.error("拼图继续");
} }
...@@ -216,6 +331,9 @@ export default class GameView extends engine.Container { ...@@ -216,6 +331,9 @@ export default class GameView extends engine.Container {
if(this.ingame){ if(this.ingame){
let passtime = (ntime - this.lastframetime)/1000; let passtime = (ntime - this.lastframetime)/1000;
this.passtime += passtime; this.passtime += passtime;
engine.globalEvent.dispatchEvent("pictures-time-passtime",{
passtime:this.passtime
});
let showtime1 = Math.round(this.gametime - this.passtime); let showtime1 = Math.round(this.gametime - this.passtime);
// console.log(passtime,this.passtime,this.gametime,this.showtime); // console.log(passtime,this.passtime,this.gametime,this.showtime);
if(this.showtime!=showtime1){ if(this.showtime!=showtime1){
...@@ -251,6 +369,10 @@ export default class GameView extends engine.Container { ...@@ -251,6 +369,10 @@ export default class GameView extends engine.Container {
this.selectImgArr.push(selectname); this.selectImgArr.push(selectname);
}else if(this.selectImgArr.length==1){ }else if(this.selectImgArr.length==1){
if(selectname==this.selectImgArr[0]){ if(selectname==this.selectImgArr[0]){
if(this.nselectimg){
this.blockcont.removeChild(this.nselectimg);
}
this.selectImgArr = new Array();
return; return;
}else{ }else{
this.selectImgArr.push(selectname); this.selectImgArr.push(selectname);
...@@ -283,6 +405,8 @@ export default class GameView extends engine.Container { ...@@ -283,6 +405,8 @@ export default class GameView extends engine.Container {
this.selectImgArr = new Array(); this.selectImgArr = new Array();
this.movesteps += 1;
if(this.nselectimg){ if(this.nselectimg){
this.blockcont.removeChild(this.nselectimg); this.blockcont.removeChild(this.nselectimg);
} }
...@@ -317,9 +441,14 @@ export default class GameView extends engine.Container { ...@@ -317,9 +441,14 @@ export default class GameView extends engine.Container {
private gameover(reason:number) { private gameover(reason:number) {
this.ingame = false; this.ingame = false;
this.ticker&&clearInterval(this.ticker); this.ticker&&clearInterval(this.ticker);
let ntime = Date.now();
let gametime = ntime - this.startime;
engine.globalEvent.dispatchEvent('pictures-game-over', { engine.globalEvent.dispatchEvent('pictures-game-over', {
reason:reason, reason:reason,
time: this.passtime time: this.passtime,
number:this.movesteps,
gametime:gametime
}); });
} }
......
import { props } from "../props"; import { props } from "../props";
import { loadImageByUrl } from "./utils"; import { loadImageByUrl } from "./utils";
import qietu from "./qietu";
const urls = []; const urls = [];
const picMap = {}; const picMap = {};
const posMap = {}; const posMap = {};
...@@ -19,6 +20,29 @@ export default async(url:any,type1:number, rows:number, cols:number,parent:engin ...@@ -19,6 +20,29 @@ export default async(url:any,type1:number, rows:number, cols:number,parent:engin
let mwid = t.width; let mwid = t.width;
let mhei = t.height; let mhei = t.height;
if(mwid<10||mhei<10){
console.log("调整222222222222");
await new Promise(res=>{
setTimeout(function(){
res();
},200);
})
return qietu(t,1,rows,cols,parent);
}
console.log('图片',t);
console.log("图片获取尺寸",mwid,mhei);
if(mwid>mhei){
if(mhei<setimgwid){
mwid = mwid*setimgwid/mhei;
mhei = setimgwid;
}
}else{
if(mwid<setimgwid){
mhei = mhei*setimgwid/mwid;
mwid = setimgwid;
}
}
console.log("适配后的图片尺寸",mwid,mhei);
let picarr = {}; let picarr = {};
let picnames = []; let picnames = [];
......
...@@ -19,7 +19,7 @@ export function createSvga(name, anchorName?) { ...@@ -19,7 +19,7 @@ export function createSvga(name, anchorName?) {
return inst; return inst;
} }
export function loadImageByUrl(url){ export async function loadImageByUrl(url){
console.log('loadImageByUrl----------:',url); console.log('loadImageByUrl----------:',url);
return new Promise((resolve) => { return new Promise((resolve) => {
if (engine.TextureCache[url]) { if (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