Commit 088c4d2b authored by spc's avatar spc

modified: dist/customs/answer-game.json

parent 2c83eaea
...@@ -269,5 +269,5 @@ ...@@ -269,5 +269,5 @@
} }
}, },
"id": "answer-game", "id": "answer-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['answer-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 SubjectManager = (function () {\r\n\t function SubjectManager() {\r\n\t this._curSubJect = 0;\r\n\t }\r\n\t SubjectManager.prototype.init = function () {\r\n\t this.insideAddEventListener();\r\n\t };\r\n\t SubjectManager.prototype.insideAddEventListener = function () {\r\n\t engine.globalEvent.addEventListener('handleOption', this.handleSubject, this);\r\n\t engine.globalEvent.addEventListener('updateSubject', this.updateSubject, this);\r\n\t engine.globalEvent.addEventListener('handleResult', this.handleResult, this);\r\n\t engine.globalEvent.addEventListener('sendAnswerResult', this.sendAnswerResult, this);\r\n\t };\r\n\t SubjectManager.prototype.handleSubject = function (subject) {\r\n\t this._curSubJect = 0;\r\n\t this._loactionCache = subject.data;\r\n\t this.updateSubject();\r\n\t engine.globalEvent.dispatchEvent('updateAnswerCount', { count: 0 });\r\n\t };\r\n\t SubjectManager.prototype.updateSubject = function () {\r\n\t if (this._curSubJect >= this._loactionCache.length) {\r\n\t console.log('没有题目');\r\n\t engine.globalEvent.dispatchEvent('answer-game-over');\r\n\t return;\r\n\t }\r\n\t this._curTmpSubject = this._loactionCache[this._curSubJect];\r\n\t var title = this._loactionCache[this._curSubJect].question;\r\n\t var options = this._loactionCache[this._curSubJect].options;\r\n\t var tmpIndex = this._loactionCache[this._curSubJect].index;\r\n\t this.updateTitle(title, tmpIndex);\r\n\t this.updateOption(options);\r\n\t this._curSubJect++;\r\n\t };\r\n\t SubjectManager.prototype.updateTitle = function (title, tmpIndex) {\r\n\t engine.globalEvent.dispatchEvent('updateSubjectTitle', { title: title, curSubJect: tmpIndex });\r\n\t };\r\n\t SubjectManager.prototype.updateOption = function (options) {\r\n\t engine.globalEvent.dispatchEvent('updateOption', { options: options });\r\n\t };\r\n\t SubjectManager.prototype.handleResult = function (result) {\r\n\t var tmp = result.data.result;\r\n\t engine.globalEvent.dispatchEvent('updateAnswerCount', { count: tmp.count });\r\n\t engine.globalEvent.dispatchEvent('handleAnswerOption', { state: tmp.state });\r\n\t };\r\n\t SubjectManager.prototype.sendAnswerResult = function (resultData) {\r\n\t var tmpAnswer = resultData.data.answer;\r\n\t engine.globalEvent.dispatchEvent('answer-game-select', { curSubJect: this._curTmpSubject.index, answer: tmpAnswer });\r\n\t };\r\n\t return SubjectManager;\r\n\t}());\r\n\t//# sourceMappingURL=SubjectManager.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\tvar OptionState;\r\n\t(function (OptionState) {\r\n\t OptionState[OptionState[\"CHOICE_RIGHT\"] = 0] = \"CHOICE_RIGHT\";\r\n\t OptionState[OptionState[\"CHOICE_WRONG\"] = 1] = \"CHOICE_WRONG\";\r\n\t OptionState[OptionState[\"CHOICE_SELECT\"] = 2] = \"CHOICE_SELECT\";\r\n\t})(OptionState || (OptionState = {}));\r\n\tvar GameState;\r\n\t(function (GameState) {\r\n\t GameState[GameState[\"STATE_START\"] = 0] = \"STATE_START\";\r\n\t GameState[GameState[\"STATE_END\"] = 1] = \"STATE_END\";\r\n\t})(GameState || (GameState = {}));\r\n\t//# sourceMappingURL=utils.js.map\n\n\tvar Background = (function (_super) {\r\n\t tslib.__extends(Background, _super);\r\n\t function Background() {\r\n\t return _super !== null && _super.apply(this, arguments) || this;\r\n\t }\r\n\t Background.prototype.init = function () {\r\n\t this.showSubjectBox();\r\n\t this.insideAddEventListener();\r\n\t };\r\n\t Background.prototype.insideAddEventListener = function () {\r\n\t engine.globalEvent.addEventListener('changeCount', this.changeCount, this);\r\n\t };\r\n\t Background.prototype.showSubjectBox = function () {\r\n\t var tmpContainer = new engine.Container();\r\n\t tmpContainer.x = 0;\r\n\t tmpContainer.y = props.subjectBox_Y;\r\n\t this.addChild(tmpContainer);\r\n\t var subjectBox = this._subjectBox = new engine.Image(getTextureByName('题目栏'));\r\n\t subjectBox.x = (750 - subjectBox.width) / 2;\r\n\t subjectBox.y = 0;\r\n\t tmpContainer.addChild(subjectBox);\r\n\t var countDownBg = this._countDownBg = new engine.Image(getTextureByName('倒计时'));\r\n\t countDownBg.x = (750 - countDownBg.width) / 2;\r\n\t countDownBg.y = -countDownBg.height / 2 + 10;\r\n\t tmpContainer.addChild(countDownBg);\r\n\t var answerCountBg = this._answerCountBg = new engine.Image(getTextureByName('答对题数'));\r\n\t answerCountBg.x = (750 - answerCountBg.width) / 2;\r\n\t answerCountBg.y = subjectBox.y + subjectBox.height - answerCountBg.height - 10;\r\n\t tmpContainer.addChild(answerCountBg);\r\n\t var answerCountText = this._answerCountText = new engine.Label();\r\n\t answerCountText.fillColor = 0x2b3134;\r\n\t answerCountText.size = 30;\r\n\t answerCountText.width = answerCountBg.width;\r\n\t answerCountText.height = answerCountBg.height;\r\n\t answerCountText.verticalAlign = engine.VERTICAL_ALIGN.MIDDLE;\r\n\t answerCountText.x = 160;\r\n\t answerCountText.y = 3;\r\n\t answerCountText.text = '0';\r\n\t answerCountBg.addChild(answerCountText);\r\n\t };\r\n\t Background.prototype.changeCount = function (data) {\r\n\t this._answerCountText.text = data.data.count + '';\r\n\t };\r\n\t return Background;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=Background.js.map\n\n\tvar SvgaManager = (function () {\r\n\t function SvgaManager() {\r\n\t }\r\n\t SvgaManager.createSvga = function (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 SvgaManager.play = function (svga, callBack) {\r\n\t if (!svga) {\r\n\t console.log('svga节点出错');\r\n\t return;\r\n\t }\r\n\t svga.gotoAndStop(0);\r\n\t svga.play();\r\n\t if (callBack) {\r\n\t svga.addEventListener(engine.Event.END_FRAME, function () {\r\n\t svga.stop();\r\n\t callBack();\r\n\t svga.removeAllEventListener();\r\n\t }, this);\r\n\t }\r\n\t };\r\n\t SvgaManager.stop = function (svga) {\r\n\t if (!svga) {\r\n\t console.log('svga节点出错');\r\n\t return;\r\n\t }\r\n\t svga.stop();\r\n\t };\r\n\t return SvgaManager;\r\n\t}());\r\n\t//# sourceMappingURL=SvgaManager.js.map\n\n\tvar SubjectTitle = (function (_super) {\r\n\t tslib.__extends(SubjectTitle, _super);\r\n\t function SubjectTitle() {\r\n\t var _this = _super !== null && _super.apply(this, arguments) || this;\r\n\t _this._frameCurrAngle = 0;\r\n\t _this._frameCount = 0;\r\n\t _this._countDownTmp = 0;\r\n\t _this._square = new engine.Graphics();\r\n\t return _this;\r\n\t }\r\n\t SubjectTitle.prototype.init = function () {\r\n\t this.showSubjectBox();\r\n\t this.insideAddEventListener();\r\n\t };\r\n\t SubjectTitle.prototype.initCountDownSvga = function (tmpNode) {\r\n\t var countDownSvga = this._countDownSvga = SvgaManager.createSvga('countdown_321');\r\n\t countDownSvga.x = (getStage().width - 120) / 2;\r\n\t countDownSvga.y = (getStage().height - 120) / 2;\r\n\t countDownSvga.visible = false;\r\n\t tmpNode.addChild(countDownSvga);\r\n\t };\r\n\t SubjectTitle.prototype.insideAddEventListener = function () {\r\n\t engine.globalEvent.addEventListener('updateSubjectTitle', this.updateSubjectTitle, this);\r\n\t engine.globalEvent.addEventListener('updateAnswerCount', this.updateAnswerCount, this);\r\n\t engine.globalEvent.addEventListener('resetTitle', this.reset, this);\r\n\t engine.globalEvent.addEventListener('outRest', this.outRest, this);\r\n\t };\r\n\t SubjectTitle.prototype.showSubjectBox = function () {\r\n\t var tmpContainer = new engine.Container();\r\n\t tmpContainer.x = 0;\r\n\t tmpContainer.y = props.subjectBox_Y;\r\n\t this.addChild(tmpContainer);\r\n\t var subjectBox = this._subjectTitleBox = new engine.Image(getTextureByName('题目栏'));\r\n\t subjectBox.x = (750 - subjectBox.width) / 2;\r\n\t subjectBox.y = 0;\r\n\t tmpContainer.addChild(subjectBox);\r\n\t var countDownBg = this._countDownBg = new engine.Image(getTextureByName('倒计时'));\r\n\t countDownBg.x = (750 - countDownBg.width) / 2;\r\n\t countDownBg.y = -countDownBg.height / 2 + 10;\r\n\t tmpContainer.addChild(countDownBg);\r\n\t var bar = this._bar = new engine.Image(getTextureByName('进度条'));\r\n\t bar.x = 0;\r\n\t bar.y = 0;\r\n\t countDownBg.addChild(bar);\r\n\t bar.anchorX = bar.width / 2;\r\n\t bar.anchorY = bar.height / 2;\r\n\t bar.rotation = -90;\r\n\t bar.addChild(this._square);\r\n\t bar.mask = this._square;\r\n\t var answerCountBg = this._answerCountBg = new engine.Image(getTextureByName('答对题数'));\r\n\t answerCountBg.x = (750 - answerCountBg.width) / 2;\r\n\t answerCountBg.y = subjectBox.y + subjectBox.height - answerCountBg.height - 10;\r\n\t tmpContainer.addChild(answerCountBg);\r\n\t this.initCountDownBar(0);\r\n\t this.initAnswerCountText();\r\n\t this.initCountDownText();\r\n\t this.initTitleText();\r\n\t this.initSvga();\r\n\t };\r\n\t SubjectTitle.prototype.initCountDownText = function () {\r\n\t var countDownText = this._countDownText = new engine.BitmapText();\r\n\t countDownText.font = props.fontName;\r\n\t countDownText.text = props.countDown;\r\n\t this.handleAlign();\r\n\t this._countDownBg.addChild(countDownText);\r\n\t this._countDownTmp = props.countDown;\r\n\t };\r\n\t SubjectTitle.prototype.handleAlign = function () {\r\n\t this._countDownText.x = (this._countDownBg.width - this._countDownText.width) / 2;\r\n\t this._countDownText.y = (this._countDownBg.height - this._countDownText.height) / 2;\r\n\t };\r\n\t SubjectTitle.prototype.countDownBitmapText = function () {\r\n\t };\r\n\t SubjectTitle.prototype.initAnswerCountText = function () {\r\n\t var answerCountText = this._answerCountText = new engine.Label();\r\n\t answerCountText.fillColor = 0x2b3134;\r\n\t answerCountText.size = 30;\r\n\t answerCountText.width = this._answerCountBg.width;\r\n\t answerCountText.height = this._answerCountBg.height;\r\n\t answerCountText.verticalAlign = engine.VERTICAL_ALIGN.MIDDLE;\r\n\t answerCountText.x = 160;\r\n\t answerCountText.y = props.answerCountText_Y;\r\n\t answerCountText.text = '0';\r\n\t this._answerCountBg.addChild(answerCountText);\r\n\t };\r\n\t SubjectTitle.prototype.initTitleText = function () {\r\n\t var titleLabel = this._titleLabel = new engine.Label();\r\n\t titleLabel.fillColor = 0xfffcc6;\r\n\t titleLabel.size = 36;\r\n\t titleLabel.width = this._subjectTitleBox.width - props.titleText_width;\r\n\t titleLabel.height = this._subjectTitleBox.height - props.titleText_height;\r\n\t titleLabel.lineType = engine.TEXT_lINETYPE.MULTI;\r\n\t titleLabel.verticalAlign = engine.VERTICAL_ALIGN.MIDDLE;\r\n\t titleLabel.textAlign = engine.TEXT_ALIGN.CENTER;\r\n\t titleLabel.x = props.titleText_X;\r\n\t titleLabel.y = props.titleText_Y;\r\n\t titleLabel.text = '';\r\n\t titleLabel.alpha = 0;\r\n\t this._subjectTitleBox.addChild(titleLabel);\r\n\t };\r\n\t SubjectTitle.prototype.initTitleNumText = function (tmpContainer) {\r\n\t var titleNumLabel = this._titleNumLabel = new engine.Label();\r\n\t titleNumLabel.fillColor = 0xfffcc6;\r\n\t titleNumLabel.size = 48;\r\n\t titleNumLabel.width = tmpContainer.width;\r\n\t titleNumLabel.height = tmpContainer.heigth;\r\n\t titleNumLabel.verticalAlign = engine.VERTICAL_ALIGN.MIDDLE;\r\n\t titleNumLabel.textAlign = engine.TEXT_ALIGN.CENTER;\r\n\t titleNumLabel.text = '';\r\n\t titleNumLabel.visible = false;\r\n\t tmpContainer.addChild(titleNumLabel);\r\n\t };\r\n\t SubjectTitle.prototype.updateTitleNumText = function (curSubJect) {\r\n\t this.rest();\r\n\t this._titleNumLabel.text = \"\\u7B2C\" + curSubJect + \"\\u9898\";\r\n\t };\r\n\t SubjectTitle.prototype.reset = function () {\r\n\t this._titleLabel.text = '';\r\n\t };\r\n\t SubjectTitle.prototype.updateSubjectTitle = function (tmpData) {\r\n\t this._titleLabel.alpha = 0;\r\n\t this._titleLabel.text = tmpData.data.title;\r\n\t this.lastTime = 0;\r\n\t this.updateTitleNumText(tmpData.data.curSubJect + 1);\r\n\t if (tmpData.data.curSubJect == 0) {\r\n\t this.fristAnswer();\r\n\t }\r\n\t else {\r\n\t this.playQuestion_enter();\r\n\t }\r\n\t };\r\n\t SubjectTitle.prototype.updateAnswerCount = function (data) {\r\n\t this._answerCountText.text = data.data.count + '';\r\n\t };\r\n\t SubjectTitle.prototype.updateCountDownText = function (count) {\r\n\t this._countDownText.text = count + '';\r\n\t this.handleAlign();\r\n\t };\r\n\t SubjectTitle.prototype.openCountDownBar = function () {\r\n\t this.rest();\r\n\t engine.gameStage.addEventListener(engine.Event.ENTER_FRAME, this.countDownBar, this);\r\n\t };\r\n\t SubjectTitle.prototype.initCountDownBar = function (currAngle) {\r\n\t var ax = this._bar.width / 2;\r\n\t var ay = this._bar.height / 2;\r\n\t this._square.clear();\r\n\t this._square.beginFill(0);\r\n\t this._square.moveTo(ax, ay);\r\n\t this._square.arc(ax, ay, this._bar.width / 2, 0, (currAngle * Math.PI / 180));\r\n\t this._square.lineTo(ax, ay);\r\n\t this._square.endFill();\r\n\t };\r\n\t SubjectTitle.prototype.countDownBar = function () {\r\n\t var now = Date.now();\r\n\t var deltaTime = this.lastTime ? now - this.lastTime : 16.7;\r\n\t this.lastTime = now;\r\n\t this._frameCurrAngle += 360 / (props.countDown * 1000) * deltaTime;\r\n\t this._frameCurrAngle = Math.min(360, this._frameCurrAngle);\r\n\t this.initCountDownBar(this._frameCurrAngle);\r\n\t this._frameCount += deltaTime;\r\n\t if (this._frameCount >= 1000) {\r\n\t var tmpTime = this._countDownTmp - 1 > 0 ? this._countDownTmp -= 1 : 0;\r\n\t if (tmpTime == 3) {\r\n\t this.playCountDownSvga();\r\n\t }\r\n\t this.updateCountDownText(tmpTime);\r\n\t this._frameCount = 0;\r\n\t if (this._frameCurrAngle >= 360) {\r\n\t engine.gameStage.removeEventListener(engine.Event.ENTER_FRAME, this.countDownBar, this);\r\n\t engine.globalEvent.dispatchEvent('upDateGameState', { gameState: GameState.STATE_END });\r\n\t engine.globalEvent.dispatchEvent('sendAnswer');\r\n\t }\r\n\t }\r\n\t };\r\n\t SubjectTitle.prototype.rest = function () {\r\n\t this._frameCurrAngle = 0;\r\n\t this._frameCount = 0;\r\n\t this._square.clear();\r\n\t this._countDownTmp = props.countDown;\r\n\t this._countDownText.text = props.countDown + '';\r\n\t this.handleAlign();\r\n\t };\r\n\t SubjectTitle.prototype.outRest = function () {\r\n\t this._frameCurrAngle = 0;\r\n\t this._frameCount = 0;\r\n\t this._square.clear();\r\n\t this._countDownTmp = props.countDown;\r\n\t this._countDownText.text = props.countDown + '';\r\n\t this.handleAlign();\r\n\t this._readyGo.visible = false;\r\n\t this._countDownSvga.visible = false;\r\n\t this._questionEnter.visible = false;\r\n\t engine.gameStage.removeEventListener(engine.Event.ENTER_FRAME, this.countDownBar, this);\r\n\t };\r\n\t SubjectTitle.prototype.initSvga = function () {\r\n\t var readyGo = this._readyGo = SvgaManager.createSvga('ready_go');\r\n\t readyGo.x = 50;\r\n\t readyGo.y = 45;\r\n\t readyGo.visible = false;\r\n\t this._subjectTitleBox.addChild(readyGo);\r\n\t var tmpRect = new engine.Rect();\r\n\t tmpRect.x = 50;\r\n\t tmpRect.y = 45;\r\n\t tmpRect.width = 520;\r\n\t tmpRect.height = 200;\r\n\t this._subjectTitleBox.addChild(tmpRect);\r\n\t readyGo.mask = tmpRect;\r\n\t var tmpContainer = new engine.Container();\r\n\t tmpContainer.width = 400;\r\n\t tmpContainer.height = 100;\r\n\t tmpContainer.x = (this._subjectTitleBox.width - 400) / 2;\r\n\t tmpContainer.y = 115;\r\n\t this._subjectTitleBox.addChild(tmpContainer);\r\n\t var questionEnter = this._questionEnter = SvgaManager.createSvga('question_enter');\r\n\t questionEnter.x = 0;\r\n\t questionEnter.y = 0;\r\n\t questionEnter.visible = false;\r\n\t tmpContainer.addChild(questionEnter);\r\n\t this.initTitleNumText(tmpContainer);\r\n\t };\r\n\t SubjectTitle.prototype.fristAnswer = function () {\r\n\t this.playReadyGo();\r\n\t };\r\n\t SubjectTitle.prototype.playReadyGo = function () {\r\n\t var _this = this;\r\n\t this._readyGo.visible = true;\r\n\t SvgaManager.play(this._readyGo, function () {\r\n\t _this._readyGo.visible = false;\r\n\t _this.playQuestion_enter();\r\n\t });\r\n\t };\r\n\t SubjectTitle.prototype.playQuestion_enter = function () {\r\n\t var _this = this;\r\n\t this._questionEnter.visible = true;\r\n\t this._titleNumLabel.visible = true;\r\n\t SvgaManager.play(this._questionEnter, function () {\r\n\t _this._questionEnter.visible = false;\r\n\t _this.playTweenTitle();\r\n\t _this._titleNumLabel.visible = false;\r\n\t _this.openCountDownBar();\r\n\t if (_this._countDownTmp == 3) {\r\n\t _this.playCountDownSvga();\r\n\t }\r\n\t engine.globalEvent.dispatchEvent('start');\r\n\t });\r\n\t };\r\n\t SubjectTitle.prototype.playTweenTitle = function () {\r\n\t var _this = this;\r\n\t engine.Tween.get(this._titleLabel, { loop: false })\r\n\t .set({ alpha: 0 })\r\n\t .to({ alpha: 1 }, 500, engine.Ease.cubicIn)\r\n\t .call(function () {\r\n\t engine.Tween.removeTweens(_this._titleLabel);\r\n\t });\r\n\t };\r\n\t SubjectTitle.prototype.playCountDownSvga = function () {\r\n\t var _this = this;\r\n\t console.log('测试次数');\r\n\t this._countDownSvga.visible = true;\r\n\t this._countDownSvga.lockStep = true;\r\n\t SvgaManager.play(this._countDownSvga, function () {\r\n\t _this._countDownSvga.visible = false;\r\n\t });\r\n\t };\r\n\t return SubjectTitle;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=SubjectTitle.js.map\n\n\tvar AnswerArea = (function (_super) {\r\n\t tslib.__extends(AnswerArea, _super);\r\n\t function AnswerArea() {\r\n\t var _this = _super !== null && _super.apply(this, arguments) || this;\r\n\t _this._optionArray = [];\r\n\t _this._choiceWrong = [];\r\n\t _this._choiceRight = [];\r\n\t _this._choiceSelect = [];\r\n\t _this._answerArray = ['A', 'B', 'C', 'D'];\r\n\t _this._answer = -1;\r\n\t _this._svgaArrayName = [];\r\n\t return _this;\r\n\t }\r\n\t AnswerArea.prototype.init = function () {\r\n\t var area = this._area = new engine.Container();\r\n\t area.x = 0;\r\n\t area.y = 0;\r\n\t this._gameState = GameState.STATE_END;\r\n\t this.addChild(area);\r\n\t this.initSvgaArray();\r\n\t this.initAnswerOption();\r\n\t this.initPeople();\r\n\t this.insideAddEventListener();\r\n\t };\r\n\t AnswerArea.prototype.initSvgaArray = function () {\r\n\t this.setSvgaName('rian_mona', 'rian_weather');\r\n\t this.setSvgaName('snow_mona', 'snow_weather');\r\n\t this.setSvgaName('thunder_mona', 'thunder_weather');\r\n\t this.setSvgaName('wind_mona', 'wind_weather');\r\n\t };\r\n\t AnswerArea.prototype.setSvgaName = function (peopleName, scene) {\r\n\t var tmpSvgaName = {};\r\n\t tmpSvgaName.people = peopleName;\r\n\t tmpSvgaName.scene = scene;\r\n\t this._svgaArrayName.push(tmpSvgaName);\r\n\t };\r\n\t AnswerArea.prototype.insideAddEventListener = function () {\r\n\t engine.globalEvent.addEventListener('updateOption', this.updateOption, this);\r\n\t engine.globalEvent.addEventListener('handleAnswerOption', this.handleAnswerOption, this);\r\n\t engine.globalEvent.addEventListener('upDateGameState', this.upDateGameState, this);\r\n\t engine.globalEvent.addEventListener('start', this.start, this);\r\n\t engine.globalEvent.addEventListener('sendAnswer', this.sendAnswer, this);\r\n\t engine.globalEvent.addEventListener('outRest', this.rest, this);\r\n\t };\r\n\t AnswerArea.prototype.initPeople = function () {\r\n\t var people = this._people = SvgaManager.createSvga('mona_walk');\r\n\t people.x = props.people_X;\r\n\t people.y = props.people_Y;\r\n\t this._area.addChild(people);\r\n\t SvgaManager.play(people);\r\n\t var mona_confuse = this._mona_confuse = SvgaManager.createSvga('mona_confuse');\r\n\t mona_confuse.x = props.people_X;\r\n\t mona_confuse.y = props.people_Y;\r\n\t mona_confuse.visible = false;\r\n\t this._area.addChild(mona_confuse);\r\n\t };\r\n\t AnswerArea.prototype.getArea = function () {\r\n\t return this._area;\r\n\t };\r\n\t AnswerArea.prototype.initAnswerOption = function () {\r\n\t var optionA = this._optionA = new engine.Image(getTextureByName('选区'));\r\n\t optionA.x = (750 - (optionA.width * 2 + 30)) / 2;\r\n\t optionA.y = props.answerArea_Y;\r\n\t optionA.name = 'A';\r\n\t optionA.alpha = 0;\r\n\t this._area.addChild(optionA);\r\n\t this._optionArray.push(optionA);\r\n\t var optionB = this._optionB = new engine.Image(getTextureByName('选区'));\r\n\t optionB.x = optionA.x + optionA.width + 30;\r\n\t optionB.y = optionA.y;\r\n\t optionB.name = 'B';\r\n\t optionB.alpha = 0;\r\n\t this._area.addChild(optionB);\r\n\t this._optionArray.push(optionB);\r\n\t var optionC = this._optionC = new engine.Image(getTextureByName('选区'));\r\n\t optionC.x = optionA.x;\r\n\t optionC.y = optionA.y + optionA.height + props.option_spaceY;\r\n\t optionC.name = 'C';\r\n\t optionC.alpha = 0;\r\n\t this._area.addChild(optionC);\r\n\t this._optionArray.push(optionC);\r\n\t var optionD = this._optionD = new engine.Image(getTextureByName('选区'));\r\n\t optionD.x = optionB.x;\r\n\t optionD.y = optionC.y;\r\n\t optionD.name = 'D';\r\n\t optionD.alpha = 0;\r\n\t this._area.addChild(optionD);\r\n\t this._optionArray.push(optionD);\r\n\t this.initOptionState();\r\n\t this.initAddEventListener();\r\n\t this.initSvga(optionA);\r\n\t this.initSvga(optionB);\r\n\t this.initSvga(optionC);\r\n\t this.initSvga(optionD);\r\n\t };\r\n\t AnswerArea.prototype.initSvga = function (tmpNode) {\r\n\t this.initSvgaNode('right_mona', tmpNode);\r\n\t for (var index = 0; index < this._svgaArrayName.length; index++) {\r\n\t var element = this._svgaArrayName[index];\r\n\t this.initSvgaNode(element.people, tmpNode);\r\n\t this.initSvgaNode(element.scene, tmpNode);\r\n\t }\r\n\t };\r\n\t AnswerArea.prototype.initSvgaNode = function (svgaName, tmpNode) {\r\n\t var tmpSvga = SvgaManager.createSvga(svgaName);\r\n\t tmpSvga.x = -30;\r\n\t tmpSvga.y = -105;\r\n\t tmpSvga.visible = false;\r\n\t tmpSvga.name = svgaName;\r\n\t tmpNode.addChild(tmpSvga);\r\n\t };\r\n\t AnswerArea.prototype.initAddEventListener = function () {\r\n\t for (var index = 0; index < this._optionArray.length; index++) {\r\n\t var element = this._optionArray[index];\r\n\t element.addEventListener(engine.MouseEvent.CLICK, this.selectOption, this);\r\n\t }\r\n\t };\r\n\t AnswerArea.prototype.optionLabel = function (parent) {\r\n\t var answerText = new engine.Label();\r\n\t answerText.fillColor = 0x164b81;\r\n\t answerText.bold = true;\r\n\t answerText.size = 30;\r\n\t answerText.width = parent.width;\r\n\t answerText.height = parent.height;\r\n\t answerText.textAlign = engine.TEXT_ALIGN.CENTER;\r\n\t answerText.x = 0;\r\n\t answerText.y = 0.75 * answerText.height;\r\n\t answerText.text = '';\r\n\t answerText.name = 'answerText';\r\n\t return answerText;\r\n\t };\r\n\t AnswerArea.prototype.initOptionState = function () {\r\n\t for (var i = 0; i < this._optionArray.length; i++) {\r\n\t var tmpNode = this._optionArray[i];\r\n\t tmpNode.addChild(this.getChoiceStateImg('选中', OptionState.CHOICE_SELECT, tmpNode.name));\r\n\t tmpNode.addChild(this.getChoiceStateImg('选错', OptionState.CHOICE_WRONG, tmpNode.name));\r\n\t tmpNode.addChild(this.getChoiceStateImg('选对', OptionState.CHOICE_RIGHT, tmpNode.name));\r\n\t tmpNode.addChild(this.optionLabel(tmpNode));\r\n\t }\r\n\t };\r\n\t AnswerArea.prototype.getChoiceStateImg = function (imgName, imgType, imgAnswer) {\r\n\t var choiceImage = new engine.Image(getTextureByName(imgName));\r\n\t choiceImage.x = 0;\r\n\t choiceImage.y = 0;\r\n\t choiceImage['type'] = imgType;\r\n\t choiceImage['imgAnswer'] = imgAnswer;\r\n\t choiceImage.visible = false;\r\n\t switch (imgType) {\r\n\t case OptionState.CHOICE_WRONG:\r\n\t this._choiceWrong.push(choiceImage);\r\n\t break;\r\n\t case OptionState.CHOICE_RIGHT:\r\n\t this._choiceRight.push(choiceImage);\r\n\t break;\r\n\t case OptionState.CHOICE_SELECT:\r\n\t this._choiceSelect.push(choiceImage);\r\n\t break;\r\n\t }\r\n\t return choiceImage;\r\n\t };\r\n\t AnswerArea.prototype.selectOption = function (event) {\r\n\t if (this._gameState != GameState.STATE_START || this._svgaPlayState == GameState.STATE_START) {\r\n\t console.log('暂时不能答题');\r\n\t return;\r\n\t }\r\n\t this._gameState = GameState.STATE_END;\r\n\t this.handleSelect(event.target.name);\r\n\t this.peopleMove(event.target.x - 30, event.target.y - 110, false);\r\n\t this._answer = this._answerArray.indexOf(event.target.name);\r\n\t console.log('点击选择选项', event.target.name, this._answer);\r\n\t };\r\n\t AnswerArea.prototype.peopleMove = function (moveX, moveY, isPlaySVGA) {\r\n\t var _this = this;\r\n\t var tmpX = moveX;\r\n\t var tmpY = moveY;\r\n\t engine.Tween.get(this._people, { loop: false })\r\n\t .to({ x: tmpX, y: tmpY }, 500, engine.Ease.cubicInOut)\r\n\t .call(function () {\r\n\t _this._gameState = GameState.STATE_START;\r\n\t if (isPlaySVGA) {\r\n\t SvgaManager.play(_this._people);\r\n\t engine.globalEvent.dispatchEvent('updateSubject');\r\n\t }\r\n\t });\r\n\t };\r\n\t AnswerArea.prototype.rest = function () {\r\n\t this._answer = -1;\r\n\t if (this._right_mona) {\r\n\t SvgaManager.stop(this._right_mona);\r\n\t this._right_mona.visible = false;\r\n\t }\r\n\t this._people.visible = true;\r\n\t this._mona_confuse.visible = false;\r\n\t this.peopleMove(props.people_X, props.people_Y, true);\r\n\t this.handleRight();\r\n\t this.handleWrong();\r\n\t this.handleSelect();\r\n\t this.optionsShow(false);\r\n\t engine.globalEvent.dispatchEvent('resetTitle');\r\n\t };\r\n\t AnswerArea.prototype.optionsShow = function (isShow) {\r\n\t for (var index = 0; index < this._optionArray.length; index++) {\r\n\t var element = this._optionArray[index];\r\n\t var tmpAlpha = isShow ? 1 : 0;\r\n\t this.optionIsShowTween(element, tmpAlpha);\r\n\t }\r\n\t };\r\n\t AnswerArea.prototype.optionIsShowTween = function (tweenNode, tmpAlpha) {\r\n\t engine.Tween.get(tweenNode, { loop: false })\r\n\t .to({ alpha: tmpAlpha }, 500);\r\n\t };\r\n\t AnswerArea.prototype.handleSelect = function (select) {\r\n\t for (var index = 0; index < this._choiceSelect.length; index++) {\r\n\t var element = this._choiceSelect[index];\r\n\t if (!select) {\r\n\t element.visible = false;\r\n\t continue;\r\n\t }\r\n\t if (element['imgAnswer'] === select) {\r\n\t element.visible = true;\r\n\t continue;\r\n\t }\r\n\t element.visible = false;\r\n\t }\r\n\t };\r\n\t AnswerArea.prototype.handleRight = function (select) {\r\n\t if (select === void 0) { select = ''; }\r\n\t for (var index = 0; index < this._choiceRight.length; index++) {\r\n\t var element = this._choiceRight[index];\r\n\t if (select == '') {\r\n\t element.visible = false;\r\n\t continue;\r\n\t }\r\n\t if (element['imgAnswer'] === select) {\r\n\t element.visible = true;\r\n\t continue;\r\n\t }\r\n\t element.visible = false;\r\n\t }\r\n\t };\r\n\t AnswerArea.prototype.handleWrong = function (select) {\r\n\t var count = 0;\r\n\t for (var index = 0; index < this._choiceWrong.length; index++) {\r\n\t var element = this._choiceWrong[index];\r\n\t if (!select) {\r\n\t element.visible = false;\r\n\t this.hideSvga(element);\r\n\t continue;\r\n\t }\r\n\t if (element['imgAnswer'] == select) {\r\n\t element.visible = false;\r\n\t continue;\r\n\t }\r\n\t count++;\r\n\t element.visible = true;\r\n\t this.playWrongTween(element, (count == this._choiceWrong.length - 1));\r\n\t }\r\n\t };\r\n\t AnswerArea.prototype.hideSvga = function (svgaNode) {\r\n\t svgaNode.parent.children.forEach(function (element) {\r\n\t if (element._instanceType == 'MovieClip') {\r\n\t element.visible = false;\r\n\t }\r\n\t });\r\n\t };\r\n\t AnswerArea.prototype.playWrongTween = function (tweenNode, isLast) {\r\n\t var _this = this;\r\n\t engine.Tween.get(tweenNode, { loop: false })\r\n\t .wait(460)\r\n\t .to({ alpha: 0.3 }, 160, engine.Ease.circInOut)\r\n\t .to({ alpha: 1 }, 160, engine.Ease.circInOut)\r\n\t .to({ alpha: 0.3 }, 160, engine.Ease.circInOut)\r\n\t .to({ alpha: 1 }, 160, engine.Ease.circInOut)\r\n\t .call(function () {\r\n\t engine.Tween.removeTweens(tweenNode);\r\n\t if (isLast) {\r\n\t if (_this._answer >= 0) {\r\n\t _this._people.visible = false;\r\n\t _this.handleSeceltRight();\r\n\t _this.handleSeceltError();\r\n\t }\r\n\t else {\r\n\t _this._people.visible = false;\r\n\t _this._mona_confuse.visible = true;\r\n\t SvgaManager.play(_this._mona_confuse, function () {\r\n\t _this.rest();\r\n\t });\r\n\t }\r\n\t }\r\n\t });\r\n\t };\r\n\t AnswerArea.prototype.playResultSvga = function (svgaNode, isLast, isShowPeople) {\r\n\t var _this = this;\r\n\t var svgaData = this._svgaArrayName[this._randomSvga - 1];\r\n\t if (isShowPeople) {\r\n\t var peopleNode = this.getSvgaNode(svgaNode, svgaData.people);\r\n\t this.playSvga(peopleNode);\r\n\t }\r\n\t var sceneNode = this.getSvgaNode(svgaNode, svgaData.scene);\r\n\t this.playSvga(sceneNode, function () {\r\n\t if (isLast)\r\n\t _this.rest();\r\n\t });\r\n\t };\r\n\t AnswerArea.prototype.getSvgaNode = function (svgaNode, svgaName) {\r\n\t var tmp = svgaNode.getChildByName(svgaName);\r\n\t if (!tmp) {\r\n\t console.log('svga节点未找到');\r\n\t return;\r\n\t }\r\n\t return tmp;\r\n\t };\r\n\t AnswerArea.prototype.playSvga = function (svgaNode, callBack) {\r\n\t svgaNode.visible = true;\r\n\t SvgaManager.play(svgaNode, function () {\r\n\t svgaNode.visible = false;\r\n\t if (callBack)\r\n\t callBack();\r\n\t });\r\n\t };\r\n\t AnswerArea.prototype.updateOption = function (optionData) {\r\n\t this._randomSvga = Math.floor(Math.random() * (this._svgaArrayName.length) + 1);\r\n\t var tmpOptionData = optionData.data.options;\r\n\t for (var index = 0; index < tmpOptionData.length; index++) {\r\n\t var element = tmpOptionData[index];\r\n\t this._optionArray[index].getChildByName('answerText').text = element;\r\n\t }\r\n\t };\r\n\t AnswerArea.prototype.handleAnswerOption = function (result) {\r\n\t this._people.gotoAndStop(1);\r\n\t var trueAnswer = this._trueAnswer = result.data.state;\r\n\t this.handleRight(this._answerArray[trueAnswer]);\r\n\t this.handleWrong(this._answerArray[trueAnswer]);\r\n\t this.handleSelect();\r\n\t this._svgaPlayState = GameState.STATE_START;\r\n\t };\r\n\t AnswerArea.prototype.handleSeceltRight = function () {\r\n\t for (var index = 0; index < this._optionArray.length; index++) {\r\n\t var element = this._optionArray[index];\r\n\t if (element.name == this._answerArray[this._answer] && this._trueAnswer == this._answer) {\r\n\t this._right_mona = this.getSvgaNode(element, 'right_mona');\r\n\t if (this._right_mona) {\r\n\t this._right_mona.visible = true;\r\n\t SvgaManager.play(this._right_mona);\r\n\t }\r\n\t }\r\n\t }\r\n\t };\r\n\t AnswerArea.prototype.handleSeceltError = function () {\r\n\t var tmpNum = 0;\r\n\t for (var index = 0; index < this._optionArray.length; index++) {\r\n\t var element = this._optionArray[index];\r\n\t if (element.name != this._answerArray[this._trueAnswer]) {\r\n\t tmpNum++;\r\n\t var isShowPeople = false;\r\n\t if (element.name == this._answerArray[this._answer]) {\r\n\t isShowPeople = true;\r\n\t }\r\n\t this.playResultSvga(element, (tmpNum == 3), isShowPeople);\r\n\t }\r\n\t }\r\n\t };\r\n\t AnswerArea.prototype.upDateGameState = function (gameState) {\r\n\t this._gameState = gameState.data.gameState;\r\n\t };\r\n\t AnswerArea.prototype.start = function () {\r\n\t this.optionsShow(true);\r\n\t this._gameState = GameState.STATE_START;\r\n\t this._svgaPlayState = GameState.STATE_END;\r\n\t };\r\n\t AnswerArea.prototype.sendAnswer = function () {\r\n\t engine.globalEvent.dispatchEvent('sendAnswerResult', { answer: this._answer });\r\n\t };\r\n\t return AnswerArea;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=answerArea.js.map\n\n\tvar GameView = (function (_super) {\r\n\t tslib.__extends(GameView, _super);\r\n\t function GameView() {\r\n\t return _super.call(this) || 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 var backgroud = this._backgroud = new Background();\r\n\t this.addChild(backgroud);\r\n\t backgroud.init();\r\n\t var subject = this._subject = new SubjectTitle();\r\n\t this.addChild(subject);\r\n\t subject.init();\r\n\t var answerArea = this._answerArea = new AnswerArea();\r\n\t this.addChild(answerArea);\r\n\t answerArea.init();\r\n\t var tmpContainer = new engine.Container();\r\n\t this.addChildAt(tmpContainer, 50);\r\n\t subject.initCountDownSvga(tmpContainer);\r\n\t var subjectManager = this._subjectManager = new SubjectManager();\r\n\t subjectManager.init();\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 return tslib.__generator(this, function (_a) {\r\n\t this.setup();\r\n\t return [2];\r\n\t });\r\n\t });\r\n\t };\r\n\t return GameView;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=GameView.js.map\n\n\tvar GameWrapper = (function (_super) {\r\n\t tslib.__extends(GameWrapper, _super);\r\n\t function GameWrapper() {\r\n\t var _this = _super.call(this) || this;\r\n\t engine.globalEvent.addEventListener('answer-game-start', _this.start, _this);\r\n\t engine.globalEvent.addEventListener('answer-game-subject', _this.initSubject, _this);\r\n\t engine.globalEvent.addEventListener('answer-game-result', _this.result, _this);\r\n\t _this.visibilitychange();\r\n\t return _this;\r\n\t }\r\n\t GameWrapper.prototype.start = function (event) {\r\n\t if (event.data.countDown) {\r\n\t props.countDown = event.data.countDown;\r\n\t }\r\n\t if (!this._gameView) {\r\n\t var gameView = this._gameView = new GameView();\r\n\t this.addChild(gameView);\r\n\t this._gameView.start();\r\n\t }\r\n\t engine.globalEvent.dispatchEvent('reset');\r\n\t };\r\n\t GameWrapper.prototype.initSubject = function (event) {\r\n\t var subjectData = event.data.subjectData;\r\n\t engine.globalEvent.dispatchEvent('handleOption', subjectData);\r\n\t };\r\n\t GameWrapper.prototype.result = function (event) {\r\n\t var result = event.data.result;\r\n\t engine.globalEvent.dispatchEvent('handleResult', { result: result });\r\n\t };\r\n\t GameWrapper.prototype.visibilitychange = function () {\r\n\t document.addEventListener('visibilitychange', function () {\r\n\t if (document.visibilityState === 'hidden') {\r\n\t console.log('放置后台');\r\n\t engine.globalEvent.dispatchEvent('outRest');\r\n\t engine.globalEvent.dispatchEvent('answer-game-visibilitychange', { hidden: true });\r\n\t }\r\n\t });\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['answer-game'] = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n\tvar props = {};\n\tfunction prepareProps() {\n\t var metaProps = getProps();\n\t engine.injectProp(props, metaProps);\n\t}\n\tfunction injectProps(p) {\n\t engine.injectProp(props, p);\n\t}\n\n\tvar SubjectManager = (function () {\n\t function SubjectManager() {\n\t this._curSubJect = 0;\n\t }\n\t SubjectManager.prototype.init = function () {\n\t this.insideAddEventListener();\n\t };\n\t SubjectManager.prototype.insideAddEventListener = function () {\n\t engine.globalEvent.addEventListener('handleOption', this.handleSubject, this);\n\t engine.globalEvent.addEventListener('updateSubject', this.updateSubject, this);\n\t engine.globalEvent.addEventListener('handleResult', this.handleResult, this);\n\t engine.globalEvent.addEventListener('sendAnswerResult', this.sendAnswerResult, this);\n\t };\n\t SubjectManager.prototype.handleSubject = function (subject) {\n\t this._curSubJect = 0;\n\t this._loactionCache = subject.data;\n\t this.updateSubject();\n\t engine.globalEvent.dispatchEvent('updateAnswerCount', { count: 0 });\n\t };\n\t SubjectManager.prototype.updateSubject = function () {\n\t if (this._curSubJect >= this._loactionCache.length) {\n\t console.log('没有题目');\n\t engine.globalEvent.dispatchEvent('answer-game-over');\n\t return;\n\t }\n\t this._curTmpSubject = this._loactionCache[this._curSubJect];\n\t var title = this._loactionCache[this._curSubJect].question;\n\t var options = this._loactionCache[this._curSubJect].options;\n\t var tmpIndex = this._loactionCache[this._curSubJect].index;\n\t this.updateTitle(title, tmpIndex);\n\t this.updateOption(options);\n\t this._curSubJect++;\n\t };\n\t SubjectManager.prototype.updateTitle = function (title, tmpIndex) {\n\t engine.globalEvent.dispatchEvent('updateSubjectTitle', { title: title, curSubJect: tmpIndex });\n\t };\n\t SubjectManager.prototype.updateOption = function (options) {\n\t engine.globalEvent.dispatchEvent('updateOption', { options: options });\n\t };\n\t SubjectManager.prototype.handleResult = function (result) {\n\t var tmp = result.data.result;\n\t engine.globalEvent.dispatchEvent('updateAnswerCount', { count: tmp.count });\n\t engine.globalEvent.dispatchEvent('handleAnswerOption', { state: tmp.state });\n\t };\n\t SubjectManager.prototype.sendAnswerResult = function (resultData) {\n\t var tmpAnswer = resultData.data.answer;\n\t engine.globalEvent.dispatchEvent('answer-game-select', { curSubJect: this._curTmpSubject.index, answer: tmpAnswer });\n\t };\n\t return SubjectManager;\n\t}());\n\n\tfunction getTexture(uuid) {\n\t return engine.Texture.from(getAssetByUUID(uuid).uuid);\n\t}\n\tfunction getTextureByName(name) {\n\t return getTexture(engine.getAssetByName(name).uuid);\n\t}\n\tfunction getStage() {\n\t return engine.gameStage.stage;\n\t}\n\tvar OptionState;\n\t(function (OptionState) {\n\t OptionState[OptionState[\"CHOICE_RIGHT\"] = 0] = \"CHOICE_RIGHT\";\n\t OptionState[OptionState[\"CHOICE_WRONG\"] = 1] = \"CHOICE_WRONG\";\n\t OptionState[OptionState[\"CHOICE_SELECT\"] = 2] = \"CHOICE_SELECT\";\n\t})(OptionState || (OptionState = {}));\n\tvar GameState;\n\t(function (GameState) {\n\t GameState[GameState[\"STATE_START\"] = 0] = \"STATE_START\";\n\t GameState[GameState[\"STATE_END\"] = 1] = \"STATE_END\";\n\t})(GameState || (GameState = {}));\n\n\tvar Background = (function (_super) {\n\t tslib.__extends(Background, _super);\n\t function Background() {\n\t return _super !== null && _super.apply(this, arguments) || this;\n\t }\n\t Background.prototype.init = function () {\n\t this.showSubjectBox();\n\t this.insideAddEventListener();\n\t };\n\t Background.prototype.insideAddEventListener = function () {\n\t engine.globalEvent.addEventListener('changeCount', this.changeCount, this);\n\t };\n\t Background.prototype.showSubjectBox = function () {\n\t var tmpContainer = new engine.Container();\n\t tmpContainer.x = 0;\n\t tmpContainer.y = props.subjectBox_Y;\n\t this.addChild(tmpContainer);\n\t var subjectBox = this._subjectBox = new engine.Image(getTextureByName('题目栏'));\n\t subjectBox.x = (750 - subjectBox.width) / 2;\n\t subjectBox.y = 0;\n\t tmpContainer.addChild(subjectBox);\n\t var countDownBg = this._countDownBg = new engine.Image(getTextureByName('倒计时'));\n\t countDownBg.x = (750 - countDownBg.width) / 2;\n\t countDownBg.y = -countDownBg.height / 2 + 10;\n\t tmpContainer.addChild(countDownBg);\n\t var answerCountBg = this._answerCountBg = new engine.Image(getTextureByName('答对题数'));\n\t answerCountBg.x = (750 - answerCountBg.width) / 2;\n\t answerCountBg.y = subjectBox.y + subjectBox.height - answerCountBg.height - 10;\n\t tmpContainer.addChild(answerCountBg);\n\t var answerCountText = this._answerCountText = new engine.Label();\n\t answerCountText.fillColor = 0x2b3134;\n\t answerCountText.size = 30;\n\t answerCountText.width = answerCountBg.width;\n\t answerCountText.height = answerCountBg.height;\n\t answerCountText.verticalAlign = engine.VERTICAL_ALIGN.MIDDLE;\n\t answerCountText.x = 160;\n\t answerCountText.y = 3;\n\t answerCountText.text = '0';\n\t answerCountBg.addChild(answerCountText);\n\t };\n\t Background.prototype.changeCount = function (data) {\n\t this._answerCountText.text = data.data.count + '';\n\t };\n\t return Background;\n\t}(engine.Container));\n\n\tvar SvgaManager = (function () {\n\t function SvgaManager() {\n\t }\n\t SvgaManager.createSvga = function (name) {\n\t var inst = new svga.Svga();\n\t inst.source = engine.getAssetByName(name).uuid;\n\t return inst;\n\t };\n\t SvgaManager.play = function (svga, callBack) {\n\t if (!svga) {\n\t console.log('svga节点出错');\n\t return;\n\t }\n\t svga.gotoAndStop(0);\n\t svga.play();\n\t if (callBack) {\n\t svga.addEventListener(engine.Event.END_FRAME, function () {\n\t svga.stop();\n\t callBack();\n\t svga.removeAllEventListener();\n\t }, this);\n\t }\n\t };\n\t SvgaManager.stop = function (svga) {\n\t if (!svga) {\n\t console.log('svga节点出错');\n\t return;\n\t }\n\t svga.stop();\n\t };\n\t return SvgaManager;\n\t}());\n\n\tvar SubjectTitle = (function (_super) {\n\t tslib.__extends(SubjectTitle, _super);\n\t function SubjectTitle() {\n\t var _this = _super !== null && _super.apply(this, arguments) || this;\n\t _this._frameCurrAngle = 0;\n\t _this._frameCount = 0;\n\t _this._countDownTmp = 0;\n\t _this._square = new engine.Graphics();\n\t return _this;\n\t }\n\t SubjectTitle.prototype.init = function () {\n\t this.showSubjectBox();\n\t this.insideAddEventListener();\n\t };\n\t SubjectTitle.prototype.initCountDownSvga = function (tmpNode) {\n\t var countDownSvga = this._countDownSvga = SvgaManager.createSvga('countdown_321');\n\t countDownSvga.x = (getStage().width - 120) / 2;\n\t countDownSvga.y = (getStage().height - 120) / 2;\n\t countDownSvga.visible = false;\n\t tmpNode.addChild(countDownSvga);\n\t };\n\t SubjectTitle.prototype.insideAddEventListener = function () {\n\t engine.globalEvent.addEventListener('updateSubjectTitle', this.updateSubjectTitle, this);\n\t engine.globalEvent.addEventListener('updateAnswerCount', this.updateAnswerCount, this);\n\t engine.globalEvent.addEventListener('resetTitle', this.reset, this);\n\t engine.globalEvent.addEventListener('outRest', this.outRest, this);\n\t };\n\t SubjectTitle.prototype.showSubjectBox = function () {\n\t var tmpContainer = new engine.Container();\n\t tmpContainer.x = 0;\n\t tmpContainer.y = props.subjectBox_Y;\n\t this.addChild(tmpContainer);\n\t var subjectBox = this._subjectTitleBox = new engine.Image(getTextureByName('题目栏'));\n\t subjectBox.x = (750 - subjectBox.width) / 2;\n\t subjectBox.y = 0;\n\t tmpContainer.addChild(subjectBox);\n\t var countDownBg = this._countDownBg = new engine.Image(getTextureByName('倒计时'));\n\t countDownBg.x = (750 - countDownBg.width) / 2;\n\t countDownBg.y = -countDownBg.height / 2 + 10;\n\t tmpContainer.addChild(countDownBg);\n\t var bar = this._bar = new engine.Image(getTextureByName('进度条'));\n\t bar.x = 0;\n\t bar.y = 0;\n\t countDownBg.addChild(bar);\n\t bar.anchorX = bar.width / 2;\n\t bar.anchorY = bar.height / 2;\n\t bar.rotation = -90;\n\t bar.addChild(this._square);\n\t bar.mask = this._square;\n\t var answerCountBg = this._answerCountBg = new engine.Image(getTextureByName('答对题数'));\n\t answerCountBg.x = (750 - answerCountBg.width) / 2;\n\t answerCountBg.y = subjectBox.y + subjectBox.height - answerCountBg.height - 10;\n\t tmpContainer.addChild(answerCountBg);\n\t this.initCountDownBar(0);\n\t this.initAnswerCountText();\n\t this.initCountDownText();\n\t this.initTitleText();\n\t this.initSvga();\n\t };\n\t SubjectTitle.prototype.initCountDownText = function () {\n\t var countDownText = this._countDownText = new engine.BitmapText();\n\t countDownText.font = props.fontName;\n\t countDownText.text = props.countDown;\n\t this.handleAlign();\n\t this._countDownBg.addChild(countDownText);\n\t this._countDownTmp = props.countDown;\n\t };\n\t SubjectTitle.prototype.handleAlign = function () {\n\t this._countDownText.x = (this._countDownBg.width - this._countDownText.width) / 2;\n\t this._countDownText.y = (this._countDownBg.height - this._countDownText.height) / 2;\n\t };\n\t SubjectTitle.prototype.countDownBitmapText = function () {\n\t };\n\t SubjectTitle.prototype.initAnswerCountText = function () {\n\t var answerCountText = this._answerCountText = new engine.Label();\n\t answerCountText.fillColor = 0x2b3134;\n\t answerCountText.size = 30;\n\t answerCountText.width = this._answerCountBg.width;\n\t answerCountText.height = this._answerCountBg.height;\n\t answerCountText.verticalAlign = engine.VERTICAL_ALIGN.MIDDLE;\n\t answerCountText.x = 160;\n\t answerCountText.y = props.answerCountText_Y;\n\t answerCountText.text = '0';\n\t this._answerCountBg.addChild(answerCountText);\n\t };\n\t SubjectTitle.prototype.initTitleText = function () {\n\t var titleLabel = this._titleLabel = new engine.Label();\n\t titleLabel.fillColor = 0xfffcc6;\n\t titleLabel.size = 36;\n\t titleLabel.width = this._subjectTitleBox.width - props.titleText_width;\n\t titleLabel.height = this._subjectTitleBox.height - props.titleText_height;\n\t titleLabel.lineType = engine.TEXT_lINETYPE.MULTI;\n\t titleLabel.verticalAlign = engine.VERTICAL_ALIGN.MIDDLE;\n\t titleLabel.textAlign = engine.TEXT_ALIGN.CENTER;\n\t titleLabel.x = props.titleText_X;\n\t titleLabel.y = props.titleText_Y;\n\t titleLabel.text = '';\n\t titleLabel.alpha = 0;\n\t this._subjectTitleBox.addChild(titleLabel);\n\t };\n\t SubjectTitle.prototype.initTitleNumText = function (tmpContainer) {\n\t var titleNumLabel = this._titleNumLabel = new engine.Label();\n\t titleNumLabel.fillColor = 0xfffcc6;\n\t titleNumLabel.size = 48;\n\t titleNumLabel.width = tmpContainer.width;\n\t titleNumLabel.height = tmpContainer.heigth;\n\t titleNumLabel.verticalAlign = engine.VERTICAL_ALIGN.MIDDLE;\n\t titleNumLabel.textAlign = engine.TEXT_ALIGN.CENTER;\n\t titleNumLabel.text = '';\n\t titleNumLabel.visible = false;\n\t tmpContainer.addChild(titleNumLabel);\n\t };\n\t SubjectTitle.prototype.updateTitleNumText = function (curSubJect) {\n\t this.rest();\n\t this._titleNumLabel.text = \"\\u7B2C\" + curSubJect + \"\\u9898\";\n\t };\n\t SubjectTitle.prototype.reset = function () {\n\t this._titleLabel.text = '';\n\t };\n\t SubjectTitle.prototype.updateSubjectTitle = function (tmpData) {\n\t this._titleLabel.alpha = 0;\n\t this._titleLabel.text = tmpData.data.title;\n\t this.lastTime = 0;\n\t this.updateTitleNumText(tmpData.data.curSubJect + 1);\n\t if (tmpData.data.curSubJect == 0) {\n\t this.fristAnswer();\n\t }\n\t else {\n\t this.playQuestion_enter();\n\t }\n\t };\n\t SubjectTitle.prototype.updateAnswerCount = function (data) {\n\t this._answerCountText.text = data.data.count + '';\n\t };\n\t SubjectTitle.prototype.updateCountDownText = function (count) {\n\t this._countDownText.text = count + '';\n\t this.handleAlign();\n\t };\n\t SubjectTitle.prototype.openCountDownBar = function () {\n\t this.rest();\n\t engine.gameStage.addEventListener(engine.Event.ENTER_FRAME, this.countDownBar, this);\n\t };\n\t SubjectTitle.prototype.initCountDownBar = function (currAngle) {\n\t var ax = this._bar.width / 2;\n\t var ay = this._bar.height / 2;\n\t this._square.clear();\n\t this._square.beginFill(0);\n\t this._square.moveTo(ax, ay);\n\t this._square.arc(ax, ay, this._bar.width / 2, 0, (currAngle * Math.PI / 180));\n\t this._square.lineTo(ax, ay);\n\t this._square.endFill();\n\t };\n\t SubjectTitle.prototype.countDownBar = function () {\n\t var now = Date.now();\n\t var deltaTime = this.lastTime ? now - this.lastTime : 16.7;\n\t this.lastTime = now;\n\t this._frameCurrAngle += 360 / (props.countDown * 1000) * deltaTime;\n\t this._frameCurrAngle = Math.min(360, this._frameCurrAngle);\n\t this.initCountDownBar(this._frameCurrAngle);\n\t this._frameCount += deltaTime;\n\t if (this._frameCount >= 1000) {\n\t var tmpTime = this._countDownTmp - 1 > 0 ? this._countDownTmp -= 1 : 0;\n\t if (tmpTime == 3) {\n\t this.playCountDownSvga();\n\t }\n\t this.updateCountDownText(tmpTime);\n\t this._frameCount = 0;\n\t if (this._frameCurrAngle >= 360) {\n\t engine.gameStage.removeEventListener(engine.Event.ENTER_FRAME, this.countDownBar, this);\n\t engine.globalEvent.dispatchEvent('upDateGameState', { gameState: GameState.STATE_END });\n\t engine.globalEvent.dispatchEvent('sendAnswer');\n\t }\n\t }\n\t };\n\t SubjectTitle.prototype.rest = function () {\n\t this._frameCurrAngle = 0;\n\t this._frameCount = 0;\n\t this._square.clear();\n\t this._countDownTmp = props.countDown;\n\t this._countDownText.text = props.countDown + '';\n\t this.handleAlign();\n\t };\n\t SubjectTitle.prototype.outRest = function () {\n\t this._frameCurrAngle = 0;\n\t this._frameCount = 0;\n\t this._square.clear();\n\t this._countDownTmp = props.countDown;\n\t this._countDownText.text = props.countDown + '';\n\t this.handleAlign();\n\t this._readyGo.visible = false;\n\t this._countDownSvga.visible = false;\n\t this._questionEnter.visible = false;\n\t engine.gameStage.removeEventListener(engine.Event.ENTER_FRAME, this.countDownBar, this);\n\t };\n\t SubjectTitle.prototype.initSvga = function () {\n\t var readyGo = this._readyGo = SvgaManager.createSvga('ready_go');\n\t readyGo.x = 50;\n\t readyGo.y = 45;\n\t readyGo.visible = false;\n\t this._subjectTitleBox.addChild(readyGo);\n\t var tmpRect = new engine.Rect();\n\t tmpRect.x = 50;\n\t tmpRect.y = 45;\n\t tmpRect.width = 520;\n\t tmpRect.height = 200;\n\t this._subjectTitleBox.addChild(tmpRect);\n\t readyGo.mask = tmpRect;\n\t var tmpContainer = new engine.Container();\n\t tmpContainer.width = 400;\n\t tmpContainer.height = 100;\n\t tmpContainer.x = (this._subjectTitleBox.width - 400) / 2;\n\t tmpContainer.y = 115;\n\t this._subjectTitleBox.addChild(tmpContainer);\n\t var questionEnter = this._questionEnter = SvgaManager.createSvga('question_enter');\n\t questionEnter.x = 0;\n\t questionEnter.y = 0;\n\t questionEnter.visible = false;\n\t tmpContainer.addChild(questionEnter);\n\t this.initTitleNumText(tmpContainer);\n\t };\n\t SubjectTitle.prototype.fristAnswer = function () {\n\t this.playReadyGo();\n\t };\n\t SubjectTitle.prototype.playReadyGo = function () {\n\t var _this = this;\n\t this._readyGo.visible = true;\n\t SvgaManager.play(this._readyGo, function () {\n\t _this._readyGo.visible = false;\n\t _this.playQuestion_enter();\n\t });\n\t };\n\t SubjectTitle.prototype.playQuestion_enter = function () {\n\t var _this = this;\n\t this._questionEnter.visible = true;\n\t this._titleNumLabel.visible = true;\n\t SvgaManager.play(this._questionEnter, function () {\n\t _this._questionEnter.visible = false;\n\t _this.playTweenTitle();\n\t _this._titleNumLabel.visible = false;\n\t _this.openCountDownBar();\n\t if (_this._countDownTmp == 3) {\n\t _this.playCountDownSvga();\n\t }\n\t engine.globalEvent.dispatchEvent('start');\n\t });\n\t };\n\t SubjectTitle.prototype.playTweenTitle = function () {\n\t var _this = this;\n\t engine.Tween.get(this._titleLabel, { loop: false })\n\t .set({ alpha: 0 })\n\t .to({ alpha: 1 }, 500, engine.Ease.cubicIn)\n\t .call(function () {\n\t engine.Tween.removeTweens(_this._titleLabel);\n\t });\n\t };\n\t SubjectTitle.prototype.playCountDownSvga = function () {\n\t var _this = this;\n\t console.log('测试次数');\n\t this._countDownSvga.visible = true;\n\t this._countDownSvga.lockStep = true;\n\t SvgaManager.play(this._countDownSvga, function () {\n\t _this._countDownSvga.visible = false;\n\t });\n\t };\n\t return SubjectTitle;\n\t}(engine.Container));\n\n\tvar AnswerArea = (function (_super) {\n\t tslib.__extends(AnswerArea, _super);\n\t function AnswerArea() {\n\t var _this = _super !== null && _super.apply(this, arguments) || this;\n\t _this._optionArray = [];\n\t _this._choiceWrong = [];\n\t _this._choiceRight = [];\n\t _this._choiceSelect = [];\n\t _this._answerArray = ['A', 'B', 'C', 'D'];\n\t _this._answer = -1;\n\t _this._svgaArrayName = [];\n\t return _this;\n\t }\n\t AnswerArea.prototype.init = function () {\n\t var area = this._area = new engine.Container();\n\t area.x = 0;\n\t area.y = 0;\n\t this._gameState = GameState.STATE_END;\n\t this.addChild(area);\n\t this.initSvgaArray();\n\t this.initAnswerOption();\n\t this.initPeople();\n\t this.insideAddEventListener();\n\t };\n\t AnswerArea.prototype.initSvgaArray = function () {\n\t this.setSvgaName('rian_mona', 'rian_weather');\n\t this.setSvgaName('snow_mona', 'snow_weather');\n\t this.setSvgaName('thunder_mona', 'thunder_weather');\n\t this.setSvgaName('wind_mona', 'wind_weather');\n\t };\n\t AnswerArea.prototype.setSvgaName = function (peopleName, scene) {\n\t var tmpSvgaName = {};\n\t tmpSvgaName.people = peopleName;\n\t tmpSvgaName.scene = scene;\n\t this._svgaArrayName.push(tmpSvgaName);\n\t };\n\t AnswerArea.prototype.insideAddEventListener = function () {\n\t engine.globalEvent.addEventListener('updateOption', this.updateOption, this);\n\t engine.globalEvent.addEventListener('handleAnswerOption', this.handleAnswerOption, this);\n\t engine.globalEvent.addEventListener('upDateGameState', this.upDateGameState, this);\n\t engine.globalEvent.addEventListener('start', this.start, this);\n\t engine.globalEvent.addEventListener('sendAnswer', this.sendAnswer, this);\n\t engine.globalEvent.addEventListener('outRest', this.rest, this);\n\t };\n\t AnswerArea.prototype.initPeople = function () {\n\t var people = this._people = SvgaManager.createSvga('mona_walk');\n\t people.x = props.people_X;\n\t people.y = props.people_Y;\n\t this._area.addChild(people);\n\t SvgaManager.play(people);\n\t var mona_confuse = this._mona_confuse = SvgaManager.createSvga('mona_confuse');\n\t mona_confuse.x = props.people_X;\n\t mona_confuse.y = props.people_Y;\n\t mona_confuse.visible = false;\n\t this._area.addChild(mona_confuse);\n\t };\n\t AnswerArea.prototype.getArea = function () {\n\t return this._area;\n\t };\n\t AnswerArea.prototype.initAnswerOption = function () {\n\t var optionA = this._optionA = new engine.Image(getTextureByName('选区'));\n\t optionA.x = (750 - (optionA.width * 2 + 30)) / 2;\n\t optionA.y = props.answerArea_Y;\n\t optionA.name = 'A';\n\t optionA.alpha = 0;\n\t this._area.addChild(optionA);\n\t this._optionArray.push(optionA);\n\t var optionB = this._optionB = new engine.Image(getTextureByName('选区'));\n\t optionB.x = optionA.x + optionA.width + 30;\n\t optionB.y = optionA.y;\n\t optionB.name = 'B';\n\t optionB.alpha = 0;\n\t this._area.addChild(optionB);\n\t this._optionArray.push(optionB);\n\t var optionC = this._optionC = new engine.Image(getTextureByName('选区'));\n\t optionC.x = optionA.x;\n\t optionC.y = optionA.y + optionA.height + props.option_spaceY;\n\t optionC.name = 'C';\n\t optionC.alpha = 0;\n\t this._area.addChild(optionC);\n\t this._optionArray.push(optionC);\n\t var optionD = this._optionD = new engine.Image(getTextureByName('选区'));\n\t optionD.x = optionB.x;\n\t optionD.y = optionC.y;\n\t optionD.name = 'D';\n\t optionD.alpha = 0;\n\t this._area.addChild(optionD);\n\t this._optionArray.push(optionD);\n\t this.initOptionState();\n\t this.initAddEventListener();\n\t this.initSvga(optionA);\n\t this.initSvga(optionB);\n\t this.initSvga(optionC);\n\t this.initSvga(optionD);\n\t };\n\t AnswerArea.prototype.initSvga = function (tmpNode) {\n\t this.initSvgaNode('right_mona', tmpNode);\n\t for (var index = 0; index < this._svgaArrayName.length; index++) {\n\t var element = this._svgaArrayName[index];\n\t this.initSvgaNode(element.people, tmpNode);\n\t this.initSvgaNode(element.scene, tmpNode);\n\t }\n\t };\n\t AnswerArea.prototype.initSvgaNode = function (svgaName, tmpNode) {\n\t var tmpSvga = SvgaManager.createSvga(svgaName);\n\t tmpSvga.x = -30;\n\t tmpSvga.y = -105;\n\t tmpSvga.visible = false;\n\t tmpSvga.name = svgaName;\n\t tmpNode.addChild(tmpSvga);\n\t };\n\t AnswerArea.prototype.initAddEventListener = function () {\n\t for (var index = 0; index < this._optionArray.length; index++) {\n\t var element = this._optionArray[index];\n\t element.addEventListener(engine.MouseEvent.CLICK, this.selectOption, this);\n\t }\n\t };\n\t AnswerArea.prototype.optionLabel = function (parent) {\n\t var answerText = new engine.Label();\n\t answerText.fillColor = 0x164b81;\n\t answerText.bold = true;\n\t answerText.size = 30;\n\t answerText.width = parent.width;\n\t answerText.height = parent.height;\n\t answerText.textAlign = engine.TEXT_ALIGN.CENTER;\n\t answerText.x = 0;\n\t answerText.y = 0.75 * answerText.height;\n\t answerText.text = '';\n\t answerText.name = 'answerText';\n\t return answerText;\n\t };\n\t AnswerArea.prototype.initOptionState = function () {\n\t for (var i = 0; i < this._optionArray.length; i++) {\n\t var tmpNode = this._optionArray[i];\n\t tmpNode.addChild(this.getChoiceStateImg('选中', OptionState.CHOICE_SELECT, tmpNode.name));\n\t tmpNode.addChild(this.getChoiceStateImg('选错', OptionState.CHOICE_WRONG, tmpNode.name));\n\t tmpNode.addChild(this.getChoiceStateImg('选对', OptionState.CHOICE_RIGHT, tmpNode.name));\n\t tmpNode.addChild(this.optionLabel(tmpNode));\n\t }\n\t };\n\t AnswerArea.prototype.getChoiceStateImg = function (imgName, imgType, imgAnswer) {\n\t var choiceImage = new engine.Image(getTextureByName(imgName));\n\t choiceImage.x = 0;\n\t choiceImage.y = 0;\n\t choiceImage['type'] = imgType;\n\t choiceImage['imgAnswer'] = imgAnswer;\n\t choiceImage.visible = false;\n\t switch (imgType) {\n\t case OptionState.CHOICE_WRONG:\n\t this._choiceWrong.push(choiceImage);\n\t break;\n\t case OptionState.CHOICE_RIGHT:\n\t this._choiceRight.push(choiceImage);\n\t break;\n\t case OptionState.CHOICE_SELECT:\n\t this._choiceSelect.push(choiceImage);\n\t break;\n\t }\n\t return choiceImage;\n\t };\n\t AnswerArea.prototype.selectOption = function (event) {\n\t if (this._gameState != GameState.STATE_START || this._svgaPlayState == GameState.STATE_START) {\n\t console.log('暂时不能答题');\n\t return;\n\t }\n\t this._gameState = GameState.STATE_END;\n\t this.handleSelect(event.target.name);\n\t this.peopleMove(event.target.x - 30, event.target.y - 110, false);\n\t this._answer = this._answerArray.indexOf(event.target.name);\n\t console.log('点击选择选项', event.target.name, this._answer);\n\t };\n\t AnswerArea.prototype.peopleMove = function (moveX, moveY, isPlaySVGA) {\n\t var _this = this;\n\t var tmpX = moveX;\n\t var tmpY = moveY;\n\t engine.Tween.get(this._people, { loop: false })\n\t .to({ x: tmpX, y: tmpY }, 500, engine.Ease.cubicInOut)\n\t .call(function () {\n\t _this._gameState = GameState.STATE_START;\n\t if (isPlaySVGA) {\n\t SvgaManager.play(_this._people);\n\t engine.globalEvent.dispatchEvent('updateSubject');\n\t }\n\t });\n\t };\n\t AnswerArea.prototype.rest = function () {\n\t this._answer = -1;\n\t if (this._right_mona) {\n\t SvgaManager.stop(this._right_mona);\n\t this._right_mona.visible = false;\n\t }\n\t this._people.visible = true;\n\t this._mona_confuse.visible = false;\n\t this.peopleMove(props.people_X, props.people_Y, true);\n\t this.handleRight();\n\t this.handleWrong();\n\t this.handleSelect();\n\t this.optionsShow(false);\n\t engine.globalEvent.dispatchEvent('resetTitle');\n\t };\n\t AnswerArea.prototype.optionsShow = function (isShow) {\n\t for (var index = 0; index < this._optionArray.length; index++) {\n\t var element = this._optionArray[index];\n\t var tmpAlpha = isShow ? 1 : 0;\n\t this.optionIsShowTween(element, tmpAlpha);\n\t }\n\t };\n\t AnswerArea.prototype.optionIsShowTween = function (tweenNode, tmpAlpha) {\n\t engine.Tween.get(tweenNode, { loop: false })\n\t .to({ alpha: tmpAlpha }, 500);\n\t };\n\t AnswerArea.prototype.handleSelect = function (select) {\n\t for (var index = 0; index < this._choiceSelect.length; index++) {\n\t var element = this._choiceSelect[index];\n\t if (!select) {\n\t element.visible = false;\n\t continue;\n\t }\n\t if (element['imgAnswer'] === select) {\n\t element.visible = true;\n\t continue;\n\t }\n\t element.visible = false;\n\t }\n\t };\n\t AnswerArea.prototype.handleRight = function (select) {\n\t if (select === void 0) { select = ''; }\n\t for (var index = 0; index < this._choiceRight.length; index++) {\n\t var element = this._choiceRight[index];\n\t if (select == '') {\n\t element.visible = false;\n\t continue;\n\t }\n\t if (element['imgAnswer'] === select) {\n\t element.visible = true;\n\t continue;\n\t }\n\t element.visible = false;\n\t }\n\t };\n\t AnswerArea.prototype.handleWrong = function (select) {\n\t var count = 0;\n\t for (var index = 0; index < this._choiceWrong.length; index++) {\n\t var element = this._choiceWrong[index];\n\t if (!select) {\n\t element.visible = false;\n\t this.hideSvga(element);\n\t continue;\n\t }\n\t if (element['imgAnswer'] == select) {\n\t element.visible = false;\n\t continue;\n\t }\n\t count++;\n\t element.visible = true;\n\t this.playWrongTween(element, (count == this._choiceWrong.length - 1));\n\t }\n\t };\n\t AnswerArea.prototype.hideSvga = function (svgaNode) {\n\t svgaNode.parent.children.forEach(function (element) {\n\t if (element._instanceType == 'MovieClip') {\n\t element.visible = false;\n\t }\n\t });\n\t };\n\t AnswerArea.prototype.playWrongTween = function (tweenNode, isLast) {\n\t var _this = this;\n\t engine.Tween.get(tweenNode, { loop: false })\n\t .wait(460)\n\t .to({ alpha: 0.3 }, 160, engine.Ease.circInOut)\n\t .to({ alpha: 1 }, 160, engine.Ease.circInOut)\n\t .to({ alpha: 0.3 }, 160, engine.Ease.circInOut)\n\t .to({ alpha: 1 }, 160, engine.Ease.circInOut)\n\t .call(function () {\n\t engine.Tween.removeTweens(tweenNode);\n\t if (isLast) {\n\t if (_this._answer >= 0) {\n\t _this._people.visible = false;\n\t _this.handleSeceltRight();\n\t _this.handleSeceltError();\n\t }\n\t else {\n\t _this._people.visible = false;\n\t _this._mona_confuse.visible = true;\n\t SvgaManager.play(_this._mona_confuse, function () {\n\t _this.rest();\n\t });\n\t }\n\t }\n\t });\n\t };\n\t AnswerArea.prototype.playResultSvga = function (svgaNode, isLast, isShowPeople) {\n\t var _this = this;\n\t var svgaData = this._svgaArrayName[this._randomSvga - 1];\n\t if (isShowPeople) {\n\t var peopleNode = this.getSvgaNode(svgaNode, svgaData.people);\n\t this.playSvga(peopleNode);\n\t }\n\t var sceneNode = this.getSvgaNode(svgaNode, svgaData.scene);\n\t this.playSvga(sceneNode, function () {\n\t if (isLast)\n\t _this.rest();\n\t });\n\t };\n\t AnswerArea.prototype.getSvgaNode = function (svgaNode, svgaName) {\n\t var tmp = svgaNode.getChildByName(svgaName);\n\t if (!tmp) {\n\t console.log('svga节点未找到');\n\t return;\n\t }\n\t return tmp;\n\t };\n\t AnswerArea.prototype.playSvga = function (svgaNode, callBack) {\n\t svgaNode.visible = true;\n\t SvgaManager.play(svgaNode, function () {\n\t svgaNode.visible = false;\n\t if (callBack)\n\t callBack();\n\t });\n\t };\n\t AnswerArea.prototype.updateOption = function (optionData) {\n\t this._randomSvga = Math.floor(Math.random() * (this._svgaArrayName.length) + 1);\n\t var tmpOptionData = optionData.data.options;\n\t for (var index = 0; index < tmpOptionData.length; index++) {\n\t var element = tmpOptionData[index];\n\t this._optionArray[index].getChildByName('answerText').text = element;\n\t }\n\t };\n\t AnswerArea.prototype.handleAnswerOption = function (result) {\n\t this._people.gotoAndStop(1);\n\t var trueAnswer = this._trueAnswer = result.data.state;\n\t this.handleRight(this._answerArray[trueAnswer]);\n\t this.handleWrong(this._answerArray[trueAnswer]);\n\t this.handleSelect();\n\t this._svgaPlayState = GameState.STATE_START;\n\t };\n\t AnswerArea.prototype.handleSeceltRight = function () {\n\t for (var index = 0; index < this._optionArray.length; index++) {\n\t var element = this._optionArray[index];\n\t if (element.name == this._answerArray[this._answer] && this._trueAnswer == this._answer) {\n\t this._right_mona = this.getSvgaNode(element, 'right_mona');\n\t if (this._right_mona) {\n\t this._right_mona.visible = true;\n\t SvgaManager.play(this._right_mona);\n\t }\n\t }\n\t }\n\t };\n\t AnswerArea.prototype.handleSeceltError = function () {\n\t var tmpNum = 0;\n\t for (var index = 0; index < this._optionArray.length; index++) {\n\t var element = this._optionArray[index];\n\t if (element.name != this._answerArray[this._trueAnswer]) {\n\t tmpNum++;\n\t var isShowPeople = false;\n\t if (element.name == this._answerArray[this._answer]) {\n\t isShowPeople = true;\n\t }\n\t this.playResultSvga(element, (tmpNum == 3), isShowPeople);\n\t }\n\t }\n\t };\n\t AnswerArea.prototype.upDateGameState = function (gameState) {\n\t this._gameState = gameState.data.gameState;\n\t };\n\t AnswerArea.prototype.start = function () {\n\t this.optionsShow(true);\n\t this._gameState = GameState.STATE_START;\n\t this._svgaPlayState = GameState.STATE_END;\n\t };\n\t AnswerArea.prototype.sendAnswer = function () {\n\t engine.globalEvent.dispatchEvent('sendAnswerResult', { answer: this._answer });\n\t };\n\t return AnswerArea;\n\t}(engine.Container));\n\n\tvar GameView = (function (_super) {\n\t tslib.__extends(GameView, _super);\n\t function GameView() {\n\t return _super.call(this) || this;\n\t }\n\t GameView.prototype.setup = function () {\n\t if (this._hasSetup) {\n\t return;\n\t }\n\t this._hasSetup = true;\n\t var backgroud = this._backgroud = new Background();\n\t this.addChild(backgroud);\n\t backgroud.init();\n\t var subject = this._subject = new SubjectTitle();\n\t this.addChild(subject);\n\t subject.init();\n\t var answerArea = this._answerArea = new AnswerArea();\n\t this.addChild(answerArea);\n\t answerArea.init();\n\t var tmpContainer = new engine.Container();\n\t this.addChildAt(tmpContainer, 50);\n\t subject.initCountDownSvga(tmpContainer);\n\t var subjectManager = this._subjectManager = new SubjectManager();\n\t subjectManager.init();\n\t };\n\t GameView.prototype.start = function () {\n\t return tslib.__awaiter(this, void 0, void 0, function () {\n\t return tslib.__generator(this, function (_a) {\n\t this.setup();\n\t return [2];\n\t });\n\t });\n\t };\n\t return GameView;\n\t}(engine.Container));\n\n\tvar GameWrapper = (function (_super) {\n\t tslib.__extends(GameWrapper, _super);\n\t function GameWrapper() {\n\t var _this = _super.call(this) || this;\n\t engine.globalEvent.addEventListener('answer-game-start', _this.start, _this);\n\t engine.globalEvent.addEventListener('answer-game-subject', _this.initSubject, _this);\n\t engine.globalEvent.addEventListener('answer-game-result', _this.result, _this);\n\t _this.visibilitychange();\n\t return _this;\n\t }\n\t GameWrapper.prototype.start = function (event) {\n\t if (event.data.countDown) {\n\t props.countDown = event.data.countDown;\n\t }\n\t if (!this._gameView) {\n\t var gameView = this._gameView = new GameView();\n\t this.addChild(gameView);\n\t this._gameView.start();\n\t }\n\t engine.globalEvent.dispatchEvent('reset');\n\t };\n\t GameWrapper.prototype.initSubject = function (event) {\n\t var subjectData = event.data.subjectData;\n\t engine.globalEvent.dispatchEvent('handleOption', subjectData);\n\t };\n\t GameWrapper.prototype.result = function (event) {\n\t var result = event.data.result;\n\t engine.globalEvent.dispatchEvent('handleResult', { result: result });\n\t };\n\t GameWrapper.prototype.visibilitychange = function () {\n\t document.addEventListener('visibilitychange', function () {\n\t if (document.visibilityState === 'hidden') {\n\t console.log('放置后台');\n\t engine.globalEvent.dispatchEvent('outRest');\n\t engine.globalEvent.dispatchEvent('answer-game-visibilitychange', { hidden: true });\n\t }\n\t });\n\t };\n\t return GameWrapper;\n\t}(engine.Container));\n\n\tfunction index (props) {\n\t prepareProps();\n\t injectProps(props);\n\t var instance = new GameWrapper();\n\t return instance;\n\t}\n\n\treturn index;\n\n})));\n"
} }
...@@ -101,5 +101,5 @@ ...@@ -101,5 +101,5 @@
} }
}, },
"id": "basket", "id": "basket",
"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.basket = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n\tfunction getTexture(uuid) {\r\n\t return engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n\t}\r\n\tfunction getTextureByName(name) {\r\n\t return getTexture(engine.getAssetByName(name).uuid);\r\n\t}\r\n\t//# sourceMappingURL=utils.js.map\n\n\tvar GameTest = (function (_super) {\r\n\t tslib.__extends(GameTest, _super);\r\n\t function GameTest() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.isDebug = true;\r\n\t _this.factor = 10;\r\n\t _this.isRight = false;\r\n\t _this.saleX = _this.isRight ? 1 : -1;\r\n\t _this.ballAddSpeedX = -10;\r\n\t _this.ballAddSpeedY = 30;\r\n\t _this.addEventListener(engine.Event.ADDED_TO_STAGE, _this.setup, _this);\r\n\t return _this;\r\n\t }\r\n\t GameTest.prototype.start = function () {\r\n\t console.log(\"starting\");\r\n\t this.stage.addEventListener(engine.MouseEvent.CLICK, this.clickball, this);\r\n\t };\r\n\t GameTest.prototype.onClick = function (e) {\r\n\t var _a = this, world = _a.world, factor = _a.factor;\r\n\t var positionX = e.stageX / factor;\r\n\t var positionY = (engine.gameStage.stage.height - e.stageY) / factor;\r\n\t var display;\r\n\t if (Math.random() > 0.5) {\r\n\t var boxShape = new p2.Box({\r\n\t width: 200 / factor,\r\n\t height: 100 / factor,\r\n\t });\r\n\t var boxBody = new p2.Body({\r\n\t mass: 1,\r\n\t position: [positionX, positionY],\r\n\t angularVelocity: 1,\r\n\t });\r\n\t boxBody.addShape(boxShape);\r\n\t world.addBody(boxBody);\r\n\t {\r\n\t display = this.createBox(boxShape.width * factor, boxShape.height * factor);\r\n\t }\r\n\t }\r\n\t else {\r\n\t var boxShape = new p2.Circle({\r\n\t radius: 60 / factor,\r\n\t });\r\n\t var boxBody = new p2.Body({\r\n\t mass: 1,\r\n\t position: [positionX, positionY],\r\n\t });\r\n\t boxBody.addShape(boxShape);\r\n\t world.addBody(boxBody);\r\n\t {\r\n\t display = this.createBitmapByName(\"篮球\");\r\n\t }\r\n\t }\r\n\t boxBody.displays = [display];\r\n\t this.addChild(display);\r\n\t };\r\n\t GameTest.prototype.setup = function () {\r\n\t console.log(\"setup\");\r\n\t var world = new p2.World({});\r\n\t world.sleepMode = p2.World.BODY_SLEEPING;\r\n\t world.defaultContactMaterial.friction = 0.3;\r\n\t world.defaultContactMaterial.restitution = 0.7;\r\n\t var planeShape = new p2.Plane();\r\n\t var planeBody = new p2.Body({\r\n\t type: p2.Body.STATIC\r\n\t });\r\n\t planeBody.addShape(planeShape);\r\n\t planeBody.displays = [];\r\n\t world.addBody(planeBody);\r\n\t this.world = world;\r\n\t this.stage.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);\r\n\t var gameBg = new engine.Sprite(getTextureByName(\"背景\"));\r\n\t this.addChild(gameBg);\r\n\t var boardShape = new p2.Box({\r\n\t width: 20 / this.factor,\r\n\t height: 200 / this.factor\r\n\t });\r\n\t var boardBody = new p2.Body({\r\n\t position: [80 / this.factor, 1000 / this.factor]\r\n\t });\r\n\t boardBody.addShape(boardShape);\r\n\t var board = this.createBitmapByName('篮板');\r\n\t this.addChild(board);\r\n\t boardBody.displays = [board];\r\n\t this.world.addBody(boardBody);\r\n\t var boardPoint = new p2.Circle({\r\n\t radius: 1 / this.factor,\r\n\t });\r\n\t var boardPointBody = new p2.Body({\r\n\t position: [100 / this.factor,]\r\n\t });\r\n\t var boxShape = new p2.Circle({ radius: 60 / this.factor });\r\n\t this.boxBody = new p2.Body({\r\n\t mass: 0.1,\r\n\t position: [300 / this.factor, 900 / this.factor],\r\n\t velocity: [-5, -10],\r\n\t angularVelocity: -1\r\n\t });\r\n\t var balldisplay = this.createBitmapByName(\"篮球\");\r\n\t this.addChild(balldisplay);\r\n\t this.boxBody.displays = [balldisplay];\r\n\t this.boxBody.addShape(boxShape);\r\n\t this.world.addBody(this.boxBody);\r\n\t };\r\n\t GameTest.prototype.onEnterFrame = function () {\r\n\t this.world.step(60 / 1000);\r\n\t var len = this.world.bodies.length;\r\n\t for (var i = 0; i < len; i++) {\r\n\t var body = this.world.bodies[i];\r\n\t var display = body.displays[0];\r\n\t var stageHeight = engine.gameStage.stage.height;\r\n\t if (display) {\r\n\t display.x = body.position[0] * this.factor;\r\n\t display.y = stageHeight - body.position[1] * this.factor;\r\n\t display.rotation =\r\n\t ((body.angle + body.shapes[0].angle) * 180) / Math.PI;\r\n\t if (body.sleepState == p2.Body.SLEEPING) {\r\n\t display.alpha = 0.5;\r\n\t }\r\n\t else {\r\n\t display.alpha = 1;\r\n\t }\r\n\t }\r\n\t }\r\n\t if (this.boxBody.position[0] < -120 / this.factor) {\r\n\t this.boxBody.position[0] = (750 + 120) / this.factor;\r\n\t }\r\n\t if (this.boxBody.position[0] > (750 + 120) / this.factor) {\r\n\t this.boxBody.position[0] = -120 / this.factor;\r\n\t }\r\n\t };\r\n\t GameTest.prototype.clickball = function () {\r\n\t var direction = this.isRight ? -1 : 1;\r\n\t this.boxBody.velocity[0] = this.ballAddSpeedX * direction;\r\n\t this.boxBody.velocity[1] = this.ballAddSpeedY;\r\n\t this.boxBody.angularVelocity = -2 * direction;\r\n\t };\r\n\t GameTest.prototype.createPlane = function (x, y, w, h) {\r\n\t var sp = new engine.Shape();\r\n\t sp.beginFill(0x0000ff, 1);\r\n\t sp.drawRect(x, y, w, h);\r\n\t sp.endFill();\r\n\t this.addChild(sp);\r\n\t return sp;\r\n\t };\r\n\t GameTest.prototype.createBall = function (r) {\r\n\t var sp = new engine.Shape();\r\n\t sp.beginFill(0xff0000, 0.4);\r\n\t sp.drawCircle(0, 0, r);\r\n\t sp.endFill();\r\n\t return sp;\r\n\t };\r\n\t GameTest.prototype.createBox = function (width, height) {\r\n\t var sp = new engine.Shape();\r\n\t sp.beginFill(0xf0f0f0, 1);\r\n\t sp.drawRect(-width / 2, -height / 2, width, height);\r\n\t sp.endFill();\r\n\t return sp;\r\n\t };\r\n\t GameTest.prototype.createBitmapByName = function (name) {\r\n\t var imgContainer = new engine.Sprite();\r\n\t var img = new engine.Sprite(getTextureByName(name));\r\n\t img.anchorX = img.width / 2;\r\n\t img.anchorY = img.height / 2;\r\n\t img.x = -img.width / 2;\r\n\t img.y = -img.height / 2;\r\n\t imgContainer.addChild(img);\r\n\t return imgContainer;\r\n\t };\r\n\t GameTest.prototype.stop = function () { };\r\n\t return GameTest;\r\n\t}(engine.Container));\n\n\tvar props = {};\r\n\tfunction prepareProps() {\r\n\t var metaProps = getProps();\r\n\t engine.injectProp(props, metaProps);\r\n\t}\r\n\tfunction injectProps(p) {\r\n\t engine.injectProp(props, p);\r\n\t}\r\n\t//# sourceMappingURL=props.js.map\n\n\tvar GameWrapper = (function (_super) {\r\n\t tslib.__extends(GameWrapper, _super);\r\n\t function GameWrapper() {\r\n\t var _this = _super.call(this) || this;\r\n\t engine.globalEvent.addEventListener('game-start', _this.start, _this);\r\n\t engine.globalEvent.addEventListener('game-stop', _this.stop, _this);\r\n\t var gameTest = _this._gameTest = new GameTest();\r\n\t _this.addChild(gameTest);\r\n\t return _this;\r\n\t }\r\n\t GameWrapper.prototype.start = function (event) {\r\n\t injectProps(event.data);\r\n\t this._gameTest.start();\r\n\t };\r\n\t GameWrapper.prototype.stop = function (event) {\r\n\t this._gameTest.stop();\r\n\t };\r\n\t return GameWrapper;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=GameWrapper.js.map\n\n\tfunction index (props) {\r\n\t prepareProps();\r\n\t injectProps(props);\r\n\t var instance = new GameWrapper();\r\n\t return instance;\r\n\t}\r\n\t//# sourceMappingURL=index.js.map\n\n\treturn index;\n\n})));\n" "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.basket = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n\tfunction getTexture(uuid) {\n\t return engine.Texture.from(getAssetByUUID(uuid).uuid);\n\t}\n\tfunction getTextureByName(name) {\n\t return getTexture(engine.getAssetByName(name).uuid);\n\t}\n\n\tvar GameTest = (function (_super) {\n\t tslib.__extends(GameTest, _super);\n\t function GameTest() {\n\t var _this = _super.call(this) || this;\n\t _this.isDebug = true;\n\t _this.factor = 10;\n\t _this.isRight = false;\n\t _this.saleX = _this.isRight ? 1 : -1;\n\t _this.ballAddSpeedX = -10;\n\t _this.ballAddSpeedY = 30;\n\t _this.addEventListener(engine.Event.ADDED_TO_STAGE, _this.setup, _this);\n\t return _this;\n\t }\n\t GameTest.prototype.start = function () {\n\t console.log(\"starting\");\n\t this.stage.addEventListener(engine.MouseEvent.CLICK, this.clickball, this);\n\t };\n\t GameTest.prototype.onClick = function (e) {\n\t var _a = this, world = _a.world, factor = _a.factor;\n\t var positionX = e.stageX / factor;\n\t var positionY = (engine.gameStage.stage.height - e.stageY) / factor;\n\t var display;\n\t if (Math.random() > 0.5) {\n\t var boxShape = new p2.Box({\n\t width: 200 / factor,\n\t height: 100 / factor,\n\t });\n\t var boxBody = new p2.Body({\n\t mass: 1,\n\t position: [positionX, positionY],\n\t angularVelocity: 1,\n\t });\n\t boxBody.addShape(boxShape);\n\t world.addBody(boxBody);\n\t {\n\t display = this.createBox(boxShape.width * factor, boxShape.height * factor);\n\t }\n\t }\n\t else {\n\t var boxShape = new p2.Circle({\n\t radius: 60 / factor,\n\t });\n\t var boxBody = new p2.Body({\n\t mass: 1,\n\t position: [positionX, positionY],\n\t });\n\t boxBody.addShape(boxShape);\n\t world.addBody(boxBody);\n\t {\n\t display = this.createBitmapByName(\"篮球\");\n\t }\n\t }\n\t boxBody.displays = [display];\n\t this.addChild(display);\n\t };\n\t GameTest.prototype.setup = function () {\n\t console.log(\"setup\");\n\t var world = new p2.World({});\n\t world.sleepMode = p2.World.BODY_SLEEPING;\n\t world.defaultContactMaterial.friction = 0.3;\n\t world.defaultContactMaterial.restitution = 0.7;\n\t var planeShape = new p2.Plane();\n\t var planeBody = new p2.Body({\n\t type: p2.Body.STATIC\n\t });\n\t planeBody.addShape(planeShape);\n\t planeBody.displays = [];\n\t world.addBody(planeBody);\n\t this.world = world;\n\t this.stage.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);\n\t var gameBg = new engine.Sprite(getTextureByName(\"背景\"));\n\t this.addChild(gameBg);\n\t var boardShape = new p2.Box({\n\t width: 20 / this.factor,\n\t height: 200 / this.factor\n\t });\n\t var boardBody = new p2.Body({\n\t position: [80 / this.factor, 1000 / this.factor]\n\t });\n\t boardBody.addShape(boardShape);\n\t var board = this.createBitmapByName('篮板');\n\t this.addChild(board);\n\t boardBody.displays = [board];\n\t this.world.addBody(boardBody);\n\t var boardPoint = new p2.Circle({\n\t radius: 1 / this.factor,\n\t });\n\t var boardPointBody = new p2.Body({\n\t position: [100 / this.factor, 800 / this.factor]\n\t });\n\t boardPointBody.addShape(boardPoint);\n\t boardPointBody.displays = [];\n\t var boxShape = new p2.Circle({ radius: 60 / this.factor });\n\t this.boxBody = new p2.Body({\n\t mass: 0.1,\n\t position: [300 / this.factor, 900 / this.factor],\n\t velocity: [-5, -10],\n\t angularVelocity: -1\n\t });\n\t var balldisplay = this.createBitmapByName(\"篮球\");\n\t this.addChild(balldisplay);\n\t this.boxBody.displays = [balldisplay];\n\t this.boxBody.addShape(boxShape);\n\t this.world.addBody(this.boxBody);\n\t };\n\t GameTest.prototype.onEnterFrame = function () {\n\t this.world.step(60 / 1000);\n\t var len = this.world.bodies.length;\n\t for (var i = 0; i < len; i++) {\n\t var body = this.world.bodies[i];\n\t var display = body.displays[0];\n\t var stageHeight = engine.gameStage.stage.height;\n\t if (display) {\n\t display.x = body.position[0] * this.factor;\n\t display.y = stageHeight - body.position[1] * this.factor;\n\t display.rotation =\n\t ((body.angle + body.shapes[0].angle) * 180) / Math.PI;\n\t if (body.sleepState == p2.Body.SLEEPING) {\n\t display.alpha = 0.5;\n\t }\n\t else {\n\t display.alpha = 1;\n\t }\n\t }\n\t }\n\t if (this.boxBody.position[0] < -120 / this.factor) {\n\t this.boxBody.position[0] = (750 + 120) / this.factor;\n\t }\n\t if (this.boxBody.position[0] > (750 + 120) / this.factor) {\n\t this.boxBody.position[0] = -120 / this.factor;\n\t }\n\t };\n\t GameTest.prototype.clickball = function () {\n\t var direction = this.isRight ? -1 : 1;\n\t this.boxBody.velocity[0] = this.ballAddSpeedX * direction;\n\t this.boxBody.velocity[1] = this.ballAddSpeedY;\n\t this.boxBody.angularVelocity = -2 * direction;\n\t };\n\t GameTest.prototype.createPlane = function (x, y, w, h) {\n\t var sp = new engine.Shape();\n\t sp.beginFill(0x0000ff, 1);\n\t sp.drawRect(x, y, w, h);\n\t sp.endFill();\n\t this.addChild(sp);\n\t return sp;\n\t };\n\t GameTest.prototype.createBall = function (r) {\n\t var sp = new engine.Shape();\n\t sp.beginFill(0xff0000, 0.4);\n\t sp.drawCircle(0, 0, r);\n\t sp.endFill();\n\t return sp;\n\t };\n\t GameTest.prototype.createBox = function (width, height) {\n\t var sp = new engine.Shape();\n\t sp.beginFill(0xf0f0f0, 1);\n\t sp.drawRect(-width / 2, -height / 2, width, height);\n\t sp.endFill();\n\t return sp;\n\t };\n\t GameTest.prototype.createBitmapByName = function (name) {\n\t var imgContainer = new engine.Sprite();\n\t var img = new engine.Sprite(getTextureByName(name));\n\t img.anchorX = img.width / 2;\n\t img.anchorY = img.height / 2;\n\t img.x = -img.width / 2;\n\t img.y = -img.height / 2;\n\t imgContainer.addChild(img);\n\t return imgContainer;\n\t };\n\t GameTest.prototype.stop = function () { };\n\t return GameTest;\n\t}(engine.Container));\n\n\tvar props = {};\n\tfunction prepareProps() {\n\t var metaProps = getProps();\n\t engine.injectProp(props, metaProps);\n\t}\n\tfunction injectProps(p) {\n\t engine.injectProp(props, p);\n\t}\n\n\tvar GameWrapper = (function (_super) {\n\t tslib.__extends(GameWrapper, _super);\n\t function GameWrapper() {\n\t var _this = _super.call(this) || this;\n\t engine.globalEvent.addEventListener('game-start', _this.start, _this);\n\t engine.globalEvent.addEventListener('game-stop', _this.stop, _this);\n\t var gameTest = _this._gameTest = new GameTest();\n\t _this.addChild(gameTest);\n\t return _this;\n\t }\n\t GameWrapper.prototype.start = function (event) {\n\t injectProps(event.data);\n\t this._gameTest.start();\n\t };\n\t GameWrapper.prototype.stop = function (event) {\n\t this._gameTest.stop();\n\t };\n\t return GameWrapper;\n\t}(engine.Container));\n\n\tfunction index (props) {\n\t prepareProps();\n\t injectProps(props);\n\t var instance = new GameWrapper();\n\t return instance;\n\t}\n\n\treturn index;\n\n})));\n"
} }
...@@ -234,5 +234,5 @@ ...@@ -234,5 +234,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 };\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 = 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));\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.Image(getTextureByName(\"ganzi\"));\r\n\t this.addChild(this._strut);\r\n\t this._strut.y = this.gany;\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.y = this.gany;\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.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 engine.globalEvent.dispatchEvent(\"bjxd-game-inmove\", {\r\n\t \"canstop\": true\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 engine.globalEvent.dispatchEvent(\"bjxd-game-inmove\", {\r\n\t \"canstop\": true\r\n\t });\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 engine.globalEvent.dispatchEvent(\"bjxd-game-inmove\", {\r\n\t \"canstop\": true\r\n\t });\r\n\t };\r\n\t GameView.prototype.setGuide = function () {\r\n\t var _this = this;\r\n\t this._road.setGuide();\r\n\t var guideLayer = this.guideLayer = new GuideLayer();\r\n\t this.addChild(guideLayer);\r\n\t this.guideLayer.show(1, { x: 20, y: 650, guideText: props.guideText1 }, function () {\r\n\t var posX = _this._road.getMovePos();\r\n\t _this.guideLayer.show(2, { x: posX + 20, y: 620, guideText: props.guideText2 }, function () {\r\n\t _this.initTouch();\r\n\t _this.registerEvent();\r\n\t });\r\n\t });\r\n\t };\r\n\t GameView.prototype.initLabScore = function () {\r\n\t };\r\n\t GameView.prototype.registerEvent = function () {\r\n\t this.removeListener();\r\n\t this.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onMouseDown, this);\r\n\t this.addEventListener(engine.MouseEvent.MOUSE_UP, this.onMouseUp, this);\r\n\t };\r\n\t GameView.prototype.removeListener = function () {\r\n\t this.removeEventListener(engine.MouseEvent.MOUSE_DOWN, this.onMouseDown, this);\r\n\t this.removeEventListener(engine.MouseEvent.MOUSE_UP, this.onMouseUp, this);\r\n\t };\r\n\t GameView.prototype.initTouch = function () {\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 engine.globalEvent.dispatchEvent(\"bjxd-game-inmove\", {\r\n\t \"canstop\": false\r\n\t });\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 engine.globalEvent.dispatchEvent(\"bjxd-game-inmove\", {\r\n\t \"canstop\": 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 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 = 20;\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-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));\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 = {};\n\tfunction prepareProps() {\n\t var metaProps = getProps();\n\t engine.injectProp(props, metaProps);\n\t}\n\tfunction injectProps(p) {\n\t engine.injectProp(props, p);\n\t}\n\n\tvar ObjectPool = engine.ObjectPool;\n\tvar Road = (function (_super) {\n\t tslib.__extends(Road, _super);\n\t function Road() {\n\t return _super !== null && _super.apply(this, arguments) || this;\n\t }\n\t Road.prototype.setup = function () {\n\t this.lastPos = 0;\n\t this.addPier();\n\t };\n\t Road.prototype.getFristPier = function () {\n\t return this.getChildAt(0).width;\n\t };\n\t Road.prototype.getDistance = function () {\n\t var distance = [];\n\t var pier1 = this.getChildAt(0);\n\t var pier2 = this.getChildAt(1);\n\t distance.push(pier2.x - pier1.x);\n\t distance.push(pier2.width);\n\t return distance;\n\t };\n\t Road.prototype.addPier = function () {\n\t while (this.children.length < props.pierCount + 1) {\n\t var childrenNum = this.children.length;\n\t var randomPos = this.makeRandomFloat(props.pierMaxDistance, props.pierMinDistance);\n\t var pier = ObjectPool.getObject('pier');\n\t this.addChild(pier);\n\t pier.changeBg();\n\t if (childrenNum == 0) {\n\t pier.x = 0;\n\t }\n\t else {\n\t pier.x = this.lastPos + randomPos;\n\t }\n\t this.lastPos = pier.x;\n\t }\n\t };\n\t Road.prototype.changeBg = function () {\n\t var nume = this.children.length;\n\t for (var i = 0; i < nume; i++) {\n\t var ipier = this.getChildAt(i);\n\t ipier.changeBg();\n\t }\n\t };\n\t Road.prototype.moveAddPier = function () {\n\t var randomPos = this.makeRandomFloat(props.pierMaxDistance, props.pierMinDistance);\n\t var pier = ObjectPool.getObject('pier');\n\t var lastChild = this.getChildAt(this.children.length - 1);\n\t pier.x = lastChild.x + randomPos;\n\t this.addChild(pier);\n\t pier.changeBg();\n\t };\n\t Road.prototype.makeRandomFloat = function (max, min) {\n\t if (min === void 0) { min = 0; }\n\t return Math.random() * (max - min) + min;\n\t };\n\t Road.prototype.setViewport = function () {\n\t var _this = this;\n\t var tmpMovepos = this.getMovePos();\n\t this.children.forEach(function (item, index) {\n\t _this.playTween(item, index, tmpMovepos);\n\t });\n\t };\n\t Road.prototype.getMovePos = function () {\n\t var movePos = this.getChildAt(1);\n\t return movePos.x;\n\t };\n\t Road.prototype.playTween = function (item, index, tmpMovepos) {\n\t var _this = this;\n\t engine.Tween.get(item, { loop: false })\n\t .to({ x: item.x - tmpMovepos }, props.pierMoveTime)\n\t .call(function () {\n\t if (_this.getChildIndex(item) == 0) {\n\t engine.Tween.removeTweens(item);\n\t _this.removeChild(item);\n\t ObjectPool.recycleObject('pier', item);\n\t }\n\t if (index == 0) {\n\t _this.moveAddPier();\n\t }\n\t });\n\t };\n\t Road.prototype.getStartGold = function (index, isClose) {\n\t if (isClose === void 0) { isClose = true; }\n\t var tmpNode = this.getChildAt(index);\n\t var haveGold = tmpNode.haveGold;\n\t if (haveGold && isClose) {\n\t tmpNode.closeGold();\n\t }\n\t return haveGold;\n\t };\n\t Road.prototype.setGuide = function () {\n\t var tmpNode = this.getChildAt(1);\n\t if (!tmpNode.haveGold) {\n\t tmpNode.children.forEach(function (item) {\n\t if (item.name == 'gold') {\n\t item.visible = true;\n\t }\n\t });\n\t tmpNode.haveGold = true;\n\t }\n\t };\n\t return Road;\n\t}(engine.Container));\n\n\tfunction getTexture(uuid) {\n\t return engine.Texture.from(getAssetByUUID(uuid).uuid);\n\t}\n\tfunction getTextureByName(name) {\n\t return getTexture(engine.getAssetByName(name).uuid);\n\t}\n\tfunction getStage() {\n\t return engine.gameStage.stage;\n\t}\n\tfunction createSvga(name) {\n\t var inst = new svga.Svga();\n\t inst.source = engine.getAssetByName(name).uuid;\n\t return inst;\n\t}\n\n\tvar GuideLayer = (function (_super) {\n\t tslib.__extends(GuideLayer, _super);\n\t function GuideLayer() {\n\t var _this = _super.call(this) || this;\n\t _this.setup();\n\t return _this;\n\t }\n\t GuideLayer.prototype.setup = function () {\n\t };\n\t GuideLayer.prototype.show = function (id, options, callback) {\n\t this.visible = true;\n\t this._callBack = callback ? callback : null;\n\t if (!this.guideMask) {\n\t var _a = this.stage, width = _a.width, height = _a.height;\n\t this.guideMask = new engine.Container();\n\t this.addChild(this.guideMask);\n\t this.guideImg = new engine.Image();\n\t this.guideMask.addChild(this.guideImg);\n\t this.shouzhi = new engine.Image(getTextureByName(\"shouzhi\"));\n\t this.guideMask.addChild(this.shouzhi);\n\t }\n\t this.guideImg.texture = getTextureByName(\"yindao\" + id);\n\t this.guideStep(id);\n\t this.once(engine.MouseEvent.CLICK, function () {\n\t this.visible = false;\n\t if (this._callBack) {\n\t this._callBack();\n\t }\n\t }, this);\n\t };\n\t GuideLayer.prototype.guideStep = function (id) {\n\t if (id == 1) {\n\t this.shouzhi.x = 244;\n\t this.shouzhi.y = 812;\n\t }\n\t if (id == 2) {\n\t this.shouzhi.x = 346;\n\t this.shouzhi.y = 1108;\n\t }\n\t };\n\t return GuideLayer;\n\t}(engine.Container));\n\n\tvar LoopComponent = (function (_super) {\n\t tslib.__extends(LoopComponent, _super);\n\t function LoopComponent() {\n\t var _this = _super.call(this) || this;\n\t _this.onceInfo = { width: 0, height: 0, count: 0 };\n\t _this.loopInfo = { width: 0, height: 0, count: 0 };\n\t _this.parts = [];\n\t return _this;\n\t }\n\t LoopComponent.prototype.setup = function (parts, info) {\n\t var _this = this;\n\t parts.forEach(function (item, index) {\n\t var part;\n\t if (typeof item == 'string') {\n\t if (item.length > 0) {\n\t part = new engine.Sprite(getTextureByName(item));\n\t }\n\t else {\n\t part = new engine.Sprite();\n\t }\n\t }\n\t else if (item instanceof engine.Texture) {\n\t part = new engine.Sprite(item);\n\t }\n\t else {\n\t part = item;\n\t }\n\t _this.addChild(part);\n\t _this.parts.push(part);\n\t if (index == 0) {\n\t info.width = part.width;\n\t info.height = part.height;\n\t }\n\t });\n\t info.count = parts.length;\n\t this.setViewport(0, 0);\n\t };\n\t LoopComponent.prototype.changeBg = function (changName) {\n\t this.parts.forEach(function (item, index) {\n\t if (changName && changName.length > 0) {\n\t item.texture = getTextureByName(changName);\n\t }\n\t });\n\t };\n\t LoopComponent.prototype.setupLoop = function (resArr) {\n\t this.setup(resArr, this.loopInfo);\n\t };\n\t LoopComponent.prototype.setViewport = function (x, y) {\n\t if (y === void 0) { y = 0; }\n\t var sizeField = y == 0 ? 'width' : 'height';\n\t var posField = y == 0 ? 'x' : 'y';\n\t var pos = y == 0 ? x : y;\n\t var index;\n\t var onceSize = this.onceInfo[sizeField];\n\t var onceCount = this.onceInfo.count;\n\t var loopCount = this.loopInfo.count;\n\t var loopSize = this.loopInfo[sizeField];\n\t index = onceSize == 0 ? -1 : Math.floor(pos / onceSize);\n\t if (index < 0 || index >= onceCount) {\n\t var loopIndex = Math.floor((pos - onceCount * onceSize) / this.loopInfo[sizeField]);\n\t index = onceCount + loopIndex;\n\t }\n\t var formerIndex = index < onceCount ? index : (index) % loopCount + onceCount;\n\t var latterIndex = index < onceCount ? index + 1 : (index - onceCount + 1) % loopCount + onceCount;\n\t var former = this.parts[formerIndex];\n\t var latter = this.parts[latterIndex];\n\t if (!former || !latter) {\n\t console.log(formerIndex, latterIndex);\n\t }\n\t former[posField] = -(pos - loopSize * (index < onceCount ? index : index - onceCount) - (index < onceCount ? 0 : onceCount * onceSize));\n\t latter[posField] = former.x + (index < onceCount ? onceSize : loopSize);\n\t };\n\t return LoopComponent;\n\t}(engine.Container));\n\n\tvar Background = (function (_super) {\n\t tslib.__extends(Background, _super);\n\t function Background() {\n\t var _this = _super !== null && _super.apply(this, arguments) || this;\n\t _this.partResHHL = ['bg1', ''];\n\t _this.partResHB = ['bg2', ''];\n\t _this.partResWH = ['bg3', ''];\n\t _this.speeds = [];\n\t _this.resArray = [];\n\t _this.frameMovePos = 0;\n\t return _this;\n\t }\n\t Background.prototype.initBg = function () {\n\t this.sumMovePos = 0;\n\t this.speeds.push(props.afterBGMoveSpeed);\n\t this.speeds.push(props.frontBGMoveSpeed);\n\t var bottomBg = new engine.Rect();\n\t bottomBg.x = 0;\n\t bottomBg.y = 0;\n\t bottomBg.width = getStage().width;\n\t bottomBg.height = 0;\n\t bottomBg.fillColor = 0x75c9f5;\n\t this.addChild(bottomBg);\n\t this.resArray.push(this.partResHHL);\n\t this.resArray.push(this.partResHB);\n\t this.resArray.push(this.partResWH);\n\t var parts = [];\n\t for (var i = 0; i < 2; i++) {\n\t var part = new LoopComponent();\n\t part.setupLoop([\n\t this.resArray[0][i],\n\t this.resArray[0][i],\n\t ]);\n\t parts.push(part);\n\t this.addChild(part);\n\t }\n\t parts[1].y = 200;\n\t };\n\t Background.prototype.setViewport = function (pos) {\n\t this.needFrameSum = (props.pierMoveTime / 1000) * 60;\n\t this.frameMovePos = pos / this.needFrameSum;\n\t this.frameIndex = 0;\n\t this.addEventListener(engine.Event.ENTER_FRAME, this.frameBack, this);\n\t };\n\t Background.prototype.frameBack = function () {\n\t if (this.frameIndex < this.needFrameSum) {\n\t for (var i = 0; i < 2; i++) {\n\t var part = this.getChildAt(i + 1);\n\t var speed = this.speeds[i];\n\t var tmpPos = ((this.frameMovePos * this.frameIndex) + this.sumMovePos) * speed;\n\t part.setViewport(tmpPos);\n\t }\n\t this.frameIndex++;\n\t }\n\t else {\n\t this.sumMovePos += this.frameMovePos * this.needFrameSum;\n\t this.frameIndex = 0;\n\t this.removeEventListener(engine.Event.ENTER_FRAME, this.frameBack, this);\n\t }\n\t };\n\t Background.prototype.changeBg = function (index) {\n\t for (var i = 0; i < 2; i++) {\n\t var part = this.getChildAt(i + 1);\n\t part.changeBg(this.resArray[index][i]);\n\t if (i == 1 && index == 1) {\n\t part.y = 400;\n\t }\n\t if (i == 1 && index == 2) {\n\t part.y = 250;\n\t }\n\t }\n\t };\n\t return Background;\n\t}(engine.Container));\n\n\tvar Pier = (function (_super) {\n\t tslib.__extends(Pier, _super);\n\t function Pier() {\n\t var _this = _super.call(this) || this;\n\t _this.part1tex = \"zhuzi1\";\n\t _this.part2tex = \"zhuzi2\";\n\t _this.part3tex = \"zhuzi3\";\n\t _this.texname = \"\";\n\t _this.zhuy = 1006;\n\t _this.bmp = new engine.Sprite();\n\t _this.addChild(_this.bmp);\n\t return _this;\n\t }\n\t Pier.prototype.init = function () {\n\t var bmp = this.bmp;\n\t bmp.alpha = 1;\n\t this.changeBg();\n\t bmp.x = 0;\n\t bmp.y = this.zhuy;\n\t };\n\t Pier.prototype.changeBg = function () {\n\t var texstr;\n\t if (GameView.bgIndex == 0) {\n\t texstr = this.part1tex;\n\t }\n\t else if (GameView.bgIndex == 1) {\n\t texstr = this.part2tex;\n\t }\n\t else {\n\t texstr = this.part3tex;\n\t }\n\t if (this.texname != texstr) {\n\t this.texname = texstr;\n\t this.bmp.texture = getTextureByName(texstr);\n\t }\n\t };\n\t Pier.prototype.setShowGold = function () {\n\t var nodeGold = this.getChildByName('gold');\n\t var randomWard = Math.random();\n\t nodeGold.alpha = 1;\n\t var isShow = randomWard < props.reward ? true : false;\n\t nodeGold.visible = isShow;\n\t this.haveGold = isShow;\n\t };\n\t Pier.prototype.setGoldPosX = function (bmp) {\n\t var nodeGold = this.getChildByName('gold');\n\t var pos = bmp.width / 2 - nodeGold.width / 2;\n\t nodeGold.x = pos;\n\t nodeGold.y = this.zhuy - nodeGold.height - 50;\n\t nodeGold.visible = false;\n\t };\n\t Pier.prototype.closeGold = function () {\n\t var _this = this;\n\t this.children.forEach(function (item) {\n\t if (item.name == 'gold') {\n\t item.anchorX = item.width / 2;\n\t item.anchorY = item.height / 2;\n\t engine.Tween.get(item, { loop: false })\n\t .to({ scaleX: 2.5, scaleY: 2.5 }, 200, engine.Ease.cubicOut)\n\t .to({ scaleX: 1, scaleY: 1, alpha: 0 }, 200, engine.Ease.cubicIn)\n\t .call(function () {\n\t item.visible = false;\n\t _this.haveGold = false;\n\t });\n\t }\n\t });\n\t };\n\t return Pier;\n\t}(engine.Container));\n\n\tvar Player = (function (_super) {\n\t tslib.__extends(Player, _super);\n\t function Player() {\n\t var _this = _super !== null && _super.apply(this, arguments) || this;\n\t _this.playery = 878;\n\t return _this;\n\t }\n\t Player.prototype.initPlayer = function (pierWidth) {\n\t this.pierWidth = pierWidth;\n\t this._container = new engine.Container();\n\t this.addChild(this._container);\n\t this.playerNode = createSvga('walk');\n\t this._container.addChild(this.playerNode);\n\t this.playerNode.y = this.playery;\n\t this.playerNode.x = pierWidth / 2 - 50;\n\t this.playerNode.play();\n\t this._container.visible = false;\n\t };\n\t Player.prototype.revive = function () {\n\t this._container.x = 0;\n\t this._container.y = 0;\n\t this.playerNode.x = this.pierWidth / 2 - 50;\n\t this.playerNode.y = this.playery;\n\t };\n\t Player.prototype.setViewport = function (pos, callBack, pierWidth) {\n\t var tmpPos = 0;\n\t var isSuccess = false;\n\t if (!pierWidth) {\n\t tmpPos = pos;\n\t isSuccess = true;\n\t }\n\t else {\n\t tmpPos = pierWidth - this.playerNode.x + pos - 60;\n\t }\n\t this.playGoTween(tmpPos, callBack, isSuccess);\n\t };\n\t Player.prototype.playGoTween = function (pos, callBack, isSuccess) {\n\t var _this = this;\n\t engine.Tween.get(this._container, { loop: false })\n\t .to({ x: pos }, props.playerMoveSpeed)\n\t .call(function () {\n\t engine.Tween.removeTweens(_this._container);\n\t if (isSuccess) {\n\t if (callBack) {\n\t callBack();\n\t }\n\t }\n\t else {\n\t _this.playDropTween(callBack);\n\t }\n\t });\n\t };\n\t Player.prototype.playDropTween = function (callBack) {\n\t var _this = this;\n\t engine.Tween.get(this._container, { loop: false })\n\t .to({ y: 2000 }, 1000)\n\t .call(function () {\n\t engine.Tween.removeTweens(_this._container);\n\t if (callBack) {\n\t callBack();\n\t }\n\t });\n\t };\n\t Player.prototype.setBackViewport = function (callBack) {\n\t var _this = this;\n\t engine.Tween.get(this._container, { loop: false })\n\t .to({ x: 0 }, props.pierMoveTime)\n\t .call(function () {\n\t engine.Tween.removeTweens(_this._container);\n\t if (callBack) {\n\t callBack();\n\t }\n\t });\n\t };\n\t return Player;\n\t}(engine.Container));\n\n\tvar Strut = (function (_super) {\n\t tslib.__extends(Strut, _super);\n\t function Strut() {\n\t var _this = _super !== null && _super.apply(this, arguments) || this;\n\t _this.gany = 1005;\n\t return _this;\n\t }\n\t Strut.prototype.init = function () {\n\t this._strut = new engine.Image(getTextureByName(\"ganzi\"));\n\t this.addChild(this._strut);\n\t this._strut.y = this.gany;\n\t this._strut.rotation = 180;\n\t };\n\t Strut.prototype.onMouseDown = function (pierWidth, distance, callBack) {\n\t var paddingx = 20;\n\t if (GameView.bgIndex == 0) {\n\t paddingx = 20;\n\t }\n\t else if (GameView.bgIndex == 1) {\n\t paddingx = 30;\n\t }\n\t else if (GameView.bgIndex == 2) {\n\t paddingx = 20;\n\t }\n\t this._strut.x = pierWidth - paddingx;\n\t this._distance = distance;\n\t this._callBack = callBack;\n\t this._strut.visible = true;\n\t this.addEventListener(engine.Event.ENTER_FRAME, this.frameStrut, this);\n\t };\n\t Strut.prototype.onMouseUp = function () {\n\t var _this = this;\n\t this.removeEventListener(engine.Event.ENTER_FRAME, this.frameStrut, this);\n\t setTimeout(function () {\n\t _this.strutRotation();\n\t }, 200);\n\t };\n\t Strut.prototype.strutRotation = function () {\n\t var _this = this;\n\t engine.Tween.get(this._strut, { loop: false })\n\t .to({ rotation: 270 }, props.strutRotationSpeed)\n\t .call(function () {\n\t _this.judgeResult();\n\t engine.Tween.removeTweens(_this._strut);\n\t });\n\t };\n\t Strut.prototype.judgeResult = function () {\n\t var isSuccess = false;\n\t var paddingx = 20;\n\t var chax = 20;\n\t if (GameView.bgIndex == 0) {\n\t paddingx = 20;\n\t chax = 20;\n\t }\n\t else if (GameView.bgIndex == 1) {\n\t paddingx = 3;\n\t chax = 39;\n\t }\n\t else if (GameView.bgIndex == 2) {\n\t paddingx = 20;\n\t chax = 20;\n\t }\n\t var mindis = this._distance[0] - this._distance[1] + chax;\n\t var maxdis = this._distance[0] + paddingx;\n\t if (mindis <= this._strut.height && this._strut.height <= maxdis) {\n\t isSuccess = true;\n\t }\n\t if (this._callBack) {\n\t this._callBack(isSuccess);\n\t }\n\t };\n\t Strut.prototype.frameStrut = function () {\n\t var maxdis = 700;\n\t if (this._strut.height < maxdis) {\n\t if (this._strut.height + GameView.speed > maxdis) {\n\t this._strut.height = maxdis;\n\t }\n\t else {\n\t this._strut.height += GameView.speed;\n\t }\n\t }\n\t };\n\t Strut.prototype.rest = function () {\n\t this._strut.y = this.gany;\n\t this._strut.rotation = 180;\n\t this._strut.height = 0;\n\t this._strut.visible = false;\n\t };\n\t Strut.prototype.getStrutHeight = function () {\n\t var distance = this._strut.height > 1000 ? 1000 : this._strut.height;\n\t return distance;\n\t };\n\t return Strut;\n\t}(engine.Container));\n\n\tvar ObjectPool$1 = engine.ObjectPool;\n\tvar PoolName = 'pier';\n\tObjectPool$1.registerPool(PoolName, function () {\n\t return new Pier();\n\t}, function (item, data) {\n\t item.init();\n\t});\n\tvar GameView = (function (_super) {\n\t tslib.__extends(GameView, _super);\n\t function GameView() {\n\t var _this = _super.call(this) || this;\n\t _this.moveX = 0;\n\t _this.playery = 878;\n\t _this.inani = true;\n\t _this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);\n\t return _this;\n\t }\n\t GameView.prototype.setup = function () {\n\t if (this._hasSetup) {\n\t return;\n\t }\n\t this._hasSetup = true;\n\t this._backgroud = new Background();\n\t this.addChild(this._backgroud);\n\t this._backgroud.initBg();\n\t var road = this._road = new Road();\n\t this.addChild(road);\n\t road.setup();\n\t var pierWidth = this._road.getFristPier();\n\t var player = this._player = new Player();\n\t this.addChild(player);\n\t player.initPlayer(pierWidth);\n\t this.pierWidth = pierWidth;\n\t this.xiacheNode = createSvga(\"xiache\");\n\t this.addChild(this.xiacheNode);\n\t this.xiacheNode.y = this.playery - 35;\n\t this.xiacheNode.x = this.pierWidth / 2 - 100;\n\t this.xiacheNode.stop();\n\t this.xiacheNode.name = \"xiacheanm\";\n\t console.log(\"下车动画帧数\", this.xiacheNode.totalFrames, this.xiacheNode);\n\t this.xiacheNode.visible = false;\n\t var strut = this._strut = new Strut();\n\t this.addChild(strut);\n\t strut.init();\n\t };\n\t GameView.prototype.playComp = function () {\n\t var curframe = this.xiacheNode.currentFrame;\n\t if (curframe == this.xiacheNode.totalFrames) {\n\t this.inani = false;\n\t this.xiacheNode.stop();\n\t this.xiacheNode.removeEventListener(engine.Event.ENTER_FRAME, this.playComp, this);\n\t for (var i = 0; i < 15; i++) {\n\t if (i < 12) {\n\t this.xiacheNode.getChildAt(i).visible = false;\n\t }\n\t }\n\t this._player._container.visible = true;\n\t }\n\t };\n\t GameView.prototype.start = function (guide) {\n\t return tslib.__awaiter(this, void 0, void 0, function () {\n\t var initScore;\n\t return tslib.__generator(this, function (_a) {\n\t this._isTouchLayer = true;\n\t this._sumScore = 0;\n\t this._isMouseDown = false;\n\t this._guide = guide;\n\t this._player.revive();\n\t this.closeStrut();\n\t initScore = 0;\n\t this.updateScore(initScore);\n\t if (this.xiacheNode.x < this.pierWidth / 2 - 105) {\n\t this.startAnm();\n\t }\n\t if (this._guide == '1') {\n\t this.setGuide();\n\t }\n\t else {\n\t this.initTouch();\n\t this.registerEvent();\n\t }\n\t engine.globalEvent.dispatchEvent(\"bjxd-game-inmove\", {\n\t \"canstop\": true\n\t });\n\t return [2];\n\t });\n\t });\n\t };\n\t GameView.prototype.startAnm = function () {\n\t this.inani = true;\n\t this.xiacheNode.visible = true;\n\t for (var i = 0; i < 15; i++) {\n\t if (i < 12) {\n\t this.xiacheNode.getChildAt(i).visible = true;\n\t }\n\t }\n\t this.xiacheNode.x = this.pierWidth / 2 - 100;\n\t this._player._container.visible = false;\n\t this.xiacheNode.gotoAndPlay(1);\n\t this.xiacheNode.addEventListener(engine.Event.ENTER_FRAME, this.playComp, this);\n\t };\n\t GameView.prototype.reset = function () {\n\t this._sumScore = 0;\n\t engine.globalEvent.dispatchEvent('bjxd-game-score', { score: this._sumScore });\n\t this._player.revive();\n\t this.closeStrut();\n\t this.changeBg(GameView.bgIndex);\n\t this.startAnm();\n\t engine.globalEvent.dispatchEvent(\"bjxd-game-inmove\", {\n\t \"canstop\": true\n\t });\n\t };\n\t GameView.prototype.revive = function () {\n\t this._player.revive();\n\t this.startAnm();\n\t this._isTouchLayer = true;\n\t this.closeStrut();\n\t engine.globalEvent.dispatchEvent(\"bjxd-game-inmove\", {\n\t \"canstop\": true\n\t });\n\t };\n\t GameView.prototype.setGuide = function () {\n\t var _this = this;\n\t this._road.setGuide();\n\t var guideLayer = this.guideLayer = new GuideLayer();\n\t this.addChild(guideLayer);\n\t this.guideLayer.show(1, { x: 20, y: 650, guideText: props.guideText1 }, function () {\n\t var posX = _this._road.getMovePos();\n\t _this.guideLayer.show(2, { x: posX + 20, y: 620, guideText: props.guideText2 }, function () {\n\t _this.initTouch();\n\t _this.registerEvent();\n\t });\n\t });\n\t };\n\t GameView.prototype.initLabScore = function () {\n\t };\n\t GameView.prototype.registerEvent = function () {\n\t this.removeListener();\n\t this.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onMouseDown, this);\n\t this.addEventListener(engine.MouseEvent.MOUSE_UP, this.onMouseUp, this);\n\t };\n\t GameView.prototype.removeListener = function () {\n\t this.removeEventListener(engine.MouseEvent.MOUSE_DOWN, this.onMouseDown, this);\n\t this.removeEventListener(engine.MouseEvent.MOUSE_UP, this.onMouseUp, this);\n\t };\n\t GameView.prototype.initTouch = function () {\n\t };\n\t GameView.prototype.setScoreShow = function () {\n\t };\n\t GameView.prototype.onMouseDown = function () {\n\t if (this._isTouchLayer && !this.inani) {\n\t engine.globalEvent.dispatchEvent(\"bjxd-game-inmove\", {\n\t \"canstop\": false\n\t });\n\t this._isMouseDown = true;\n\t this._strut.onMouseDown(this._road.getFristPier(), this._road.getDistance(), this.goCallBcak.bind(this));\n\t }\n\t };\n\t GameView.prototype.onMouseUp = function () {\n\t if (this._isTouchLayer && this._isMouseDown) {\n\t this._strut.onMouseUp();\n\t this._isMouseDown = false;\n\t this._isTouchLayer = false;\n\t }\n\t };\n\t GameView.prototype.goCallBcak = function (isSuccess) {\n\t var _this = this;\n\t if (isSuccess) {\n\t var movePos = this._road.getMovePos();\n\t if (this._road.getStartGold(1, false)) {\n\t this.updateScore(props.singleScore + props.goldScore);\n\t }\n\t else {\n\t this.updateScore(props.singleScore);\n\t }\n\t this._player.setViewport(movePos, this.complete.bind(this));\n\t }\n\t else {\n\t this._player.setViewport(this._strut.getStrutHeight(), function () {\n\t engine.globalEvent.dispatchEvent('bjxd-game-over', { score: _this._sumScore });\n\t }, this._road.getFristPier());\n\t }\n\t };\n\t GameView.prototype.complete = function () {\n\t var _this = this;\n\t this._road.getStartGold(1);\n\t var movePos = this._road.getMovePos();\n\t this._road.setViewport();\n\t this._backgroud.setViewport(movePos);\n\t this._player.setBackViewport(function () {\n\t _this._isTouchLayer = true;\n\t });\n\t var carx = this.xiacheNode.x;\n\t if (carx > -200) {\n\t carx -= movePos;\n\t engine.Tween.get(this.xiacheNode, { loop: false })\n\t .to({\n\t x: carx\n\t }, props.pierMoveTime);\n\t }\n\t engine.globalEvent.dispatchEvent(\"bjxd-game-inmove\", {\n\t \"canstop\": true\n\t });\n\t this.closeStrut();\n\t };\n\t GameView.prototype.closeStrut = function () {\n\t this._strut.rest();\n\t };\n\t GameView.prototype.updateScore = function (score) {\n\t this._sumScore += score;\n\t engine.globalEvent.dispatchEvent('bjxd-game-score', { score: this._sumScore });\n\t };\n\t GameView.prototype.getScore = function () {\n\t return this._sumScore;\n\t };\n\t GameView.prototype.changeBg = function (index) {\n\t if (GameView.bgIndex != index) {\n\t GameView.bgIndex = index;\n\t this._backgroud.changeBg(index);\n\t this._road.changeBg();\n\t }\n\t };\n\t GameView.prototype.changeSpeed = function (speed) {\n\t if (GameView.speed != speed) {\n\t GameView.speed = speed;\n\t }\n\t };\n\t GameView.bgIndex = 0;\n\t GameView.speed = 20;\n\t return GameView;\n\t}(engine.Container));\n\n\tvar GameWrapper = (function (_super) {\n\t tslib.__extends(GameWrapper, _super);\n\t function GameWrapper() {\n\t var _this = _super.call(this) || this;\n\t engine.globalEvent.addEventListener('bjxd-game-start', _this.start, _this);\n\t engine.globalEvent.addEventListener('bjxd-game-reset', _this.reset, _this);\n\t engine.globalEvent.addEventListener('bjxd-game-revive', _this.revive, _this);\n\t engine.globalEvent.addEventListener('bjxd-game-change', _this.change, _this);\n\t engine.globalEvent.addEventListener('bjxd-game-speed', _this.speed, _this);\n\t var gameView = _this._gameView = new GameView();\n\t _this.addChild(gameView);\n\t return _this;\n\t }\n\t GameWrapper.prototype.start = function (event) {\n\t this._gameView.start(event.data.guide);\n\t };\n\t GameWrapper.prototype.reset = function () {\n\t this._gameView.reset();\n\t };\n\t GameWrapper.prototype.revive = function () {\n\t this._gameView.revive();\n\t };\n\t GameWrapper.prototype.change = function (event) {\n\t this._gameView.changeBg(event.data.index);\n\t };\n\t GameWrapper.prototype.speed = function (event) {\n\t this._gameView.changeSpeed(event.data.speed);\n\t };\n\t return GameWrapper;\n\t}(engine.Container));\n\n\tfunction index (props) {\n\t prepareProps();\n\t injectProps(props);\n\t var instance = new GameWrapper();\n\t return instance;\n\t}\n\n\treturn index;\n\n})));\n"
} }
{
"name": "套圈",
"desc": "套圈模块",
"props": {
"ferruleModuleGlobalPosition": {
"alias": "套圈模块的位置",
"type": "array<number>",
"default": "0,0"
},
"ferruleModuleWidthHeight": {
"alias": "套圈模块的宽高",
"type": "array<number>",
"default": "750,450"
}
},
"assets": [
{
"name": "圈",
"url": "//yun.duiba.com.cn/aurora/assets/668313c9b296603cbfd24f92c3683c41df0aa1e9.png",
"uuid": "c1fc9984-900f-44e0-87e5-128e7ccdfb62",
"ext": ".png"
},
{
"name": "礼盒",
"url": "//yun.duiba.com.cn/aurora/assets/3b13cb2a324c05e3bef2c27f1fd27b5fe49a0ea3.png",
"uuid": "e3ee8791-880f-4408-9f31-2f5faa75d044",
"ext": ".png"
},
{
"name": "套中动效",
"url": "//yun.duiba.com.cn/aurora/assets/8b650dd07a82a1357f0572e1201a9834e8b7d302.svga",
"uuid": "5e569c9c-a1e4-44df-83eb-9249e00e228b",
"ext": ".svga"
}
],
"events": {
"in": {
"circle-game-start": {
"alias": "开始"
},
"circle-game-init": {
"alias": "初始化"
}
},
"out": {
"circle-game-end": {
"alias": "套圈完毕",
"data": {
"reason": "套圈结束,执行抽奖"
}
}
}
},
"id": "circle",
"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.circle = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n\tfunction getTexture(uuid) {\n\t return engine.Texture.from(getAssetByUUID(uuid).uuid);\n\t}\n\tfunction getTextureByName(name) {\n\t console.log('name', engine.getAssetByName(name));\n\t return getTexture(engine.getAssetByName(name).uuid);\n\t}\n\tfunction createSvga(name, anchorName) {\n\t var inst = new svga.Svga();\n\t inst.source = 'asset://' + engine.getAssetByName(name).uuid;\n\t return inst;\n\t}\n\n\tvar props = {};\n\tfunction prepareProps() {\n\t var metaProps = getProps();\n\t engine.injectProp(props, metaProps);\n\t}\n\tfunction injectProps(p) {\n\t engine.injectProp(props, p);\n\t}\n\n\tvar Gameinit = (function (_super) {\n\t tslib.__extends(Gameinit, _super);\n\t function Gameinit() {\n\t var _this = _super.call(this) || this;\n\t _this._isSetUp = false;\n\t _this.totleY = 1200;\n\t _this.isMove = false;\n\t _this.isChoose = true;\n\t _this.isDid = true;\n\t _this.listGift = [];\n\t console.log(\"11111111111111\");\n\t _this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);\n\t return _this;\n\t }\n\t Gameinit.prototype.setup = function () {\n\t console.log(\"初始化加载000000000000000000000000!\");\n\t if (this._isSetUp) {\n\t return;\n\t }\n\t else {\n\t this.loadThings();\n\t console.log(\"this._isSetUp=\", this._isSetUp, '<<<<');\n\t }\n\t };\n\t Gameinit.prototype.loadThings = function () {\n\t var self = this;\n\t var body;\n\t body = this._body = new engine.Rect;\n\t body.width = 0.0001;\n\t body.height = 0.0001;\n\t this.addChild(body);\n\t var gift0 = this.addRes(body, '礼盒', 250, 100, 247, 188);\n\t var gift1 = this.addRes(body, '礼盒', 485, 85, 247, 190);\n\t var gift2 = this.addRes(body, '礼盒', 385, -15, 222, 170);\n\t var gift3 = this.addRes(body, '礼盒', 165, -15, 222, 170);\n\t var gift4 = this.addRes(body, '礼盒', 20, 85, 247, 190);\n\t this.listGift = [gift0, gift1, gift2, gift3, gift4];\n\t var circle = this.addRes(body, '圈', 260, 350, 240, 80);\n\t var giftSvga = createSvga(\"套中动效\");\n\t giftSvga.visible = false;\n\t body.addChild(giftSvga);\n\t var _a = props.ferruleModuleGlobalPosition, v2X = _a[0], v2Y = _a[1];\n\t body.x = v2X;\n\t body.y = v2Y;\n\t engine.globalEvent.addEventListener(\"circle-game-start\", function () {\n\t self.isMove = true;\n\t console.log('this.isMove===', self.isMove);\n\t }, this);\n\t engine.globalEvent.addEventListener(\"circle-game-init\", function () {\n\t self.isChoose = true;\n\t giftSvga.visible = false;\n\t body.children[self.num].visible = true;\n\t circle.x = 260;\n\t circle.y = 350;\n\t circle.width = 240;\n\t circle.height = 80;\n\t circle.visible = true;\n\t }, this);\n\t circle.addEventListener(engine.Event.ENTER_FRAME, function () {\n\t if (self.isMove) {\n\t console.log(\"物体移动\");\n\t if (self.isChoose) {\n\t self.num = Math.floor(Math.random() * self.listGift.length);\n\t self.isChoose = false;\n\t }\n\t self.nodeMove(circle, self.listGift[self.num], giftSvga);\n\t }\n\t });\n\t };\n\t Gameinit.prototype.aniPlay = function (node0, targetNode, bool) {\n\t node0.scaleX = this.currentScale(targetNode.y, this.totleY) - 0.05 * this.currentScale(targetNode.y, this.totleY);\n\t node0.scaleY = this.currentScale(targetNode.y, this.totleY) - 0.05 * this.currentScale(targetNode.y, this.totleY);\n\t node0.x = targetNode.x;\n\t node0.y = targetNode.y;\n\t node0.visible = true;\n\t node0.play(false, false);\n\t node0.addEventListener(engine.Event.END_FRAME, function () {\n\t console.log(\"播放到最后一帧\", bool, '<<<');\n\t engine.globalEvent.dispatchEvent(\"circle-game-end\");\n\t bool = false;\n\t });\n\t };\n\t Gameinit.prototype.addRes = function (fatherNode, resName, v2X, v2Y, resW, resH) {\n\t console.log(\"进行资源的添加\");\n\t var thing = new engine.Sprite(getTextureByName(resName));\n\t thing.x = v2X;\n\t thing.y = v2Y;\n\t thing.width = resW;\n\t thing.height = resH;\n\t return fatherNode.addChild(thing);\n\t };\n\t Gameinit.prototype.nodeMove = function (moveNode, targetNode, nodePlay) {\n\t console.log(\"moveNode.x=\", moveNode.x, \"targetNode.x=\", targetNode.x);\n\t var moveX = targetNode.x - moveNode.x;\n\t var moveY = targetNode.y - moveNode.y;\n\t console.log('moveX=', moveX, 'moveY=', moveY);\n\t if (this.isDid) {\n\t if (Math.abs(moveX) > 2) {\n\t moveNode.x += moveX / Math.abs(moveX) * 5;\n\t }\n\t if (Math.abs(moveY) > 2) {\n\t moveNode.y += moveY / Math.abs(moveY) * 5;\n\t moveNode.scaleX = this.currentScale(moveNode.y, this.totleY) + 0.2;\n\t moveNode.scaleY = moveNode.scaleX;\n\t }\n\t if (Math.abs(moveX) < 3 && Math.abs(moveY) < 3) {\n\t targetNode.visible = false;\n\t moveNode.visible = false;\n\t this.aniPlay(nodePlay, targetNode, this.isDid);\n\t this.isMove = false;\n\t }\n\t }\n\t };\n\t Gameinit.prototype.currentScale = function (currentY, totoleDisY) {\n\t return (currentY + 830) / totoleDisY;\n\t };\n\t return Gameinit;\n\t}(engine.Container));\n\n\tfunction index (props) {\n\t prepareProps();\n\t injectProps(props);\n\t var instance = new Gameinit();\n\t return instance;\n\t}\n\n\treturn index;\n\n})));\n"
}
...@@ -398,5 +398,5 @@ ...@@ -398,5 +398,5 @@
} }
}, },
"id": "jump-high", "id": "jump-high",
"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['jump-high'] = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n\tvar props = {};\n\tfunction prepareProps() {\n\t var metaProps = getProps();\n\t engine.injectProp(props, metaProps);\n\t}\n\tfunction injectProps(p) {\n\t engine.injectProp(props, p);\n\t}\n\n\tfunction getTextureByName(name) {\n\t return engine.Texture.from(getAssetByName(name).uuid);\n\t}\n\tfunction getBlockAsset(type) {\n\t return engine.getAssetByName(props.blockAssets[type]);\n\t}\n\tfunction createSvga(name, anchorName) {\n\t var inst = new svga.Svga();\n\t inst.source = 'asset://' + getAssetByName(name).uuid;\n\t var anchor = props[anchorName];\n\t if (anchor) {\n\t inst.x = -anchor.x;\n\t inst.y = -anchor.y;\n\t inst.anchorX = anchor.x;\n\t inst.anchorY = anchor.y;\n\t }\n\t return inst;\n\t}\n\tfunction playSound(name) {\n\t engine.playSound(getAssetByName(name).uuid, { keep: true });\n\t}\n\n\tvar Block = (function (_super) {\n\t tslib.__extends(Block, _super);\n\t function Block() {\n\t var _this = _super.call(this) || this;\n\t var body = _this.body = new svga.Svga();\n\t body.x = -props.blockWidth / 2;\n\t body.y = -props.blockHitHeight - props.blockPaddingTop;\n\t _this.addChild(body);\n\t return _this;\n\t }\n\t Block.prototype.reset = function (_a) {\n\t var type = _a.type;\n\t this.dir = Math.random() > 0.5 ? 1 : -1;\n\t if (this.type != type) {\n\t this.type = type;\n\t var asset = getBlockAsset(type);\n\t this.body.source = 'asset://' + asset.uuid;\n\t }\n\t this.scaleX = this.dir;\n\t this.body.gotoAndStop(1);\n\t };\n\t Block.prototype.playEnter = function (index, animation) {\n\t var _this = this;\n\t this.visible = true;\n\t this.x = this.dir * this.stage.width;\n\t var _a = props.blockDurationRange, min = _a[0], max = _a[1];\n\t var duration = Math.max(max - index * props.blockDurationStep, min);\n\t duration = duration + max * Math.random() * props.blockDurationRandom * (Math.random() > 0.5 ? 1 : -1);\n\t return new Promise(function (resolve) {\n\t if (animation) {\n\t engine.Tween.get(_this, null, null, true)\n\t .to({ x: 0, }, duration)\n\t .call(resolve);\n\t }\n\t else {\n\t _this.x = 0;\n\t setTimeout(function () {\n\t console.log(_this.body);\n\t }, 200);\n\t resolve();\n\t }\n\t });\n\t };\n\t Block.prototype.playLeave = function () {\n\t this.visible = false;\n\t };\n\t Block.prototype.playEffect = function () {\n\t var body = this.body;\n\t body.play(true, false);\n\t body.once(engine.Event.END_FRAME, function () {\n\t body.gotoAndStop(1);\n\t }, this);\n\t };\n\t Block.prototype.stop = function () {\n\t engine.Tween.removeTweens(this);\n\t };\n\t return Block;\n\t}(engine.Container));\n\n\tvar Background = (function (_super) {\n\t tslib.__extends(Background, _super);\n\t function Background() {\n\t return _super.call(this) || this;\n\t }\n\t Background.prototype.setup = function () {\n\t var _a = this.stage, width = _a.width, height = _a.height;\n\t var bg = this._bg = new engine.Image(getTextureByName('背景图'));\n\t bg.anchorX = bg.width / 2;\n\t bg.anchorY = bg.height / 2;\n\t bg.x = -(bg.width - width) / 2;\n\t bg.y = -(bg.height - height) / 2;\n\t this.addChild(bg);\n\t this._minScale = width / bg.width;\n\t };\n\t Background.prototype.playZoom = function (type, duration) {\n\t var _this = this;\n\t if (duration === void 0) { duration = 700; }\n\t return new Promise(function (resolve) {\n\t var scale = type === 'in' ? 1 : _this._minScale;\n\t engine.Tween.get(_this._bg, null, null, true)\n\t .to({ scaleX: scale, scaleY: scale }, duration, engine.Ease.cubicInOut)\n\t .call(resolve);\n\t });\n\t };\n\t return Background;\n\t}(engine.Container));\n\n\tvar svgaAssets = {\n\t aniReady: { name: '准备立正', dir: 1 },\n\t aniJump: { name: '跳上升', dir: 1 },\n\t aniFall: { name: '跳下落', dir: 1 },\n\t aniLandNormal: { name: '普通着地', dir: 1 },\n\t aniLandSide: { name: '边缘着地', dir: -1 },\n\t aniHit: { name: '被撞开', dir: -1 },\n\t aniParachute: { name: '降落', dir: -1 },\n\t};\n\tvar Player = (function (_super) {\n\t tslib.__extends(Player, _super);\n\t function Player() {\n\t var _this = _super.call(this) || this;\n\t _this.g = props.gravity;\n\t _this.addEventListener(engine.Event.ENTER_FRAME, _this.onEnterFrame, _this);\n\t return _this;\n\t }\n\t Player.prototype.switchAni = function (name, dir, play, loop) {\n\t var _this = this;\n\t if (dir === void 0) { dir = 1; }\n\t if (play === void 0) { play = true; }\n\t if (loop === void 0) { loop = false; }\n\t return new Promise(function (resolve) {\n\t _this.scaleX = dir;\n\t if (_this._aniName !== name) {\n\t _this._aniName = name;\n\t var oldAni = _this.removeChild(_this.getChildByName('body'));\n\t if (oldAni) {\n\t oldAni.stop();\n\t }\n\t var ani = _this._currentAni = _this['ani' + name];\n\t _this.addChild(ani);\n\t if (play) {\n\t ani.play(false, loop);\n\t if (loop) {\n\t resolve();\n\t }\n\t else {\n\t ani.once(engine.Event.END_FRAME, resolve);\n\t }\n\t }\n\t else {\n\t ani.gotoAndStop(1);\n\t resolve();\n\t }\n\t }\n\t });\n\t };\n\t Player.prototype.setup = function () {\n\t this.prefectEffect = createSvga('完美着地特效', 'playerLandPrefectAnchor');\n\t this.landEffect = createSvga('着地特效', 'playerLandEffectAnchor');\n\t for (var key in svgaAssets) {\n\t var _a = svgaAssets[key], name = _a.name, dir = _a.dir;\n\t var body = this[key] = createSvga(name, key.replace('ani', 'player') + 'Anchor');\n\t body.name = 'body';\n\t body.scaleX = dir;\n\t }\n\t };\n\t Player.prototype.reset = function (revive) {\n\t this.x = 0;\n\t this.rotation = 0;\n\t this.scaleX = this.scaleY = 1;\n\t this._prefectLandCounting = 0;\n\t engine.Tween.removeTweens(this);\n\t if (revive) {\n\t this.switchAni('Jump', 1, false);\n\t }\n\t };\n\t Player.prototype.playReady = function () {\n\t var _this = this;\n\t return new Promise(function (resolve) {\n\t _this.switchAni('Ready', 1);\n\t _this._currentAni.once(engine.Event.END_FRAME, function () {\n\t this.switchAni('Jump', 1, false);\n\t resolve();\n\t }, _this);\n\t });\n\t };\n\t Player.prototype.onEnterFrame = function (event) {\n\t if (!this.playing) {\n\t return;\n\t }\n\t this.vy += this.g;\n\t this.y += this.vy;\n\t if (this.vy > 0 && this._aniName !== 'Fall') {\n\t this.dispatchEvent('jump-on-top');\n\t this.switchAni('Fall');\n\t }\n\t if (this.y > this.baseY) {\n\t this.y = this.baseY;\n\t this.playing = false;\n\t this.jumpPromise && this.jumpPromise({\n\t aboveBlock: this.aboveBlock,\n\t });\n\t this.jumpPromise = null;\n\t }\n\t };\n\t Player.prototype.changeBaseY = function (v) {\n\t if (this.baseY == v) {\n\t return;\n\t }\n\t this.aboveBlock = true;\n\t this.baseY = v;\n\t };\n\t Player.prototype.jump = function () {\n\t var _this = this;\n\t playSound('跳起音效');\n\t this.switchAni('Jump', 1, false);\n\t this._currentAni.play(false, false);\n\t this.aboveBlock = false;\n\t this.playing = true;\n\t this.baseY = this.y;\n\t this.vy = -props.jumpSpeed;\n\t return new Promise(function (resolve) {\n\t _this.jumpPromise = resolve;\n\t });\n\t };\n\t Player.prototype.playLand = function (type, dir) {\n\t return tslib.__awaiter(this, void 0, void 0, function () {\n\t var _a, prefectEffect_1, landEffect_1;\n\t return tslib.__generator(this, function (_b) {\n\t switch (_b.label) {\n\t case 0:\n\t _a = type;\n\t switch (_a) {\n\t case 0: return [3, 1];\n\t case 1: return [3, 3];\n\t case 2: return [3, 3];\n\t case 3: return [3, 4];\n\t }\n\t return [3, 5];\n\t case 1:\n\t this._prefectLandCounting++;\n\t playSound('完美落地音效' + Math.min(4, this._prefectLandCounting));\n\t prefectEffect_1 = this.prefectEffect;\n\t this.addChildAt(prefectEffect_1, 0);\n\t prefectEffect_1.gotoAndPlay(1);\n\t prefectEffect_1.once(engine.Event.END_FRAME, function () {\n\t this.removeChild(prefectEffect_1);\n\t }, this);\n\t landEffect_1 = this.landEffect;\n\t this.addChildAt(landEffect_1, 0);\n\t landEffect_1.gotoAndPlay(1);\n\t landEffect_1.once(engine.Event.END_FRAME, function () {\n\t this.removeChild(landEffect_1);\n\t }, this);\n\t return [4, this.switchAni('LandNormal')];\n\t case 2:\n\t _b.sent();\n\t return [3, 5];\n\t case 3:\n\t this._prefectLandCounting = 0;\n\t playSound('普通落地音效');\n\t this.switchAni('LandNormal');\n\t return [3, 5];\n\t case 4:\n\t this._prefectLandCounting = 0;\n\t playSound('边缘落地音效');\n\t this.switchAni('LandSide', dir);\n\t return [3, 5];\n\t case 5: return [2];\n\t }\n\t });\n\t });\n\t };\n\t Player.prototype.hitAway = function (dir) {\n\t return tslib.__awaiter(this, void 0, void 0, function () {\n\t var _this = this;\n\t return tslib.__generator(this, function (_a) {\n\t switch (_a.label) {\n\t case 0:\n\t this.jumpPromise && this.jumpPromise();\n\t this.jumpPromise = null;\n\t playSound('被撞开音效');\n\t this.switchAni('Hit', dir);\n\t this.vy = 0;\n\t return [4, new Promise(function (resolve) {\n\t engine.Tween.get(_this)\n\t .to({\n\t x: -dir * props.hitAwayDistance.x,\n\t }, props.hitAwayDuration, engine.Ease.quartOut);\n\t engine.Tween.get(_this)\n\t .to({\n\t y: _this.y + props.hitAwayDistance.y,\n\t }, props.hitAwayDuration, engine.Ease.cubicOut)\n\t .call(resolve);\n\t })];\n\t case 1:\n\t _a.sent();\n\t return [2];\n\t }\n\t });\n\t });\n\t };\n\t Player.prototype.parachute = function (dir) {\n\t var _this = this;\n\t this.switchAni('Parachute', dir);\n\t return new Promise(function (resolve) {\n\t engine.Tween.get(_this)\n\t .wait(200)\n\t .call(function () {\n\t playSound('降落伞下落音效');\n\t })\n\t .wait(300)\n\t .to({ y: _this.y + props.parachuteDistance }, props.parachuteDuration)\n\t .set({ anchorOffsetY: 0 })\n\t .call(resolve);\n\t });\n\t };\n\t return Player;\n\t}(engine.Container));\n\n\tvar Base = (function (_super) {\n\t tslib.__extends(Base, _super);\n\t function Base() {\n\t return _super.call(this, getTextureByName('底座')) || this;\n\t }\n\t Base.prototype.setup = function () {\n\t this.x = -(this.width) / 2;\n\t };\n\t Base.prototype.reset = function () {\n\t this.y = -props.baseOffset;\n\t };\n\t return Base;\n\t}(engine.Image));\n\n\tvar GuideLayer = (function (_super) {\n\t tslib.__extends(GuideLayer, _super);\n\t function GuideLayer() {\n\t var _this = _super.call(this) || this;\n\t _this.setup();\n\t return _this;\n\t }\n\t GuideLayer.prototype.setup = function () {\n\t };\n\t GuideLayer.prototype.show = function (id, options) {\n\t var _this = this;\n\t return new Promise(function (resolve) {\n\t _this.visible = true;\n\t if (!_this.guideMask) {\n\t var _a = _this.stage, width = _a.width, height = _a.height;\n\t var guideMask = _this.guideMask = new engine.Container();\n\t var guideHole = new engine.Image(getTextureByName('引导遮罩'));\n\t guideHole.x = (width - guideHole.width) / 2;\n\t guideHole.y = options.y;\n\t guideMask.addChild(guideHole);\n\t _this.createRect(guideMask, 0, 0, width, guideHole.y);\n\t _this.createRect(guideMask, 0, guideHole.y, guideHole.x, guideHole.height);\n\t _this.createRect(guideMask, guideHole.x + guideHole.width, guideHole.y, width - guideHole.x - guideHole.width, guideHole.height);\n\t _this.createRect(guideMask, 0, guideHole.y + guideHole.height, width, height - guideHole.y - guideHole.height);\n\t var label = _this.label = new engine.Label();\n\t label.fillColor = 'white';\n\t label.size = 25;\n\t label.text = props.guideText;\n\t label.x = (width - label.width) / 2;\n\t label.y = guideHole.y + guideHole.height + 50;\n\t guideMask.addChild(label);\n\t _this.addChild(guideMask);\n\t }\n\t _this.once(engine.MouseEvent.CLICK, function () {\n\t this.visible = false;\n\t resolve();\n\t }, _this);\n\t });\n\t };\n\t GuideLayer.prototype.createRect = function (container, x, y, width, height) {\n\t var rect = new engine.Rect();\n\t rect.x = x;\n\t rect.y = y;\n\t rect.width = width;\n\t rect.height = height;\n\t rect.fillColor = 'black';\n\t rect.alpha = 0.7;\n\t container.addChild(rect);\n\t };\n\t return GuideLayer;\n\t}(engine.Container));\n\n\tvar GoldBag = (function (_super) {\n\t tslib.__extends(GoldBag, _super);\n\t function GoldBag() {\n\t var _this = _super.call(this) || this;\n\t _this.setup();\n\t return _this;\n\t }\n\t GoldBag.prototype.setup = function () {\n\t var avatar = this.avatar = new engine.Sprite(getTextureByName('钱袋-静态'));\n\t avatar.x = -props.goldPackAvatarAnchor.x;\n\t avatar.y = -props.goldPackAvatarAnchor.y;\n\t this.addChild(avatar);\n\t var svga = this.svga = createSvga('钱袋', 'goldPackAnchor');\n\t svga.visible = false;\n\t this.addChild(svga);\n\t };\n\t GoldBag.prototype.reset = function (data) {\n\t this.y = data.y;\n\t this.avatar.visible = true;\n\t this.svga.visible = false;\n\t this.svga.gotoAndStop(1);\n\t this.remain = data.remain;\n\t };\n\t GoldBag.prototype.playOpen = function () {\n\t var _this = this;\n\t this.avatar.visible = false;\n\t this.svga.visible = true;\n\t return new Promise(function (resolve) {\n\t _this.svga.play(true, false);\n\t _this.svga.once(engine.Event.END_FRAME, function () {\n\t this.svga.visible = false;\n\t resolve();\n\t }, _this);\n\t });\n\t };\n\t return GoldBag;\n\t}(engine.Container));\n\n\tvar ObjectPool = engine.ObjectPool;\n\tvar PoolName = 'gold-bag';\n\tObjectPool.registerPool(PoolName, function () {\n\t return new GoldBag();\n\t}, function (item, data) {\n\t item.reset(data);\n\t});\n\tvar GameView = (function (_super) {\n\t tslib.__extends(GameView, _super);\n\t function GameView() {\n\t var _this = _super.call(this) || this;\n\t _this.index = -1;\n\t _this.goldBags = [];\n\t _this.baseOffset = -props.baseOffset + props.playerOffset;\n\t _this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);\n\t return _this;\n\t }\n\t GameView.prototype.setup = function () {\n\t if (this._hasSetup) {\n\t return;\n\t }\n\t this._hasSetup = true;\n\t var _a = this.stage, width = _a.width, height = _a.height;\n\t var background = this.background = new Background();\n\t this.addChild(background);\n\t background.setup();\n\t var frontContainer = this.frontContainer = new engine.Container();\n\t frontContainer.x = width / 2;\n\t this.addChild(frontContainer);\n\t var guideLayer = this.guideLayer = new GuideLayer();\n\t this.addChild(guideLayer);\n\t var base = this.base = new Base();\n\t frontContainer.addChild(base);\n\t base.setup();\n\t var blockContainer = this.blockContainer = new engine.Container();\n\t frontContainer.addChild(blockContainer);\n\t var player = this.player = new Player();\n\t frontContainer.addChild(player);\n\t player.setup();\n\t player.addEventListener('jump-on-top', this.onPlayerJumpOnTop, this);\n\t ObjectPool.recycleObject(PoolName, ObjectPool.getObject(PoolName, {\n\t y: 0,\n\t remain: 0,\n\t }));\n\t this.hitEffect = createSvga('被撞烟雾', 'hitEffectAnchor');\n\t this.pos = 0;\n\t this.background.setup();\n\t this.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);\n\t this.reset();\n\t };\n\t GameView.prototype.reset = function (revive) {\n\t if (revive === void 0) { revive = false; }\n\t return tslib.__awaiter(this, void 0, void 0, function () {\n\t var blockContainer, i, li, block, i, i, li, goldBag;\n\t return tslib.__generator(this, function (_a) {\n\t switch (_a.label) {\n\t case 0:\n\t this.base.reset();\n\t this.index = -1;\n\t this._score = 0;\n\t if (revive) ;\n\t else {\n\t this.pos = 0;\n\t blockContainer = this.blockContainer;\n\t for (i = 0, li = blockContainer.children.length; i < li; i++) {\n\t block = blockContainer.getChildAt(i);\n\t block.playLeave();\n\t }\n\t }\n\t for (i = 0; i < props.initBlockCount; i++) {\n\t this.addBlock(false);\n\t }\n\t for (i = 0, li = this.goldBags.length; i < li; i++) {\n\t goldBag = this.goldBags[i];\n\t this.frontContainer.removeChild(goldBag);\n\t ObjectPool.recycleObject(PoolName, goldBag);\n\t }\n\t this.goldBags.splice(0);\n\t this.playZoom('in');\n\t return [4, this.resetPlayer(revive)];\n\t case 1:\n\t _a.sent();\n\t return [2];\n\t }\n\t });\n\t });\n\t };\n\t GameView.prototype.resetPlayer = function (revive) {\n\t if (revive === void 0) { revive = false; }\n\t return tslib.__awaiter(this, void 0, void 0, function () {\n\t return tslib.__generator(this, function (_a) {\n\t this.player.reset(revive);\n\t this.player.y = this.baseOffset - (this.index + 1) * props.blockHitHeight;\n\t return [2];\n\t });\n\t });\n\t };\n\t GameView.prototype.start = function (revive) {\n\t if (revive === void 0) { revive = false; }\n\t return tslib.__awaiter(this, void 0, void 0, function () {\n\t var guideFlagKey, guideFlag;\n\t var _this = this;\n\t return tslib.__generator(this, function (_a) {\n\t switch (_a.label) {\n\t case 0:\n\t if (!!revive) return [3, 2];\n\t return [4, this.player.playReady()];\n\t case 1:\n\t _a.sent();\n\t _a.label = 2;\n\t case 2:\n\t guideFlagKey = 'jump-high-guide_' + props.guideFlagKey;\n\t guideFlag = localStorage.getItem(guideFlagKey);\n\t if (!!guideFlag) return [3, 4];\n\t localStorage.setItem(guideFlagKey, '1');\n\t return [4, this.guideLayer.show('', { y: this.stage.height + this.player.y - 280 })];\n\t case 3:\n\t _a.sent();\n\t _a.label = 4;\n\t case 4:\n\t this.lastLandType = 0;\n\t this._remainToShowGoldBag = props.goldBagScoreMultiple - props.goldBagScoreSubtraction;\n\t this._touchEnabled = true;\n\t setTimeout(function () {\n\t _this.addBlock();\n\t }, 100);\n\t engine.globalEvent.dispatchEvent('jump-high-game-start');\n\t return [2];\n\t }\n\t });\n\t });\n\t };\n\t GameView.prototype.pause = function () {\n\t if (this.currentBlock) {\n\t engine.Tween.pauseTweens(this.currentBlock);\n\t }\n\t engine.Tween.pauseTweens(this.player);\n\t };\n\t GameView.prototype.resume = function () {\n\t if (this.currentBlock) {\n\t engine.Tween.resumeTweens(this.currentBlock);\n\t }\n\t engine.Tween.resumeTweens(this.player);\n\t };\n\t GameView.prototype.revive = function () {\n\t return tslib.__awaiter(this, void 0, void 0, function () {\n\t return tslib.__generator(this, function (_a) {\n\t switch (_a.label) {\n\t case 0:\n\t this.blockContainer.getChildAt(this.index).visible = false;\n\t this.index--;\n\t return [4, this.resetPlayer(true)];\n\t case 1:\n\t _a.sent();\n\t return [4, this.playZoom('in')];\n\t case 2:\n\t _a.sent();\n\t this.start(true);\n\t return [2];\n\t }\n\t });\n\t });\n\t };\n\t GameView.prototype.addBlock = function (animation) {\n\t var _this = this;\n\t if (animation === void 0) { animation = true; }\n\t this.index++;\n\t var blockContainer = this.blockContainer;\n\t var block;\n\t if (blockContainer.children.length > this.index) {\n\t block = blockContainer.getChildAt(this.index);\n\t block.visible = true;\n\t }\n\t else {\n\t block = new Block();\n\t blockContainer.addChild(block);\n\t }\n\t block.reset({\n\t type: Math.floor(Math.random() * props.blockAssets.length),\n\t });\n\t block.y = this.baseOffset - this.index * props.blockHitHeight;\n\t this.blockComplete = false;\n\t block.playEnter(this.index, animation).then(function (data) {\n\t _this.blockComplete = true;\n\t });\n\t if (animation) {\n\t this.needHitTest = true;\n\t }\n\t this.currentBlock = block;\n\t };\n\t GameView.prototype.addGoldBag = function () {\n\t var goldBag = ObjectPool.getObject(PoolName, {\n\t y: this.baseOffset - (this.blockCount + props.goldBagDistance + props.goldBagJumpSubtraction) * props.blockHitHeight,\n\t remain: props.goldBagDistance,\n\t });\n\t this.frontContainer.addChild(goldBag);\n\t this.goldBags.push(goldBag);\n\t };\n\t GameView.prototype.playOpenGoldBag = function () {\n\t return tslib.__awaiter(this, void 0, void 0, function () {\n\t var i, li, goldBag;\n\t return tslib.__generator(this, function (_a) {\n\t switch (_a.label) {\n\t case 0:\n\t i = 0, li = this.goldBags.length;\n\t _a.label = 1;\n\t case 1:\n\t if (!(i < li)) return [3, 4];\n\t goldBag = this.goldBags[i];\n\t goldBag.remain--;\n\t if (!(goldBag.remain <= 0)) return [3, 3];\n\t this.goldBags.splice(i, 1);\n\t i--;\n\t li--;\n\t this.nextToUpdateScore = true;\n\t return [4, goldBag.playOpen()];\n\t case 2:\n\t _a.sent();\n\t this.frontContainer.removeChild(goldBag);\n\t ObjectPool.recycleObject(PoolName, goldBag);\n\t _a.label = 3;\n\t case 3:\n\t i++;\n\t return [3, 1];\n\t case 4: return [2];\n\t }\n\t });\n\t });\n\t };\n\t GameView.prototype.onPlayerJumpOnTop = function () {\n\t if (this.nextToUpdateScore) {\n\t this.nextToUpdateScore = false;\n\t this.scoreChange(4);\n\t playSound('撞击钱袋音效');\n\t }\n\t };\n\t Object.defineProperty(GameView.prototype, \"blockCount\", {\n\t get: function () {\n\t return this.index - props.initBlockCount + 1;\n\t },\n\t enumerable: true,\n\t configurable: true\n\t });\n\t Object.defineProperty(GameView.prototype, \"pos\", {\n\t get: function () {\n\t return this._pos;\n\t },\n\t set: function (v) {\n\t this._pos = v;\n\t this.updatePos();\n\t },\n\t enumerable: true,\n\t configurable: true\n\t });\n\t GameView.prototype.updatePos = function () {\n\t this.frontContainer.y = this.stage.height + this._pos;\n\t };\n\t GameView.prototype.onEnterFrame = function (event) {\n\t if (this.needHitTest) {\n\t if (this.currentBlock) {\n\t var _a = this.currentBlock, bx = _a.x, by = _a.y, dir = _a.dir;\n\t var _b = this.player, px = _b.x, py = _b.y;\n\t var blockHitWidth = props.blockHitWidth, blockHitHeight = props.blockHitHeight, playerWidth = props.playerWidth;\n\t var hitOn = false;\n\t if (Math.abs(px - bx) < (blockHitWidth + playerWidth) / 2) {\n\t this.player.changeBaseY(by - blockHitHeight);\n\t if (py > by - blockHitHeight) {\n\t hitOn = true;\n\t }\n\t }\n\t if (hitOn) {\n\t this.onHitOn(dir);\n\t }\n\t }\n\t }\n\t };\n\t GameView.prototype.onHitOn = function (dir) {\n\t return tslib.__awaiter(this, void 0, void 0, function () {\n\t return tslib.__generator(this, function (_a) {\n\t switch (_a.label) {\n\t case 0:\n\t this._touchEnabled = false;\n\t this.needHitTest = false;\n\t clearInterval(this.timer);\n\t this.currentBlock.stop();\n\t this.playHitEffect(dir);\n\t return [4, this.player.hitAway(dir)];\n\t case 1:\n\t _a.sent();\n\t this.playZoom('out');\n\t return [4, this.player.parachute(dir)];\n\t case 2:\n\t _a.sent();\n\t engine.globalEvent.dispatchEvent('jump-high-game-end');\n\t return [2];\n\t }\n\t });\n\t });\n\t };\n\t GameView.prototype.jump = function () {\n\t return tslib.__awaiter(this, void 0, void 0, function () {\n\t var result, pos, type, lastLandType;\n\t var _this = this;\n\t return tslib.__generator(this, function (_a) {\n\t switch (_a.label) {\n\t case 0:\n\t if (!this._touchEnabled) {\n\t return [2];\n\t }\n\t this._touchEnabled = false;\n\t this.playOpenGoldBag();\n\t return [4, this.player.jump()];\n\t case 1:\n\t result = _a.sent();\n\t if (!result) return [3, 5];\n\t if (!result.aboveBlock) return [3, 4];\n\t pos = Math.abs(this.currentBlock.x);\n\t type = 0;\n\t if (pos > 0) {\n\t type = pos > 0 && pos < props.scoreThreshold ? 2 : 3;\n\t }\n\t lastLandType = this.lastLandType;\n\t this.lastLandType = type;\n\t if (type === 0) {\n\t if (lastLandType !== type) {\n\t type = 1;\n\t }\n\t }\n\t if (type < 3) {\n\t this.currentBlock.playEffect();\n\t }\n\t this.player.playLand(type, this.currentBlock.dir);\n\t this.currentBlock.stop();\n\t this.scoreChange(type);\n\t return [4, this.playShake()];\n\t case 2:\n\t _a.sent();\n\t return [4, new Promise(function (resolve) {\n\t engine.Tween.get(_this, null, null, true)\n\t .to({ pos: props.blockHitHeight * _this.index }, 300, engine.Ease.cubicOut)\n\t .call(resolve);\n\t })];\n\t case 3:\n\t _a.sent();\n\t this.addBlock();\n\t _a.label = 4;\n\t case 4:\n\t this._touchEnabled = true;\n\t _a.label = 5;\n\t case 5: return [2];\n\t }\n\t });\n\t });\n\t };\n\t GameView.prototype.scoreChange = function (type) {\n\t var scoreAdd = props.scoreWeights[type];\n\t this._score += scoreAdd;\n\t this._remainToShowGoldBag -= scoreAdd;\n\t var score = this._score;\n\t engine.globalEvent.dispatchEvent('jump-high-score', {\n\t type: type,\n\t score: score,\n\t scoreAdd: scoreAdd,\n\t });\n\t console.log(score, this._remainToShowGoldBag);\n\t if (this._remainToShowGoldBag <= 0) {\n\t this._remainToShowGoldBag += props.goldBagScoreMultiple;\n\t this.addGoldBag();\n\t console.log('addGoldBag');\n\t }\n\t };\n\t GameView.prototype.playHitEffect = function (dir) {\n\t var hitEffect = this.hitEffect;\n\t hitEffect.scaleX = dir;\n\t hitEffect.y = this.player.y - props.hitEffectAnchor.y;\n\t hitEffect.play(true, false);\n\t hitEffect.once(engine.Event.END_FRAME, function () {\n\t this.frontContainer.removeChild(hitEffect);\n\t }, this);\n\t this.frontContainer.addChild(hitEffect);\n\t };\n\t GameView.prototype.playZoom = function (type, duration) {\n\t var _this = this;\n\t if (duration === void 0) { duration = 700; }\n\t this.background.playZoom(type, duration);\n\t var count = this.stage.height / props.blockHitHeight;\n\t return new Promise(function (resolve) {\n\t _this.frontContainer.anchorY = -props.blockHitHeight * (_this.index + count * 1.3) + props.baseOffset;\n\t var scale = type === 'in' ? 1 : Math.min((_this.stage.height / props.blockHitHeight / (_this.index + count)), props.maxScale);\n\t console.log(scale);\n\t engine.Tween.get(_this.frontContainer, null, null, true)\n\t .to({ scaleX: scale, scaleY: scale }, duration, engine.Ease.cubicInOut)\n\t .call(resolve);\n\t });\n\t };\n\t GameView.prototype.playShake = function () {\n\t var _this = this;\n\t var _a = this.frontContainer, x = _a.x, y = _a.y;\n\t return new Promise(function (resolve) {\n\t var shakeOffset = 7;\n\t var duration = 30;\n\t engine.Tween.get(_this.frontContainer, null, null, true)\n\t .to({ x: x, y: y - shakeOffset }, duration)\n\t .to({ x: x, y: y + shakeOffset }, duration)\n\t .to({ x: x + shakeOffset, y: y }, duration)\n\t .to({ x: x - shakeOffset, y: y }, duration)\n\t .to({ x: x, y: y }, duration)\n\t .call(resolve);\n\t });\n\t };\n\t return GameView;\n\t}(engine.Container));\n\n\tvar JumpHigh = (function (_super) {\n\t tslib.__extends(JumpHigh, _super);\n\t function JumpHigh() {\n\t var _this = _super.call(this) || this;\n\t engine.globalEvent.addEventListener('jump-high-reset', _this.reset, _this);\n\t engine.globalEvent.addEventListener('jump-high-start', _this.start, _this);\n\t engine.globalEvent.addEventListener('jump-high-pause', _this.pause, _this);\n\t engine.globalEvent.addEventListener('jump-high-resume', _this.resume, _this);\n\t engine.globalEvent.addEventListener('jump-high-revive', _this.revive, _this);\n\t _this.addEventListener(engine.MouseEvent.MOUSE_DOWN, _this.onTap, _this);\n\t var gameView = _this._gameView = new GameView();\n\t _this.addChild(gameView);\n\t return _this;\n\t }\n\t JumpHigh.prototype.reset = function () {\n\t this._gameView.reset();\n\t };\n\t JumpHigh.prototype.start = function (event) {\n\t {\n\t injectProps(event.data);\n\t }\n\t this._status = 1;\n\t this._gameView.start();\n\t };\n\t JumpHigh.prototype.pause = function () {\n\t this._gameView.pause();\n\t };\n\t JumpHigh.prototype.resume = function () {\n\t this._gameView.resume();\n\t };\n\t JumpHigh.prototype.revive = function () {\n\t this._gameView.revive();\n\t };\n\t JumpHigh.prototype.onTap = function (event) {\n\t this._gameView.jump();\n\t };\n\t return JumpHigh;\n\t}(engine.Container));\n\n\tfunction index (props) {\n\t prepareProps();\n\t injectProps(props);\n\t var instance = new JumpHigh();\n\t return instance;\n\t}\n\n\treturn index;\n\n})));\n" "code": "(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :\n\ttypeof define === 'function' && define.amd ? define(['tslib'], factory) :\n\t(global = global || self, global['jump-high'] = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n\tvar props = {};\n\tfunction prepareProps() {\n\t var metaProps = getProps();\n\t engine.injectProp(props, metaProps);\n\t}\n\tfunction injectProps(p) {\n\t engine.injectProp(props, p);\n\t}\n\t//# sourceMappingURL=props.js.map\n\n\tfunction getTextureByName(name) {\n\t return engine.Texture.from(getAssetByName(name).uuid);\n\t}\n\tfunction getBlockAsset(type) {\n\t return engine.getAssetByName(props.blockAssets[type]);\n\t}\n\tfunction createSvga(name, anchorName) {\n\t var inst = new svga.Svga();\n\t inst.source = 'asset://' + getAssetByName(name).uuid;\n\t var anchor = props[anchorName];\n\t if (anchor) {\n\t inst.x = -anchor.x;\n\t inst.y = -anchor.y;\n\t inst.anchorX = anchor.x;\n\t inst.anchorY = anchor.y;\n\t }\n\t return inst;\n\t}\n\tfunction playSound(name) {\n\t engine.playSound(getAssetByName(name).uuid, { keep: true });\n\t}\n\t//# sourceMappingURL=utils.js.map\n\n\tvar Block = (function (_super) {\n\t tslib.__extends(Block, _super);\n\t function Block() {\n\t var _this_1 = _super.call(this) || this;\n\t _this_1._deltaTime = 0;\n\t _this_1.startTime = 0;\n\t _this_1.lastTime = 0;\n\t _this_1.curTime = 0;\n\t _this_1.per = 0;\n\t var body = _this_1.body = new svga.Svga();\n\t body.x = -props.blockWidth / 2;\n\t body.y = -props.blockHitHeight - props.blockPaddingTop;\n\t _this_1.addChild(body);\n\t _this_1.addEventListener(engine.Event.ENTER_FRAME, _this_1.onEnterFrame, _this_1);\n\t return _this_1;\n\t }\n\t Block.prototype.reset = function (_a) {\n\t var type = _a.type;\n\t this.dir = Math.random() > 0.5 ? 1 : -1;\n\t if (this.type != type) {\n\t this.type = type;\n\t var asset = getBlockAsset(type);\n\t this.body.source = 'asset://' + asset.uuid;\n\t }\n\t this.scaleX = this.dir;\n\t this.body.gotoAndStop(1);\n\t };\n\t Block.prototype.onEnterFrame = function () {\n\t this.lastTime = this.curTime;\n\t this.curTime = Date.now() - this.startTime;\n\t this._deltaTime = this.curTime - this.lastTime;\n\t this._deltaTime = this._deltaTime < 0 ? 0 : this._deltaTime;\n\t var offMoveX = this.per * this._deltaTime;\n\t if (this.per < 0) {\n\t if (this.x + offMoveX > 0) {\n\t this.x += offMoveX;\n\t }\n\t else {\n\t this.x = 0;\n\t }\n\t }\n\t else {\n\t if (this.x + offMoveX < 0) {\n\t this.x += offMoveX;\n\t }\n\t else {\n\t this.x = 0;\n\t }\n\t }\n\t };\n\t Block.prototype.playEnter = function (index, animation) {\n\t var _this_1 = this;\n\t var _this = this;\n\t this.visible = true;\n\t this.x = this.dir * this.stage.width;\n\t var _a = props.blockDurationRange, min = _a[0], max = _a[1];\n\t var duration = Math.max(max - index * props.blockDurationStep, min);\n\t duration = duration + max * Math.random() * props.blockDurationRandom * (Math.random() > 0.5 ? 1 : -1);\n\t var offX = 0 - this.x;\n\t this.per = offX / duration;\n\t return new Promise(function (resolve) {\n\t if (animation) {\n\t _this.startTime = Date.now();\n\t setTimeout(function () {\n\t resolve(1);\n\t }, duration);\n\t }\n\t else {\n\t _this_1.x = 0;\n\t setTimeout(function () {\n\t console.log(_this_1.body);\n\t }, 200);\n\t resolve(1);\n\t }\n\t });\n\t };\n\t Block.prototype.playLeave = function () {\n\t this.visible = false;\n\t };\n\t Block.prototype.playEffect = function () {\n\t var body = this.body;\n\t body.play(true, false);\n\t body.once(engine.Event.END_FRAME, function () {\n\t body.gotoAndStop(1);\n\t }, this);\n\t };\n\t Block.prototype.stop = function () {\n\t this.removeEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);\n\t };\n\t return Block;\n\t}(engine.Container));\n\t//# sourceMappingURL=Block.js.map\n\n\tvar Background = (function (_super) {\n\t tslib.__extends(Background, _super);\n\t function Background() {\n\t return _super.call(this) || this;\n\t }\n\t Background.prototype.setup = function () {\n\t var _a = this.stage, width = _a.width, height = _a.height;\n\t var bg = this._bg = new engine.Image(getTextureByName('背景图'));\n\t bg.anchorX = bg.width / 2;\n\t bg.anchorY = bg.height / 2;\n\t bg.x = -(bg.width - width) / 2;\n\t bg.y = -(bg.height - height) / 2;\n\t this.addChild(bg);\n\t this._minScale = width / bg.width;\n\t };\n\t Background.prototype.playZoom = function (type, duration) {\n\t var _this = this;\n\t if (duration === void 0) { duration = 700; }\n\t return new Promise(function (resolve) {\n\t var scale = type === 'in' ? 1 : _this._minScale;\n\t engine.Tween.get(_this._bg, null, null, true)\n\t .to({ scaleX: scale, scaleY: scale }, duration, engine.Ease.cubicInOut)\n\t .call(resolve);\n\t });\n\t };\n\t return Background;\n\t}(engine.Container));\n\t//# sourceMappingURL=Background.js.map\n\n\tvar svgaAssets = {\n\t aniReady: { name: '准备立正', dir: 1 },\n\t aniJump: { name: '跳上升', dir: 1 },\n\t aniFall: { name: '跳下落', dir: 1 },\n\t aniLandNormal: { name: '普通着地', dir: 1 },\n\t aniLandSide: { name: '边缘着地', dir: -1 },\n\t aniHit: { name: '被撞开', dir: -1 },\n\t aniParachute: { name: '降落', dir: -1 },\n\t};\n\tvar Player = (function (_super) {\n\t tslib.__extends(Player, _super);\n\t function Player() {\n\t var _this = _super.call(this) || this;\n\t _this.g = props.gravity;\n\t _this._deltaTime = 0;\n\t _this.startTime = 0;\n\t _this.lastTime = 0;\n\t _this.curTime = 0;\n\t _this.addEventListener(engine.Event.ENTER_FRAME, _this.onEnterFrame, _this);\n\t return _this;\n\t }\n\t Player.prototype.switchAni = function (name, dir, play, loop) {\n\t var _this = this;\n\t if (dir === void 0) { dir = 1; }\n\t if (play === void 0) { play = true; }\n\t if (loop === void 0) { loop = false; }\n\t return new Promise(function (resolve) {\n\t _this.scaleX = dir;\n\t if (_this._aniName !== name) {\n\t _this._aniName = name;\n\t var oldAni = _this.removeChild(_this.getChildByName('body'));\n\t if (oldAni) {\n\t oldAni.stop();\n\t }\n\t var ani = _this._currentAni = _this['ani' + name];\n\t _this.addChild(ani);\n\t if (play) {\n\t ani.play(false, loop);\n\t if (loop) {\n\t resolve(1);\n\t }\n\t else {\n\t ani.once(engine.Event.END_FRAME, resolve);\n\t }\n\t }\n\t else {\n\t ani.gotoAndStop(1);\n\t resolve(1);\n\t }\n\t }\n\t });\n\t };\n\t Player.prototype.setup = function () {\n\t this.prefectEffect = createSvga('完美着地特效', 'playerLandPrefectAnchor');\n\t this.landEffect = createSvga('着地特效', 'playerLandEffectAnchor');\n\t for (var key in svgaAssets) {\n\t var _a = svgaAssets[key], name = _a.name, dir = _a.dir;\n\t var body = this[key] = createSvga(name, key.replace('ani', 'player') + 'Anchor');\n\t body.name = 'body';\n\t body.scaleX = dir;\n\t }\n\t };\n\t Player.prototype.reset = function (revive) {\n\t this.x = 0;\n\t this.rotation = 0;\n\t this.scaleX = this.scaleY = 1;\n\t this._prefectLandCounting = 0;\n\t engine.Tween.removeTweens(this);\n\t if (revive) {\n\t this.switchAni('Jump', 1, false);\n\t }\n\t };\n\t Player.prototype.playReady = function () {\n\t var _this = this;\n\t return new Promise(function (resolve) {\n\t _this.switchAni('Ready', 1);\n\t _this._currentAni.once(engine.Event.END_FRAME, function () {\n\t this.switchAni('Jump', 1, false);\n\t resolve(1);\n\t }, _this);\n\t });\n\t };\n\t Player.prototype.onEnterFrame = function (event) {\n\t if (!this.playing) {\n\t return;\n\t }\n\t this.lastTime = this.curTime;\n\t this.curTime = Date.now() - this.startTime;\n\t this._deltaTime = this.curTime - this.lastTime;\n\t this._deltaTime = this._deltaTime < 0 ? 0 : this._deltaTime;\n\t this.vy += this.g * this._deltaTime / 16;\n\t this.y += this.vy * this._deltaTime / 16;\n\t if (this.vy > 0 && this._aniName !== 'Fall') {\n\t this.dispatchEvent('jump-on-top');\n\t this.switchAni('Fall');\n\t }\n\t if (this.y > this.baseY) {\n\t this.y = this.baseY;\n\t this.playing = false;\n\t this.jumpPromise && this.jumpPromise({\n\t aboveBlock: this.aboveBlock,\n\t });\n\t this.jumpPromise = null;\n\t }\n\t };\n\t Player.prototype.changeBaseY = function (v) {\n\t if (this.baseY == v) {\n\t return;\n\t }\n\t this.aboveBlock = true;\n\t this.baseY = v;\n\t };\n\t Player.prototype.jump = function () {\n\t var _this = this;\n\t playSound('跳起音效');\n\t this.switchAni('Jump', 1, false);\n\t this._currentAni.play(false, false);\n\t this.aboveBlock = false;\n\t this.playing = true;\n\t this.baseY = this.y;\n\t this.vy = -props.jumpSpeed;\n\t this.startTime = Date.now();\n\t return new Promise(function (resolve) {\n\t _this.jumpPromise = resolve;\n\t });\n\t };\n\t Player.prototype.playLand = function (type, dir) {\n\t return tslib.__awaiter(this, void 0, void 0, function () {\n\t var _a, prefectEffect_1, landEffect_1;\n\t return tslib.__generator(this, function (_b) {\n\t switch (_b.label) {\n\t case 0:\n\t _a = type;\n\t switch (_a) {\n\t case 0: return [3, 1];\n\t case 1: return [3, 3];\n\t case 2: return [3, 3];\n\t case 3: return [3, 4];\n\t }\n\t return [3, 5];\n\t case 1:\n\t this._prefectLandCounting++;\n\t playSound('完美落地音效' + Math.min(4, this._prefectLandCounting));\n\t prefectEffect_1 = this.prefectEffect;\n\t this.addChildAt(prefectEffect_1, 0);\n\t prefectEffect_1.gotoAndPlay(1);\n\t prefectEffect_1.once(engine.Event.END_FRAME, function () {\n\t this.removeChild(prefectEffect_1);\n\t }, this);\n\t landEffect_1 = this.landEffect;\n\t this.addChildAt(landEffect_1, 0);\n\t landEffect_1.gotoAndPlay(1);\n\t landEffect_1.once(engine.Event.END_FRAME, function () {\n\t this.removeChild(landEffect_1);\n\t }, this);\n\t return [4, this.switchAni('LandNormal')];\n\t case 2:\n\t _b.sent();\n\t return [3, 5];\n\t case 3:\n\t this._prefectLandCounting = 0;\n\t playSound('普通落地音效');\n\t this.switchAni('LandNormal');\n\t return [3, 5];\n\t case 4:\n\t this._prefectLandCounting = 0;\n\t playSound('边缘落地音效');\n\t this.switchAni('LandSide', dir);\n\t return [3, 5];\n\t case 5: return [2];\n\t }\n\t });\n\t });\n\t };\n\t Player.prototype.hitAway = function (dir) {\n\t return tslib.__awaiter(this, void 0, void 0, function () {\n\t var _this = this;\n\t return tslib.__generator(this, function (_a) {\n\t switch (_a.label) {\n\t case 0:\n\t this.jumpPromise && this.jumpPromise();\n\t this.jumpPromise = null;\n\t playSound('被撞开音效');\n\t this.switchAni('Hit', dir);\n\t this.vy = 0;\n\t return [4, new Promise(function (resolve) {\n\t engine.Tween.get(_this)\n\t .to({\n\t x: -dir * props.hitAwayDistance.x,\n\t }, props.hitAwayDuration, engine.Ease.quartOut);\n\t engine.Tween.get(_this)\n\t .to({\n\t y: _this.y + props.hitAwayDistance.y,\n\t }, props.hitAwayDuration, engine.Ease.cubicOut)\n\t .call(resolve);\n\t })];\n\t case 1:\n\t _a.sent();\n\t return [2];\n\t }\n\t });\n\t });\n\t };\n\t Player.prototype.parachute = function (dir) {\n\t var _this = this;\n\t this.switchAni('Parachute', dir);\n\t return new Promise(function (resolve) {\n\t engine.Tween.get(_this)\n\t .wait(200)\n\t .call(function () {\n\t playSound('降落伞下落音效');\n\t })\n\t .wait(300)\n\t .to({ y: _this.y + props.parachuteDistance }, props.parachuteDuration)\n\t .set({ anchorOffsetY: 0 })\n\t .call(resolve);\n\t });\n\t };\n\t return Player;\n\t}(engine.Container));\n\t//# sourceMappingURL=Player.js.map\n\n\tvar Base = (function (_super) {\n\t tslib.__extends(Base, _super);\n\t function Base() {\n\t return _super.call(this, getTextureByName('底座')) || this;\n\t }\n\t Base.prototype.setup = function () {\n\t this.x = -(this.width) / 2;\n\t };\n\t Base.prototype.reset = function () {\n\t this.y = -props.baseOffset;\n\t };\n\t return Base;\n\t}(engine.Image));\n\t//# sourceMappingURL=Base.js.map\n\n\tvar GuideLayer = (function (_super) {\n\t tslib.__extends(GuideLayer, _super);\n\t function GuideLayer() {\n\t var _this = _super.call(this) || this;\n\t _this.setup();\n\t return _this;\n\t }\n\t GuideLayer.prototype.setup = function () {\n\t };\n\t GuideLayer.prototype.show = function (id, options) {\n\t var _this = this;\n\t return new Promise(function (resolve) {\n\t _this.visible = true;\n\t if (!_this.guideMask) {\n\t var _a = _this.stage, width = _a.width, height = _a.height;\n\t var guideMask = _this.guideMask = new engine.Container();\n\t var guideHole = new engine.Image(getTextureByName('引导遮罩'));\n\t guideHole.x = (width - guideHole.width) / 2;\n\t guideHole.y = options.y;\n\t guideMask.addChild(guideHole);\n\t _this.createRect(guideMask, 0, 0, width, guideHole.y);\n\t _this.createRect(guideMask, 0, guideHole.y, guideHole.x, guideHole.height);\n\t _this.createRect(guideMask, guideHole.x + guideHole.width, guideHole.y, width - guideHole.x - guideHole.width, guideHole.height);\n\t _this.createRect(guideMask, 0, guideHole.y + guideHole.height, width, height - guideHole.y - guideHole.height);\n\t var label = _this.label = new engine.Label();\n\t label.fillColor = 'white';\n\t label.size = 25;\n\t label.text = props.guideText;\n\t label.x = (width - label.width) / 2;\n\t label.y = guideHole.y + guideHole.height + 50;\n\t guideMask.addChild(label);\n\t _this.addChild(guideMask);\n\t }\n\t _this.once(engine.MouseEvent.CLICK, function () {\n\t this.visible = false;\n\t resolve();\n\t }, _this);\n\t });\n\t };\n\t GuideLayer.prototype.createRect = function (container, x, y, width, height) {\n\t var rect = new engine.Rect();\n\t rect.x = x;\n\t rect.y = y;\n\t rect.width = width;\n\t rect.height = height;\n\t rect.fillColor = 'black';\n\t rect.alpha = 0.7;\n\t container.addChild(rect);\n\t };\n\t return GuideLayer;\n\t}(engine.Container));\n\t//# sourceMappingURL=GuideLayer.js.map\n\n\tvar GoldBag = (function (_super) {\n\t tslib.__extends(GoldBag, _super);\n\t function GoldBag() {\n\t var _this = _super.call(this) || this;\n\t _this.setup();\n\t return _this;\n\t }\n\t GoldBag.prototype.setup = function () {\n\t var avatar = this.avatar = new engine.Sprite(getTextureByName('钱袋-静态'));\n\t avatar.x = -props.goldPackAvatarAnchor.x;\n\t avatar.y = -props.goldPackAvatarAnchor.y;\n\t this.addChild(avatar);\n\t var svga = this.svga = createSvga('钱袋', 'goldPackAnchor');\n\t svga.visible = false;\n\t this.addChild(svga);\n\t };\n\t GoldBag.prototype.reset = function (data) {\n\t this.y = data.y;\n\t this.avatar.visible = true;\n\t this.svga.visible = false;\n\t this.svga.gotoAndStop(1);\n\t this.remain = data.remain;\n\t };\n\t GoldBag.prototype.playOpen = function () {\n\t var _this = this;\n\t this.avatar.visible = false;\n\t this.svga.visible = true;\n\t return new Promise(function (resolve) {\n\t _this.svga.play(true, false);\n\t _this.svga.once(engine.Event.END_FRAME, function () {\n\t this.svga.visible = false;\n\t resolve();\n\t }, _this);\n\t });\n\t };\n\t return GoldBag;\n\t}(engine.Container));\n\t//# sourceMappingURL=GoldBag.js.map\n\n\tvar ObjectPool = engine.ObjectPool;\n\tvar PoolName = 'gold-bag';\n\tObjectPool.registerPool(PoolName, function () {\n\t return new GoldBag();\n\t}, function (item, data) {\n\t item.reset(data);\n\t});\n\tvar GameView = (function (_super) {\n\t tslib.__extends(GameView, _super);\n\t function GameView() {\n\t var _this = _super.call(this) || this;\n\t _this.index = -1;\n\t _this.goldBags = [];\n\t _this.baseOffset = -props.baseOffset + props.playerOffset;\n\t _this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);\n\t return _this;\n\t }\n\t GameView.prototype.setup = function () {\n\t if (this._hasSetup) {\n\t return;\n\t }\n\t this._hasSetup = true;\n\t var _a = this.stage, width = _a.width, height = _a.height;\n\t var background = this.background = new Background();\n\t this.addChild(background);\n\t background.setup();\n\t var frontContainer = this.frontContainer = new engine.Container();\n\t frontContainer.x = width / 2;\n\t this.addChild(frontContainer);\n\t var guideLayer = this.guideLayer = new GuideLayer();\n\t this.addChild(guideLayer);\n\t var base = this.base = new Base();\n\t frontContainer.addChild(base);\n\t base.setup();\n\t var blockContainer = this.blockContainer = new engine.Container();\n\t frontContainer.addChild(blockContainer);\n\t var player = this.player = new Player();\n\t frontContainer.addChild(player);\n\t player.setup();\n\t player.addEventListener('jump-on-top', this.onPlayerJumpOnTop, this);\n\t ObjectPool.recycleObject(PoolName, ObjectPool.getObject(PoolName, {\n\t y: 0,\n\t remain: 0,\n\t }));\n\t this.hitEffect = createSvga('被撞烟雾', 'hitEffectAnchor');\n\t this.pos = 0;\n\t this.background.setup();\n\t this.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);\n\t this.reset();\n\t };\n\t GameView.prototype.reset = function (revive) {\n\t if (revive === void 0) { revive = false; }\n\t return tslib.__awaiter(this, void 0, void 0, function () {\n\t var blockContainer, i, li, block, i, i, li, goldBag;\n\t return tslib.__generator(this, function (_a) {\n\t switch (_a.label) {\n\t case 0:\n\t this.base.reset();\n\t this.index = -1;\n\t this._score = 0;\n\t if (revive) ;\n\t else {\n\t this.pos = 0;\n\t blockContainer = this.blockContainer;\n\t for (i = 0, li = blockContainer.children.length; i < li; i++) {\n\t block = blockContainer.getChildAt(i);\n\t block.playLeave();\n\t }\n\t }\n\t for (i = 0; i < props.initBlockCount; i++) {\n\t this.addBlock(false);\n\t }\n\t for (i = 0, li = this.goldBags.length; i < li; i++) {\n\t goldBag = this.goldBags[i];\n\t this.frontContainer.removeChild(goldBag);\n\t ObjectPool.recycleObject(PoolName, goldBag);\n\t }\n\t this.goldBags.splice(0);\n\t this.playZoom('in');\n\t return [4, this.resetPlayer(revive)];\n\t case 1:\n\t _a.sent();\n\t return [2];\n\t }\n\t });\n\t });\n\t };\n\t GameView.prototype.resetPlayer = function (revive) {\n\t if (revive === void 0) { revive = false; }\n\t return tslib.__awaiter(this, void 0, void 0, function () {\n\t return tslib.__generator(this, function (_a) {\n\t this.player.reset(revive);\n\t this.player.y = this.baseOffset - (this.index + 1) * props.blockHitHeight;\n\t return [2];\n\t });\n\t });\n\t };\n\t GameView.prototype.start = function (revive) {\n\t if (revive === void 0) { revive = false; }\n\t return tslib.__awaiter(this, void 0, void 0, function () {\n\t var guideFlagKey, guideFlag;\n\t var _this = this;\n\t return tslib.__generator(this, function (_a) {\n\t switch (_a.label) {\n\t case 0:\n\t if (!!revive) return [3, 2];\n\t return [4, this.player.playReady()];\n\t case 1:\n\t _a.sent();\n\t _a.label = 2;\n\t case 2:\n\t guideFlagKey = 'jump-high-guide_' + props.guideFlagKey;\n\t guideFlag = localStorage.getItem(guideFlagKey);\n\t if (!!guideFlag) return [3, 4];\n\t localStorage.setItem(guideFlagKey, '1');\n\t return [4, this.guideLayer.show('', { y: this.stage.height + this.player.y - 280 })];\n\t case 3:\n\t _a.sent();\n\t _a.label = 4;\n\t case 4:\n\t this.lastLandType = 0;\n\t this._remainToShowGoldBag = props.goldBagScoreMultiple - props.goldBagScoreSubtraction;\n\t this._touchEnabled = true;\n\t setTimeout(function () {\n\t _this.addBlock();\n\t }, 100);\n\t engine.globalEvent.dispatchEvent('jump-high-game-start');\n\t return [2];\n\t }\n\t });\n\t });\n\t };\n\t GameView.prototype.pause = function () {\n\t if (this.currentBlock) {\n\t engine.Tween.pauseTweens(this.currentBlock);\n\t }\n\t engine.Tween.pauseTweens(this.player);\n\t };\n\t GameView.prototype.resume = function () {\n\t if (this.currentBlock) {\n\t engine.Tween.resumeTweens(this.currentBlock);\n\t }\n\t engine.Tween.resumeTweens(this.player);\n\t };\n\t GameView.prototype.revive = function () {\n\t return tslib.__awaiter(this, void 0, void 0, function () {\n\t return tslib.__generator(this, function (_a) {\n\t switch (_a.label) {\n\t case 0:\n\t this.blockContainer.getChildAt(this.index).visible = false;\n\t this.index--;\n\t return [4, this.resetPlayer(true)];\n\t case 1:\n\t _a.sent();\n\t return [4, this.playZoom('in')];\n\t case 2:\n\t _a.sent();\n\t this.start(true);\n\t return [2];\n\t }\n\t });\n\t });\n\t };\n\t GameView.prototype.addBlock = function (animation) {\n\t var _this = this;\n\t if (animation === void 0) { animation = true; }\n\t this.index++;\n\t var blockContainer = this.blockContainer;\n\t var block;\n\t if (blockContainer.children.length > this.index) {\n\t block = blockContainer.getChildAt(this.index);\n\t block.visible = true;\n\t }\n\t else {\n\t block = new Block();\n\t blockContainer.addChild(block);\n\t }\n\t block.reset({\n\t type: Math.floor(Math.random() * props.blockAssets.length),\n\t });\n\t block.y = this.baseOffset - this.index * props.blockHitHeight;\n\t this.blockComplete = false;\n\t block.playEnter(this.index, animation).then(function (data) {\n\t _this.blockComplete = true;\n\t });\n\t if (animation) {\n\t this.needHitTest = true;\n\t }\n\t this.currentBlock = block;\n\t };\n\t GameView.prototype.addGoldBag = function () {\n\t var goldBag = ObjectPool.getObject(PoolName, {\n\t y: this.baseOffset - (this.blockCount + props.goldBagDistance + props.goldBagJumpSubtraction) * props.blockHitHeight,\n\t remain: props.goldBagDistance,\n\t });\n\t this.frontContainer.addChild(goldBag);\n\t this.goldBags.push(goldBag);\n\t };\n\t GameView.prototype.playOpenGoldBag = function () {\n\t return tslib.__awaiter(this, void 0, void 0, function () {\n\t var i, li, goldBag;\n\t return tslib.__generator(this, function (_a) {\n\t switch (_a.label) {\n\t case 0:\n\t i = 0, li = this.goldBags.length;\n\t _a.label = 1;\n\t case 1:\n\t if (!(i < li)) return [3, 4];\n\t goldBag = this.goldBags[i];\n\t goldBag.remain--;\n\t if (!(goldBag.remain <= 0)) return [3, 3];\n\t this.goldBags.splice(i, 1);\n\t i--;\n\t li--;\n\t this.nextToUpdateScore = true;\n\t return [4, goldBag.playOpen()];\n\t case 2:\n\t _a.sent();\n\t this.frontContainer.removeChild(goldBag);\n\t ObjectPool.recycleObject(PoolName, goldBag);\n\t _a.label = 3;\n\t case 3:\n\t i++;\n\t return [3, 1];\n\t case 4: return [2];\n\t }\n\t });\n\t });\n\t };\n\t GameView.prototype.onPlayerJumpOnTop = function () {\n\t if (this.nextToUpdateScore) {\n\t this.nextToUpdateScore = false;\n\t this.scoreChange(4);\n\t playSound('撞击钱袋音效');\n\t }\n\t };\n\t Object.defineProperty(GameView.prototype, \"blockCount\", {\n\t get: function () {\n\t return this.index - props.initBlockCount + 1;\n\t },\n\t enumerable: false,\n\t configurable: true\n\t });\n\t Object.defineProperty(GameView.prototype, \"pos\", {\n\t get: function () {\n\t return this._pos;\n\t },\n\t set: function (v) {\n\t this._pos = v;\n\t this.updatePos();\n\t },\n\t enumerable: false,\n\t configurable: true\n\t });\n\t GameView.prototype.updatePos = function () {\n\t this.frontContainer.y = this.stage.height + this._pos;\n\t };\n\t GameView.prototype.onEnterFrame = function (event) {\n\t if (this.needHitTest) {\n\t if (this.currentBlock) {\n\t var _a = this.currentBlock, bx = _a.x, by = _a.y, dir = _a.dir;\n\t var _b = this.player, px = _b.x, py = _b.y;\n\t var blockHitWidth = props.blockHitWidth, blockHitHeight = props.blockHitHeight, playerWidth = props.playerWidth;\n\t var hitOn = false;\n\t if (Math.abs(px - bx) < (blockHitWidth + playerWidth) / 2) {\n\t this.player.changeBaseY(by - blockHitHeight);\n\t if (py > by - blockHitHeight) {\n\t hitOn = true;\n\t }\n\t }\n\t if (hitOn) {\n\t this.onHitOn(dir);\n\t }\n\t }\n\t }\n\t };\n\t GameView.prototype.onHitOn = function (dir) {\n\t return tslib.__awaiter(this, void 0, void 0, function () {\n\t return tslib.__generator(this, function (_a) {\n\t switch (_a.label) {\n\t case 0:\n\t this._touchEnabled = false;\n\t this.needHitTest = false;\n\t clearInterval(this.timer);\n\t this.currentBlock.stop();\n\t this.playHitEffect(dir);\n\t return [4, this.player.hitAway(dir)];\n\t case 1:\n\t _a.sent();\n\t this.playZoom('out');\n\t return [4, this.player.parachute(dir)];\n\t case 2:\n\t _a.sent();\n\t engine.globalEvent.dispatchEvent('jump-high-game-end');\n\t return [2];\n\t }\n\t });\n\t });\n\t };\n\t GameView.prototype.jump = function () {\n\t return tslib.__awaiter(this, void 0, void 0, function () {\n\t var result, pos, type, lastLandType;\n\t var _this = this;\n\t return tslib.__generator(this, function (_a) {\n\t switch (_a.label) {\n\t case 0:\n\t if (!this._touchEnabled) {\n\t return [2];\n\t }\n\t this._touchEnabled = false;\n\t this.playOpenGoldBag();\n\t return [4, this.player.jump()];\n\t case 1:\n\t result = _a.sent();\n\t if (!result) return [3, 5];\n\t if (!result.aboveBlock) return [3, 4];\n\t pos = Math.abs(this.currentBlock.x);\n\t type = 0;\n\t if (pos > 0) {\n\t type = pos > 0 && pos < props.scoreThreshold ? 2 : 3;\n\t }\n\t lastLandType = this.lastLandType;\n\t this.lastLandType = type;\n\t if (type === 0) {\n\t if (lastLandType !== type) {\n\t type = 1;\n\t }\n\t }\n\t if (type < 3) {\n\t this.currentBlock.playEffect();\n\t }\n\t this.player.playLand(type, this.currentBlock.dir);\n\t this.currentBlock.stop();\n\t this.scoreChange(type);\n\t return [4, this.playShake()];\n\t case 2:\n\t _a.sent();\n\t return [4, new Promise(function (resolve) {\n\t engine.Tween.get(_this, null, null, true)\n\t .to({ pos: props.blockHitHeight * _this.index }, 300, engine.Ease.cubicOut)\n\t .call(resolve);\n\t })];\n\t case 3:\n\t _a.sent();\n\t this.addBlock();\n\t _a.label = 4;\n\t case 4:\n\t this._touchEnabled = true;\n\t _a.label = 5;\n\t case 5: return [2];\n\t }\n\t });\n\t });\n\t };\n\t GameView.prototype.scoreChange = function (type) {\n\t var scoreAdd = props.scoreWeights[type];\n\t this._score += scoreAdd;\n\t this._remainToShowGoldBag -= scoreAdd;\n\t var score = this._score;\n\t engine.globalEvent.dispatchEvent('jump-high-score', {\n\t type: type,\n\t score: score,\n\t scoreAdd: scoreAdd,\n\t });\n\t console.log(score, this._remainToShowGoldBag);\n\t if (this._remainToShowGoldBag <= 0) {\n\t this._remainToShowGoldBag += props.goldBagScoreMultiple;\n\t this.addGoldBag();\n\t console.log('addGoldBag');\n\t }\n\t };\n\t GameView.prototype.playHitEffect = function (dir) {\n\t var hitEffect = this.hitEffect;\n\t hitEffect.scaleX = dir;\n\t hitEffect.y = this.player.y - props.hitEffectAnchor.y;\n\t hitEffect.play(true, false);\n\t hitEffect.once(engine.Event.END_FRAME, function () {\n\t this.frontContainer.removeChild(hitEffect);\n\t }, this);\n\t this.frontContainer.addChild(hitEffect);\n\t };\n\t GameView.prototype.playZoom = function (type, duration) {\n\t var _this = this;\n\t if (duration === void 0) { duration = 700; }\n\t this.background.playZoom(type, duration);\n\t var count = this.stage.height / props.blockHitHeight;\n\t return new Promise(function (resolve) {\n\t _this.frontContainer.anchorY = -props.blockHitHeight * (_this.index + count * 1.3) + props.baseOffset;\n\t var scale = type === 'in' ? 1 : Math.min((_this.stage.height / props.blockHitHeight / (_this.index + count)), props.maxScale);\n\t console.log(scale);\n\t engine.Tween.get(_this.frontContainer, null, null, true)\n\t .to({ scaleX: scale, scaleY: scale }, duration, engine.Ease.cubicInOut)\n\t .call(resolve);\n\t });\n\t };\n\t GameView.prototype.playShake = function () {\n\t var _this = this;\n\t var _a = this.frontContainer, x = _a.x, y = _a.y;\n\t return new Promise(function (resolve) {\n\t var shakeOffset = 7;\n\t var duration = 30;\n\t engine.Tween.get(_this.frontContainer, null, null, true)\n\t .to({ x: x, y: y - shakeOffset }, duration)\n\t .to({ x: x, y: y + shakeOffset }, duration)\n\t .to({ x: x + shakeOffset, y: y }, duration)\n\t .to({ x: x - shakeOffset, y: y }, duration)\n\t .to({ x: x, y: y }, duration)\n\t .call(resolve);\n\t });\n\t };\n\t return GameView;\n\t}(engine.Container));\n\t//# sourceMappingURL=GameView.js.map\n\n\tvar JumpHigh = (function (_super) {\n\t tslib.__extends(JumpHigh, _super);\n\t function JumpHigh() {\n\t var _this = _super.call(this) || this;\n\t engine.globalEvent.addEventListener('jump-high-reset', _this.reset, _this);\n\t engine.globalEvent.addEventListener('jump-high-start', _this.start, _this);\n\t engine.globalEvent.addEventListener('jump-high-pause', _this.pause, _this);\n\t engine.globalEvent.addEventListener('jump-high-resume', _this.resume, _this);\n\t engine.globalEvent.addEventListener('jump-high-revive', _this.revive, _this);\n\t _this.addEventListener(engine.MouseEvent.MOUSE_DOWN, _this.onTap, _this);\n\t var gameView = _this._gameView = new GameView();\n\t _this.addChild(gameView);\n\t return _this;\n\t }\n\t JumpHigh.prototype.reset = function () {\n\t this._gameView.reset();\n\t };\n\t JumpHigh.prototype.start = function (event) {\n\t {\n\t injectProps(event.data);\n\t }\n\t this._status = 1;\n\t this._gameView.start();\n\t };\n\t JumpHigh.prototype.pause = function () {\n\t this._gameView.pause();\n\t };\n\t JumpHigh.prototype.resume = function () {\n\t this._gameView.resume();\n\t };\n\t JumpHigh.prototype.revive = function () {\n\t this._gameView.revive();\n\t };\n\t JumpHigh.prototype.onTap = function (event) {\n\t this._gameView.jump();\n\t };\n\t return JumpHigh;\n\t}(engine.Container));\n\t//# sourceMappingURL=JumpHigh.js.map\n\n\tfunction index (props) {\n\t prepareProps();\n\t injectProps(props);\n\t var instance = new JumpHigh();\n\t return instance;\n\t}\n\t//# sourceMappingURL=index.js.map\n\n\treturn index;\n\n})));\n"
} }
...@@ -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 SubjectManager = (function () { var SubjectManager = (function () {
function SubjectManager() { function SubjectManager() {
...@@ -64,7 +63,6 @@ ...@@ -64,7 +63,6 @@
}; };
return SubjectManager; return SubjectManager;
}()); }());
//# sourceMappingURL=SubjectManager.js.map
function getTexture(uuid) { function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid); return engine.Texture.from(getAssetByUUID(uuid).uuid);
...@@ -86,7 +84,6 @@ ...@@ -86,7 +84,6 @@
GameState[GameState["STATE_START"] = 0] = "STATE_START"; GameState[GameState["STATE_START"] = 0] = "STATE_START";
GameState[GameState["STATE_END"] = 1] = "STATE_END"; GameState[GameState["STATE_END"] = 1] = "STATE_END";
})(GameState || (GameState = {})); })(GameState || (GameState = {}));
//# sourceMappingURL=utils.js.map
var Background = (function (_super) { var Background = (function (_super) {
tslib.__extends(Background, _super); tslib.__extends(Background, _super);
...@@ -133,7 +130,6 @@ ...@@ -133,7 +130,6 @@
}; };
return Background; return Background;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=Background.js.map
var SvgaManager = (function () { var SvgaManager = (function () {
function SvgaManager() { function SvgaManager() {
...@@ -167,7 +163,6 @@ ...@@ -167,7 +163,6 @@
}; };
return SvgaManager; return SvgaManager;
}()); }());
//# sourceMappingURL=SvgaManager.js.map
var SubjectTitle = (function (_super) { var SubjectTitle = (function (_super) {
tslib.__extends(SubjectTitle, _super); tslib.__extends(SubjectTitle, _super);
...@@ -435,7 +430,6 @@ ...@@ -435,7 +430,6 @@
}; };
return SubjectTitle; return SubjectTitle;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=SubjectTitle.js.map
var AnswerArea = (function (_super) { var AnswerArea = (function (_super) {
tslib.__extends(AnswerArea, _super); tslib.__extends(AnswerArea, _super);
...@@ -812,7 +806,6 @@ ...@@ -812,7 +806,6 @@
}; };
return AnswerArea; return AnswerArea;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=answerArea.js.map
var GameView = (function (_super) { var GameView = (function (_super) {
tslib.__extends(GameView, _super); tslib.__extends(GameView, _super);
...@@ -849,7 +842,6 @@ ...@@ -849,7 +842,6 @@
}; };
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);
...@@ -891,7 +883,6 @@ ...@@ -891,7 +883,6 @@
}; };
return GameWrapper; return GameWrapper;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=GameWrapper.js.map
function index (props) { function index (props) {
prepareProps(); prepareProps();
...@@ -899,7 +890,6 @@ ...@@ -899,7 +890,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.
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
function getTextureByName(name) { function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid); return getTexture(engine.getAssetByName(name).uuid);
} }
//# sourceMappingURL=utils.js.map
var GameTest = (function (_super) { var GameTest = (function (_super) {
tslib.__extends(GameTest, _super); tslib.__extends(GameTest, _super);
...@@ -100,8 +99,10 @@ ...@@ -100,8 +99,10 @@
radius: 1 / this.factor, radius: 1 / this.factor,
}); });
var boardPointBody = new p2.Body({ var boardPointBody = new p2.Body({
position: [100 / this.factor,] position: [100 / this.factor, 800 / this.factor]
}); });
boardPointBody.addShape(boardPoint);
boardPointBody.displays = [];
var boxShape = new p2.Circle({ radius: 60 / this.factor }); var boxShape = new p2.Circle({ radius: 60 / this.factor });
this.boxBody = new p2.Body({ this.boxBody = new p2.Body({
mass: 0.1, mass: 0.1,
...@@ -192,7 +193,6 @@ ...@@ -192,7 +193,6 @@
function injectProps(p) { function injectProps(p) {
engine.injectProp(props, p); engine.injectProp(props, p);
} }
//# sourceMappingURL=props.js.map
var GameWrapper = (function (_super) { var GameWrapper = (function (_super) {
tslib.__extends(GameWrapper, _super); tslib.__extends(GameWrapper, _super);
...@@ -213,7 +213,6 @@ ...@@ -213,7 +213,6 @@
}; };
return GameWrapper; return GameWrapper;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=GameWrapper.js.map
function index (props) { function index (props) {
prepareProps(); prepareProps();
...@@ -221,7 +220,6 @@ ...@@ -221,7 +220,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/basket/src/game/utils.ts","src/custom/basket/src/game/GameTest.ts","src/custom/basket/src/props.ts","src/custom/basket/src/game/GameWrapper.ts","src/custom/basket/src/index.ts"],"sourcesContent":["/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\n\r\nexport function getTexture(uuid) {\r\n\treturn engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n}\r\n\r\nexport function getTextureByName(name) {\r\n\treturn getTexture(engine.getAssetByName(name).uuid);\r\n}\r\n\r\nexport function playSound(name) {\r\n\tengine.playSound(engine.getAssetByName(name).uuid, {keep: true});\r\n}\r\nexport function createSvga(name, anchorName?) {\r\n\tlet inst = new svga.Svga();\r\n\tinst.source = 'asset://' + engine.getAssetByName(name).uuid;\r\n\treturn inst;\r\n}\r\n\r\n\r\n\r\nexport function getIndexFromRC(row,col,maxCol){\r\n\tlet index;\r\n\tindex = row * maxCol + col ;\r\n\treturn index\r\n}\r\n\r\n\r\n\r\n\r\nexport function getRandomArray(array){\r\n\tarray.sort(function() {\r\n\t\treturn .5 - Math.random();\r\n\t});\r\n}","import { getTextureByName, getTexture } from \"./utils\";\r\n\r\nexport default class GameTest extends engine.Container {\r\n world: p2.World;\r\n planeBody: p2.Body;\r\n isDebug = true;\r\n private plane;\r\n private boxBody: p2.Body;\r\n factor = 10;\r\n\r\n private isRight = false;\r\n private saleX = this.isRight ? 1 : -1;\r\n\r\n private ballAddSpeedX = -10;\r\n private ballAddSpeedY = 30;\r\n\r\n constructor() {\r\n super();\r\n this.addEventListener(engine.Event.ADDED_TO_STAGE, this.setup, this);\r\n }\r\n start() {\r\n console.log(\"starting\");\r\n\r\n // this.stage.addEventListener(\r\n // engine.MouseEvent.CLICK,\r\n // this.onClick,\r\n // this\r\n // );\r\n\r\n this.stage.addEventListener(\r\n engine.MouseEvent.CLICK,\r\n this.clickball,\r\n this\r\n );\r\n }\r\n\r\n onClick(e: engine.MouseEvent) {\r\n const { world, factor } = this;\r\n\r\n var positionX: number = e.stageX / factor;\r\n var positionY: number =\r\n (engine.gameStage.stage.height - e.stageY) / factor;\r\n var display: engine.DisplayObject;\r\n var self = this;\r\n if (Math.random() > 0.5) {\r\n //添加方形刚体\r\n var boxShape: p2.Shape = new p2.Box({\r\n width: 200 / factor,\r\n height: 100 / factor,\r\n });\r\n var boxBody: p2.Body = new p2.Body({\r\n mass: 1,\r\n position: [positionX, positionY],\r\n angularVelocity: 1,\r\n });\r\n boxBody.addShape(boxShape);\r\n world.addBody(boxBody);\r\n\r\n // if (this.isDebug) {\r\n if (true) {\r\n display = this.createBox(\r\n (<p2.Box>boxShape).width * factor,\r\n (<p2.Box>boxShape).height * factor\r\n );\r\n } else {\r\n // display = self.createBitmapByName(\"rect\");\r\n // display.width = (<p2.Box>boxShape).width * factor;\r\n // display.height = (<p2.Box>boxShape).height * factor;\r\n }\r\n } else {\r\n //添加圆形刚体\r\n var boxShape: p2.Shape = new p2.Circle({\r\n radius: 60 / factor,\r\n });\r\n var boxBody: p2.Body = new p2.Body({\r\n mass: 1,\r\n position: [positionX, positionY],\r\n });\r\n boxBody.addShape(boxShape);\r\n world.addBody(boxBody);\r\n\r\n // if (this.isDebug) {\r\n if (false) {\r\n display = this.createBall(\r\n (<p2.Circle>boxShape).radius * factor\r\n );\r\n } else {\r\n display = this.createBitmapByName(\"篮球\");\r\n // display.width = (<p2.Circle>boxShape).radius * 2 * this.factor;\r\n // display.height = (<p2.Circle>boxShape).radius * 2 * this.factor;\r\n }\r\n\r\n // display.width = (<p2.Circle>boxShape).radius * 2 * factor;\r\n // display.height = (<p2.Circle>boxShape).radius * 2 * factor;\r\n }\r\n\r\n // display.anchorX = display.width / 2;\r\n // display.anchorY = display.height / 2;\r\n\r\n boxBody.displays = [display];\r\n\r\n this.addChild(display);\r\n }\r\n\r\n setup() {\r\n // // 创建地平面\r\n // var plane: p2.Plane = new p2.Plane();\r\n // this.planeBody = new p2.Body({\r\n // position: [0, 100 / this.factor],\r\n // type:p2.Body.STATIC\r\n // });\r\n\r\n // // this.planeBody.angle = Math.PI;\r\n\r\n // this.planeBody.addShape(plane);\r\n\r\n // this.world.addBody(this.planeBody);\r\n // this.plane = this.createPlane(\r\n // 0,\r\n // 100,\r\n // engine.gameStage.width,\r\n // 20\r\n // );\r\n\r\n // this.planeBody.displays = [this.plane];\r\n\r\n console.log(\"setup\");\r\n\r\n //创建world\r\n var world: p2.World = new p2.World({\r\n // gravity: [0, -1],\r\n });\r\n\r\n world.sleepMode = p2.World.BODY_SLEEPING;\r\n world.defaultContactMaterial.friction = 0.3;\r\n world.defaultContactMaterial.restitution = 0.7;\r\n //创建plane\r\n var planeShape: p2.Plane = new p2.Plane();\r\n var planeBody: p2.Body = new p2.Body({\r\n type:p2.Body.STATIC\r\n });\r\n planeBody.addShape(planeShape);\r\n planeBody.displays = [];\r\n world.addBody(planeBody);\r\n this.world = world;\r\n\r\n this.stage.addEventListener(\r\n engine.Event.ENTER_FRAME,\r\n this.onEnterFrame,\r\n this\r\n );\r\n\r\n\r\n var display: engine.DisplayObject;\r\n\r\n // 背景\r\n let gameBg = new engine.Sprite(getTextureByName(\"背景\"));\r\n this.addChild(gameBg);\r\n \r\n\r\n // 篮板\r\n var boardShape:p2.Shape = new p2.Box({\r\n width:20/this.factor,\r\n height:200/this.factor\r\n });\r\n var boardBody = new p2.Body({\r\n position:[80/this.factor,1000/this.factor]\r\n })\r\n boardBody.addShape(boardShape);\r\n let board = this.createBitmapByName('篮板');\r\n this.addChild(board)\r\n boardBody.displays = [board];\r\n this.world.addBody(boardBody)\r\n\r\n // 框点\r\n var boardPoint:p2.Shape = new p2.Circle({\r\n radius:1/this.factor,\r\n })\r\n var boardPointBody:p2.Body = new p2.Body({\r\n position:[100/this.factor,]\r\n })\r\n\r\n // 篮球\r\n var boxShape: p2.Shape = new p2.Circle({radius: 60 / this.factor});\r\n this.boxBody = new p2.Body({\r\n mass: 0.1,\r\n position: [300/this.factor, 900/this.factor],\r\n velocity:[-5,-10],\r\n angularVelocity:-1\r\n });\r\n let balldisplay = this.createBitmapByName(\"篮球\");\r\n this.addChild(balldisplay)\r\n this.boxBody.displays = [balldisplay]\r\n this.boxBody.addShape(boxShape);\r\n this.world.addBody(this.boxBody);\r\n\r\n\r\n }\r\n\r\n onEnterFrame() {\r\n this.world.step(60 / 1000);\r\n var len: number = this.world.bodies.length;\r\n for (var i: number = 0; i < len; i++) {\r\n var body: p2.Body = this.world.bodies[i];\r\n var display: engine.DisplayObject = body.displays[0];\r\n const stageHeight = engine.gameStage.stage.height;\r\n if (display) {\r\n display.x = body.position[0] * this.factor; //同步刚体和egret显示对象的位置和旋转角度\r\n display.y = stageHeight - body.position[1] * this.factor;\r\n\r\n display.rotation =\r\n ((body.angle + body.shapes[0].angle) * 180) / Math.PI;\r\n if (body.sleepState == p2.Body.SLEEPING) {\r\n display.alpha = 0.5;\r\n } else {\r\n display.alpha = 1;\r\n }\r\n }\r\n // display.rotation = (body.angle * 180) / Math.PI;\r\n }\r\n if(this.boxBody.position[0] < -120/this.factor){\r\n this.boxBody.position[0] = (750 + 120) / this.factor;\r\n }\r\n if(this.boxBody.position[0] > (750 +120) / this.factor){\r\n this.boxBody.position[0] = -120 /this.factor\r\n }\r\n\r\n }\r\n clickball(){\r\n var direction = this.isRight ? -1 : 1;\r\n this.boxBody.velocity[0] = this.ballAddSpeedX * direction;\r\n this.boxBody.velocity[1] = this.ballAddSpeedY;\r\n this.boxBody.angularVelocity = -2 * direction;\r\n }\r\n\r\n private createPlane(x, y, w, h) {\r\n var sp = new engine.Shape();\r\n sp.beginFill(0x0000ff, 1);\r\n sp.drawRect(x, y, w, h);\r\n sp.endFill();\r\n // sp.anchorX = sp.width / 2;\r\n // sp.anchorY = sp.height / 2;\r\n this.addChild(sp);\r\n return sp;\r\n }\r\n\r\n private createBall(r) {\r\n var sp = new engine.Shape();\r\n sp.beginFill(0xff0000, 0.4);\r\n sp.drawCircle(0, 0, r);\r\n sp.endFill();\r\n // this.addChild(sp);\r\n return sp;\r\n }\r\n\r\n private createBox(width, height) {\r\n var sp = new engine.Shape();\r\n sp.beginFill(0xf0f0f0, 1);\r\n sp.drawRect(-width / 2, -height / 2, width, height);\r\n sp.endFill();\r\n // sp.anchorX = w / 2;\r\n // sp.anchorY = h / 2;\r\n return sp;\r\n }\r\n\r\n // 图片的中心点位置\r\n private createBitmapByName(name) {\r\n const imgContainer = new engine.Sprite();\r\n const img = new engine.Sprite(getTextureByName(name));\r\n img.anchorX = img.width / 2;\r\n img.anchorY = img.height / 2;\r\n img.x = -img.width / 2;\r\n img.y = -img.height / 2;\r\n imgContainer.addChild(img);\r\n return imgContainer;\r\n }\r\n\r\n stop() {}\r\n}\r\n","\r\n\r\nexport let props: any = {};\r\n\r\nexport function prepareProps() {\r\n\tlet metaProps = getProps();\r\n\r\n\tengine.injectProp(props, metaProps);\r\n}\r\n\r\nexport function injectProps(p) {\r\n\tengine.injectProp(props, p);\r\n}\r\n","\r\nimport GameView from \"./GameView\";\r\nimport GameTest from './GameTest'\r\n\r\nimport { injectProps } from \"../props\";\r\n\r\n\r\nexport class GameWrapper extends engine.Container {\r\n\t// private _status;\r\n\tprivate _gameView: GameView;\r\n\tprivate _gameTest: GameTest;\r\n\r\n\tconstructor() {\r\n\t\tsuper();\r\n\r\n\t\tengine.globalEvent.addEventListener('game-start', this.start, this);\r\n\t\tengine.globalEvent.addEventListener('game-stop', this.stop, this);\r\n\r\n\t\t//创建实例\r\n\t\t// let gameView = this._gameView = new GameView();\r\n\t\t// this.addChild(gameView);\r\n\t\tlet gameTest = this._gameTest = new GameTest();\r\n\t\tthis.addChild(gameTest);\r\n\r\n\t}\r\n\r\n\tstart(event: engine.Event) {\r\n\t\tinjectProps(event.data);\r\n\r\n\t\t// this._status = 1;\r\n\r\n\t\t// this._gameView.start();\r\n\t\tthis._gameTest.start();\r\n\t}\r\n\tstop(event: engine.Event) {\r\n\t\t\r\n\t\t// this._gameView.stop();\r\n\t\tthis._gameTest.stop();\r\n\t}\r\n\r\n\t// reset(event:engine.Event){\r\n\t// \tthis._gameView.reset();\r\n\t// }\r\n}\r\n","\r\n\r\nimport {GameWrapper} from \"./game/GameWrapper\";\r\nimport {injectProps, prepareProps} from \"./props\";\r\n\r\nexport default function (props) {\r\n\tprepareProps();\r\n\tinjectProps(props);\r\n\r\n\tlet instance = new GameWrapper();\r\n\t\r\n\treturn instance;\r\n}\r\n"],"names":["__extends"],"mappings":";;;;;;UAIgB,UAAU,CAAC,IAAI;KAC9B,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAA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CAAC;CAC7B,CAAC;;;CCLD;KAAiCA,qCAAgB;KAKhD;SAAA,YACC,iBAAO,SAWP;SATA,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,YAAY,EAAE,KAAI,CAAC,KAAK,EAAE,KAAI,CAAC,CAAC;SACpE,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,WAAW,EAAE,KAAI,CAAC,IAAI,EAAE,KAAI,CAAC,CAAC;SAKlE,IAAI,QAAQ,GAAG,KAAI,CAAC,SAAS,GAAG,IAAI,QAAQ,EAAE,CAAC;SAC/C,KAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;;MAExB;KAED,2BAAK,GAAL,UAAM,KAAmB;SACxB,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SAKxB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;MACvB;KACD,0BAAI,GAAJ,UAAK,KAAmB;SAGvB,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;MACtB;KAKF,kBAAC;CAAD,CAAC,CApCgC,MAAM,CAAC,SAAS,GAoChD;;;iBCtCwB,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/basket/src/game/utils.ts","src/custom/basket/src/game/GameTest.ts","src/custom/basket/src/props.ts","src/custom/basket/src/game/GameWrapper.ts","src/custom/basket/src/index.ts"],"sourcesContent":["/**\n * Created by rockyl on 2020-01-21.\n */\n\nexport function getTexture(uuid) {\n\treturn engine.Texture.from(getAssetByUUID(uuid).uuid);\n}\n\nexport function getTextureByName(name) {\n\treturn getTexture(engine.getAssetByName(name).uuid);\n}\n\nexport function playSound(name) {\n\tengine.playSound(engine.getAssetByName(name).uuid, {keep: true});\n}\nexport function createSvga(name, anchorName?) {\n\tlet inst = new svga.Svga();\n\tinst.source = 'asset://' + engine.getAssetByName(name).uuid;\n\treturn inst;\n}\n\n\n\nexport function getIndexFromRC(row,col,maxCol){\n\tlet index;\n\tindex = row * maxCol + col ;\n\treturn index\n}\n\n\n\n\nexport function getRandomArray(array){\n\tarray.sort(function() {\n\t\treturn .5 - Math.random();\n\t});\n}","import { getTextureByName, getTexture } from \"./utils\";\n\nexport default class GameTest extends engine.Container {\n world: p2.World;\n planeBody: p2.Body;\n isDebug = true;\n private plane;\n private boxBody: p2.Body;\n factor = 10;\n\n private isRight = false;\n private saleX = this.isRight ? 1 : -1;\n\n private ballAddSpeedX = -10;\n private ballAddSpeedY = 30;\n\n constructor() {\n super();\n this.addEventListener(engine.Event.ADDED_TO_STAGE, this.setup, this);\n }\n start() {\n console.log(\"starting\");\n\n // this.stage.addEventListener(\n // engine.MouseEvent.CLICK,\n // this.onClick,\n // this\n // );\n\n this.stage.addEventListener(\n engine.MouseEvent.CLICK,\n this.clickball,\n this\n );\n }\n\n onClick(e: engine.MouseEvent) {\n const { world, factor } = this;\n\n var positionX: number = e.stageX / factor;\n var positionY: number =\n (engine.gameStage.stage.height - e.stageY) / factor;\n var display: engine.DisplayObject;\n var self = this;\n if (Math.random() > 0.5) {\n //添加方形刚体\n var boxShape: p2.Shape = new p2.Box({\n width: 200 / factor,\n height: 100 / factor,\n });\n var boxBody: p2.Body = new p2.Body({\n mass: 1,\n position: [positionX, positionY],\n angularVelocity: 1,\n });\n boxBody.addShape(boxShape);\n world.addBody(boxBody);\n\n // if (this.isDebug) {\n if (true) {\n display = this.createBox(\n (<p2.Box>boxShape).width * factor,\n (<p2.Box>boxShape).height * factor\n );\n } else {\n // display = self.createBitmapByName(\"rect\");\n // display.width = (<p2.Box>boxShape).width * factor;\n // display.height = (<p2.Box>boxShape).height * factor;\n }\n } else {\n //添加圆形刚体\n var boxShape: p2.Shape = new p2.Circle({\n radius: 60 / factor,\n });\n var boxBody: p2.Body = new p2.Body({\n mass: 1,\n position: [positionX, positionY],\n });\n boxBody.addShape(boxShape);\n world.addBody(boxBody);\n\n // if (this.isDebug) {\n if (false) {\n display = this.createBall(\n (<p2.Circle>boxShape).radius * factor\n );\n } else {\n display = this.createBitmapByName(\"篮球\");\n // display.width = (<p2.Circle>boxShape).radius * 2 * this.factor;\n // display.height = (<p2.Circle>boxShape).radius * 2 * this.factor;\n }\n\n // display.width = (<p2.Circle>boxShape).radius * 2 * factor;\n // display.height = (<p2.Circle>boxShape).radius * 2 * factor;\n }\n\n // display.anchorX = display.width / 2;\n // display.anchorY = display.height / 2;\n\n boxBody.displays = [display];\n\n this.addChild(display);\n }\n\n setup() {\n // // 创建地平面\n // var plane: p2.Plane = new p2.Plane();\n // this.planeBody = new p2.Body({\n // position: [0, 100 / this.factor],\n // type:p2.Body.STATIC\n // });\n\n // // this.planeBody.angle = Math.PI;\n\n // this.planeBody.addShape(plane);\n\n // this.world.addBody(this.planeBody);\n // this.plane = this.createPlane(\n // 0,\n // 100,\n // engine.gameStage.width,\n // 20\n // );\n\n // this.planeBody.displays = [this.plane];\n\n console.log(\"setup\");\n\n //创建world\n var world: p2.World = new p2.World({\n // gravity: [0, -1],\n });\n\n world.sleepMode = p2.World.BODY_SLEEPING;\n world.defaultContactMaterial.friction = 0.3;\n world.defaultContactMaterial.restitution = 0.7;\n //创建plane\n var planeShape: p2.Plane = new p2.Plane();\n var planeBody: p2.Body = new p2.Body({\n type:p2.Body.STATIC\n });\n planeBody.addShape(planeShape);\n planeBody.displays = [];\n world.addBody(planeBody);\n this.world = world;\n\n this.stage.addEventListener(\n engine.Event.ENTER_FRAME,\n this.onEnterFrame,\n this\n );\n\n\n var display: engine.DisplayObject;\n\n // 背景\n let gameBg = new engine.Sprite(getTextureByName(\"背景\"));\n this.addChild(gameBg);\n \n\n // 篮板\n var boardShape:p2.Shape = new p2.Box({\n width:20/this.factor,\n height:200/this.factor\n });\n var boardBody = new p2.Body({\n position:[80/this.factor,1000/this.factor]\n })\n boardBody.addShape(boardShape);\n let board = this.createBitmapByName('篮板');\n this.addChild(board)\n boardBody.displays = [board];\n this.world.addBody(boardBody)\n\n // 框点\n var boardPoint:p2.Shape = new p2.Circle({\n radius:1/this.factor,\n })\n var boardPointBody:p2.Body = new p2.Body({\n position:[100/this.factor,800/this.factor]\n })\n boardPointBody.addShape(boardPoint);\n boardPointBody.displays = []\n\n // 篮球\n var boxShape: p2.Shape = new p2.Circle({radius: 60 / this.factor});\n this.boxBody = new p2.Body({\n mass: 0.1,\n position: [300/this.factor, 900/this.factor],\n velocity:[-5,-10],\n angularVelocity:-1\n });\n let balldisplay = this.createBitmapByName(\"篮球\");\n this.addChild(balldisplay)\n this.boxBody.displays = [balldisplay]\n this.boxBody.addShape(boxShape);\n this.world.addBody(this.boxBody);\n\n\n }\n\n onEnterFrame() {\n this.world.step(60 / 1000);\n var len: number = this.world.bodies.length;\n for (var i: number = 0; i < len; i++) {\n var body: p2.Body = this.world.bodies[i];\n var display: engine.DisplayObject = body.displays[0];\n const stageHeight = engine.gameStage.stage.height;\n if (display) {\n display.x = body.position[0] * this.factor; //同步刚体和egret显示对象的位置和旋转角度\n display.y = stageHeight - body.position[1] * this.factor;\n\n display.rotation =\n ((body.angle + body.shapes[0].angle) * 180) / Math.PI;\n if (body.sleepState == p2.Body.SLEEPING) {\n display.alpha = 0.5;\n } else {\n display.alpha = 1;\n }\n }\n // display.rotation = (body.angle * 180) / Math.PI;\n }\n if(this.boxBody.position[0] < -120/this.factor){\n this.boxBody.position[0] = (750 + 120) / this.factor;\n }\n if(this.boxBody.position[0] > (750 +120) / this.factor){\n this.boxBody.position[0] = -120 /this.factor\n }\n\n }\n clickball(){\n var direction = this.isRight ? -1 : 1;\n this.boxBody.velocity[0] = this.ballAddSpeedX * direction;\n this.boxBody.velocity[1] = this.ballAddSpeedY;\n this.boxBody.angularVelocity = -2 * direction;\n }\n\n private createPlane(x, y, w, h) {\n var sp = new engine.Shape();\n sp.beginFill(0x0000ff, 1);\n sp.drawRect(x, y, w, h);\n sp.endFill();\n // sp.anchorX = sp.width / 2;\n // sp.anchorY = sp.height / 2;\n this.addChild(sp);\n return sp;\n }\n\n private createBall(r) {\n var sp = new engine.Shape();\n sp.beginFill(0xff0000, 0.4);\n sp.drawCircle(0, 0, r);\n sp.endFill();\n // this.addChild(sp);\n return sp;\n }\n\n private createBox(width, height) {\n var sp = new engine.Shape();\n sp.beginFill(0xf0f0f0, 1);\n sp.drawRect(-width / 2, -height / 2, width, height);\n sp.endFill();\n // sp.anchorX = w / 2;\n // sp.anchorY = h / 2;\n return sp;\n }\n\n // 图片的中心点位置\n private createBitmapByName(name) {\n const imgContainer = new engine.Sprite();\n const img = new engine.Sprite(getTextureByName(name));\n img.anchorX = img.width / 2;\n img.anchorY = img.height / 2;\n img.x = -img.width / 2;\n img.y = -img.height / 2;\n imgContainer.addChild(img);\n return imgContainer;\n }\n\n stop() {}\n}\n","\n\nexport let props: any = {};\n\nexport function prepareProps() {\n\tlet metaProps = getProps();\n\n\tengine.injectProp(props, metaProps);\n}\n\nexport function injectProps(p) {\n\tengine.injectProp(props, p);\n}\n","\nimport GameView from \"./GameView\";\nimport GameTest from './GameTest'\n\nimport { injectProps } from \"../props\";\n\n\nexport class GameWrapper extends engine.Container {\n\t// private _status;\n\tprivate _gameView: GameView;\n\tprivate _gameTest: GameTest;\n\n\tconstructor() {\n\t\tsuper();\n\n\t\tengine.globalEvent.addEventListener('game-start', this.start, this);\n\t\tengine.globalEvent.addEventListener('game-stop', this.stop, this);\n\n\t\t//创建实例\n\t\t// let gameView = this._gameView = new GameView();\n\t\t// this.addChild(gameView);\n\t\tlet gameTest = this._gameTest = new GameTest();\n\t\tthis.addChild(gameTest);\n\n\t}\n\n\tstart(event: engine.Event) {\n\t\tinjectProps(event.data);\n\n\t\t// this._status = 1;\n\n\t\t// this._gameView.start();\n\t\tthis._gameTest.start();\n\t}\n\tstop(event: engine.Event) {\n\t\t\n\t\t// this._gameView.stop();\n\t\tthis._gameTest.stop();\n\t}\n\n\t// reset(event:engine.Event){\n\t// \tthis._gameView.reset();\n\t// }\n}\n","\n\nimport {GameWrapper} from \"./game/GameWrapper\";\nimport {injectProps, prepareProps} from \"./props\";\n\nexport default function (props) {\n\tprepareProps();\n\tinjectProps(props);\n\n\tlet instance = new GameWrapper();\n\t\n\treturn instance;\n}\n"],"names":["__extends"],"mappings":";;;;;;UAIgB,UAAU,CAAC,IAAI;KAC9B,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;CACvD,CAAC;UAEe,gBAAgB,CAAC,IAAI;KACpC,OAAO,UAAU,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;CACrD;;CCRA;KAAsCA,kCAAgB;KAclD;SAAA,YACI,iBAAO,SAEV;SAdD,aAAO,GAAG,IAAI,CAAC;SAGf,YAAM,GAAG,EAAE,CAAC;SAEJ,aAAO,GAAG,KAAK,CAAC;SAChB,WAAK,GAAG,KAAI,CAAC,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;SAE9B,mBAAa,GAAG,CAAC,EAAE,CAAC;SACpB,mBAAa,GAAG,EAAE,CAAC;SAIvB,KAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,EAAE,KAAI,CAAC,KAAK,EAAE,KAAI,CAAC,CAAC;;MACxE;KACD,wBAAK,GAAL;SACI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;SAQxB,IAAI,CAAC,KAAK,CAAC,gBAAgB,CACvB,MAAM,CAAC,UAAU,CAAC,KAAK,EACvB,IAAI,CAAC,SAAS,EACd,IAAI,CACP,CAAC;MACL;KAED,0BAAO,GAAP,UAAQ,CAAoB;SAClB,IAAA,KAAoB,IAAI,EAAtB,KAAK,WAAA,EAAE,MAAM,YAAS,CAAC;SAE/B,IAAI,SAAS,GAAW,CAAC,CAAC,MAAM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,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
...@@ -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);
...@@ -401,7 +395,6 @@ ...@@ -401,7 +395,6 @@
}; };
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);
...@@ -479,7 +472,6 @@ ...@@ -479,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);
...@@ -575,7 +567,6 @@ ...@@ -575,7 +567,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';
...@@ -808,7 +799,6 @@ ...@@ -808,7 +799,6 @@
GameView.speed = 20; GameView.speed = 20;
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);
...@@ -840,7 +830,6 @@ ...@@ -840,7 +830,6 @@
}; };
return GameWrapper; return GameWrapper;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=GameWrapper.js.map
function index (props) { function index (props) {
prepareProps(); prepareProps();
...@@ -848,7 +837,6 @@ ...@@ -848,7 +837,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.
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
inst.source = 'asset://' + engine.getAssetByName(name).uuid; inst.source = 'asset://' + engine.getAssetByName(name).uuid;
return inst; return inst;
} }
//# sourceMappingURL=utils.js.map
var props = {}; var props = {};
function prepareProps() { function prepareProps() {
...@@ -26,7 +25,6 @@ ...@@ -26,7 +25,6 @@
function injectProps(p) { function injectProps(p) {
engine.injectProp(props, p); engine.injectProp(props, p);
} }
//# sourceMappingURL=props.js.map
var Gameinit = (function (_super) { var Gameinit = (function (_super) {
tslib.__extends(Gameinit, _super); tslib.__extends(Gameinit, _super);
...@@ -153,7 +151,6 @@ ...@@ -153,7 +151,6 @@
var instance = new Gameinit(); var instance = new Gameinit();
return instance; return instance;
} }
//# sourceMappingURL=index.js.map
return index; return index;
......
{"version":3,"file":"index.js","sources":["src/custom/circle/src/game/utils.ts","src/custom/circle/src/props.ts","src/custom/circle/src/game/Gameinit.ts","src/custom/circle/src/index.ts"],"sourcesContent":["/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\n\r\nexport function getTexture(uuid) {\r\n\treturn engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n}\r\n\r\nexport function getTextureByName(name) {\r\n\tconsole.log('name',engine.getAssetByName(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\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\tengine.injectProp(props, metaProps);\r\n\r\n}\r\n\r\nexport function injectProps(p) {\r\n\tengine.injectProp(props, p);\r\n}\r\n","\r\nimport { getTextureByName, createSvga } from './utils';\r\nimport { props } from \"../props\";\r\n\r\nexport default class Gameinit extends engine.Container {\r\n\r\n private _isSetUp = false;\r\n private totleY = 1200;\r\n _body: engine.Rect;\r\n isMove = false;\r\n isChoose = true;\r\n isDid = true;\r\n num;\r\n listGift = [];\r\n constructor() {\r\n super();\r\n console.log(\"11111111111111\");\r\n this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);\r\n }\r\n /**首页加载 */\r\n setup() {\r\n console.log(\"初始化加载000000000000000000000000!\");\r\n if (this._isSetUp) {\r\n return;\r\n }\r\n else {\r\n this.loadThings();\r\n console.log(\"this._isSetUp=\", this._isSetUp, '<<<<');\r\n }\r\n }\r\n /**套圈资源加载 */\r\n loadThings() {\r\n let self = this;\r\n let body;\r\n body = this._body = new engine.Rect;\r\n body.width = 0.0001;\r\n body.height = 0.0001;\r\n this.addChild(body);\r\n // let gift4 = this.addRes(body, '礼盒', 35, 115, 215, 122);\r\n let gift0 = this.addRes(body, '礼盒', 250, 100, 247, 188);\r\n let gift1 = this.addRes(body, '礼盒', 485, 85, 247, 190);\r\n let gift2 = this.addRes(body, '礼盒', 385, -15, 222, 170);\r\n let gift3 = this.addRes(body, '礼盒', 165, -15, 222, 170);\r\n let gift4 = this.addRes(body, '礼盒', 20, 85, 247, 190);\r\n this.listGift = [gift0, gift1, gift2, gift3, gift4];\r\n let circle = this.addRes(body, '圈', 260, 350, 240, 80);\r\n let giftSvga = createSvga(\"套中动效\");\r\n giftSvga.visible = false;\r\n body.addChild(giftSvga);\r\n let [v2X, v2Y] = props.ferruleModuleGlobalPosition;\r\n body.x = v2X;\r\n body.y = v2Y;\r\n /* VVVVVVVVVVVVVVVV */\r\n // let btn = this.addRes(body, '礼盒', 300, 900, 150, 150);\r\n // btn.addEventListener(engine.MouseEvent.MOUSE_DOWN, function () {\r\n // self.isMove = true;\r\n // }, this);\r\n // let btn1 = this.addRes(body, '礼盒', 500, 900, 200, 200);\r\n // btn1.addEventListener(engine.MouseEvent.MOUSE_DOWN, function () {\r\n // self.isChoose = true;\r\n // giftSvga.visible = false;\r\n // console.log(body.children[0], body.children[1], body.children[2], body.children[3], body.children[4], body.children[5]);\r\n // body.children[self.num].visible = true;\r\n // circle.x = 260; circle.y = 350; circle.width = 240; circle.height = 80;\r\n // circle.visible = true;\r\n // }, this);\r\n /* AAAAAAAAAAAAAAAAA */\r\n engine.globalEvent.addEventListener(\"circle-game-start\", function () {\r\n self.isMove = true;\r\n console.log('this.isMove===', self.isMove);\r\n }, this);\r\n engine.globalEvent.addEventListener(\"circle-game-init\", function () {\r\n self.isChoose = true;\r\n giftSvga.visible = false;\r\n // console.log(body.children[0], body.children[1], body.children[2], body.children[3], body.children[4], body.children[5]);\r\n body.children[self.num].visible = true;\r\n circle.x = 260; circle.y = 350; circle.width = 240; circle.height = 80;\r\n circle.visible = true;\r\n }, this);\r\n\r\n circle.addEventListener(engine.Event.ENTER_FRAME, function () {\r\n if (self.isMove) {\r\n console.log(\"物体移动\");\r\n if (self.isChoose) {\r\n self.num = Math.floor(Math.random() * self.listGift.length);\r\n self.isChoose = false;\r\n }\r\n self.nodeMove(circle, self.listGift[self.num], giftSvga);\r\n }\r\n });\r\n }\r\n /**套中动画播放 */\r\n aniPlay(node0, targetNode, bool) {\r\n node0.scaleX = this.currentScale(targetNode.y, this.totleY) - 0.05 * this.currentScale(targetNode.y, this.totleY);\r\n node0.scaleY = this.currentScale(targetNode.y, this.totleY) - 0.05 * this.currentScale(targetNode.y, this.totleY);\r\n // node0.anchor.x = node0.width / 2;\r\n // node0.anchor.y = node0.height / 2;\r\n node0.x = targetNode.x;\r\n node0.y = targetNode.y;\r\n node0.visible = true;\r\n node0.play(false, false);\r\n /**动画播放完毕,派发(执行)一个事件 */\r\n node0.addEventListener(engine.Event.END_FRAME, function () {\r\n console.log(\"播放到最后一帧\", bool, '<<<');\r\n engine.globalEvent.dispatchEvent(\"circle-game-end\");\r\n bool = false;\r\n })\r\n }\r\n /**给场景添加图片,resName:资源名字,v2X:资源X位置, v2Y:资源Y位置, resW:资源Width, resH:资源Height */\r\n addRes(fatherNode, resName, v2X, v2Y, resW, resH) {\r\n console.log(\"进行资源的添加\");\r\n let thing = new engine.Sprite(getTextureByName(resName));\r\n thing.x = v2X;\r\n thing.y = v2Y;\r\n thing.width = resW;\r\n thing.height = resH;\r\n return fatherNode.addChild(thing);\r\n }\r\n /** circle move */\r\n nodeMove(moveNode, targetNode, nodePlay) {\r\n console.log(\"moveNode.x=\", moveNode.x, \"targetNode.x=\", targetNode.x);\r\n let moveX = targetNode.x - moveNode.x;\r\n let moveY = targetNode.y - moveNode.y;\r\n console.log('moveX=', moveX, 'moveY=', moveY);\r\n if (this.isDid) {\r\n if (Math.abs(moveX) > 2) {\r\n moveNode.x += moveX / Math.abs(moveX) * 5;\r\n }\r\n if (Math.abs(moveY) > 2) {\r\n moveNode.y += moveY / Math.abs(moveY) * 5;\r\n moveNode.scaleX = this.currentScale(moveNode.y, this.totleY) + 0.2;\r\n moveNode.scaleY = moveNode.scaleX;\r\n }\r\n if (Math.abs(moveX) < 3 && Math.abs(moveY) < 3) {\r\n targetNode.visible = false;\r\n moveNode.visible = false;\r\n this.aniPlay(nodePlay, targetNode, this.isDid);\r\n this.isMove = false;\r\n }\r\n }\r\n }\r\n /**当前位置应该的尺寸大小 */\r\n currentScale(currentY, totoleDisY) {\r\n return (currentY + 830) / totoleDisY;\r\n }\r\n}\r\n","/**\r\n * Created by rockyl on 2019-11-20.\r\n */\r\n\r\nimport Gameinit from \"./game/Gameinit\";\r\nimport { injectProps, prepareProps } from \"./props\";\r\n\r\nexport default function (props) {\r\n\tprepareProps();\r\n\tinjectProps(props);\r\n\tlet instance = new Gameinit();\r\n\treturn instance;\r\n}\r\n"],"names":["__extends"],"mappings":";;;;;;UAIgB,UAAU,CAAC,IAAI;KAC9B,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;CACvD,CAAC;UAEe,gBAAgB,CAAC,IAAI;KACpC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;KAChD,OAAO,UAAU,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,C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G,QAAQ,CAAC,MAAM,CAAC;cACrC;aACD,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;iBAC5C,UAAU,CAAC,OAAO,GAAG,KAAK,CAAC;iBAC3B,QAAQ,CAAC,OAAO,GAAG,KAAK,CAAC;iBACzB,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;iBAC/C,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;cACvB;UACJ;MACJ;KAED,+BAAY,GAAZ,UAAa,QAAQ,EAAE,UAAU;SAC7B,OAAO,CAAC,QAAQ,GAAG,GAAG,IAAI,UAAU,CAAC;MACxC;KACL,eAAC;CAAD,CAAC,CA7IqC,MAAM,CAAC,SAAS,GA6IrD;;iBC1IwB,KAAK;KAC7B,YAAY,EAAE,CAAC;KACf,WAAW,CAAC,KAAK,CAAC,CAAC;KACnB,IAAI,QAAQ,GAAG,IAAI,QAAQ,EAAE,CAAC;KAC9B,OAAO,QAAQ,CAAC;CACjB,CAAC;;;;;;;;;"} {"version":3,"file":"index.js","sources":["src/custom/circle/src/game/utils.ts","src/custom/circle/src/props.ts","src/custom/circle/src/game/Gameinit.ts","src/custom/circle/src/index.ts"],"sourcesContent":["/**\n * Created by rockyl on 2020-01-21.\n */\n\nexport function getTexture(uuid) {\n\treturn engine.Texture.from(getAssetByUUID(uuid).uuid);\n}\n\nexport function getTextureByName(name) {\n\tconsole.log('name',engine.getAssetByName(name));\n\treturn getTexture(engine.getAssetByName(name).uuid);\n}\n\nexport function playSound(name) {\n\tengine.playSound(engine.getAssetByName(name).uuid, {keep: true});\n}\nexport function createSvga(name, anchorName?) {\n\tlet inst = new svga.Svga();\n\tinst.source = 'asset://' + engine.getAssetByName(name).uuid;\n\treturn inst;\n}\n","/**\n * Created by rockyl on 2020-01-21.\n */\n\nexport let props: any = {};\n\nexport function prepareProps() {\n\tlet metaProps = getProps();\n\tengine.injectProp(props, metaProps);\n\n}\n\nexport function injectProps(p) {\n\tengine.injectProp(props, p);\n}\n","\nimport { getTextureByName, createSvga } from './utils';\nimport { props } from \"../props\";\n\nexport default class Gameinit extends engine.Container {\n\n private _isSetUp = false;\n private totleY = 1200;\n _body: engine.Rect;\n isMove = false;\n isChoose = true;\n isDid = true;\n num;\n listGift = [];\n constructor() {\n super();\n console.log(\"11111111111111\");\n this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);\n }\n /**首页加载 */\n setup() {\n console.log(\"初始化加载000000000000000000000000!\");\n if (this._isSetUp) {\n return;\n }\n else {\n this.loadThings();\n console.log(\"this._isSetUp=\", this._isSetUp, '<<<<');\n }\n }\n /**套圈资源加载 */\n loadThings() {\n let self = this;\n let body;\n body = this._body = new engine.Rect;\n body.width = 0.0001;\n body.height = 0.0001;\n this.addChild(body);\n // let gift4 = this.addRes(body, '礼盒', 35, 115, 215, 122);\n let gift0 = this.addRes(body, '礼盒', 250, 100, 247, 188);\n let gift1 = this.addRes(body, '礼盒', 485, 85, 247, 190);\n let gift2 = this.addRes(body, '礼盒', 385, -15, 222, 170);\n let gift3 = this.addRes(body, '礼盒', 165, -15, 222, 170);\n let gift4 = this.addRes(body, '礼盒', 20, 85, 247, 190);\n this.listGift = [gift0, gift1, gift2, gift3, gift4];\n let circle = this.addRes(body, '圈', 260, 350, 240, 80);\n let giftSvga = createSvga(\"套中动效\");\n giftSvga.visible = false;\n body.addChild(giftSvga);\n let [v2X, v2Y] = props.ferruleModuleGlobalPosition;\n body.x = v2X;\n body.y = v2Y;\n /* VVVVVVVVVVVVVVVV */\n // let btn = this.addRes(body, '礼盒', 300, 900, 150, 150);\n // btn.addEventListener(engine.MouseEvent.MOUSE_DOWN, function () {\n // self.isMove = true;\n // }, this);\n // let btn1 = this.addRes(body, '礼盒', 500, 900, 200, 200);\n // btn1.addEventListener(engine.MouseEvent.MOUSE_DOWN, function () {\n // self.isChoose = true;\n // giftSvga.visible = false;\n // console.log(body.children[0], body.children[1], body.children[2], body.children[3], body.children[4], body.children[5]);\n // body.children[self.num].visible = true;\n // circle.x = 260; circle.y = 350; circle.width = 240; circle.height = 80;\n // circle.visible = true;\n // }, this);\n /* AAAAAAAAAAAAAAAAA */\n engine.globalEvent.addEventListener(\"circle-game-start\", function () {\n self.isMove = true;\n console.log('this.isMove===', self.isMove);\n }, this);\n engine.globalEvent.addEventListener(\"circle-game-init\", function () {\n self.isChoose = true;\n giftSvga.visible = false;\n // console.log(body.children[0], body.children[1], body.children[2], body.children[3], body.children[4], body.children[5]);\n body.children[self.num].visible = true;\n circle.x = 260; circle.y = 350; circle.width = 240; circle.height = 80;\n circle.visible = true;\n }, this);\n\n circle.addEventListener(engine.Event.ENTER_FRAME, function () {\n if (self.isMove) {\n console.log(\"物体移动\");\n if (self.isChoose) {\n self.num = Math.floor(Math.random() * self.listGift.length);\n self.isChoose = false;\n }\n self.nodeMove(circle, self.listGift[self.num], giftSvga);\n }\n });\n }\n /**套中动画播放 */\n aniPlay(node0, targetNode, bool) {\n node0.scaleX = this.currentScale(targetNode.y, this.totleY) - 0.05 * this.currentScale(targetNode.y, this.totleY);\n node0.scaleY = this.currentScale(targetNode.y, this.totleY) - 0.05 * this.currentScale(targetNode.y, this.totleY);\n // node0.anchor.x = node0.width / 2;\n // node0.anchor.y = node0.height / 2;\n node0.x = targetNode.x;\n node0.y = targetNode.y;\n node0.visible = true;\n node0.play(false, false);\n /**动画播放完毕,派发(执行)一个事件 */\n node0.addEventListener(engine.Event.END_FRAME, function () {\n console.log(\"播放到最后一帧\", bool, '<<<');\n engine.globalEvent.dispatchEvent(\"circle-game-end\");\n bool = false;\n })\n }\n /**给场景添加图片,resName:资源名字,v2X:资源X位置, v2Y:资源Y位置, resW:资源Width, resH:资源Height */\n addRes(fatherNode, resName, v2X, v2Y, resW, resH) {\n console.log(\"进行资源的添加\");\n let thing = new engine.Sprite(getTextureByName(resName));\n thing.x = v2X;\n thing.y = v2Y;\n thing.width = resW;\n thing.height = resH;\n return fatherNode.addChild(thing);\n }\n /** circle move */\n nodeMove(moveNode, targetNode, nodePlay) {\n console.log(\"moveNode.x=\", moveNode.x, \"targetNode.x=\", targetNode.x);\n let moveX = targetNode.x - moveNode.x;\n let moveY = targetNode.y - moveNode.y;\n console.log('moveX=', moveX, 'moveY=', moveY);\n if (this.isDid) {\n if (Math.abs(moveX) > 2) {\n moveNode.x += moveX / Math.abs(moveX) * 5;\n }\n if (Math.abs(moveY) > 2) {\n moveNode.y += moveY / Math.abs(moveY) * 5;\n moveNode.scaleX = this.currentScale(moveNode.y, this.totleY) + 0.2;\n moveNode.scaleY = moveNode.scaleX;\n }\n if (Math.abs(moveX) < 3 && Math.abs(moveY) < 3) {\n targetNode.visible = false;\n moveNode.visible = false;\n this.aniPlay(nodePlay, targetNode, this.isDid);\n this.isMove = false;\n }\n }\n }\n /**当前位置应该的尺寸大小 */\n currentScale(currentY, totoleDisY) {\n return (currentY + 830) / totoleDisY;\n }\n}\n","/**\n * Created by rockyl on 2019-11-20.\n */\n\nimport Gameinit from \"./game/Gameinit\";\nimport { injectProps, prepareProps } from \"./props\";\n\nexport default function (props) {\n\tprepareProps();\n\tinjectProps(props);\n\tlet instance = new Gameinit();\n\treturn instance;\n}\n"],"names":["__extends"],"mappings":";;;;;;UAIgB,UAAU,CAAC,IAAI;KAC9B,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;CACvD,CAAC;UAEe,gBAAgB,CAAC,IAAI;KACpC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;KAChD,OAAO,UAAU,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;CACrD,CAAC;UAKe,UAAU,CAAC,IAAI,EAAE,UAAW;KAC3C,IAA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I,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;iBAC5C,UAAU,CAAC,OAAO,GAAG,KAAK,CAAC;iBAC3B,QAAQ,CAAC,OAAO,GAAG,KAAK,CAAC;iBACzB,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;iBAC/C,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;cACvB;UACJ;MACJ;KAED,+BAAY,GAAZ,UAAa,QAAQ,EAAE,UAAU;SAC7B,OAAO,CAAC,QAAQ,GAAG,GAAG,IAAI,UAAU,CAAC;MACxC;KACL,eAAC;CAAD,CAAC,CA7IqC,MAAM,CAAC,SAAS,GA6IrD;;iBC1IwB,KAAK;KAC7B,YAAY,EAAE,CAAC;KACf,WAAW,CAAC,KAAK,CAAC,CAAC;KACnB,IAAI,QAAQ,GAAG,IAAI,QAAQ,EAAE,CAAC;KAC9B,OAAO,QAAQ,CAAC;CACjB,CAAC;;;;;;;;"}
\ No newline at end of file \ No newline at end of file
...@@ -29,9 +29,9 @@ ...@@ -29,9 +29,9 @@
<body> <body>
<div id="game-container" style="line-height:0;font-size:0"></div> <div id="game-container" style="line-height:0;font-size:0"></div>
<script src="http://localhost:4002/debug/engine.js"></script> <!-- <script src="http://localhost:4002/debug/engine.js"></script> -->
<script src="http://localhost:4003/debug/engine-svga.js"></script> <script crossorigin="anonymous" src="//yun.duiba.com.cn/editor/zeroing/libs/engine.50cdcef6ebe4e8c0fbc624f9d4fbf225102c5750.js"></script>
<!--<script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.9a9dbfda4cb2dd5508ecddfe3d95dfd88063f7b5.js"></script>--> <script crossorigin="anonymous" src="//yun.duiba.com.cn/editor/zeroing/libs/svga.fd3923ae6e664251ca7981801a65809cc5f36bc3.js"></script>
<script src="app.js"></script> <script src="app.js"></script>
<script src="props.js"></script> <script src="props.js"></script>
<script src="load-assets.js"></script> <script src="load-assets.js"></script>
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
function injectProps(p) { function injectProps(p) {
engine.injectProp(props, p); engine.injectProp(props, p);
} }
//# sourceMappingURL=props.js.map
function getTextureByName(name) { function getTextureByName(name) {
return engine.Texture.from(getAssetByName(name).uuid); return engine.Texture.from(getAssetByName(name).uuid);
...@@ -34,16 +35,23 @@ ...@@ -34,16 +35,23 @@
function playSound(name) { function playSound(name) {
engine.playSound(getAssetByName(name).uuid, { keep: true }); engine.playSound(getAssetByName(name).uuid, { keep: true });
} }
//# sourceMappingURL=utils.js.map
var Block = (function (_super) { var Block = (function (_super) {
tslib.__extends(Block, _super); tslib.__extends(Block, _super);
function Block() { function Block() {
var _this = _super.call(this) || this; var _this_1 = _super.call(this) || this;
var body = _this.body = new svga.Svga(); _this_1._deltaTime = 0;
_this_1.startTime = 0;
_this_1.lastTime = 0;
_this_1.curTime = 0;
_this_1.per = 0;
var body = _this_1.body = new svga.Svga();
body.x = -props.blockWidth / 2; body.x = -props.blockWidth / 2;
body.y = -props.blockHitHeight - props.blockPaddingTop; body.y = -props.blockHitHeight - props.blockPaddingTop;
_this.addChild(body); _this_1.addChild(body);
return _this; _this_1.addEventListener(engine.Event.ENTER_FRAME, _this_1.onEnterFrame, _this_1);
return _this_1;
} }
Block.prototype.reset = function (_a) { Block.prototype.reset = function (_a) {
var type = _a.type; var type = _a.type;
...@@ -56,25 +64,52 @@ ...@@ -56,25 +64,52 @@
this.scaleX = this.dir; this.scaleX = this.dir;
this.body.gotoAndStop(1); this.body.gotoAndStop(1);
}; };
Block.prototype.onEnterFrame = function () {
this.lastTime = this.curTime;
this.curTime = Date.now() - this.startTime;
this._deltaTime = this.curTime - this.lastTime;
this._deltaTime = this._deltaTime < 0 ? 0 : this._deltaTime;
var offMoveX = this.per * this._deltaTime;
if (this.per < 0) {
if (this.x + offMoveX > 0) {
this.x += offMoveX;
}
else {
this.x = 0;
}
}
else {
if (this.x + offMoveX < 0) {
this.x += offMoveX;
}
else {
this.x = 0;
}
}
};
Block.prototype.playEnter = function (index, animation) { Block.prototype.playEnter = function (index, animation) {
var _this_1 = this;
var _this = this; var _this = this;
this.visible = true; this.visible = true;
this.x = this.dir * this.stage.width; this.x = this.dir * this.stage.width;
var _a = props.blockDurationRange, min = _a[0], max = _a[1]; var _a = props.blockDurationRange, min = _a[0], max = _a[1];
var duration = Math.max(max - index * props.blockDurationStep, min); var duration = Math.max(max - index * props.blockDurationStep, min);
duration = duration + max * Math.random() * props.blockDurationRandom * (Math.random() > 0.5 ? 1 : -1); duration = duration + max * Math.random() * props.blockDurationRandom * (Math.random() > 0.5 ? 1 : -1);
var offX = 0 - this.x;
this.per = offX / duration;
return new Promise(function (resolve) { return new Promise(function (resolve) {
if (animation) { if (animation) {
engine.Tween.get(_this, null, null, true) _this.startTime = Date.now();
.to({ x: 0, }, duration) setTimeout(function () {
.call(resolve); resolve(1);
}, duration);
} }
else { else {
_this.x = 0; _this_1.x = 0;
setTimeout(function () { setTimeout(function () {
console.log(_this.body); console.log(_this_1.body);
}, 200); }, 200);
resolve(); resolve(1);
} }
}); });
}; };
...@@ -89,10 +124,11 @@ ...@@ -89,10 +124,11 @@
}, this); }, this);
}; };
Block.prototype.stop = function () { Block.prototype.stop = function () {
engine.Tween.removeTweens(this); this.removeEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);
}; };
return Block; return Block;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=Block.js.map
var Background = (function (_super) { var Background = (function (_super) {
tslib.__extends(Background, _super); tslib.__extends(Background, _super);
...@@ -121,6 +157,7 @@ ...@@ -121,6 +157,7 @@
}; };
return Background; return Background;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=Background.js.map
var svgaAssets = { var svgaAssets = {
aniReady: { name: '准备立正', dir: 1 }, aniReady: { name: '准备立正', dir: 1 },
...@@ -136,6 +173,10 @@ ...@@ -136,6 +173,10 @@
function Player() { function Player() {
var _this = _super.call(this) || this; var _this = _super.call(this) || this;
_this.g = props.gravity; _this.g = props.gravity;
_this._deltaTime = 0;
_this.startTime = 0;
_this.lastTime = 0;
_this.curTime = 0;
_this.addEventListener(engine.Event.ENTER_FRAME, _this.onEnterFrame, _this); _this.addEventListener(engine.Event.ENTER_FRAME, _this.onEnterFrame, _this);
return _this; return _this;
} }
...@@ -157,7 +198,7 @@ ...@@ -157,7 +198,7 @@
if (play) { if (play) {
ani.play(false, loop); ani.play(false, loop);
if (loop) { if (loop) {
resolve(); resolve(1);
} }
else { else {
ani.once(engine.Event.END_FRAME, resolve); ani.once(engine.Event.END_FRAME, resolve);
...@@ -165,7 +206,7 @@ ...@@ -165,7 +206,7 @@
} }
else { else {
ani.gotoAndStop(1); ani.gotoAndStop(1);
resolve(); resolve(1);
} }
} }
}); });
...@@ -196,7 +237,7 @@ ...@@ -196,7 +237,7 @@
_this.switchAni('Ready', 1); _this.switchAni('Ready', 1);
_this._currentAni.once(engine.Event.END_FRAME, function () { _this._currentAni.once(engine.Event.END_FRAME, function () {
this.switchAni('Jump', 1, false); this.switchAni('Jump', 1, false);
resolve(); resolve(1);
}, _this); }, _this);
}); });
}; };
...@@ -204,8 +245,12 @@ ...@@ -204,8 +245,12 @@
if (!this.playing) { if (!this.playing) {
return; return;
} }
this.vy += this.g; this.lastTime = this.curTime;
this.y += this.vy; this.curTime = Date.now() - this.startTime;
this._deltaTime = this.curTime - this.lastTime;
this._deltaTime = this._deltaTime < 0 ? 0 : this._deltaTime;
this.vy += this.g * this._deltaTime / 16;
this.y += this.vy * this._deltaTime / 16;
if (this.vy > 0 && this._aniName !== 'Fall') { if (this.vy > 0 && this._aniName !== 'Fall') {
this.dispatchEvent('jump-on-top'); this.dispatchEvent('jump-on-top');
this.switchAni('Fall'); this.switchAni('Fall');
...@@ -235,6 +280,7 @@ ...@@ -235,6 +280,7 @@
this.playing = true; this.playing = true;
this.baseY = this.y; this.baseY = this.y;
this.vy = -props.jumpSpeed; this.vy = -props.jumpSpeed;
this.startTime = Date.now();
return new Promise(function (resolve) { return new Promise(function (resolve) {
_this.jumpPromise = resolve; _this.jumpPromise = resolve;
}); });
...@@ -333,6 +379,7 @@ ...@@ -333,6 +379,7 @@
}; };
return Player; return Player;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=Player.js.map
var Base = (function (_super) { var Base = (function (_super) {
tslib.__extends(Base, _super); tslib.__extends(Base, _super);
...@@ -347,6 +394,7 @@ ...@@ -347,6 +394,7 @@
}; };
return Base; return Base;
}(engine.Image)); }(engine.Image));
//# sourceMappingURL=Base.js.map
var GuideLayer = (function (_super) { var GuideLayer = (function (_super) {
tslib.__extends(GuideLayer, _super); tslib.__extends(GuideLayer, _super);
...@@ -399,6 +447,7 @@ ...@@ -399,6 +447,7 @@
}; };
return GuideLayer; return GuideLayer;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=GuideLayer.js.map
var GoldBag = (function (_super) { var GoldBag = (function (_super) {
tslib.__extends(GoldBag, _super); tslib.__extends(GoldBag, _super);
...@@ -437,6 +486,7 @@ ...@@ -437,6 +486,7 @@
}; };
return GoldBag; return GoldBag;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=GoldBag.js.map
var ObjectPool = engine.ObjectPool; var ObjectPool = engine.ObjectPool;
var PoolName = 'gold-bag'; var PoolName = 'gold-bag';
...@@ -678,7 +728,7 @@ ...@@ -678,7 +728,7 @@
get: function () { get: function () {
return this.index - props.initBlockCount + 1; return this.index - props.initBlockCount + 1;
}, },
enumerable: true, enumerable: false,
configurable: true configurable: true
}); });
Object.defineProperty(GameView.prototype, "pos", { Object.defineProperty(GameView.prototype, "pos", {
...@@ -689,7 +739,7 @@ ...@@ -689,7 +739,7 @@
this._pos = v; this._pos = v;
this.updatePos(); this.updatePos();
}, },
enumerable: true, enumerable: false,
configurable: true configurable: true
}); });
GameView.prototype.updatePos = function () { GameView.prototype.updatePos = function () {
...@@ -850,6 +900,7 @@ ...@@ -850,6 +900,7 @@
}; };
return GameView; return GameView;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=GameView.js.map
var JumpHigh = (function (_super) { var JumpHigh = (function (_super) {
tslib.__extends(JumpHigh, _super); tslib.__extends(JumpHigh, _super);
...@@ -889,6 +940,7 @@ ...@@ -889,6 +940,7 @@
}; };
return JumpHigh; return JumpHigh;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=JumpHigh.js.map
function index (props) { function index (props) {
prepareProps(); prepareProps();
...@@ -896,6 +948,7 @@ ...@@ -896,6 +948,7 @@
var instance = new JumpHigh(); var instance = new JumpHigh();
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.
/**
* Created by rockyl on 2019-12-16.
*/
const customId = 'jump-high';
(async function () {
let customModule = await fetch(`../meta.json`);
customModule = await customModule.json();
console.log(customModule);
await loadAssets(customModule.assets);
launchWithCustomModule(customModule);
})();
function launchWithCustomModule(customModule) {
engine.globalEvent.addEventListener('update-game-status', (e) => {
console.log(e.type, e.data);
});
//engine.registerCustomCodeModule(customModule);
engine.registerCustomModule(customId, window[customId]);
const {props: propsOption, assets} = customModule;
let props = engine.computeProps(customModuleProps, propsOption);
const customModuleIns = {
id: customId,
props,
assets,
};
engine.registerCustomModules([customModuleIns]);
engine.launchWithConfig({
options: {
entrySceneView: 'entry',
},
assets: [],
views: [{
name: 'entry',
type: 'node',
}],
}, null, function () {
setTimeout(() => {
engine.addCustomModule(customId, engine.gameStage.sceneContainer.getChildAt(0));
}, 100);
setTimeout(() => {
engine.globalEvent.dispatchEvent('jump-high-start', {level: 1});
}, 500);
});
}
function getAssetByUUID(uuid) {
return engine.resolveCustomAsset(customId, uuid);
}
function getAssetByName(name){
return getAssetByUUID(engine.getAssetByName(name).uuid);
}
function getProps() {
return engine.getProps(customId);
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>叠叠高</title>
<meta name="viewport"
content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="full-screen" content="true"/>
<meta name="screen-orientation" content="portrait"/>
<meta name="x5-fullscreen" content="true"/>
<meta name="360-fullscreen" content="true"/>
<style>
html,
body {
padding: 0;
margin: 0;
border: 0;
width: 100%;
height: 100%;
overflow: hidden;
position: absolute;
background-color: transparent;
}
</style>
</head>
<body>
<div id="game-container" style="line-height:0;font-size:0"></div>
<!-- <script src="http://localhost:4002/debug/engine.js"></script> -->
<script crossorigin="anonymous" src="//yun.duiba.com.cn/editor/zeroing/libs/engine.50cdcef6ebe4e8c0fbc624f9d4fbf225102c5750.js"></script>
<script crossorigin="anonymous" src="//yun.duiba.com.cn/editor/zeroing/libs/svga.fd3923ae6e664251ca7981801a65809cc5f36bc3.js"></script>
<script src="app.js"></script>
<script src="props.js"></script>
<script src="load-assets.js"></script>
<script src="main.js"></script>
<script>
</script>
</body>
\ No newline at end of file
/**
* Created by rockyl on 2020-01-21.
*/
const assets = [
{
"name": "方块素材0",
"url": "//yun.duiba.com.cn/aurora/assets/0307ca8906e9f553e6873c346ae5c6ec3655db59.svga",
"uuid": "4e31f5d7-bd03-41a3-873c-3755fe4862e6",
"ext": '.svga'
}
];
function loadAssets(customModuleAssets, onProgress, onComplete){
return engine.loadAssets(assets.concat(...customModuleAssets), onProgress, onComplete);
}
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :
typeof define === 'function' && define.amd ? define(['tslib'], factory) :
(global = global || self, global['jump-high'] = factory(global.tslib));
}(this, (function (tslib) { 'use strict';
var props = {};
function prepareProps() {
var metaProps = getProps();
engine.injectProp(props, metaProps);
}
function injectProps(p) {
engine.injectProp(props, p);
}
//# sourceMappingURL=props.js.map
function getTextureByName(name) {
return engine.Texture.from(getAssetByName(name).uuid);
}
function getBlockAsset(type) {
return engine.getAssetByName(props.blockAssets[type]);
}
function createSvga(name, anchorName) {
var inst = new svga.Svga();
inst.source = 'asset://' + getAssetByName(name).uuid;
var anchor = props[anchorName];
if (anchor) {
inst.x = -anchor.x;
inst.y = -anchor.y;
inst.anchorX = anchor.x;
inst.anchorY = anchor.y;
}
return inst;
}
function playSound(name) {
engine.playSound(getAssetByName(name).uuid, { keep: true });
}
//# sourceMappingURL=utils.js.map
var Block = (function (_super) {
tslib.__extends(Block, _super);
function Block() {
var _this_1 = _super.call(this) || this;
_this_1._deltaTime = 0;
_this_1.startTime = 0;
_this_1.lastTime = 0;
_this_1.curTime = 0;
_this_1.per = 0;
var body = _this_1.body = new svga.Svga();
body.x = -props.blockWidth / 2;
body.y = -props.blockHitHeight - props.blockPaddingTop;
_this_1.addChild(body);
_this_1.addEventListener(engine.Event.ENTER_FRAME, _this_1.onEnterFrame, _this_1);
return _this_1;
}
Block.prototype.reset = function (_a) {
var type = _a.type;
this.dir = Math.random() > 0.5 ? 1 : -1;
if (this.type != type) {
this.type = type;
var asset = getBlockAsset(type);
this.body.source = 'asset://' + asset.uuid;
}
this.scaleX = this.dir;
this.body.gotoAndStop(1);
};
Block.prototype.onEnterFrame = function () {
this.lastTime = this.curTime;
this.curTime = Date.now() - this.startTime;
this._deltaTime = this.curTime - this.lastTime;
this._deltaTime = this._deltaTime < 0 ? 0 : this._deltaTime;
var offMoveX = this.per * this._deltaTime;
if (this.per < 0) {
if (this.x + offMoveX > 0) {
this.x += offMoveX;
}
else {
this.x = 0;
}
}
else {
if (this.x + offMoveX < 0) {
this.x += offMoveX;
}
else {
this.x = 0;
}
}
};
Block.prototype.playEnter = function (index, animation) {
var _this_1 = this;
var _this = this;
this.visible = true;
this.x = this.dir * this.stage.width;
var _a = props.blockDurationRange, min = _a[0], max = _a[1];
var duration = Math.max(max - index * props.blockDurationStep, min);
duration = duration + max * Math.random() * props.blockDurationRandom * (Math.random() > 0.5 ? 1 : -1);
var offX = 0 - this.x;
this.per = offX / duration;
return new Promise(function (resolve) {
if (animation) {
_this.startTime = Date.now();
setTimeout(function () {
resolve(1);
}, duration);
}
else {
_this_1.x = 0;
setTimeout(function () {
console.log(_this_1.body);
}, 200);
resolve(1);
}
});
};
Block.prototype.playLeave = function () {
this.visible = false;
};
Block.prototype.playEffect = function () {
var body = this.body;
body.play(true, false);
body.once(engine.Event.END_FRAME, function () {
body.gotoAndStop(1);
}, this);
};
Block.prototype.stop = function () {
this.removeEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);
};
return Block;
}(engine.Container));
//# sourceMappingURL=Block.js.map
var Background = (function (_super) {
tslib.__extends(Background, _super);
function Background() {
return _super.call(this) || this;
}
Background.prototype.setup = function () {
var _a = this.stage, width = _a.width, height = _a.height;
var bg = this._bg = new engine.Image(getTextureByName('背景图'));
bg.anchorX = bg.width / 2;
bg.anchorY = bg.height / 2;
bg.x = -(bg.width - width) / 2;
bg.y = -(bg.height - height) / 2;
this.addChild(bg);
this._minScale = width / bg.width;
};
Background.prototype.playZoom = function (type, duration) {
var _this = this;
if (duration === void 0) { duration = 700; }
return new Promise(function (resolve) {
var scale = type === 'in' ? 1 : _this._minScale;
engine.Tween.get(_this._bg, null, null, true)
.to({ scaleX: scale, scaleY: scale }, duration, engine.Ease.cubicInOut)
.call(resolve);
});
};
return Background;
}(engine.Container));
//# sourceMappingURL=Background.js.map
var svgaAssets = {
aniReady: { name: '准备立正', dir: 1 },
aniJump: { name: '跳上升', dir: 1 },
aniFall: { name: '跳下落', dir: 1 },
aniLandNormal: { name: '普通着地', dir: 1 },
aniLandSide: { name: '边缘着地', dir: -1 },
aniHit: { name: '被撞开', dir: -1 },
aniParachute: { name: '降落', dir: -1 },
};
var Player = (function (_super) {
tslib.__extends(Player, _super);
function Player() {
var _this = _super.call(this) || this;
_this.g = props.gravity;
_this._deltaTime = 0;
_this.startTime = 0;
_this.lastTime = 0;
_this.curTime = 0;
_this.addEventListener(engine.Event.ENTER_FRAME, _this.onEnterFrame, _this);
return _this;
}
Player.prototype.switchAni = function (name, dir, play, loop) {
var _this = this;
if (dir === void 0) { dir = 1; }
if (play === void 0) { play = true; }
if (loop === void 0) { loop = false; }
return new Promise(function (resolve) {
_this.scaleX = dir;
if (_this._aniName !== name) {
_this._aniName = name;
var oldAni = _this.removeChild(_this.getChildByName('body'));
if (oldAni) {
oldAni.stop();
}
var ani = _this._currentAni = _this['ani' + name];
_this.addChild(ani);
if (play) {
ani.play(false, loop);
if (loop) {
resolve(1);
}
else {
ani.once(engine.Event.END_FRAME, resolve);
}
}
else {
ani.gotoAndStop(1);
resolve(1);
}
}
});
};
Player.prototype.setup = function () {
this.prefectEffect = createSvga('完美着地特效', 'playerLandPrefectAnchor');
this.landEffect = createSvga('着地特效', 'playerLandEffectAnchor');
for (var key in svgaAssets) {
var _a = svgaAssets[key], name = _a.name, dir = _a.dir;
var body = this[key] = createSvga(name, key.replace('ani', 'player') + 'Anchor');
body.name = 'body';
body.scaleX = dir;
}
};
Player.prototype.reset = function (revive) {
this.x = 0;
this.rotation = 0;
this.scaleX = this.scaleY = 1;
this._prefectLandCounting = 0;
engine.Tween.removeTweens(this);
if (revive) {
this.switchAni('Jump', 1, false);
}
};
Player.prototype.playReady = function () {
var _this = this;
return new Promise(function (resolve) {
_this.switchAni('Ready', 1);
_this._currentAni.once(engine.Event.END_FRAME, function () {
this.switchAni('Jump', 1, false);
resolve(1);
}, _this);
});
};
Player.prototype.onEnterFrame = function (event) {
if (!this.playing) {
return;
}
this.lastTime = this.curTime;
this.curTime = Date.now() - this.startTime;
this._deltaTime = this.curTime - this.lastTime;
this._deltaTime = this._deltaTime < 0 ? 0 : this._deltaTime;
this.vy += this.g * this._deltaTime / 16;
this.y += this.vy * this._deltaTime / 16;
if (this.vy > 0 && this._aniName !== 'Fall') {
this.dispatchEvent('jump-on-top');
this.switchAni('Fall');
}
if (this.y > this.baseY) {
this.y = this.baseY;
this.playing = false;
this.jumpPromise && this.jumpPromise({
aboveBlock: this.aboveBlock,
});
this.jumpPromise = null;
}
};
Player.prototype.changeBaseY = function (v) {
if (this.baseY == v) {
return;
}
this.aboveBlock = true;
this.baseY = v;
};
Player.prototype.jump = function () {
var _this = this;
playSound('跳起音效');
this.switchAni('Jump', 1, false);
this._currentAni.play(false, false);
this.aboveBlock = false;
this.playing = true;
this.baseY = this.y;
this.vy = -props.jumpSpeed;
this.startTime = Date.now();
return new Promise(function (resolve) {
_this.jumpPromise = resolve;
});
};
Player.prototype.playLand = function (type, dir) {
return tslib.__awaiter(this, void 0, void 0, function () {
var _a, prefectEffect_1, landEffect_1;
return tslib.__generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = type;
switch (_a) {
case 0: return [3, 1];
case 1: return [3, 3];
case 2: return [3, 3];
case 3: return [3, 4];
}
return [3, 5];
case 1:
this._prefectLandCounting++;
playSound('完美落地音效' + Math.min(4, this._prefectLandCounting));
prefectEffect_1 = this.prefectEffect;
this.addChildAt(prefectEffect_1, 0);
prefectEffect_1.gotoAndPlay(1);
prefectEffect_1.once(engine.Event.END_FRAME, function () {
this.removeChild(prefectEffect_1);
}, this);
landEffect_1 = this.landEffect;
this.addChildAt(landEffect_1, 0);
landEffect_1.gotoAndPlay(1);
landEffect_1.once(engine.Event.END_FRAME, function () {
this.removeChild(landEffect_1);
}, this);
return [4, this.switchAni('LandNormal')];
case 2:
_b.sent();
return [3, 5];
case 3:
this._prefectLandCounting = 0;
playSound('普通落地音效');
this.switchAni('LandNormal');
return [3, 5];
case 4:
this._prefectLandCounting = 0;
playSound('边缘落地音效');
this.switchAni('LandSide', dir);
return [3, 5];
case 5: return [2];
}
});
});
};
Player.prototype.hitAway = function (dir) {
return tslib.__awaiter(this, void 0, void 0, function () {
var _this = this;
return tslib.__generator(this, function (_a) {
switch (_a.label) {
case 0:
this.jumpPromise && this.jumpPromise();
this.jumpPromise = null;
playSound('被撞开音效');
this.switchAni('Hit', dir);
this.vy = 0;
return [4, new Promise(function (resolve) {
engine.Tween.get(_this)
.to({
x: -dir * props.hitAwayDistance.x,
}, props.hitAwayDuration, engine.Ease.quartOut);
engine.Tween.get(_this)
.to({
y: _this.y + props.hitAwayDistance.y,
}, props.hitAwayDuration, engine.Ease.cubicOut)
.call(resolve);
})];
case 1:
_a.sent();
return [2];
}
});
});
};
Player.prototype.parachute = function (dir) {
var _this = this;
this.switchAni('Parachute', dir);
return new Promise(function (resolve) {
engine.Tween.get(_this)
.wait(200)
.call(function () {
playSound('降落伞下落音效');
})
.wait(300)
.to({ y: _this.y + props.parachuteDistance }, props.parachuteDuration)
.set({ anchorOffsetY: 0 })
.call(resolve);
});
};
return Player;
}(engine.Container));
//# sourceMappingURL=Player.js.map
var Base = (function (_super) {
tslib.__extends(Base, _super);
function Base() {
return _super.call(this, getTextureByName('底座')) || this;
}
Base.prototype.setup = function () {
this.x = -(this.width) / 2;
};
Base.prototype.reset = function () {
this.y = -props.baseOffset;
};
return Base;
}(engine.Image));
//# sourceMappingURL=Base.js.map
var GuideLayer = (function (_super) {
tslib.__extends(GuideLayer, _super);
function GuideLayer() {
var _this = _super.call(this) || this;
_this.setup();
return _this;
}
GuideLayer.prototype.setup = function () {
};
GuideLayer.prototype.show = function (id, options) {
var _this = this;
return new Promise(function (resolve) {
_this.visible = true;
if (!_this.guideMask) {
var _a = _this.stage, width = _a.width, height = _a.height;
var guideMask = _this.guideMask = new engine.Container();
var guideHole = new engine.Image(getTextureByName('引导遮罩'));
guideHole.x = (width - guideHole.width) / 2;
guideHole.y = options.y;
guideMask.addChild(guideHole);
_this.createRect(guideMask, 0, 0, width, guideHole.y);
_this.createRect(guideMask, 0, guideHole.y, guideHole.x, guideHole.height);
_this.createRect(guideMask, guideHole.x + guideHole.width, guideHole.y, width - guideHole.x - guideHole.width, guideHole.height);
_this.createRect(guideMask, 0, guideHole.y + guideHole.height, width, height - guideHole.y - guideHole.height);
var label = _this.label = new engine.Label();
label.fillColor = 'white';
label.size = 25;
label.text = props.guideText;
label.x = (width - label.width) / 2;
label.y = guideHole.y + guideHole.height + 50;
guideMask.addChild(label);
_this.addChild(guideMask);
}
_this.once(engine.MouseEvent.CLICK, function () {
this.visible = false;
resolve();
}, _this);
});
};
GuideLayer.prototype.createRect = function (container, x, y, width, height) {
var rect = new engine.Rect();
rect.x = x;
rect.y = y;
rect.width = width;
rect.height = height;
rect.fillColor = 'black';
rect.alpha = 0.7;
container.addChild(rect);
};
return GuideLayer;
}(engine.Container));
//# sourceMappingURL=GuideLayer.js.map
var GoldBag = (function (_super) {
tslib.__extends(GoldBag, _super);
function GoldBag() {
var _this = _super.call(this) || this;
_this.setup();
return _this;
}
GoldBag.prototype.setup = function () {
var avatar = this.avatar = new engine.Sprite(getTextureByName('钱袋-静态'));
avatar.x = -props.goldPackAvatarAnchor.x;
avatar.y = -props.goldPackAvatarAnchor.y;
this.addChild(avatar);
var svga = this.svga = createSvga('钱袋', 'goldPackAnchor');
svga.visible = false;
this.addChild(svga);
};
GoldBag.prototype.reset = function (data) {
this.y = data.y;
this.avatar.visible = true;
this.svga.visible = false;
this.svga.gotoAndStop(1);
this.remain = data.remain;
};
GoldBag.prototype.playOpen = function () {
var _this = this;
this.avatar.visible = false;
this.svga.visible = true;
return new Promise(function (resolve) {
_this.svga.play(true, false);
_this.svga.once(engine.Event.END_FRAME, function () {
this.svga.visible = false;
resolve();
}, _this);
});
};
return GoldBag;
}(engine.Container));
//# sourceMappingURL=GoldBag.js.map
var ObjectPool = engine.ObjectPool;
var PoolName = 'gold-bag';
ObjectPool.registerPool(PoolName, function () {
return new GoldBag();
}, function (item, data) {
item.reset(data);
});
var GameView = (function (_super) {
tslib.__extends(GameView, _super);
function GameView() {
var _this = _super.call(this) || this;
_this.index = -1;
_this.goldBags = [];
_this.baseOffset = -props.baseOffset + props.playerOffset;
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
return _this;
}
GameView.prototype.setup = function () {
if (this._hasSetup) {
return;
}
this._hasSetup = true;
var _a = this.stage, width = _a.width, height = _a.height;
var background = this.background = new Background();
this.addChild(background);
background.setup();
var frontContainer = this.frontContainer = new engine.Container();
frontContainer.x = width / 2;
this.addChild(frontContainer);
var guideLayer = this.guideLayer = new GuideLayer();
this.addChild(guideLayer);
var base = this.base = new Base();
frontContainer.addChild(base);
base.setup();
var blockContainer = this.blockContainer = new engine.Container();
frontContainer.addChild(blockContainer);
var player = this.player = new Player();
frontContainer.addChild(player);
player.setup();
player.addEventListener('jump-on-top', this.onPlayerJumpOnTop, this);
ObjectPool.recycleObject(PoolName, ObjectPool.getObject(PoolName, {
y: 0,
remain: 0,
}));
this.hitEffect = createSvga('被撞烟雾', 'hitEffectAnchor');
this.pos = 0;
this.background.setup();
this.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);
this.reset();
};
GameView.prototype.reset = function (revive) {
if (revive === void 0) { revive = false; }
return tslib.__awaiter(this, void 0, void 0, function () {
var blockContainer, i, li, block, i, i, li, goldBag;
return tslib.__generator(this, function (_a) {
switch (_a.label) {
case 0:
this.base.reset();
this.index = -1;
this._score = 0;
if (revive) ;
else {
this.pos = 0;
blockContainer = this.blockContainer;
for (i = 0, li = blockContainer.children.length; i < li; i++) {
block = blockContainer.getChildAt(i);
block.playLeave();
}
}
for (i = 0; i < props.initBlockCount; i++) {
this.addBlock(false);
}
for (i = 0, li = this.goldBags.length; i < li; i++) {
goldBag = this.goldBags[i];
this.frontContainer.removeChild(goldBag);
ObjectPool.recycleObject(PoolName, goldBag);
}
this.goldBags.splice(0);
this.playZoom('in');
return [4, this.resetPlayer(revive)];
case 1:
_a.sent();
return [2];
}
});
});
};
GameView.prototype.resetPlayer = function (revive) {
if (revive === void 0) { revive = false; }
return tslib.__awaiter(this, void 0, void 0, function () {
return tslib.__generator(this, function (_a) {
this.player.reset(revive);
this.player.y = this.baseOffset - (this.index + 1) * props.blockHitHeight;
return [2];
});
});
};
GameView.prototype.start = function (revive) {
if (revive === void 0) { revive = false; }
return tslib.__awaiter(this, void 0, void 0, function () {
var guideFlagKey, guideFlag;
var _this = this;
return tslib.__generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!!revive) return [3, 2];
return [4, this.player.playReady()];
case 1:
_a.sent();
_a.label = 2;
case 2:
guideFlagKey = 'jump-high-guide_' + props.guideFlagKey;
guideFlag = localStorage.getItem(guideFlagKey);
if (!!guideFlag) return [3, 4];
localStorage.setItem(guideFlagKey, '1');
return [4, this.guideLayer.show('', { y: this.stage.height + this.player.y - 280 })];
case 3:
_a.sent();
_a.label = 4;
case 4:
this.lastLandType = 0;
this._remainToShowGoldBag = props.goldBagScoreMultiple - props.goldBagScoreSubtraction;
this._touchEnabled = true;
setTimeout(function () {
_this.addBlock();
}, 100);
engine.globalEvent.dispatchEvent('jump-high-game-start');
return [2];
}
});
});
};
GameView.prototype.pause = function () {
if (this.currentBlock) {
engine.Tween.pauseTweens(this.currentBlock);
}
engine.Tween.pauseTweens(this.player);
};
GameView.prototype.resume = function () {
if (this.currentBlock) {
engine.Tween.resumeTweens(this.currentBlock);
}
engine.Tween.resumeTweens(this.player);
};
GameView.prototype.revive = function () {
return tslib.__awaiter(this, void 0, void 0, function () {
return tslib.__generator(this, function (_a) {
switch (_a.label) {
case 0:
this.blockContainer.getChildAt(this.index).visible = false;
this.index--;
return [4, this.resetPlayer(true)];
case 1:
_a.sent();
return [4, this.playZoom('in')];
case 2:
_a.sent();
this.start(true);
return [2];
}
});
});
};
GameView.prototype.addBlock = function (animation) {
var _this = this;
if (animation === void 0) { animation = true; }
this.index++;
var blockContainer = this.blockContainer;
var block;
if (blockContainer.children.length > this.index) {
block = blockContainer.getChildAt(this.index);
block.visible = true;
}
else {
block = new Block();
blockContainer.addChild(block);
}
block.reset({
type: Math.floor(Math.random() * props.blockAssets.length),
});
block.y = this.baseOffset - this.index * props.blockHitHeight;
this.blockComplete = false;
block.playEnter(this.index, animation).then(function (data) {
_this.blockComplete = true;
});
if (animation) {
this.needHitTest = true;
}
this.currentBlock = block;
};
GameView.prototype.addGoldBag = function () {
var goldBag = ObjectPool.getObject(PoolName, {
y: this.baseOffset - (this.blockCount + props.goldBagDistance + props.goldBagJumpSubtraction) * props.blockHitHeight,
remain: props.goldBagDistance,
});
this.frontContainer.addChild(goldBag);
this.goldBags.push(goldBag);
};
GameView.prototype.playOpenGoldBag = function () {
return tslib.__awaiter(this, void 0, void 0, function () {
var i, li, goldBag;
return tslib.__generator(this, function (_a) {
switch (_a.label) {
case 0:
i = 0, li = this.goldBags.length;
_a.label = 1;
case 1:
if (!(i < li)) return [3, 4];
goldBag = this.goldBags[i];
goldBag.remain--;
if (!(goldBag.remain <= 0)) return [3, 3];
this.goldBags.splice(i, 1);
i--;
li--;
this.nextToUpdateScore = true;
return [4, goldBag.playOpen()];
case 2:
_a.sent();
this.frontContainer.removeChild(goldBag);
ObjectPool.recycleObject(PoolName, goldBag);
_a.label = 3;
case 3:
i++;
return [3, 1];
case 4: return [2];
}
});
});
};
GameView.prototype.onPlayerJumpOnTop = function () {
if (this.nextToUpdateScore) {
this.nextToUpdateScore = false;
this.scoreChange(4);
playSound('撞击钱袋音效');
}
};
Object.defineProperty(GameView.prototype, "blockCount", {
get: function () {
return this.index - props.initBlockCount + 1;
},
enumerable: false,
configurable: true
});
Object.defineProperty(GameView.prototype, "pos", {
get: function () {
return this._pos;
},
set: function (v) {
this._pos = v;
this.updatePos();
},
enumerable: false,
configurable: true
});
GameView.prototype.updatePos = function () {
this.frontContainer.y = this.stage.height + this._pos;
};
GameView.prototype.onEnterFrame = function (event) {
if (this.needHitTest) {
if (this.currentBlock) {
var _a = this.currentBlock, bx = _a.x, by = _a.y, dir = _a.dir;
var _b = this.player, px = _b.x, py = _b.y;
var blockHitWidth = props.blockHitWidth, blockHitHeight = props.blockHitHeight, playerWidth = props.playerWidth;
var hitOn = false;
if (Math.abs(px - bx) < (blockHitWidth + playerWidth) / 2) {
this.player.changeBaseY(by - blockHitHeight);
if (py > by - blockHitHeight) {
hitOn = true;
}
}
if (hitOn) {
this.onHitOn(dir);
}
}
}
};
GameView.prototype.onHitOn = function (dir) {
return tslib.__awaiter(this, void 0, void 0, function () {
return tslib.__generator(this, function (_a) {
switch (_a.label) {
case 0:
this._touchEnabled = false;
this.needHitTest = false;
clearInterval(this.timer);
this.currentBlock.stop();
this.playHitEffect(dir);
return [4, this.player.hitAway(dir)];
case 1:
_a.sent();
this.playZoom('out');
return [4, this.player.parachute(dir)];
case 2:
_a.sent();
engine.globalEvent.dispatchEvent('jump-high-game-end');
return [2];
}
});
});
};
GameView.prototype.jump = function () {
return tslib.__awaiter(this, void 0, void 0, function () {
var result, pos, type, lastLandType;
var _this = this;
return tslib.__generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!this._touchEnabled) {
return [2];
}
this._touchEnabled = false;
this.playOpenGoldBag();
return [4, this.player.jump()];
case 1:
result = _a.sent();
if (!result) return [3, 5];
if (!result.aboveBlock) return [3, 4];
pos = Math.abs(this.currentBlock.x);
type = 0;
if (pos > 0) {
type = pos > 0 && pos < props.scoreThreshold ? 2 : 3;
}
lastLandType = this.lastLandType;
this.lastLandType = type;
if (type === 0) {
if (lastLandType !== type) {
type = 1;
}
}
if (type < 3) {
this.currentBlock.playEffect();
}
this.player.playLand(type, this.currentBlock.dir);
this.currentBlock.stop();
this.scoreChange(type);
return [4, this.playShake()];
case 2:
_a.sent();
return [4, new Promise(function (resolve) {
engine.Tween.get(_this, null, null, true)
.to({ pos: props.blockHitHeight * _this.index }, 300, engine.Ease.cubicOut)
.call(resolve);
})];
case 3:
_a.sent();
this.addBlock();
_a.label = 4;
case 4:
this._touchEnabled = true;
_a.label = 5;
case 5: return [2];
}
});
});
};
GameView.prototype.scoreChange = function (type) {
var scoreAdd = props.scoreWeights[type];
this._score += scoreAdd;
this._remainToShowGoldBag -= scoreAdd;
var score = this._score;
engine.globalEvent.dispatchEvent('jump-high-score', {
type: type,
score: score,
scoreAdd: scoreAdd,
});
console.log(score, this._remainToShowGoldBag);
if (this._remainToShowGoldBag <= 0) {
this._remainToShowGoldBag += props.goldBagScoreMultiple;
this.addGoldBag();
console.log('addGoldBag');
}
};
GameView.prototype.playHitEffect = function (dir) {
var hitEffect = this.hitEffect;
hitEffect.scaleX = dir;
hitEffect.y = this.player.y - props.hitEffectAnchor.y;
hitEffect.play(true, false);
hitEffect.once(engine.Event.END_FRAME, function () {
this.frontContainer.removeChild(hitEffect);
}, this);
this.frontContainer.addChild(hitEffect);
};
GameView.prototype.playZoom = function (type, duration) {
var _this = this;
if (duration === void 0) { duration = 700; }
this.background.playZoom(type, duration);
var count = this.stage.height / props.blockHitHeight;
return new Promise(function (resolve) {
_this.frontContainer.anchorY = -props.blockHitHeight * (_this.index + count * 1.3) + props.baseOffset;
var scale = type === 'in' ? 1 : Math.min((_this.stage.height / props.blockHitHeight / (_this.index + count)), props.maxScale);
console.log(scale);
engine.Tween.get(_this.frontContainer, null, null, true)
.to({ scaleX: scale, scaleY: scale }, duration, engine.Ease.cubicInOut)
.call(resolve);
});
};
GameView.prototype.playShake = function () {
var _this = this;
var _a = this.frontContainer, x = _a.x, y = _a.y;
return new Promise(function (resolve) {
var shakeOffset = 7;
var duration = 30;
engine.Tween.get(_this.frontContainer, null, null, true)
.to({ x: x, y: y - shakeOffset }, duration)
.to({ x: x, y: y + shakeOffset }, duration)
.to({ x: x + shakeOffset, y: y }, duration)
.to({ x: x - shakeOffset, y: y }, duration)
.to({ x: x, y: y }, duration)
.call(resolve);
});
};
return GameView;
}(engine.Container));
//# sourceMappingURL=GameView.js.map
var JumpHigh = (function (_super) {
tslib.__extends(JumpHigh, _super);
function JumpHigh() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('jump-high-reset', _this.reset, _this);
engine.globalEvent.addEventListener('jump-high-start', _this.start, _this);
engine.globalEvent.addEventListener('jump-high-pause', _this.pause, _this);
engine.globalEvent.addEventListener('jump-high-resume', _this.resume, _this);
engine.globalEvent.addEventListener('jump-high-revive', _this.revive, _this);
_this.addEventListener(engine.MouseEvent.MOUSE_DOWN, _this.onTap, _this);
var gameView = _this._gameView = new GameView();
_this.addChild(gameView);
return _this;
}
JumpHigh.prototype.reset = function () {
this._gameView.reset();
};
JumpHigh.prototype.start = function (event) {
{
injectProps(event.data);
}
this._status = 1;
this._gameView.start();
};
JumpHigh.prototype.pause = function () {
this._gameView.pause();
};
JumpHigh.prototype.resume = function () {
this._gameView.resume();
};
JumpHigh.prototype.revive = function () {
this._gameView.revive();
};
JumpHigh.prototype.onTap = function (event) {
this._gameView.jump();
};
return JumpHigh;
}(engine.Container));
//# sourceMappingURL=JumpHigh.js.map
function index (props) {
prepareProps();
injectProps(props);
var instance = new JumpHigh();
return instance;
}
//# sourceMappingURL=index.js.map
return index;
})));
//# sourceMappingURL=main.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sources":["src/custom/jump-high/src/props.ts","src/custom/jump-high/src/game/utils.ts","src/custom/jump-high/src/game/Block.ts","src/custom/jump-high/src/game/Background.ts","src/custom/jump-high/src/game/Player.ts","src/custom/jump-high/src/game/Base.ts","src/custom/jump-high/src/game/GuideLayer.ts","src/custom/jump-high/src/game/GoldBag.ts","src/custom/jump-high/src/game/GameView.ts","src/custom/jump-high/src/game/JumpHigh.ts","src/custom/jump-high/src/index.ts"],"sourcesContent":["/**\n * Created by rockyl on 2020-01-21.\n */\n\nexport let props: any = {};\n\nexport function prepareProps() {\n\tlet metaProps = getProps();\n\n\tengine.injectProp(props, metaProps);\n}\n\nexport function injectProps(p) {\n\tengine.injectProp(props, p);\n}\n","/**\n * Created by rockyl on 2020-01-21.\n */\nimport {props} from \"../props\";\n\nexport function getTexture(uuid) {\n\treturn engine.Texture.from(uuid);\n}\n\nexport function getTextureByName(name) {\n\treturn engine.Texture.from(getAssetByName(name).uuid);\n}\n\nexport function getBlockAsset(type) {\n\treturn engine.getAssetByName(props.blockAssets[type]);\n}\n\nexport function createSvga(name, anchorName) {\n\tlet inst = new svga.Svga();\n\tinst.source = 'asset://' + getAssetByName(name).uuid;\n\tlet anchor = props[anchorName];\n\tif (anchor) {\n\t\tinst.x = -anchor.x;\n\t\tinst.y = -anchor.y;\n\n\t\tinst.anchorX = anchor.x;\n\t\tinst.anchorY = anchor.y;\n\t}\n\treturn inst;\n}\n\nexport function playSound(name) {\n\tengine.playSound(getAssetByName(name).uuid, {keep: true});\n}","/**\n * Created by rockyl on 2018/8/17.\n * 障碍块\n */\n\nimport { getBlockAsset } from \"./utils\";\nimport { props } from \"../props\";\n\nexport default class Block extends engine.Container {\n\tprivate body: svga.Svga;\n\n\tprivate _deltaTime = 0;\n\tprivate startTime = 0;\n\tprivate lastTime = 0;\n\tprivate curTime = 0;\n\tprivate per = 0;\n\n\ttype;\n\tdir;\n\n\tconstructor() {\n\t\tsuper();\n\n\t\tlet body = this.body = new svga.Svga();\n\t\tbody.x = -props.blockWidth / 2;\n\t\tbody.y = -props.blockHitHeight - props.blockPaddingTop;\n\t\tthis.addChild(body);\n\t\tthis.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);\n\t}\n\n\treset({ type, }) {\n\t\tthis.dir = Math.random() > 0.5 ? 1 : -1;\n\n\t\tif (this.type != type) {\n\t\t\tthis.type = type;\n\n\t\t\tlet asset = getBlockAsset(type);\n\t\t\tthis.body.source = 'asset://' + asset.uuid;\n\t\t}\n\t\tthis.scaleX = this.dir;\n\t\tthis.body.gotoAndStop(1);\n\t}\n\n\tonEnterFrame() {\n\t\tthis.lastTime = this.curTime;\n\t\tthis.curTime = Date.now() - this.startTime;\n\t\tthis._deltaTime = this.curTime - this.lastTime;\n\t\tthis._deltaTime = this._deltaTime < 0 ? 0 : this._deltaTime;\n\t\tvar offMoveX = this.per * this._deltaTime;\n\t\tif (this.per < 0) {\n\t\t\tif (this.x + offMoveX > 0) {\n\t\t\t\tthis.x += offMoveX;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthis.x = 0;\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tif (this.x + offMoveX < 0) {\n\t\t\t\tthis.x += offMoveX;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthis.x = 0;\n\t\t\t}\n\t\t}\n\t}\n\n\tplayEnter(index, animation) {\n\t\tlet _this = this;\n\t\tthis.visible = true;\n\t\tthis.x = this.dir * this.stage.width;\n\t\tconst [min, max] = props.blockDurationRange;\n\t\tlet duration = Math.max(max - index * props.blockDurationStep, min);\n\t\tduration = duration + max * Math.random() * props.blockDurationRandom * (Math.random() > 0.5 ? 1 : -1);\n\t\tlet offX = 0 - this.x;\n\t\tthis.per = offX / duration;\n\t\treturn new Promise(resolve => {\n\t\t\tif (animation) {\n\t\t\t\t_this.startTime = Date.now();\n\t\t\t\tsetTimeout(function () {\n\t\t\t\t\tresolve(1);\n\t\t\t\t}, duration);\n\t\t\t} else {\n\t\t\t\tthis.x = 0;\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tconsole.log(this.body);\n\t\t\t\t}, 200);\n\t\t\t\tresolve(1);\n\t\t\t}\n\t\t})\n\t}\n\n\tplayLeave() {\n\t\tthis.visible = false;\n\t}\n\n\tplayEffect() {\n\t\tlet body = this.body;\n\t\tbody.play(true, false);\n\t\tbody.once(engine.Event.END_FRAME, function () {\n\t\t\tbody.gotoAndStop(1);\n\t\t}, this);\n\t}\n\n\tstop() {\n\t\tthis.removeEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);\n\t}\n}\n","/**\n * Created by rockyl on 2020-01-21.\n */\nimport {getTextureByName} from \"./utils\";\n\nexport class Background extends engine.Container {\n\tprivate _bg: engine.Image;\n\tprivate _minScale: number;\n\n\tconstructor() {\n\t\tsuper();\n\n\t}\n\n\tsetup() {\n\t\tconst {width, height} = this.stage;\n\n\t\tlet bg = this._bg = new engine.Image(getTextureByName('背景图'));\n\t\tbg.anchorX = bg.width / 2;\n\t\tbg.anchorY = bg.height / 2;\n\t\tbg.x = -(bg.width - width) / 2;\n\t\tbg.y = -(bg.height - height) / 2;\n\t\tthis.addChild(bg);\n\n\t\tthis._minScale = width / bg.width;\n\t}\n\n\tplayZoom(type: 'in' | 'out', duration = 700) {\n\t\treturn new Promise(resolve => {\n\t\t\tlet scale = type === 'in' ? 1 : this._minScale;\n\t\t\tengine.Tween.get(this._bg, null, null, true)\n\t\t\t\t.to({scaleX: scale, scaleY: scale}, duration, engine.Ease.cubicInOut)\n\t\t\t\t.call(resolve);\n\t\t})\n\t}\n}\n","/**\n * Created by rockyl on 2018/8/17.\n */\n\nimport { props } from \"../props\";\nimport { createSvga, playSound } from \"./utils\";\n\nconst svgaAssets = {\n\taniReady: { name: '准备立正', dir: 1 },\n\taniJump: { name: '跳上升', dir: 1 },\n\taniFall: { name: '跳下落', dir: 1 },\n\taniLandNormal: { name: '普通着地', dir: 1 },\n\taniLandSide: { name: '边缘着地', dir: -1 },\n\taniHit: { name: '被撞开', dir: -1 },\n\taniParachute: { name: '降落', dir: -1 },\n};\n\nexport default class Player extends engine.Container {\n\tprivate jumpPromise;\n\tprivate playing;\n\tprivate vy;\n\tprivate g = props.gravity;\n\tprivate baseY;\n\n\tprivate aboveBlock;\n\n\tprivate _aniName;\n\n\tprivate _currentAni: svga.Svga;\n\tprivate _prefectLandCounting;\n\n\tprivate aniJump: svga.Svga;\n\tprivate aniFall: svga.Svga;\n\tprivate aniLandNormal: svga.Svga;\n\tprivate aniLandSide: svga.Svga;\n\tprivate aniHit: svga.Svga;\n\tprivate aniParachute: svga.Svga;\n\n\tprivate prefectEffect: svga.Svga;\n\tprivate landEffect: svga.Svga;\n\n\tprivate _deltaTime = 0\n\tprivate startTime = 0\n\tprivate lastTime = 0\n\tprivate curTime = 0\n\n\n\tconstructor() {\n\t\tsuper();\n\n\t\tthis.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);\n\t}\n\n\tswitchAni(name, dir = 1, play = true, loop = false) {\n\t\treturn new Promise(resolve => {\n\t\t\tthis.scaleX = dir;\n\t\t\tif (this._aniName !== name) {\n\t\t\t\tthis._aniName = name;\n\t\t\t\tlet oldAni = <svga.Svga>this.removeChild(this.getChildByName('body'));\n\t\t\t\tif (oldAni) {\n\t\t\t\t\toldAni.stop();\n\t\t\t\t}\n\t\t\t\tlet ani: svga.Svga = this._currentAni = this['ani' + name];\n\t\t\t\tthis.addChild(ani);\n\n\t\t\t\tif (play) {\n\t\t\t\t\tani.play(false, loop);\n\t\t\t\t\tif (loop) {\n\t\t\t\t\t\tresolve(1);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tani.once(engine.Event.END_FRAME, resolve);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tani.gotoAndStop(1);\n\t\t\t\t\tresolve(1);\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t}\n\n\tsetup() {\n\t\tthis.prefectEffect = createSvga('完美着地特效', 'playerLandPrefectAnchor');\n\t\tthis.landEffect = createSvga('着地特效', 'playerLandEffectAnchor');\n\n\t\tfor (let key in svgaAssets) {\n\t\t\tlet { name, dir } = svgaAssets[key];\n\t\t\tlet body = this[key] = createSvga(name, key.replace('ani', 'player') + 'Anchor');\n\n\t\t\tbody.name = 'body';\n\t\t\tbody.scaleX = dir;\n\t\t}\n\t}\n\n\treset(revive) {\n\t\tthis.x = 0;\n\t\tthis.rotation = 0;\n\t\tthis.scaleX = this.scaleY = 1;\n\t\tthis._prefectLandCounting = 0;\n\n\t\tengine.Tween.removeTweens(this);\n\t\tif (revive) {\n\t\t\tthis.switchAni('Jump', 1, false);\n\t\t}\n\t}\n\n\tplayReady() {\n\t\treturn new Promise(resolve => {\n\t\t\tthis.switchAni('Ready', 1);\n\t\t\tthis._currentAni.once(engine.Event.END_FRAME, function () {\n\t\t\t\tthis.switchAni('Jump', 1, false);\n\t\t\t\tresolve(1);\n\t\t\t}, this);\n\t\t})\n\t}\n\n\tprivate onEnterFrame(event) {\n\t\tif (!this.playing) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.lastTime = this.curTime;\n\t\tthis.curTime = Date.now() - this.startTime;\n\t\tthis._deltaTime = this.curTime - this.lastTime;\n\t\tthis._deltaTime = this._deltaTime < 0 ? 0 : this._deltaTime;\n\t\tthis.vy += this.g * this._deltaTime / 16;\n\t\tthis.y += this.vy * this._deltaTime / 16;\n\n\t\tif (this.vy > 0 && this._aniName !== 'Fall') {\n\t\t\tthis.dispatchEvent('jump-on-top');\n\t\t\tthis.switchAni('Fall');\n\t\t}\n\n\t\tif (this.y > this.baseY) {\n\t\t\tthis.y = this.baseY;\n\n\t\t\tthis.playing = false;\n\t\t\t//this.aniDown.play(0);\n\n\t\t\tthis.jumpPromise && this.jumpPromise({\n\t\t\t\taboveBlock: this.aboveBlock,\n\t\t\t});\n\t\t\tthis.jumpPromise = null;\n\t\t}\n\t}\n\n\tchangeBaseY(v) {\n\t\tif (this.baseY == v) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.aboveBlock = true;\n\t\tthis.baseY = v;\n\t}\n\n\tjump() {\n\t\tplaySound('跳起音效');\n\t\tthis.switchAni('Jump', 1, false);\n\t\tthis._currentAni.play(false, false);\n\n\t\tthis.aboveBlock = false;\n\t\tthis.playing = true;\n\n\t\tthis.baseY = this.y;\n\t\tthis.vy = -props.jumpSpeed;\n\n\t\tthis.startTime = Date.now();\n\t\treturn new Promise(resolve => {\n\t\t\tthis.jumpPromise = resolve;\n\t\t})\n\t}\n\n\tasync playLand(type, dir) {\n\t\tswitch (type) {\n\t\t\tcase 0:\n\t\t\t\tthis._prefectLandCounting++;\n\t\t\t\tplaySound('完美落地音效' + Math.min(4, this._prefectLandCounting));\n\n\t\t\t\tlet prefectEffect = this.prefectEffect;\n\t\t\t\tthis.addChildAt(prefectEffect, 0);\n\t\t\t\tprefectEffect.gotoAndPlay(1);\n\t\t\t\tprefectEffect.once(engine.Event.END_FRAME, function () {\n\t\t\t\t\tthis.removeChild(prefectEffect);\n\t\t\t\t}, this);\n\n\t\t\t\tlet landEffect = this.landEffect;\n\t\t\t\tthis.addChildAt(landEffect, 0);\n\t\t\t\tlandEffect.gotoAndPlay(1);\n\t\t\t\tlandEffect.once(engine.Event.END_FRAME, function () {\n\t\t\t\t\tthis.removeChild(landEffect);\n\t\t\t\t}, this);\n\n\t\t\t\tawait this.switchAni('LandNormal');\n\t\t\t\tbreak;\n\t\t\tcase 1:\n\t\t\tcase 2:\n\t\t\t\tthis._prefectLandCounting = 0;\n\t\t\t\tplaySound('普通落地音效');\n\t\t\t\tthis.switchAni('LandNormal');\n\t\t\t\tbreak;\n\t\t\tcase 3:\n\t\t\t\tthis._prefectLandCounting = 0;\n\t\t\t\tplaySound('边缘落地音效');\n\t\t\t\tthis.switchAni('LandSide', dir);\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\tasync hitAway(dir) {\n\t\tthis.jumpPromise && this.jumpPromise();\n\t\tthis.jumpPromise = null;\n\n\t\tplaySound('被撞开音效');\n\t\tthis.switchAni('Hit', dir);\n\n\t\tthis.vy = 0;\n\t\tawait new Promise(resolve => {\n\t\t\tengine.Tween.get(this)\n\t\t\t\t.to({\n\t\t\t\t\tx: -dir * props.hitAwayDistance.x,\n\t\t\t\t}, props.hitAwayDuration, engine.Ease.quartOut);\n\t\t\tengine.Tween.get(this)\n\t\t\t\t.to({\n\t\t\t\t\ty: this.y + props.hitAwayDistance.y,\n\t\t\t\t}, props.hitAwayDuration, engine.Ease.cubicOut)\n\t\t\t\t.call(resolve)\n\t\t});\n\t}\n\n\tparachute(dir) {\n\t\tthis.switchAni('Parachute', dir);\n\n\t\treturn new Promise(resolve => {\n\t\t\tengine.Tween.get(this)\n\t\t\t\t.wait(200)\n\t\t\t\t.call(function () {\n\t\t\t\t\tplaySound('降落伞下落音效');\n\t\t\t\t})\n\t\t\t\t.wait(300)\n\t\t\t\t.to({ y: this.y + props.parachuteDistance }, props.parachuteDuration)\n\t\t\t\t.set({ anchorOffsetY: 0 })\n\t\t\t\t.call(resolve)\n\t\t});\n\t}\n}\n","/**\n * Created by rockyl on 2020-01-21.\n */\n\nimport {getTextureByName} from \"./utils\";\nimport {props} from \"../props\";\n\nexport class Base extends engine.Image{\n\tconstructor(){\n\t\tsuper(getTextureByName('底座'));\n\t}\n\n\tsetup(){\n\t\tthis.x = -(this.width) / 2;\n\t}\n\n\treset(){\n\t\tthis.y = - props.baseOffset;\n\t}\n}\n","/**\n * Created by rockyl on 2020-01-30.\n */\nimport {props} from \"../props\";\nimport {getTextureByName} from \"./utils\";\n\nexport class GuideLayer extends engine.Container {\n\tprivate guideMask: engine.Container;\n\tprivate label: engine.Label;\n\n\tconstructor() {\n\t\tsuper();\n\n\t\tthis.setup();\n\t}\n\n\tprivate setup() {\n\n\t}\n\n\tshow(id, options) {\n\t\treturn new Promise(resolve => {\n\t\t\tthis.visible = true;\n\t\t\tif (!this.guideMask) {\n\t\t\t\tconst {width, height} = this.stage;\n\t\t\t\tlet guideMask = this.guideMask = new engine.Container();\n\n\t\t\t\tlet guideHole = new engine.Image(getTextureByName('引导遮罩'));\n\t\t\t\tguideHole.x = (width - guideHole.width) / 2;\n\t\t\t\tguideHole.y = options.y;\n\t\t\t\tguideMask.addChild(guideHole);\n\n\t\t\t\tthis.createRect(guideMask, 0, 0, width, guideHole.y);\n\t\t\t\tthis.createRect(guideMask, 0, guideHole.y, guideHole.x, guideHole.height);\n\t\t\t\tthis.createRect(guideMask, guideHole.x + guideHole.width, guideHole.y, width - guideHole.x - guideHole.width, guideHole.height);\n\t\t\t\tthis.createRect(guideMask, 0, guideHole.y + guideHole.height, width, height - guideHole.y - guideHole.height);\n\n\t\t\t\tlet label = this.label = new engine.Label();\n\t\t\t\tlabel.fillColor = 'white';\n\t\t\t\tlabel.size = 25;\n\t\t\t\tlabel.text = props.guideText;\n\t\t\t\tlabel.x = (width - label.width) / 2;\n\t\t\t\tlabel.y = guideHole.y + guideHole.height + 50;\n\t\t\t\tguideMask.addChild(label);\n\n\t\t\t\tthis.addChild(guideMask);\n\t\t\t}\n\t\t\tthis.once(engine.MouseEvent.CLICK, function(){\n\t\t\t\tthis.visible = false;\n\t\t\t\tresolve();\n\t\t\t}, this);\n\t\t})\n\t}\n\n\tcreateRect(container, x, y, width, height) {\n\t\tlet rect = new engine.Rect();\n\t\trect.x = x;\n\t\trect.y = y;\n\t\trect.width = width;\n\t\trect.height = height;\n\t\trect.fillColor = 'black';\n\t\trect.alpha = 0.7;\n\n\t\tcontainer.addChild(rect);\n\t}\n}\n","/**\n * Created by rockyl on 2020-01-21.\n */\n\nimport {props} from '../props'\nimport {createSvga, getTextureByName} from \"./utils\";\n\nexport class GoldBag extends engine.Container {\n\tprivate svga: svga.Svga;\n\tprivate avatar: engine.Sprite;\n\n\tremain: number;\n\n\tconstructor() {\n\t\tsuper();\n\n\t\tthis.setup();\n\t}\n\n\tsetup() {\n\t\tlet avatar = this.avatar = new engine.Sprite(getTextureByName('钱袋-静态'));\n\t\tavatar.x = -props.goldPackAvatarAnchor.x;\n\t\tavatar.y = -props.goldPackAvatarAnchor.y;\n\t\tthis.addChild(avatar);\n\t\tlet svga = this.svga = createSvga('钱袋', 'goldPackAnchor');\n\t\tsvga.visible = false;\n\t\tthis.addChild(svga);\n\t}\n\n\treset(data) {\n\t\tthis.y = data.y;\n\t\tthis.avatar.visible = true;\n\t\tthis.svga.visible = false;\n\t\tthis.svga.gotoAndStop(1);\n\t\tthis.remain = data.remain;\n\t}\n\n\tplayOpen() {\n\t\tthis.avatar.visible = false;\n\t\tthis.svga.visible = true;\n\t\treturn new Promise(resolve => {\n\t\t\tthis.svga.play(true, false);\n\t\t\tthis.svga.once(engine.Event.END_FRAME, function () {\n\t\t\t\tthis.svga.visible = false;\n\t\t\t\tresolve();\n\t\t\t}, this);\n\t\t})\n\t}\n}\n","/**\n * Created by rockyl on 2018/8/16.\n */\nimport Block from \"./Block\";\nimport {Background} from \"./Background\";\nimport Player from \"./Player\";\nimport {props} from \"../props\";\nimport {createSvga, playSound} from \"./utils\";\nimport {Base} from \"./Base\";\nimport {GuideLayer} from \"./GuideLayer\";\nimport {GoldBag} from \"./GoldBag\";\nimport ObjectPool = engine.ObjectPool;\n\nconst PoolName: string = 'gold-bag';\n\nObjectPool.registerPool(PoolName, function () {\n\treturn new GoldBag();\n}, function (item: GoldBag, data) {\n\titem.reset(data);\n});\n\nexport default class GameView extends engine.Container {\n\tbackground: Background;\n\tbase: Base;\n\tfrontContainer: engine.Container;\n\tblockContainer: engine.Container;\n\tguideLayer: GuideLayer;\n\tplayer: Player;\n\thitEffect: svga.Svga;\n\n\tcurrentBlock: Block;\n\tneedHitTest;\n\n\tindex = -1;\n\tblockComplete;\n\n\tbaseOffset: number;\n\n\ttimer;\n\n\t_pos;\n\t_score;\n\t_remainToShowGoldBag;\n\tlastLandType;\n\n\t_touchEnabled;\n\tprivate _hasSetup;\n\n\tconstructor() {\n\t\tsuper();\n\n\t\tthis.baseOffset = -props.baseOffset + props.playerOffset;\n\t\tthis.once(engine.Event.ADDED_TO_STAGE, this.setup, this);\n\t}\n\n\tsetup() {\n\t\tif (this._hasSetup) {\n\t\t\treturn;\n\t\t}\n\t\tthis._hasSetup = true;\n\n\t\tconst {width, height} = this.stage;\n\n\t\tconst background = this.background = new Background();\n\t\tthis.addChild(background);\n\t\tbackground.setup();\n\n\t\tconst frontContainer = this.frontContainer = new engine.Container();\n\t\tfrontContainer.x = width / 2;\n\t\tthis.addChild(frontContainer);\n\n\t\tconst guideLayer = this.guideLayer = new GuideLayer();\n\t\tthis.addChild(guideLayer);\n\n\t\tconst base = this.base = new Base();\n\t\tfrontContainer.addChild(base);\n\t\tbase.setup();\n\n\t\tconst blockContainer = this.blockContainer = new engine.Container();\n\t\tfrontContainer.addChild(blockContainer);\n\n\t\tconst player = this.player = new Player();\n\t\tfrontContainer.addChild(player);\n\t\tplayer.setup();\n\t\tplayer.addEventListener('jump-on-top', this.onPlayerJumpOnTop, this);\n\n\t\tObjectPool.recycleObject(PoolName, ObjectPool.getObject(PoolName, {\n\t\t\ty: 0,\n\t\t\tremain: 0,\n\t\t}));\n\n\t\tthis.hitEffect = createSvga('被撞烟雾', 'hitEffectAnchor');\n\n\t\tthis.pos = 0;\n\n\t\tthis.background.setup();\n\t\tthis.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);\n\n\t\tthis.reset();\n\t}\n\n\tasync reset(revive = false) {\n\t\tthis.base.reset();\n\t\tthis.index = -1;\n\t\tthis._score = 0;\n\n\t\tif (revive) {\n\t\t} else {\n\t\t\tthis.pos = 0;\n\t\t\tconst blockContainer = this.blockContainer;\n\t\t\tfor (let i = 0, li = blockContainer.children.length; i < li; i++) {\n\t\t\t\tconst block = <Block>blockContainer.getChildAt(i);\n\t\t\t\tblock.playLeave();\n\t\t\t}\n\t\t}\n\n\t\tfor (let i = 0; i < props.initBlockCount; i++) {\n\t\t\tthis.addBlock(false);\n\t\t}\n\n\t\tfor (let i = 0, li = this.goldBags.length; i < li; i++) {\n\t\t\tconst goldBag = this.goldBags[i];\n\t\t\tthis.frontContainer.removeChild(goldBag);\n\t\t\tObjectPool.recycleObject(PoolName, goldBag);\n\t\t}\n\t\tthis.goldBags.splice(0);\n\t\t//this.addGoldBag();\n\n\t\tthis.playZoom('in');\n\t\tawait this.resetPlayer(revive);\n\t}\n\n\tasync resetPlayer(revive = false) {\n\t\tthis.player.reset(revive);\n\t\tthis.player.y = this.baseOffset - (this.index + 1) * props.blockHitHeight;\n\t}\n\n\tasync start(revive = false) {\n\t\tif (!revive) {\n\t\t\tawait this.player.playReady();\n\t\t}\n\n\t\tlet guideFlagKey = 'jump-high-guide_' + props.guideFlagKey;\n\t\tlet guideFlag = localStorage.getItem(guideFlagKey);\n\t\tif (!guideFlag) {\n\t\t\tlocalStorage.setItem(guideFlagKey, '1');\n\t\t\tawait this.guideLayer.show('', {y: this.stage.height + this.player.y - 280});\n\t\t}\n\n\t\tthis.lastLandType = 0;\n\t\tthis._remainToShowGoldBag = props.goldBagScoreMultiple - props.goldBagScoreSubtraction;\n\t\tthis._touchEnabled = true;\n\t\tsetTimeout(() => {\n\t\t\tthis.addBlock();\n\t\t}, 100);\n\t\tengine.globalEvent.dispatchEvent('jump-high-game-start');\n\t}\n\n\tpause() {\n\t\tif (this.currentBlock) {\n\t\t\tengine.Tween.pauseTweens(this.currentBlock);\n\t\t}\n\t\tengine.Tween.pauseTweens(this.player);\n\t}\n\n\tresume() {\n\t\tif (this.currentBlock) {\n\t\t\tengine.Tween.resumeTweens(this.currentBlock);\n\t\t}\n\t\tengine.Tween.resumeTweens(this.player);\n\t}\n\n\tasync revive() {\n\t\tthis.blockContainer.getChildAt(this.index).visible = false;\n\t\tthis.index--;\n\t\tawait this.resetPlayer(true);\n\t\tawait this.playZoom('in');\n\t\tthis.start(true);\n\t}\n\n\taddBlock(animation = true) {\n\t\tthis.index++;\n\n\t\tconst blockContainer = this.blockContainer;\n\t\tlet block: Block;\n\n\t\tif (blockContainer.children.length > this.index) {\n\t\t\tblock = <Block>blockContainer.getChildAt(this.index);\n\t\t\tblock.visible = true;\n\t\t} else {\n\t\t\tblock = new Block();\n\t\t\tblockContainer.addChild(block);\n\t\t}\n\t\tblock.reset({\n\t\t\ttype: Math.floor(Math.random() * props.blockAssets.length),\n\t\t});\n\t\tblock.y = this.baseOffset - this.index * props.blockHitHeight;\n\n\t\tthis.blockComplete = false;\n\t\tblock.playEnter(this.index, animation).then(\n\t\t\t(data) => {\n\t\t\t\tthis.blockComplete = true;\n\t\t\t}\n\t\t);\n\n\t\tif (animation) {\n\t\t\tthis.needHitTest = true;\n\t\t}\n\t\tthis.currentBlock = block;\n\n\t\t/*if (this.blockCount > 0 && this.blockCount % props.goldBagMultiple === 0) {\n\t\t\tthis.addGoldBag();\n\t\t}*/\n\t}\n\n\tprivate goldBags: GoldBag[] = [];\n\n\taddGoldBag() {\n\t\tlet goldBag = <GoldBag>ObjectPool.getObject(PoolName, {\n\t\t\ty: this.baseOffset - (this.blockCount + props.goldBagDistance + props.goldBagJumpSubtraction) * props.blockHitHeight,\n\t\t\tremain: props.goldBagDistance,\n\t\t});\n\t\tthis.frontContainer.addChild(goldBag);\n\t\tthis.goldBags.push(goldBag);\n\t}\n\n\tprivate nextToUpdateScore;\n\n\tasync playOpenGoldBag() {\n\t\tfor (let i = 0, li = this.goldBags.length; i < li; i++) {\n\t\t\tconst goldBag = this.goldBags[i];\n\t\t\tgoldBag.remain--;\n\n\t\t\tif (goldBag.remain <= 0) {\n\t\t\t\tthis.goldBags.splice(i, 1);\n\t\t\t\ti--;\n\t\t\t\tli--;\n\n\t\t\t\tthis.nextToUpdateScore = true;\n\t\t\t\tawait goldBag.playOpen();\n\t\t\t\tthis.frontContainer.removeChild(goldBag);\n\t\t\t\tObjectPool.recycleObject(PoolName, goldBag);\n\t\t\t}\n\t\t}\n\t}\n\n\tonPlayerJumpOnTop() {\n\t\tif (this.nextToUpdateScore) {\n\t\t\tthis.nextToUpdateScore = false;\n\t\t\tthis.scoreChange(4);\n\t\t\tplaySound('撞击钱袋音效');\n\t\t}\n\t}\n\n\tget blockCount() {\n\t\treturn this.index - props.initBlockCount + 1;\n\t}\n\n\tget pos() {\n\t\treturn this._pos;\n\t}\n\n\tset pos(v) {\n\t\tthis._pos = v;\n\t\tthis.updatePos();\n\t}\n\n\tupdatePos() {\n\t\tthis.frontContainer.y = this.stage.height + this._pos;\n\t}\n\n\tprivate onEnterFrame(event) {\n\t\tif (this.needHitTest) {\n\t\t\tif (this.currentBlock) {\n\t\t\t\tconst {x: bx, y: by, dir} = this.currentBlock;\n\t\t\t\tconst {x: px, y: py} = this.player;\n\t\t\t\tconst {blockHitWidth, blockHitHeight, playerWidth} = props;\n\n\t\t\t\tlet hitOn = false;\n\t\t\t\tif (Math.abs(px - bx) < (blockHitWidth + playerWidth) / 2) {\n\t\t\t\t\tthis.player.changeBaseY(by - blockHitHeight);\n\t\t\t\t\tif (py > by - blockHitHeight) {\n\t\t\t\t\t\thitOn = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (hitOn) {\n\t\t\t\t\tthis.onHitOn(dir);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tasync onHitOn(dir) {\n\t\tthis._touchEnabled = false;\n\t\tthis.needHitTest = false;\n\n\t\tclearInterval(this.timer);\n\n\t\tthis.currentBlock.stop();\n\t\tthis.playHitEffect(dir);\n\t\tawait this.player.hitAway(dir);\n\t\tthis.playZoom('out');\n\t\tawait this.player.parachute(dir);\n\n\t\tengine.globalEvent.dispatchEvent('jump-high-game-end');\n\t}\n\n\tasync jump() {\n\t\tif (!this._touchEnabled) {\n\t\t\treturn;\n\t\t}\n\t\tthis._touchEnabled = false;\n\t\tthis.playOpenGoldBag();\n\t\tconst result: any = await this.player.jump();\n\t\tif (result) {\n\t\t\tif (result.aboveBlock) {\n\t\t\t\tlet pos = Math.abs(this.currentBlock.x);\n\t\t\t\tlet type = 0;\n\t\t\t\tif (pos > 0) {\n\t\t\t\t\ttype = pos > 0 && pos < props.scoreThreshold ? 2 : 3;\n\t\t\t\t}\n\t\t\t\tlet lastLandType = this.lastLandType;\n\t\t\t\tthis.lastLandType = type;\n\t\t\t\tif (type === 0) {\n\t\t\t\t\tif (lastLandType !== type) { //如果前一次不是完美落地说明block没到正中间,所以没有重叠\n\t\t\t\t\t\ttype = 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (type < 3) {\n\t\t\t\t\tthis.currentBlock.playEffect();\n\t\t\t\t}\n\t\t\t\tthis.player.playLand(type, this.currentBlock.dir);\n\t\t\t\tthis.currentBlock.stop();\n\t\t\t\tthis.scoreChange(type);\n\t\t\t\tawait this.playShake();\n\t\t\t\tawait new Promise(resolve => {\n\t\t\t\t\tengine.Tween.get(this, null, null, true)\n\t\t\t\t\t\t.to({pos: props.blockHitHeight * this.index}, 300, engine.Ease.cubicOut)\n\t\t\t\t\t\t.call(resolve)\n\t\t\t\t});\n\t\t\t\tthis.addBlock();\n\t\t\t}\n\t\t\tthis._touchEnabled = true;\n\t\t}\n\t}\n\n\tprivate scoreChange(type) {\n\t\tlet scoreAdd = props.scoreWeights[type];\n\t\tthis._score += scoreAdd;\n\t\tthis._remainToShowGoldBag -= scoreAdd;\n\t\tlet score = this._score;\n\t\tengine.globalEvent.dispatchEvent('jump-high-score', {\n\t\t\ttype,\n\t\t\tscore,\n\t\t\tscoreAdd,\n\t\t});\n\n\t\tconsole.log(score, this._remainToShowGoldBag);\n\n\t\tif (this._remainToShowGoldBag <= 0) {\n\t\t\tthis._remainToShowGoldBag += props.goldBagScoreMultiple;\n\t\t\tthis.addGoldBag();\n\t\t\tconsole.log('addGoldBag');\n\t\t}\n\t}\n\n\tplayHitEffect(dir) {\n\t\tlet hitEffect = this.hitEffect;\n\t\thitEffect.scaleX = dir;\n\t\thitEffect.y = this.player.y - props.hitEffectAnchor.y;\n\t\thitEffect.play(true, false);\n\t\thitEffect.once(engine.Event.END_FRAME, function () {\n\t\t\tthis.frontContainer.removeChild(hitEffect);\n\t\t}, this);\n\t\tthis.frontContainer.addChild(hitEffect);\n\t}\n\n\tplayZoom(type: 'in' | 'out', duration = 700) {\n\t\tthis.background.playZoom(type, duration);\n\t\tlet count = this.stage.height / props.blockHitHeight;\n\t\treturn new Promise(resolve => {\n\t\t\tthis.frontContainer.anchorY = -props.blockHitHeight * (this.index + count * 1.3) + props.baseOffset;\n\t\t\tlet scale = type === 'in' ? 1 : /*Math.max(*/Math.min((this.stage.height / props.blockHitHeight / (this.index + count)), props.maxScale)/*, props.minScale)*/;\n\t\t\tconsole.log(scale);\n\t\t\tengine.Tween.get(this.frontContainer, null, null, true)\n\t\t\t\t.to({scaleX: scale, scaleY: scale}, duration, engine.Ease.cubicInOut)\n\t\t\t\t.call(resolve);\n\t\t})\n\t}\n\n\tplayShake(){\n\t\tconst {x, y} = this.frontContainer;\n\t\treturn new Promise(resolve => {\n\t\t\tconst shakeOffset = 7;\n\t\t\tconst duration = 30;\n\t\t\tengine.Tween.get(this.frontContainer, null, null, true)\n\t\t\t\t.to({x: x, y: y - shakeOffset}, duration)\n\t\t\t\t.to({x: x, y: y + shakeOffset}, duration)\n\t\t\t\t.to({x: x + shakeOffset, y: y}, duration)\n\t\t\t\t.to({x: x - shakeOffset, y: y}, duration)\n\t\t\t\t.to({x: x, y: y}, duration)\n\t\t\t\t.call(resolve)\n\t\t})\n\t}\n}\n","/**\n * Created by rockyl on 2020-01-09.\n */\n\nimport GameView from \"./GameView\";\nimport {injectProps} from \"../props\";\n\nexport class JumpHigh extends engine.Container {\n\tprivate _status;\n\tprivate _gameView: GameView;\n\n\tconstructor() {\n\t\tsuper();\n\n\t\tengine.globalEvent.addEventListener('jump-high-reset', this.reset, this);\n\t\tengine.globalEvent.addEventListener('jump-high-start', this.start, this);\n\t\tengine.globalEvent.addEventListener('jump-high-pause', this.pause, this);\n\t\tengine.globalEvent.addEventListener('jump-high-resume', this.resume, this);\n\t\tengine.globalEvent.addEventListener('jump-high-revive', this.revive, this);\n\n\t\tthis.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onTap, this);\n\n\t\tlet gameView = this._gameView = new GameView();\n\t\tthis.addChild(gameView);\n\t}\n\n\treset() {\n\t\tthis._gameView.reset();\n\t}\n\n\tstart(event: engine.Event) {\n\t\tif ('jump-high-start') {\n\t\t\tinjectProps(event.data);\n\t\t}\n\n\t\tthis._status = 1;\n\n\t\tthis._gameView.start();\n\t}\n\n\tpause() {\n\t\tthis._gameView.pause();\n\t}\n\n\tresume() {\n\t\tthis._gameView.resume();\n\t}\n\n\trevive() {\n\t\tthis._gameView.revive();\n\t}\n\n\tprivate onTap(event) {\n\t\tthis._gameView.jump();\n\t}\n}\n","/**\n * Created by rockyl on 2019-11-20.\n */\n\nimport {JumpHigh} from \"./game/JumpHigh\";\nimport {injectProps, prepareProps} from \"./props\";\n\nexport default function (props) {\n\tprepareProps();\n\tinjectProps(props);\n\n\tlet instance = new JumpHigh();\n\treturn instance;\n}\n"],"names":["__extends"],"mappings":";;;;;;CAIO,IAAI,KAAK,GAAQ,EAAE,CAAC;UAEX,YAAY;KAC3B,IAAI,SAAS,GAAG,QAAQ,EAAE,CAAC;KAE3B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;CACrC,CAAC;UAEe,WAAW,CAAC,CAAC;KAC5B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;CAC7B,CAAC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AC,CAAC;SAEtE,IAAI,QAAQ,GAAG,KAAI,CAAC,SAAS,GAAG,IAAI,QAAQ,EAAE,CAAC;SAC/C,KAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;;MACxB;KAED,wBAAK,GAAL;SACC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;MACvB;KAED,wBAAK,GAAL,UAAM,KAAmB;SACxB,AAAuB;aACtB,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;UACxB;SAED,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;SAEjB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;MACvB;KAED,wBAAK,GAAL;SACC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;MACvB;KAED,yBAAM,GAAN;SACC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;MACxB;KAED,yBAAM,GAAN;SACC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;MACxB;KAEO,wBAAK,GAAb,UAAc,KAAK;SAClB,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;MACtB;KACF,eAAC;CAAD,CAAC,CAhD6B,MAAM,CAAC,SAAS,GAgD7C;;;iBChDwB,KAAK;KAC7B,YAAY,EAAE,CAAC;KACf,WAAW,CAAC,KAAK,CAAC,CAAC;KAEnB,IAAI,QAAQ,GAAG,IAAI,QAAQ,EAAE,CAAC;KAC9B,OAAO,QAAQ,CAAC;CACjB,CAAC;;;;;;;;;"}
\ No newline at end of file
/**
* Created by rockyl on 2020-01-21.
*/
let customModuleProps = {
};
{
"name": "叠叠高",
"desc": "叠叠高模块",
"props": {
"guideText": {
"alias": "引导文本",
"type": "string",
"default": "点击屏幕跳跃躲避飞来的钞票"
},
"guideFlagKey": {
"alias": "引导标识名",
"type": "string",
"default": "test"
},
"scoreWeights": {
"alias": "分值权重(完美,仅中央,正常,边缘,福袋)",
"type": "array<number>",
"default": "4,2,1,1,5"
},
"goldBagScoreMultiple": {
"alias": "出现钱袋的分数倍数",
"type": "number",
"default": 30
},
"goldBagScoreSubtraction": {
"alias": "出现钱袋的分数补偿",
"type": "number",
"default": 5
},
"goldBagDistance": {
"alias": "出现钱袋的距离",
"type": "number",
"default": 10
},
"goldBagJumpSubtraction": {
"alias": "跳起触碰钱袋高度偏差",
"type": "number",
"default": 6
},
"blockAssets": {
"alias": "方块素材组",
"type": "array<string>",
"default": "方块素材0"
},
"blockDurationRange": {
"alias": "方块进入时间范围",
"type": "array<number>",
"default": "500,1500"
},
"blockDurationRandom": {
"alias": "方块进入时间随机系数",
"type": "number",
"default": 0.2
},
"blockDurationStep": {
"alias": "方块进入时间递减",
"type": "number",
"default": 20
},
"gravity": {
"alias": "下落加速度",
"type": "number",
"default": 1.8
},
"scoreThreshold": {
"alias": "分数阈值数组",
"type": "number",
"default": 130
},
"blockWidth": {
"alias": "方块宽度",
"type": "number",
"default": 396
},
"blockHitWidth": {
"alias": "方块碰撞宽度",
"type": "number",
"default": 312
},
"blockHitHeight": {
"alias": "方块碰撞高度",
"type": "number",
"default": 66
},
"blockPaddingTop": {
"alias": "方块上边距",
"type": "number",
"default": 100
},
"blockPaddingBottom": {
"alias": "方块下边距",
"type": "number",
"default": 64
},
"minScale": {
"alias": "最小缩放比例",
"type": "number",
"default": 0.4
},
"maxScale": {
"alias": "最大缩放比例",
"type": "number",
"default": 0.7
},
"baseOffset": {
"alias": "底座偏移",
"type": "number",
"default": 500
},
"playerOffset": {
"alias": "角色偏移",
"type": "number",
"default": 120
},
"initBlockCount": {
"alias": "初始方块数量",
"type": "number",
"default": 1
},
"playerWidth": {
"alias": "角色宽度",
"type": "number",
"default": 100
},
"parachuteDistance": {
"alias": "降落距离",
"type": "number",
"default": 250
},
"jumpSpeed": {
"alias": "挑起速度",
"type": "number",
"default": 30
},
"parachuteDuration": {
"alias": "降落时间",
"type": "number",
"default": 3000
},
"hitAwayDistance": {
"alias": "撞开距离",
"type": "vector2",
"default": "250,50"
},
"hitAwayDuration": {
"alias": "撞开时间",
"type": "number",
"default": 1000
},
"playerReadyAnchor": {
"alias": "角色准备锚点",
"type": "vector2",
"default": "167,242"
},
"playerJumpAnchor": {
"alias": "角色跳起锚点",
"type": "vector2",
"default": "150,190"
},
"playerFallAnchor": {
"alias": "角色下落锚点",
"type": "vector2",
"default": "150,190"
},
"playerHitAnchor": {
"alias": "角色撞开锚点",
"type": "vector2",
"default": "200,290"
},
"playerParachuteAnchor": {
"alias": "角色降落锚点",
"type": "vector2",
"default": "160,310"
},
"playerLandNormalAnchor": {
"alias": "角色正常落地锚点",
"type": "vector2",
"default": "155,245"
},
"playerLandEffectAnchor": {
"alias": "角色落地特效锚点",
"type": "vector2",
"default": "310,100"
},
"playerLandSideAnchor": {
"alias": "角色边缘落地锚点",
"type": "vector2",
"default": "155,245"
},
"playerLandPrefectAnchor": {
"alias": "角色完美落地锚点",
"type": "vector2",
"default": "225,900"
},
"hitEffectAnchor": {
"alias": "被撞烟雾锚点",
"type": "vector2",
"default": "200,300"
},
"goldPackAnchor": {
"alias": "钱袋锚点",
"type": "vector2",
"default": "375,300"
},
"goldPackAvatarAnchor": {
"alias": "静态钱袋锚点",
"type": "vector2",
"default": "850,598"
}
},
"assets": [
{
"name": "背景图",
"url": "//yun.duiba.com.cn/aurora/assets/e6df446ccda45e3e6b6af8471dd1d27b4b3ea016.jpg",
"uuid": "43618417-f27f-429c-bba3-e0715e552ca2",
"ext": ".jpg"
},
{
"name": "底座",
"url": "//yun.duiba.com.cn/aurora/assets/1c0ba12a718076601b24ff63e5ab7ee59462deaa.png",
"uuid": "a6b3f654-2c26-434a-a873-aabc12cd1d80",
"ext": ".png"
},
{
"name": "引导遮罩",
"url": "//yun.duiba.com.cn/aurora/assets/75cc4ea91654fd1e9900d071cac5ca5296b1bd19.png",
"uuid": "6879e370-59c1-453c-8d61-cd3d724ea650",
"ext": ".png"
},
{
"name": "准备立正",
"url": "//yun.duiba.com.cn/aurora/assets/883c41459f1700a17dd20a75b49717fc1b732030.svga",
"uuid": "25dc07d0-b223-4bab-8ea6-2f3282d4eb44",
"ext": ".svga"
},
{
"name": "跳上升",
"url": "//yun.duiba.com.cn/aurora/assets/5b7950568fdc540aad6444a944274ba0bf27571d.svga",
"uuid": "d0a20432-023b-4fd4-8595-f3bb726dfd5e",
"ext": ".svga"
},
{
"name": "跳下落",
"url": "//yun.duiba.com.cn/aurora/assets/7e2c1f241bf2cdcda5614b145910f3f2440ac473.svga",
"uuid": "f3b46174-3353-40c1-957f-fcd9c0227e04",
"ext": ".svga"
},
{
"name": "普通着地",
"url": "//yun.duiba.com.cn/aurora/assets/f7171bff5d525950b02dd578d705054c4ac09ad0.svga",
"uuid": "67b427ed-7dc6-475e-bcc3-a45554629d91",
"ext": ".svga"
},
{
"name": "着地特效",
"url": "//yun.duiba.com.cn/aurora/assets/f5a28ac3ef8acb9adc1ea59faf93213b56a797a0.svga",
"uuid": "cc3f6f1b-1dad-4023-a040-0c7c2ef0ca41",
"ext": ".svga"
},
{
"name": "完美着地特效",
"url": "//yun.duiba.com.cn/aurora/assets/27fa0246bb6e6af977fb29aebe19fbdb30ec03f5.svga",
"uuid": "839215b0-e5df-49db-852d-472a6a78510e",
"ext": ".svga"
},
{
"name": "边缘着地",
"url": "//yun.duiba.com.cn/aurora/assets/1eb7d525c85671c4ec3a40ab923c3142027d0d9e.svga",
"uuid": "33fabc67-c475-44bd-b403-9653abdf2d13",
"ext": ".svga"
},
{
"name": "被撞开",
"url": "//yun.duiba.com.cn/aurora/assets/30864d1f89748d1476232403ad6ab582cc806606.svga",
"uuid": "ecf58409-ecda-40f3-b152-70b0eb285caf",
"ext": ".svga"
},
{
"name": "被撞烟雾",
"url": "//yun.duiba.com.cn/aurora/assets/91841eb45559ee7f1f43378b74be10d9234aac61.svga",
"uuid": "5497949d-1f04-4403-acd8-e0191631f016",
"ext": ".svga"
},
{
"name": "降落",
"url": "//yun.duiba.com.cn/aurora/assets/eea97e28c37a2da354021f697476c7a31c8362f5.svga",
"uuid": "82b514a9-69c4-425c-a77d-f34efeef1997",
"ext": ".svga"
},
{
"name": "钱袋",
"url": "//yun.duiba.com.cn/aurora/assets/12d46f318471f2cff30306f3c0b0c506d67ee166.svga",
"uuid": "3b7feeae-ebb5-49cf-b838-64f46c585978",
"ext": ".svga"
},
{
"name": "钱袋-静态",
"url": "//yun.duiba.com.cn/aurora/assets/35116c957aa4161ea3444611530c0110a69919cf.png",
"uuid": "80a6f0f2-7934-4b2b-a1af-c566dae1040f",
"ext": ".png"
},
{
"name": "跳起音效",
"url": "//yun.duiba.com.cn/aurora/assets/8e3c6af83c20daff6ad34ff198413f0be4903039.mp3",
"uuid": "f9826065-0815-4b6d-be7f-b28478975c68",
"ext": ".mp3"
},
{
"name": "普通落地音效",
"url": "//yun.duiba.com.cn/aurora/assets/b83729366abd4c6aed590bf40bb3ad15e806c8d5.mp3",
"uuid": "dd2a8a0b-18ea-49a7-841d-221e1a3d2d50",
"ext": ".mp3"
},
{
"name": "边缘落地音效",
"url": "//yun.duiba.com.cn/aurora/assets/069079dea1901151594684de3ef294925556c1c3.mp3",
"uuid": "44bfc5ac-0093-4b40-8c8f-cef3000fb436",
"ext": ".mp3"
},
{
"name": "被撞开音效",
"url": "//yun.duiba.com.cn/aurora/assets/6f19e09e8a5300d59b069ed55b82ab8f8b876dc6.mp3",
"uuid": "f7cbf9ef-76b5-4ae8-9e05-680a3b0d223f",
"ext": ".mp3"
},
{
"name": "完美落地音效1",
"url": "//yun.duiba.com.cn/aurora/assets/c492aa71c3f385ae179977b328ec3d93c4c085e2.mp3",
"uuid": "8f5fea1d-d11f-4fd1-a27a-85b0145d54e5",
"ext": ".mp3"
},
{
"name": "完美落地音效2",
"url": "//yun.duiba.com.cn/aurora/assets/317e268d07cefddc69309941e38dbcf7d48f8ebc.mp3",
"uuid": "7452d198-9ab2-46e2-99e2-877fdce9fbe1",
"ext": ".mp3"
},
{
"name": "完美落地音效3",
"url": "//yun.duiba.com.cn/aurora/assets/5e7795c318bdf5357441085d0c681221274a72a9.mp3",
"uuid": "81209b74-d23a-4250-8695-284e9d9a6c00",
"ext": ".mp3"
},
{
"name": "完美落地音效4",
"url": "//yun.duiba.com.cn/aurora/assets/7a62f51f550ea3968fe080ee56abf28be8a92f8c.mp3",
"uuid": "ff87ce4f-c3bd-49ec-b890-4215bedb921d",
"ext": ".mp3"
},
{
"name": "降落伞下落音效",
"url": "//yun.duiba.com.cn/aurora/assets/eb4246b47a8fc2c5707d764bee2cd6a710bdc13e.mp3",
"uuid": "adb5d3ab-143f-4648-a2c4-ff794aceb2fd",
"ext": ".mp3"
},
{
"name": "撞击钱袋音效",
"url": "//yun.duiba.com.cn/aurora/assets/a6e1c99e49f258a42d65ac00b81c5a2b103aa172.mp3",
"uuid": "f06fb9b4-ef76-43ff-80ad-0f920e2ce69c",
"ext": ".mp3"
}
],
"events": {
"in": {
"jump-high-reset": {
"alias": "重置"
},
"jump-high-start": {
"alias": "开始"
},
"jump-high-revive": {
"alias": "复活"
},
"jump-high-pause": {
"alias": "暂停"
},
"jump-high-resume": {
"alias": "恢复"
}
},
"out": {
"jump-high-game-start": {
"alias": "游戏开始",
"data": {
}
},
"jump-high-game-end": {
"alias": "游戏结束",
"data": {
}
},
"jump-high-score": {
"alias": "分数变化",
"data": {
"type": "类型(0:完美,1:仅中央,2:正常,3:边缘,4:钱袋)",
"score": "分数",
"scoreAdd": "增值分数"
}
}
}
}
}
\ No newline at end of file
/**
* Created by rockyl on 2020-01-21.
*/
import {getTextureByName} from "./utils";
export class Background extends engine.Container {
private _bg: engine.Image;
private _minScale: number;
constructor() {
super();
}
setup() {
const {width, height} = this.stage;
let bg = this._bg = new engine.Image(getTextureByName('背景图'));
bg.anchorX = bg.width / 2;
bg.anchorY = bg.height / 2;
bg.x = -(bg.width - width) / 2;
bg.y = -(bg.height - height) / 2;
this.addChild(bg);
this._minScale = width / bg.width;
}
playZoom(type: 'in' | 'out', duration = 700) {
return new Promise(resolve => {
let scale = type === 'in' ? 1 : this._minScale;
engine.Tween.get(this._bg, null, null, true)
.to({scaleX: scale, scaleY: scale}, duration, engine.Ease.cubicInOut)
.call(resolve);
})
}
}
/**
* Created by rockyl on 2020-01-21.
*/
import {getTextureByName} from "./utils";
import {props} from "../props";
export class Base extends engine.Image{
constructor(){
super(getTextureByName('底座'));
}
setup(){
this.x = -(this.width) / 2;
}
reset(){
this.y = - props.baseOffset;
}
}
/**
* Created by rockyl on 2018/8/17.
* 障碍块
*/
import { getBlockAsset } from "./utils";
import { props } from "../props";
export default class Block extends engine.Container {
private body: svga.Svga;
private _deltaTime = 0;
private startTime = 0;
private lastTime = 0;
private curTime = 0;
private per = 0;
type;
dir;
constructor() {
super();
let body = this.body = new svga.Svga();
body.x = -props.blockWidth / 2;
body.y = -props.blockHitHeight - props.blockPaddingTop;
this.addChild(body);
this.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);
}
reset({ type, }) {
this.dir = Math.random() > 0.5 ? 1 : -1;
if (this.type != type) {
this.type = type;
let asset = getBlockAsset(type);
this.body.source = 'asset://' + asset.uuid;
}
this.scaleX = this.dir;
this.body.gotoAndStop(1);
}
onEnterFrame() {
this.lastTime = this.curTime;
this.curTime = Date.now() - this.startTime;
this._deltaTime = this.curTime - this.lastTime;
this._deltaTime = this._deltaTime < 0 ? 0 : this._deltaTime;
var offMoveX = this.per * this._deltaTime;
if (this.per < 0) {
if (this.x + offMoveX > 0) {
this.x += offMoveX;
}
else {
this.x = 0;
}
}
else {
if (this.x + offMoveX < 0) {
this.x += offMoveX;
}
else {
this.x = 0;
}
}
}
playEnter(index, animation) {
let _this = this;
this.visible = true;
this.x = this.dir * this.stage.width;
const [min, max] = props.blockDurationRange;
let duration = Math.max(max - index * props.blockDurationStep, min);
duration = duration + max * Math.random() * props.blockDurationRandom * (Math.random() > 0.5 ? 1 : -1);
let offX = 0 - this.x;
this.per = offX / duration;
return new Promise(resolve => {
if (animation) {
_this.startTime = Date.now();
setTimeout(function () {
resolve(1);
}, duration);
} else {
this.x = 0;
setTimeout(() => {
console.log(this.body);
}, 200);
resolve(1);
}
})
}
playLeave() {
this.visible = false;
}
playEffect() {
let body = this.body;
body.play(true, false);
body.once(engine.Event.END_FRAME, function () {
body.gotoAndStop(1);
}, this);
}
stop() {
this.removeEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);
}
}
/**
* Created by rockyl on 2018/8/16.
*/
import Block from "./Block";
import {Background} from "./Background";
import Player from "./Player";
import {props} from "../props";
import {createSvga, playSound} from "./utils";
import {Base} from "./Base";
import {GuideLayer} from "./GuideLayer";
import {GoldBag} from "./GoldBag";
import ObjectPool = engine.ObjectPool;
const PoolName: string = 'gold-bag';
ObjectPool.registerPool(PoolName, function () {
return new GoldBag();
}, function (item: GoldBag, data) {
item.reset(data);
});
export default class GameView extends engine.Container {
background: Background;
base: Base;
frontContainer: engine.Container;
blockContainer: engine.Container;
guideLayer: GuideLayer;
player: Player;
hitEffect: svga.Svga;
currentBlock: Block;
needHitTest;
index = -1;
blockComplete;
baseOffset: number;
timer;
_pos;
_score;
_remainToShowGoldBag;
lastLandType;
_touchEnabled;
private _hasSetup;
constructor() {
super();
this.baseOffset = -props.baseOffset + props.playerOffset;
this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);
}
setup() {
if (this._hasSetup) {
return;
}
this._hasSetup = true;
const {width, height} = this.stage;
const background = this.background = new Background();
this.addChild(background);
background.setup();
const frontContainer = this.frontContainer = new engine.Container();
frontContainer.x = width / 2;
this.addChild(frontContainer);
const guideLayer = this.guideLayer = new GuideLayer();
this.addChild(guideLayer);
const base = this.base = new Base();
frontContainer.addChild(base);
base.setup();
const blockContainer = this.blockContainer = new engine.Container();
frontContainer.addChild(blockContainer);
const player = this.player = new Player();
frontContainer.addChild(player);
player.setup();
player.addEventListener('jump-on-top', this.onPlayerJumpOnTop, this);
ObjectPool.recycleObject(PoolName, ObjectPool.getObject(PoolName, {
y: 0,
remain: 0,
}));
this.hitEffect = createSvga('被撞烟雾', 'hitEffectAnchor');
this.pos = 0;
this.background.setup();
this.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);
this.reset();
}
async reset(revive = false) {
this.base.reset();
this.index = -1;
this._score = 0;
if (revive) {
} else {
this.pos = 0;
const blockContainer = this.blockContainer;
for (let i = 0, li = blockContainer.children.length; i < li; i++) {
const block = <Block>blockContainer.getChildAt(i);
block.playLeave();
}
}
for (let i = 0; i < props.initBlockCount; i++) {
this.addBlock(false);
}
for (let i = 0, li = this.goldBags.length; i < li; i++) {
const goldBag = this.goldBags[i];
this.frontContainer.removeChild(goldBag);
ObjectPool.recycleObject(PoolName, goldBag);
}
this.goldBags.splice(0);
//this.addGoldBag();
this.playZoom('in');
await this.resetPlayer(revive);
}
async resetPlayer(revive = false) {
this.player.reset(revive);
this.player.y = this.baseOffset - (this.index + 1) * props.blockHitHeight;
}
async start(revive = false) {
if (!revive) {
await this.player.playReady();
}
let guideFlagKey = 'jump-high-guide_' + props.guideFlagKey;
let guideFlag = localStorage.getItem(guideFlagKey);
if (!guideFlag) {
localStorage.setItem(guideFlagKey, '1');
await this.guideLayer.show('', {y: this.stage.height + this.player.y - 280});
}
this.lastLandType = 0;
this._remainToShowGoldBag = props.goldBagScoreMultiple - props.goldBagScoreSubtraction;
this._touchEnabled = true;
setTimeout(() => {
this.addBlock();
}, 100);
engine.globalEvent.dispatchEvent('jump-high-game-start');
}
pause() {
if (this.currentBlock) {
engine.Tween.pauseTweens(this.currentBlock);
}
engine.Tween.pauseTweens(this.player);
}
resume() {
if (this.currentBlock) {
engine.Tween.resumeTweens(this.currentBlock);
}
engine.Tween.resumeTweens(this.player);
}
async revive() {
this.blockContainer.getChildAt(this.index).visible = false;
this.index--;
await this.resetPlayer(true);
await this.playZoom('in');
this.start(true);
}
addBlock(animation = true) {
this.index++;
const blockContainer = this.blockContainer;
let block: Block;
if (blockContainer.children.length > this.index) {
block = <Block>blockContainer.getChildAt(this.index);
block.visible = true;
} else {
block = new Block();
blockContainer.addChild(block);
}
block.reset({
type: Math.floor(Math.random() * props.blockAssets.length),
});
block.y = this.baseOffset - this.index * props.blockHitHeight;
this.blockComplete = false;
block.playEnter(this.index, animation).then(
(data) => {
this.blockComplete = true;
}
);
if (animation) {
this.needHitTest = true;
}
this.currentBlock = block;
/*if (this.blockCount > 0 && this.blockCount % props.goldBagMultiple === 0) {
this.addGoldBag();
}*/
}
private goldBags: GoldBag[] = [];
addGoldBag() {
let goldBag = <GoldBag>ObjectPool.getObject(PoolName, {
y: this.baseOffset - (this.blockCount + props.goldBagDistance + props.goldBagJumpSubtraction) * props.blockHitHeight,
remain: props.goldBagDistance,
});
this.frontContainer.addChild(goldBag);
this.goldBags.push(goldBag);
}
private nextToUpdateScore;
async playOpenGoldBag() {
for (let i = 0, li = this.goldBags.length; i < li; i++) {
const goldBag = this.goldBags[i];
goldBag.remain--;
if (goldBag.remain <= 0) {
this.goldBags.splice(i, 1);
i--;
li--;
this.nextToUpdateScore = true;
await goldBag.playOpen();
this.frontContainer.removeChild(goldBag);
ObjectPool.recycleObject(PoolName, goldBag);
}
}
}
onPlayerJumpOnTop() {
if (this.nextToUpdateScore) {
this.nextToUpdateScore = false;
this.scoreChange(4);
playSound('撞击钱袋音效');
}
}
get blockCount() {
return this.index - props.initBlockCount + 1;
}
get pos() {
return this._pos;
}
set pos(v) {
this._pos = v;
this.updatePos();
}
updatePos() {
this.frontContainer.y = this.stage.height + this._pos;
}
private onEnterFrame(event) {
if (this.needHitTest) {
if (this.currentBlock) {
const {x: bx, y: by, dir} = this.currentBlock;
const {x: px, y: py} = this.player;
const {blockHitWidth, blockHitHeight, playerWidth} = props;
let hitOn = false;
if (Math.abs(px - bx) < (blockHitWidth + playerWidth) / 2) {
this.player.changeBaseY(by - blockHitHeight);
if (py > by - blockHitHeight) {
hitOn = true;
}
}
if (hitOn) {
this.onHitOn(dir);
}
}
}
}
async onHitOn(dir) {
this._touchEnabled = false;
this.needHitTest = false;
clearInterval(this.timer);
this.currentBlock.stop();
this.playHitEffect(dir);
await this.player.hitAway(dir);
this.playZoom('out');
await this.player.parachute(dir);
engine.globalEvent.dispatchEvent('jump-high-game-end');
}
async jump() {
if (!this._touchEnabled) {
return;
}
this._touchEnabled = false;
this.playOpenGoldBag();
const result: any = await this.player.jump();
if (result) {
if (result.aboveBlock) {
let pos = Math.abs(this.currentBlock.x);
let type = 0;
if (pos > 0) {
type = pos > 0 && pos < props.scoreThreshold ? 2 : 3;
}
let lastLandType = this.lastLandType;
this.lastLandType = type;
if (type === 0) {
if (lastLandType !== type) { //如果前一次不是完美落地说明block没到正中间,所以没有重叠
type = 1;
}
}
if (type < 3) {
this.currentBlock.playEffect();
}
this.player.playLand(type, this.currentBlock.dir);
this.currentBlock.stop();
this.scoreChange(type);
await this.playShake();
await new Promise(resolve => {
engine.Tween.get(this, null, null, true)
.to({pos: props.blockHitHeight * this.index}, 300, engine.Ease.cubicOut)
.call(resolve)
});
this.addBlock();
}
this._touchEnabled = true;
}
}
private scoreChange(type) {
let scoreAdd = props.scoreWeights[type];
this._score += scoreAdd;
this._remainToShowGoldBag -= scoreAdd;
let score = this._score;
engine.globalEvent.dispatchEvent('jump-high-score', {
type,
score,
scoreAdd,
});
console.log(score, this._remainToShowGoldBag);
if (this._remainToShowGoldBag <= 0) {
this._remainToShowGoldBag += props.goldBagScoreMultiple;
this.addGoldBag();
console.log('addGoldBag');
}
}
playHitEffect(dir) {
let hitEffect = this.hitEffect;
hitEffect.scaleX = dir;
hitEffect.y = this.player.y - props.hitEffectAnchor.y;
hitEffect.play(true, false);
hitEffect.once(engine.Event.END_FRAME, function () {
this.frontContainer.removeChild(hitEffect);
}, this);
this.frontContainer.addChild(hitEffect);
}
playZoom(type: 'in' | 'out', duration = 700) {
this.background.playZoom(type, duration);
let count = this.stage.height / props.blockHitHeight;
return new Promise(resolve => {
this.frontContainer.anchorY = -props.blockHitHeight * (this.index + count * 1.3) + props.baseOffset;
let scale = type === 'in' ? 1 : /*Math.max(*/Math.min((this.stage.height / props.blockHitHeight / (this.index + count)), props.maxScale)/*, props.minScale)*/;
console.log(scale);
engine.Tween.get(this.frontContainer, null, null, true)
.to({scaleX: scale, scaleY: scale}, duration, engine.Ease.cubicInOut)
.call(resolve);
})
}
playShake(){
const {x, y} = this.frontContainer;
return new Promise(resolve => {
const shakeOffset = 7;
const duration = 30;
engine.Tween.get(this.frontContainer, null, null, true)
.to({x: x, y: y - shakeOffset}, duration)
.to({x: x, y: y + shakeOffset}, duration)
.to({x: x + shakeOffset, y: y}, duration)
.to({x: x - shakeOffset, y: y}, duration)
.to({x: x, y: y}, duration)
.call(resolve)
})
}
}
/**
* Created by rockyl on 2020-01-21.
*/
import {props} from '../props'
import {createSvga, getTextureByName} from "./utils";
export class GoldBag extends engine.Container {
private svga: svga.Svga;
private avatar: engine.Sprite;
remain: number;
constructor() {
super();
this.setup();
}
setup() {
let avatar = this.avatar = new engine.Sprite(getTextureByName('钱袋-静态'));
avatar.x = -props.goldPackAvatarAnchor.x;
avatar.y = -props.goldPackAvatarAnchor.y;
this.addChild(avatar);
let svga = this.svga = createSvga('钱袋', 'goldPackAnchor');
svga.visible = false;
this.addChild(svga);
}
reset(data) {
this.y = data.y;
this.avatar.visible = true;
this.svga.visible = false;
this.svga.gotoAndStop(1);
this.remain = data.remain;
}
playOpen() {
this.avatar.visible = false;
this.svga.visible = true;
return new Promise(resolve => {
this.svga.play(true, false);
this.svga.once(engine.Event.END_FRAME, function () {
this.svga.visible = false;
resolve();
}, this);
})
}
}
/**
* Created by rockyl on 2020-01-30.
*/
import {props} from "../props";
import {getTextureByName} from "./utils";
export class GuideLayer extends engine.Container {
private guideMask: engine.Container;
private label: engine.Label;
constructor() {
super();
this.setup();
}
private setup() {
}
show(id, options) {
return new Promise(resolve => {
this.visible = true;
if (!this.guideMask) {
const {width, height} = this.stage;
let guideMask = this.guideMask = new engine.Container();
let guideHole = new engine.Image(getTextureByName('引导遮罩'));
guideHole.x = (width - guideHole.width) / 2;
guideHole.y = options.y;
guideMask.addChild(guideHole);
this.createRect(guideMask, 0, 0, width, guideHole.y);
this.createRect(guideMask, 0, guideHole.y, guideHole.x, guideHole.height);
this.createRect(guideMask, guideHole.x + guideHole.width, guideHole.y, width - guideHole.x - guideHole.width, guideHole.height);
this.createRect(guideMask, 0, guideHole.y + guideHole.height, width, height - guideHole.y - guideHole.height);
let label = this.label = new engine.Label();
label.fillColor = 'white';
label.size = 25;
label.text = props.guideText;
label.x = (width - label.width) / 2;
label.y = guideHole.y + guideHole.height + 50;
guideMask.addChild(label);
this.addChild(guideMask);
}
this.once(engine.MouseEvent.CLICK, function(){
this.visible = false;
resolve();
}, this);
})
}
createRect(container, x, y, width, height) {
let rect = new engine.Rect();
rect.x = x;
rect.y = y;
rect.width = width;
rect.height = height;
rect.fillColor = 'black';
rect.alpha = 0.7;
container.addChild(rect);
}
}
/**
* Created by rockyl on 2020-01-09.
*/
import GameView from "./GameView";
import {injectProps} from "../props";
export class JumpHigh extends engine.Container {
private _status;
private _gameView: GameView;
constructor() {
super();
engine.globalEvent.addEventListener('jump-high-reset', this.reset, this);
engine.globalEvent.addEventListener('jump-high-start', this.start, this);
engine.globalEvent.addEventListener('jump-high-pause', this.pause, this);
engine.globalEvent.addEventListener('jump-high-resume', this.resume, this);
engine.globalEvent.addEventListener('jump-high-revive', this.revive, this);
this.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onTap, this);
let gameView = this._gameView = new GameView();
this.addChild(gameView);
}
reset() {
this._gameView.reset();
}
start(event: engine.Event) {
if ('jump-high-start') {
injectProps(event.data);
}
this._status = 1;
this._gameView.start();
}
pause() {
this._gameView.pause();
}
resume() {
this._gameView.resume();
}
revive() {
this._gameView.revive();
}
private onTap(event) {
this._gameView.jump();
}
}
/**
* Created by rockyl on 2018/8/17.
*/
import { props } from "../props";
import { createSvga, playSound } from "./utils";
const svgaAssets = {
aniReady: { name: '准备立正', dir: 1 },
aniJump: { name: '跳上升', dir: 1 },
aniFall: { name: '跳下落', dir: 1 },
aniLandNormal: { name: '普通着地', dir: 1 },
aniLandSide: { name: '边缘着地', dir: -1 },
aniHit: { name: '被撞开', dir: -1 },
aniParachute: { name: '降落', dir: -1 },
};
export default class Player extends engine.Container {
private jumpPromise;
private playing;
private vy;
private g = props.gravity;
private baseY;
private aboveBlock;
private _aniName;
private _currentAni: svga.Svga;
private _prefectLandCounting;
private aniJump: svga.Svga;
private aniFall: svga.Svga;
private aniLandNormal: svga.Svga;
private aniLandSide: svga.Svga;
private aniHit: svga.Svga;
private aniParachute: svga.Svga;
private prefectEffect: svga.Svga;
private landEffect: svga.Svga;
private _deltaTime = 0
private startTime = 0
private lastTime = 0
private curTime = 0
constructor() {
super();
this.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);
}
switchAni(name, dir = 1, play = true, loop = false) {
return new Promise(resolve => {
this.scaleX = dir;
if (this._aniName !== name) {
this._aniName = name;
let oldAni = <svga.Svga>this.removeChild(this.getChildByName('body'));
if (oldAni) {
oldAni.stop();
}
let ani: svga.Svga = this._currentAni = this['ani' + name];
this.addChild(ani);
if (play) {
ani.play(false, loop);
if (loop) {
resolve(1);
} else {
ani.once(engine.Event.END_FRAME, resolve);
}
} else {
ani.gotoAndStop(1);
resolve(1);
}
}
})
}
setup() {
this.prefectEffect = createSvga('完美着地特效', 'playerLandPrefectAnchor');
this.landEffect = createSvga('着地特效', 'playerLandEffectAnchor');
for (let key in svgaAssets) {
let { name, dir } = svgaAssets[key];
let body = this[key] = createSvga(name, key.replace('ani', 'player') + 'Anchor');
body.name = 'body';
body.scaleX = dir;
}
}
reset(revive) {
this.x = 0;
this.rotation = 0;
this.scaleX = this.scaleY = 1;
this._prefectLandCounting = 0;
engine.Tween.removeTweens(this);
if (revive) {
this.switchAni('Jump', 1, false);
}
}
playReady() {
return new Promise(resolve => {
this.switchAni('Ready', 1);
this._currentAni.once(engine.Event.END_FRAME, function () {
this.switchAni('Jump', 1, false);
resolve(1);
}, this);
})
}
private onEnterFrame(event) {
if (!this.playing) {
return;
}
this.lastTime = this.curTime;
this.curTime = Date.now() - this.startTime;
this._deltaTime = this.curTime - this.lastTime;
this._deltaTime = this._deltaTime < 0 ? 0 : this._deltaTime;
this.vy += this.g * this._deltaTime / 16;
this.y += this.vy * this._deltaTime / 16;
if (this.vy > 0 && this._aniName !== 'Fall') {
this.dispatchEvent('jump-on-top');
this.switchAni('Fall');
}
if (this.y > this.baseY) {
this.y = this.baseY;
this.playing = false;
//this.aniDown.play(0);
this.jumpPromise && this.jumpPromise({
aboveBlock: this.aboveBlock,
});
this.jumpPromise = null;
}
}
changeBaseY(v) {
if (this.baseY == v) {
return;
}
this.aboveBlock = true;
this.baseY = v;
}
jump() {
playSound('跳起音效');
this.switchAni('Jump', 1, false);
this._currentAni.play(false, false);
this.aboveBlock = false;
this.playing = true;
this.baseY = this.y;
this.vy = -props.jumpSpeed;
this.startTime = Date.now();
return new Promise(resolve => {
this.jumpPromise = resolve;
})
}
async playLand(type, dir) {
switch (type) {
case 0:
this._prefectLandCounting++;
playSound('完美落地音效' + Math.min(4, this._prefectLandCounting));
let prefectEffect = this.prefectEffect;
this.addChildAt(prefectEffect, 0);
prefectEffect.gotoAndPlay(1);
prefectEffect.once(engine.Event.END_FRAME, function () {
this.removeChild(prefectEffect);
}, this);
let landEffect = this.landEffect;
this.addChildAt(landEffect, 0);
landEffect.gotoAndPlay(1);
landEffect.once(engine.Event.END_FRAME, function () {
this.removeChild(landEffect);
}, this);
await this.switchAni('LandNormal');
break;
case 1:
case 2:
this._prefectLandCounting = 0;
playSound('普通落地音效');
this.switchAni('LandNormal');
break;
case 3:
this._prefectLandCounting = 0;
playSound('边缘落地音效');
this.switchAni('LandSide', dir);
break;
}
}
async hitAway(dir) {
this.jumpPromise && this.jumpPromise();
this.jumpPromise = null;
playSound('被撞开音效');
this.switchAni('Hit', dir);
this.vy = 0;
await new Promise(resolve => {
engine.Tween.get(this)
.to({
x: -dir * props.hitAwayDistance.x,
}, props.hitAwayDuration, engine.Ease.quartOut);
engine.Tween.get(this)
.to({
y: this.y + props.hitAwayDistance.y,
}, props.hitAwayDuration, engine.Ease.cubicOut)
.call(resolve)
});
}
parachute(dir) {
this.switchAni('Parachute', dir);
return new Promise(resolve => {
engine.Tween.get(this)
.wait(200)
.call(function () {
playSound('降落伞下落音效');
})
.wait(300)
.to({ y: this.y + props.parachuteDistance }, props.parachuteDuration)
.set({ anchorOffsetY: 0 })
.call(resolve)
});
}
}
/**
* Created by rockyl on 2020-01-21.
*/
import {props} from "../props";
export function getTexture(uuid) {
return engine.Texture.from(uuid);
}
export function getTextureByName(name) {
return engine.Texture.from(getAssetByName(name).uuid);
}
export function getBlockAsset(type) {
return engine.getAssetByName(props.blockAssets[type]);
}
export function createSvga(name, anchorName) {
let inst = new svga.Svga();
inst.source = 'asset://' + getAssetByName(name).uuid;
let anchor = props[anchorName];
if (anchor) {
inst.x = -anchor.x;
inst.y = -anchor.y;
inst.anchorX = anchor.x;
inst.anchorY = anchor.y;
}
return inst;
}
export function playSound(name) {
engine.playSound(getAssetByName(name).uuid, {keep: true});
}
\ No newline at end of file
/**
* Created by rockyl on 2019-11-20.
*/
import {JumpHigh} from "./game/JumpHigh";
import {injectProps, prepareProps} from "./props";
export default function (props) {
prepareProps();
injectProps(props);
let instance = new JumpHigh();
return instance;
}
/**
* Created by rockyl on 2020-01-21.
*/
export let props: any = {};
export function prepareProps() {
let metaProps = getProps();
engine.injectProp(props, metaProps);
}
export function injectProps(p) {
engine.injectProp(props, p);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment