Commit 3db6819a authored by zjz1994's avatar zjz1994

弹球暂存

parent 596ecfbe
......@@ -126,5 +126,5 @@
}
},
"id": "food-fell",
"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['food-fell'] = 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 getTexture(uuid) {\n\t return engine.Texture.from(getAssetByUUID(uuid).uuid);\n\t}\n\tfunction getTextureByName(name) {\n\t return getTexture(engine.getAssetByName(name).uuid);\n\t}\n\tfunction createSvga(name, anchorName) {\n\t var inst = new svga.Svga();\n\t inst.source = 'asset://' + engine.getAssetByName(name).uuid;\n\t return inst;\n\t}\n\n\tvar Goods = (function (_super) {\n\t tslib.__extends(Goods, _super);\n\t function Goods() {\n\t var _this = _super.call(this) || this;\n\t var body;\n\t body = _this._body = new engine.Rect();\n\t var rain = new engine.Sprite(getTextureByName('雨滴'));\n\t rain[\"npcType\"] = \"rain\";\n\t var stone = new engine.Sprite(getTextureByName('石块'));\n\t stone[\"npcType\"] = \"stone\";\n\t var boom = new engine.Sprite(getTextureByName('炸弹'));\n\t boom[\"npcType\"] = \"boom\";\n\t rain.visible = false;\n\t stone.visible = false;\n\t boom.visible = false;\n\t body.addChild(rain);\n\t body.addChild(stone);\n\t body.addChild(boom);\n\t _this.addChild(body);\n\t body.width = .0001;\n\t body.height = .0001;\n\t body.mouseEnabled = false;\n\t return _this;\n\t }\n\t Goods.prototype.getRandomNumberByRange = function (start, end) {\n\t return Math.floor(Math.random() * (end - start) + start);\n\t };\n\t Goods.prototype.reset = function () {\n\t this.visible = true;\n\t this.rotation = 0;\n\t this.anchorOffsetY = 0;\n\t this.y = 0;\n\t this.x = (750 - 120) * Math.random() + 30;\n\t this.rotation = 0;\n\t var random = Math.random();\n\t if (random < props.goodsProbability[0]) {\n\t this.showNpc(\"rain\");\n\t }\n\t else if (random >= props.goodsProbability[0] && random <= (props.goodsProbability[0] + props.goodsProbability[1])) {\n\t this.showNpc(\"stone\");\n\t }\n\t else if (random > (props.goodsProbability[0] + props.goodsProbability[1])) {\n\t this.showNpc(\"boom\");\n\t }\n\t };\n\t Goods.prototype.showNpc = function (type) {\n\t for (var i = 0; i < this._body.children.length; i++) {\n\t this._body.children[i].visible = false;\n\t this._body.children[i].mouseEnabled = false;\n\t }\n\t for (var i = 0; i < this._body.children.length; i++) {\n\t if (this._body.children[i][\"npcType\"] == type) {\n\t this[\"npcType\"] = type;\n\t this._body.children[i].visible = true;\n\t this._body.children[i].mouseEnabled = false;\n\t }\n\t }\n\t };\n\t Object.defineProperty(Goods.prototype, \"anchorOffsetY\", {\n\t set: function (v) {\n\t this._body.y = v;\n\t },\n\t enumerable: true,\n\t configurable: true\n\t });\n\t return Goods;\n\t}(engine.Container));\n\n\tvar ObjectPool = engine.ObjectPool;\n\tvar PoolName = 'goods';\n\tObjectPool.registerPool(PoolName, function () {\n\t return new Goods();\n\t}, function (item, data) {\n\t item.reset();\n\t});\n\n\tvar ObjectPool$1 = engine.ObjectPool;\n\tvar GameView = (function (_super) {\n\t tslib.__extends(GameView, _super);\n\t function GameView() {\n\t var _this = _super.call(this) || this;\n\t _this.goodsItems = [];\n\t _this.moveCatchX = 0;\n\t _this.playerCatchX = 0;\n\t _this.onDownStage = function (e) {\n\t _this.moveCatchX = e.localX;\n\t _this.playerCatchX = _this.player.x;\n\t };\n\t _this.onMoveStage = function (e) {\n\t if (_this.gameIng) {\n\t _this.player.x = _this.playerCatchX + (e.localX - _this.moveCatchX);\n\t }\n\t };\n\t _this.onOutStage = function (e) {\n\t _this.moveCatchX = 0;\n\t };\n\t _this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);\n\t return _this;\n\t }\n\t GameView.prototype.setup = function () {\n\t var _this = this;\n\t if (this._hasSetup) {\n\t return;\n\t }\n\t this._hasSetup = true;\n\t this.NpcBg = new engine.Container();\n\t this.NpcBg.alpha = 1;\n\t this.NpcBg.width = 0;\n\t this.NpcBg.height = 0;\n\t this.addChild(this.NpcBg);\n\t this.player = new engine.Container();\n\t this.player.mouseEnabled = false;\n\t this.addChild(this.player);\n\t this.waterSvga = createSvga(\"水花\");\n\t this.playerSvga = createSvga(\"玩家\");\n\t this.boomSvga = createSvga(\"炸弹svga\");\n\t this.player.addChild(this.playerSvga);\n\t this.player.addChild(this.waterSvga);\n\t this.player.addChild(this.boomSvga);\n\t this.playerSvga.gotoAndPlay(1);\n\t this.visible = false;\n\t setTimeout(function () {\n\t _this.visible = true;\n\t _this.player.anchorY = _this.player.height / 2;\n\t _this.player.anchorX = _this.player.width / 2;\n\t console.log(_this.player.width);\n\t console.log(_this.playerSvga.width);\n\t _this.player.x = 375 - _this.player.width / 2;\n\t _this.player.y = props.playerPositionY;\n\t }, 300);\n\t this.rectBg = new engine.Rect();\n\t this.rectBg.alpha = 0;\n\t this.rectBg.width = 750;\n\t this.rectBg.height = 1624;\n\t this.addChild(this.rectBg);\n\t this.rectBg.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDownStage, this);\n\t this.rectBg.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMoveStage, this);\n\t this.rectBg.addEventListener(engine.MouseEvent.MOUSE_OUT, this.onOutStage, this);\n\t };\n\t GameView.prototype.reset = function () {\n\t this.recycleGoods();\n\t };\n\t GameView.prototype.start = function () {\n\t var _this = this;\n\t this.score = 0;\n\t this.speed = 1;\n\t this.gameIng = true;\n\t this.creatNpc();\n\t this.beginNpc();\n\t this.countdown = props.countDown;\n\t this.countdownTimer = setInterval(function () {\n\t if (_this.gameIng) {\n\t if (_this.countdown > 0) {\n\t engine.globalEvent.dispatchEvent('food-fell-time-update', {\n\t time: _this.countdown,\n\t });\n\t _this.countdown -= 1;\n\t }\n\t else {\n\t engine.globalEvent.dispatchEvent('food-fell-game-over', {\n\t score: _this.score,\n\t reason: 1\n\t });\n\t _this.died();\n\t }\n\t }\n\t }, 1000);\n\t };\n\t GameView.prototype.beginNpc = function () {\n\t var _this = this;\n\t this.timer = setTimeout(function () {\n\t if (_this.gameIng) {\n\t _this.speed += props.acceleratedSpeed;\n\t _this.creatNpc();\n\t }\n\t _this.beginNpc();\n\t }, 2000 / this.speed);\n\t };\n\t GameView.prototype.pause = function () {\n\t this.gameIng = false;\n\t };\n\t GameView.prototype.revive = function () {\n\t this.gameIng = true;\n\t };\n\t GameView.prototype.resume = function () {\n\t this.reset();\n\t this.start();\n\t };\n\t GameView.prototype.creatNpc = function () {\n\t var _this = this;\n\t var goods = this._goods = ObjectPool$1.getObject(PoolName);\n\t this.goodsItems.push(goods);\n\t this.NpcBg.addChild(goods);\n\t goods.addEventListener(engine.Event.ENTER_FRAME, goods[\"onGoodsEnter\"] = function () {\n\t if (goods.y > 1624) {\n\t _this.removeNpc(goods);\n\t }\n\t else {\n\t if (_this.gameIng) {\n\t goods.y += (4 * _this.speed);\n\t if (_this.hasHit(_this.player, goods)) {\n\t if (goods[\"npcType\"] == \"rain\") {\n\t console.log(\"碰到雨滴\");\n\t _this.score += props.rainScore;\n\t _this.waterSvga.visible = true;\n\t _this.waterSvga.play(false, false);\n\t _this.waterSvga.once(engine.Event.END_FRAME, function () {\n\t _this.waterSvga.visible = false;\n\t }, _this);\n\t }\n\t else if (goods[\"npcType\"] == \"stone\") {\n\t console.log(\"碰到石头\");\n\t _this.score += props.stoneScore;\n\t }\n\t else if (goods[\"npcType\"] == \"boom\") {\n\t console.log(\"碰到炸弹\");\n\t _this.boomSvga.visible = true;\n\t _this.boomSvga.play(false, false);\n\t _this.boomSvga.once(engine.Event.END_FRAME, function () {\n\t _this.boomSvga.visible = false;\n\t }, _this);\n\t engine.globalEvent.dispatchEvent('food-fell-game-over', {\n\t score: _this.score,\n\t reason: 2\n\t });\n\t _this.died();\n\t }\n\t engine.globalEvent.dispatchEvent('food-fell-score-update', {\n\t score: _this.score,\n\t });\n\t _this.removeNpc(goods);\n\t }\n\t }\n\t }\n\t }, this);\n\t };\n\t GameView.prototype.died = function () {\n\t this.score = 0;\n\t this.pause();\n\t };\n\t GameView.prototype.removeNpc = function (goods) {\n\t this.NpcBg.removeChild(goods);\n\t ObjectPool$1.recycleObject(PoolName, goods);\n\t goods.removeEventListener(engine.Event.ENTER_FRAME, goods[\"onGoodsEnter\"], this);\n\t var index = this.goodsItems.indexOf(goods);\n\t if (index > -1) {\n\t this.goodsItems.splice(index, 1);\n\t }\n\t };\n\t GameView.prototype.recycleGoods = function () {\n\t clearTimeout(this.timer);\n\t clearInterval(this.countdownTimer);\n\t for (var _i = 0, _a = this.goodsItems; _i < _a.length; _i++) {\n\t var goods = _a[_i];\n\t if (goods) {\n\t this.removeChild(goods);\n\t ObjectPool$1.recycleObject(PoolName, goods);\n\t goods.removeEventListener(engine.Event.ENTER_FRAME, goods[\"onGoodsEnter\"], this);\n\t }\n\t }\n\t this.goodsItems = [];\n\t };\n\t GameView.prototype.hasHit = function (a, b) {\n\t if (Math.abs((a.x + a.width / 2) - (b.x + b.width / 2)) < a.width / 2 + b.width / 2\n\t &&\n\t Math.abs((a.y + a.height / 2) - (b.y + b.height / 2)) < a.height / 2 + b.height / 2) {\n\t return true;\n\t }\n\t else {\n\t return false;\n\t }\n\t };\n\t return GameView;\n\t}(engine.Container));\n\n\tvar GameWrapper = (function (_super) {\n\t tslib.__extends(GameWrapper, _super);\n\t function GameWrapper() {\n\t var _this = _super.call(this) || this;\n\t engine.globalEvent.addEventListener('food-fell-reset', _this.reset, _this);\n\t engine.globalEvent.addEventListener('food-fell-start', _this.start, _this);\n\t engine.globalEvent.addEventListener('food-fell-pause', _this.pause, _this);\n\t engine.globalEvent.addEventListener('food-fell-resume', _this.resume, _this);\n\t engine.globalEvent.addEventListener('food-fell-revive', _this.revive, _this);\n\t engine.globalEvent.addEventListener('food-fell-clear', _this.clear, _this);\n\t _this.addEventListener(engine.MouseEvent.CLICK, _this.onTap, _this);\n\t var gameView = _this._gameView = new GameView();\n\t _this.addChild(gameView);\n\t return _this;\n\t }\n\t GameWrapper.prototype.reset = function (event) {\n\t injectProps(event.data);\n\t this._gameView.visible = true;\n\t this._gameView.reset();\n\t };\n\t GameWrapper.prototype.start = function (event) {\n\t injectProps(event.data);\n\t this._status = 1;\n\t this._gameView.start();\n\t };\n\t GameWrapper.prototype.pause = function () {\n\t this._gameView.pause();\n\t };\n\t GameWrapper.prototype.resume = function () {\n\t this._gameView.resume();\n\t };\n\t GameWrapper.prototype.revive = function () {\n\t this._gameView.revive();\n\t };\n\t GameWrapper.prototype.clear = function () {\n\t this._gameView.visible = false;\n\t };\n\t GameWrapper.prototype.onTap = function (event) {\n\t };\n\t return GameWrapper;\n\t}(engine.Container));\n\n\tfunction index (props) {\n\t prepareProps();\n\t injectProps(props);\n\t var instance = new GameWrapper();\n\t return instance;\n\t}\n\n\treturn index;\n\n})));\n"
"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['food-fell'] = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n\tvar props = {};\r\n\tfunction prepareProps() {\r\n\t var metaProps = getProps();\r\n\t engine.injectProp(props, metaProps);\r\n\t}\r\n\tfunction injectProps(p) {\r\n\t engine.injectProp(props, p);\r\n\t}\r\n\t//# sourceMappingURL=props.js.map\n\n\tfunction getTexture(uuid) {\r\n\t return engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n\t}\r\n\tfunction getTextureByName(name) {\r\n\t return getTexture(engine.getAssetByName(name).uuid);\r\n\t}\r\n\tfunction createSvga(name, anchorName) {\r\n\t var inst = new svga.Svga();\r\n\t inst.source = 'asset://' + engine.getAssetByName(name).uuid;\r\n\t return inst;\r\n\t}\r\n\t//# sourceMappingURL=utils.js.map\n\n\tvar Goods = (function (_super) {\r\n\t tslib.__extends(Goods, _super);\r\n\t function Goods() {\r\n\t var _this = _super.call(this) || this;\r\n\t var body;\r\n\t body = _this._body = new engine.Rect();\r\n\t var rain = new engine.Sprite(getTextureByName('雨滴'));\r\n\t rain[\"npcType\"] = \"rain\";\r\n\t var stone = new engine.Sprite(getTextureByName('石块'));\r\n\t stone[\"npcType\"] = \"stone\";\r\n\t var boom = new engine.Sprite(getTextureByName('炸弹'));\r\n\t boom[\"npcType\"] = \"boom\";\r\n\t rain.visible = false;\r\n\t stone.visible = false;\r\n\t boom.visible = false;\r\n\t body.addChild(rain);\r\n\t body.addChild(stone);\r\n\t body.addChild(boom);\r\n\t _this.addChild(body);\r\n\t body.width = .0001;\r\n\t body.height = .0001;\r\n\t body.mouseEnabled = false;\r\n\t return _this;\r\n\t }\r\n\t Goods.prototype.getRandomNumberByRange = function (start, end) {\r\n\t return Math.floor(Math.random() * (end - start) + start);\r\n\t };\r\n\t Goods.prototype.reset = function () {\r\n\t this.visible = true;\r\n\t this.rotation = 0;\r\n\t this.anchorOffsetY = 0;\r\n\t this.y = 0;\r\n\t this.x = (750 - 120) * Math.random() + 30;\r\n\t this.rotation = 0;\r\n\t var random = Math.random();\r\n\t if (random < props.goodsProbability[0]) {\r\n\t this.showNpc(\"rain\");\r\n\t }\r\n\t else if (random >= props.goodsProbability[0] && random <= (props.goodsProbability[0] + props.goodsProbability[1])) {\r\n\t this.showNpc(\"stone\");\r\n\t }\r\n\t else if (random > (props.goodsProbability[0] + props.goodsProbability[1])) {\r\n\t this.showNpc(\"boom\");\r\n\t }\r\n\t };\r\n\t Goods.prototype.showNpc = function (type) {\r\n\t for (var i = 0; i < this._body.children.length; i++) {\r\n\t this._body.children[i].visible = false;\r\n\t this._body.children[i].mouseEnabled = false;\r\n\t }\r\n\t for (var i = 0; i < this._body.children.length; i++) {\r\n\t if (this._body.children[i][\"npcType\"] == type) {\r\n\t this[\"npcType\"] = type;\r\n\t this._body.children[i].visible = true;\r\n\t this._body.children[i].mouseEnabled = false;\r\n\t }\r\n\t }\r\n\t };\r\n\t Object.defineProperty(Goods.prototype, \"anchorOffsetY\", {\r\n\t set: function (v) {\r\n\t this._body.y = v;\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t return Goods;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=Goods.js.map\n\n\tvar ObjectPool = engine.ObjectPool;\r\n\tvar PoolName = 'goods';\r\n\tObjectPool.registerPool(PoolName, function () {\r\n\t return new Goods();\r\n\t}, function (item, data) {\r\n\t item.reset();\r\n\t});\r\n\t//# sourceMappingURL=object-pool-init.js.map\n\n\tvar ObjectPool$1 = engine.ObjectPool;\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.goodsItems = [];\r\n\t _this.moveCatchX = 0;\r\n\t _this.playerCatchX = 0;\r\n\t _this.onDownStage = function (e) {\r\n\t _this.moveCatchX = e.localX;\r\n\t _this.playerCatchX = _this.player.x;\r\n\t };\r\n\t _this.onMoveStage = function (e) {\r\n\t if (_this.gameIng) {\r\n\t _this.player.x = _this.playerCatchX + (e.localX - _this.moveCatchX);\r\n\t }\r\n\t };\r\n\t _this.onOutStage = function (e) {\r\n\t _this.moveCatchX = 0;\r\n\t };\r\n\t _this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);\r\n\t return _this;\r\n\t }\r\n\t GameView.prototype.setup = function () {\r\n\t var _this = this;\r\n\t if (this._hasSetup) {\r\n\t return;\r\n\t }\r\n\t this._hasSetup = true;\r\n\t this.NpcBg = new engine.Container();\r\n\t this.NpcBg.alpha = 1;\r\n\t this.NpcBg.width = 0;\r\n\t this.NpcBg.height = 0;\r\n\t this.addChild(this.NpcBg);\r\n\t this.player = new engine.Container();\r\n\t this.player.mouseEnabled = false;\r\n\t this.addChild(this.player);\r\n\t this.waterSvga = createSvga(\"水花\");\r\n\t this.playerSvga = createSvga(\"玩家\");\r\n\t this.boomSvga = createSvga(\"炸弹svga\");\r\n\t this.player.addChild(this.playerSvga);\r\n\t this.player.addChild(this.waterSvga);\r\n\t this.player.addChild(this.boomSvga);\r\n\t this.playerSvga.gotoAndPlay(1);\r\n\t this.visible = false;\r\n\t setTimeout(function () {\r\n\t _this.visible = true;\r\n\t _this.player.anchorY = _this.player.height / 2;\r\n\t _this.player.anchorX = _this.player.width / 2;\r\n\t console.log(_this.player.width);\r\n\t console.log(_this.playerSvga.width);\r\n\t _this.player.x = 375 - _this.player.width / 2;\r\n\t _this.player.y = props.playerPositionY;\r\n\t }, 300);\r\n\t this.rectBg = new engine.Rect();\r\n\t this.rectBg.alpha = 0;\r\n\t this.rectBg.width = 750;\r\n\t this.rectBg.height = 1624;\r\n\t this.addChild(this.rectBg);\r\n\t this.rectBg.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDownStage, this);\r\n\t this.rectBg.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMoveStage, this);\r\n\t this.rectBg.addEventListener(engine.MouseEvent.MOUSE_OUT, this.onOutStage, this);\r\n\t };\r\n\t GameView.prototype.reset = function () {\r\n\t this.recycleGoods();\r\n\t };\r\n\t GameView.prototype.start = function () {\r\n\t var _this = this;\r\n\t this.score = 0;\r\n\t this.speed = 1;\r\n\t this.gameIng = true;\r\n\t this.creatNpc();\r\n\t this.beginNpc();\r\n\t this.countdown = props.countDown;\r\n\t this.countdownTimer = setInterval(function () {\r\n\t if (_this.gameIng) {\r\n\t if (_this.countdown > 0) {\r\n\t engine.globalEvent.dispatchEvent('food-fell-time-update', {\r\n\t time: _this.countdown,\r\n\t });\r\n\t _this.countdown -= 1;\r\n\t }\r\n\t else {\r\n\t engine.globalEvent.dispatchEvent('food-fell-game-over', {\r\n\t score: _this.score,\r\n\t reason: 1\r\n\t });\r\n\t _this.died();\r\n\t }\r\n\t }\r\n\t }, 1000);\r\n\t };\r\n\t GameView.prototype.beginNpc = function () {\r\n\t var _this = this;\r\n\t this.timer = setTimeout(function () {\r\n\t if (_this.gameIng) {\r\n\t _this.speed += props.acceleratedSpeed;\r\n\t _this.creatNpc();\r\n\t }\r\n\t _this.beginNpc();\r\n\t }, 2000 / this.speed);\r\n\t };\r\n\t GameView.prototype.pause = function () {\r\n\t this.gameIng = false;\r\n\t };\r\n\t GameView.prototype.revive = function () {\r\n\t this.gameIng = true;\r\n\t };\r\n\t GameView.prototype.resume = function () {\r\n\t this.reset();\r\n\t this.start();\r\n\t };\r\n\t GameView.prototype.creatNpc = function () {\r\n\t var _this = this;\r\n\t var goods = this._goods = ObjectPool$1.getObject(PoolName);\r\n\t this.goodsItems.push(goods);\r\n\t this.NpcBg.addChild(goods);\r\n\t goods.addEventListener(engine.Event.ENTER_FRAME, goods[\"onGoodsEnter\"] = function () {\r\n\t if (goods.y > 1624) {\r\n\t _this.removeNpc(goods);\r\n\t }\r\n\t else {\r\n\t if (_this.gameIng) {\r\n\t goods.y += (4 * _this.speed);\r\n\t if (_this.hasHit(_this.player, goods)) {\r\n\t if (goods[\"npcType\"] == \"rain\") {\r\n\t console.log(\"碰到雨滴\");\r\n\t _this.score += props.rainScore;\r\n\t _this.waterSvga.visible = true;\r\n\t _this.waterSvga.play(false, false);\r\n\t _this.waterSvga.once(engine.Event.END_FRAME, function () {\r\n\t _this.waterSvga.visible = false;\r\n\t }, _this);\r\n\t }\r\n\t else if (goods[\"npcType\"] == \"stone\") {\r\n\t console.log(\"碰到石头\");\r\n\t _this.score += props.stoneScore;\r\n\t }\r\n\t else if (goods[\"npcType\"] == \"boom\") {\r\n\t console.log(\"碰到炸弹\");\r\n\t _this.boomSvga.visible = true;\r\n\t _this.boomSvga.play(false, false);\r\n\t _this.boomSvga.once(engine.Event.END_FRAME, function () {\r\n\t _this.boomSvga.visible = false;\r\n\t }, _this);\r\n\t engine.globalEvent.dispatchEvent('food-fell-game-over', {\r\n\t score: _this.score,\r\n\t reason: 2\r\n\t });\r\n\t _this.died();\r\n\t }\r\n\t engine.globalEvent.dispatchEvent('food-fell-score-update', {\r\n\t score: _this.score,\r\n\t });\r\n\t _this.removeNpc(goods);\r\n\t }\r\n\t }\r\n\t }\r\n\t }, this);\r\n\t };\r\n\t GameView.prototype.died = function () {\r\n\t this.score = 0;\r\n\t this.pause();\r\n\t };\r\n\t GameView.prototype.removeNpc = function (goods) {\r\n\t this.NpcBg.removeChild(goods);\r\n\t ObjectPool$1.recycleObject(PoolName, goods);\r\n\t goods.removeEventListener(engine.Event.ENTER_FRAME, goods[\"onGoodsEnter\"], this);\r\n\t var index = this.goodsItems.indexOf(goods);\r\n\t if (index > -1) {\r\n\t this.goodsItems.splice(index, 1);\r\n\t }\r\n\t };\r\n\t GameView.prototype.recycleGoods = function () {\r\n\t clearTimeout(this.timer);\r\n\t clearInterval(this.countdownTimer);\r\n\t for (var _i = 0, _a = this.goodsItems; _i < _a.length; _i++) {\r\n\t var goods = _a[_i];\r\n\t if (goods) {\r\n\t this.removeChild(goods);\r\n\t ObjectPool$1.recycleObject(PoolName, goods);\r\n\t goods.removeEventListener(engine.Event.ENTER_FRAME, goods[\"onGoodsEnter\"], this);\r\n\t }\r\n\t }\r\n\t this.goodsItems = [];\r\n\t };\r\n\t GameView.prototype.hasHit = function (a, b) {\r\n\t if (Math.abs((a.x + a.width / 2) - (b.x + b.width / 2)) < a.width / 2 + b.width / 2\r\n\t &&\r\n\t Math.abs((a.y + a.height / 2) - (b.y + b.height / 2)) < a.height / 2 + b.height / 2) {\r\n\t return true;\r\n\t }\r\n\t else {\r\n\t return false;\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('food-fell-reset', _this.reset, _this);\r\n\t engine.globalEvent.addEventListener('food-fell-start', _this.start, _this);\r\n\t engine.globalEvent.addEventListener('food-fell-pause', _this.pause, _this);\r\n\t engine.globalEvent.addEventListener('food-fell-resume', _this.resume, _this);\r\n\t engine.globalEvent.addEventListener('food-fell-revive', _this.revive, _this);\r\n\t engine.globalEvent.addEventListener('food-fell-clear', _this.clear, _this);\r\n\t _this.addEventListener(engine.MouseEvent.CLICK, _this.onTap, _this);\r\n\t var gameView = _this._gameView = new GameView();\r\n\t _this.addChild(gameView);\r\n\t return _this;\r\n\t }\r\n\t GameWrapper.prototype.reset = function (event) {\r\n\t injectProps(event.data);\r\n\t this._gameView.visible = true;\r\n\t this._gameView.reset();\r\n\t };\r\n\t GameWrapper.prototype.start = function (event) {\r\n\t injectProps(event.data);\r\n\t this._status = 1;\r\n\t this._gameView.start();\r\n\t };\r\n\t GameWrapper.prototype.pause = function () {\r\n\t this._gameView.pause();\r\n\t };\r\n\t GameWrapper.prototype.resume = function () {\r\n\t this._gameView.resume();\r\n\t };\r\n\t GameWrapper.prototype.revive = function () {\r\n\t this._gameView.revive();\r\n\t };\r\n\t GameWrapper.prototype.clear = function () {\r\n\t this._gameView.visible = false;\r\n\t };\r\n\t GameWrapper.prototype.onTap = function (event) {\r\n\t };\r\n\t return GameWrapper;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=GameWrapper.js.map\n\n\tfunction index (props) {\r\n\t prepareProps();\r\n\t injectProps(props);\r\n\t var instance = new GameWrapper();\r\n\t return instance;\r\n\t}\r\n\t//# sourceMappingURL=index.js.map\n\n\treturn index;\n\n})));\n"
}
{
"name": "弹球",
"desc": "弹球模块",
"props": {
"addscore": {
"alias": "消除一个数字加的分数",
"type": "number",
"default": 1
}
},
"assets": [
{
"name": "door",
"url": "//yun.duiba.com.cn/aurora/assets/a6dd9ac99733adbe0f175397dc1f94ee16301847.png",
"uuid": "fc8ca082-90b7-4c22-85cf-9165ffaf47bf",
"ext": ".png"
},
{
"name": "地",
"url": "//yun.duiba.com.cn/aurora/assets/45fca6ffa65282fc61587442c9847b23006c49b0.png",
"uuid": "995b0f29-885a-425d-bb4e-c9f829df4e7d",
"ext": ".png"
},
{
"name": "炮",
"url": "//yun.duiba.com.cn/aurora/assets/c5fd86a2360a34e13bf09600fb1f5742719489db.png",
"uuid": "2a1b3f6e-5bf5-41d1-b6be-39a77728b230",
"ext": ".png"
},
{
"name": "shootline",
"url": "//yun.duiba.com.cn/aurora/assets/ac3bc89a4eccadfa48d3a8abfc834973d6db0aad.png",
"uuid": "0f2c1ee9-c965-4780-82f2-2d8595173952",
"ext": ".png"
},
{
"name": "sq1",
"url": "//yun.duiba.com.cn/aurora/assets/ba9cd3fc1859d4046b6368a45d95f80b35e3fa6e.png",
"uuid": "7b97ea0d-fb86-4842-9fc7-06e6b5ae3882",
"ext": ".png"
},
{
"name": "sq2",
"url": "//yun.duiba.com.cn/aurora/assets/ba6368eb586671cd4045d09126456229dd8dd503.png",
"uuid": "a171bf2c-c6fd-4ba2-aaff-bc8c91a04fe9",
"ext": ".png"
},
{
"name": "sq3",
"url": "//yun.duiba.com.cn/aurora/assets/7960d9aa4b0502c5c791490f575234a66706b63d.png",
"uuid": "d057cc19-66fe-46f6-91c8-cba2686e8d5d",
"ext": ".png"
},
{
"name": "sq4",
"url": "//yun.duiba.com.cn/aurora/assets/e9e31a95fd93bb2941e98156dc08aaa75b7671bf.png",
"uuid": "1865ae57-f5a3-4794-9c43-0b6aa812f971",
"ext": ".png"
},
{
"name": "tri1",
"url": "//yun.duiba.com.cn/aurora/assets/1b4103f506db3ab6739213a30fb3a7d2abc33f3f.png",
"uuid": "b33457fb-4237-4fca-b48c-bc6074bbe29a",
"ext": ".png"
},
{
"name": "tri2",
"url": "//yun.duiba.com.cn/aurora/assets/56b8a873aafed8241f761061204f5f5f890d2a32.png",
"uuid": "738d6649-6e7f-4006-83cc-0b8a904ec071",
"ext": ".png"
},
{
"name": "风扇",
"url": "//yun.duiba.com.cn/aurora/assets/9f5cf7feac84bc6000bea0a038c7df419f3d5dfb.png",
"uuid": "f26b8a49-f8ee-49ac-a24d-4c83858f5c92",
"ext": ".png"
},
{
"name": "风扇1",
"url": "//yun.duiba.com.cn/aurora/assets/48bc2d0380c7a47defad851d5feaf58cd54e7465.png",
"uuid": "e7363682-e025-49ac-a4ef-fc1a61560014",
"ext": ".png"
},
{
"name": "ball",
"url": "//yun.duiba.com.cn/aurora/assets/28dcf9632e585903c87cb234b09d60244d253dde.png",
"uuid": "8a580ff7-2ece-413e-b87a-11b47f2a28ea",
"ext": ".png"
},
{
"name": "circle1",
"url": "//yun.duiba.com.cn/aurora/assets/3c0c22f57ff647f83fbb8811e9e4437c8a1ad0b4.png",
"uuid": "9af5e780-9701-4cb0-afab-9f4aec42a9ca",
"ext": ".png"
},
{
"name": "+1",
"url": "//yun.duiba.com.cn/aurora/assets/d4013a0ed9f5a367ec20be286ba26581c680b20f.png",
"uuid": "aae627c9-dd32-4ae7-b580-baaefdb77a88",
"ext": ".png"
}
],
"events": {
"in": {
"game-reset": {
"alias": "重置"
},
"game-start": {
"alias": "开始",
"data": {
"ballNums": "初始球的数量"
}
},
"game-pause": {
"alias": "暂停"
},
"game-resume": {
"alias": "恢复"
}
},
"out": {
"game-score-update": {
"alias": "分数更新",
"data": {
"score": "分数"
}
},
"game-over": {
"alias": "游戏结束",
"data": {}
}
}
},
"id": "tanqiu",
"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.tanqiu = 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 BALL_D = 34;\r\n\tvar LEFT_GROUND = 80;\r\n\tvar RIGHT_GROUND = 675;\r\n\tvar LADDER_START = 350 - 100;\r\n\tvar LADDER_END = 1150;\r\n\tvar LADDER_NUMS = 10;\r\n\tvar LADDER_H_START = 130;\r\n\tvar LADDER_H_END = 710;\r\n\tvar LADDER_H_NUMS = 7;\r\n\tvar ACELE_DELAY = 4000;\r\n\t//# sourceMappingURL=gameconsts.js.map\n\n\tvar SoundType;\r\n\t(function (SoundType) {\r\n\t SoundType[\"click\"] = \"click\";\r\n\t SoundType[\"bounce\"] = \"bounce\";\r\n\t SoundType[\"good\"] = \"good\";\r\n\t SoundType[\"recover\"] = \"recover\";\r\n\t SoundType[\"shoot\"] = \"shoot\";\r\n\t})(SoundType || (SoundType = {}));\r\n\tvar isSpecialBody = function (body) {\r\n\t return body.type != 'circle' && body.type != 'square' && body.type != 'regTriangle';\r\n\t};\r\n\tvar isSpecialCircle = function (body) {\r\n\t return body.type === 'specialCircle';\r\n\t};\r\n\tvar ladderHeight = LADDER_END - LADDER_START;\r\n\tvar getLadderPosition = function (i) {\r\n\t return ladderHeight / LADDER_NUMS * i + LADDER_START;\r\n\t};\r\n\tvar ladderWidth = LADDER_H_END - LADDER_H_START;\r\n\tvar getLadderHPosition = function (i) {\r\n\t return ladderWidth / LADDER_H_NUMS * i + LADDER_H_START;\r\n\t};\r\n\tvar getLadderGap = function () {\r\n\t return ladderHeight / LADDER_NUMS;\r\n\t};\r\n\tvar getBounce = function () {\r\n\t return 0.9 + Math.random() * 0.09;\r\n\t};\r\n\tvar shuffle = function (array) {\r\n\t var _array = array.concat();\r\n\t for (var i = _array.length; i--;) {\r\n\t var j = Math.floor(Math.random() * (i + 1));\r\n\t var temp = _array[i];\r\n\t _array[i] = _array[j];\r\n\t _array[j] = temp;\r\n\t }\r\n\t return _array;\r\n\t};\r\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 playSound(name) {\r\n\t return;\r\n\t}\r\n\t//# sourceMappingURL=utils.js.map\n\n\tvar counter;\r\n\tvar resetCounter = function () {\r\n\t counter = 1;\r\n\t};\r\n\tvar getBlockShape = function () {\r\n\t var list = shuffle([1, 2, 3]);\r\n\t return list[0];\r\n\t};\r\n\tvar random = function (start, end) {\r\n\t return start + (end - start) * Math.random();\r\n\t};\r\n\tvar getNums = function (currBallNums) {\r\n\t return Math.ceil(currBallNums * random(1 * window['numsP'], 3.5 * window['numsP']));\r\n\t};\r\n\tvar getNums2 = function (currBallNums) {\r\n\t return Math.ceil(currBallNums * random(4 * window['numsP'], 7 * window['numsP']));\r\n\t};\r\n\tvar getSpecialNumBlocksNums = function (currBallNums) {\r\n\t if (currBallNums < 20)\r\n\t return 1;\r\n\t if (currBallNums < 50)\r\n\t return 2;\r\n\t return 3;\r\n\t};\r\n\tvar getBlocks = function (currBallNums) {\r\n\t var blockNums = Math.random() > 0.3 ? 3 : 2;\r\n\t var specialBall = 0;\r\n\t if (counter % 3 === 0) {\r\n\t specialBall = 1;\r\n\t }\r\n\t var list = [];\r\n\t for (var i = 0; i < LADDER_H_NUMS; i++) {\r\n\t list.push(i);\r\n\t }\r\n\t list = shuffle(list);\r\n\t var blockPositions = list.slice(0, blockNums);\r\n\t var specialBallPosition = list[list.length - 1];\r\n\t var blocksInfo = [];\r\n\t for (var j = 0; j < blockPositions.length; j++) {\r\n\t var p = blockPositions[j];\r\n\t var nums = getNums(currBallNums);\r\n\t var specialNumBlocksNums = getSpecialNumBlocksNums(currBallNums);\r\n\t if (Math.random() < 0.3 && j < specialNumBlocksNums) {\r\n\t nums = getNums2(currBallNums);\r\n\t }\r\n\t if (currBallNums >= 50)\r\n\t nums = getNums2(currBallNums);\r\n\t blocksInfo.push({\r\n\t position: p,\r\n\t type: getBlockShape(),\r\n\t nums: nums || 2\r\n\t });\r\n\t }\r\n\t counter++;\r\n\t return {\r\n\t blocksInfo: blocksInfo,\r\n\t specialBallPosition: specialBall ? specialBallPosition : -1\r\n\t };\r\n\t};\r\n\t//# sourceMappingURL=blockGen.js.map\n\n\tvar Vector = (function () {\r\n\t function Vector(x, y) {\r\n\t if (x === void 0) { x = 0; }\r\n\t if (y === void 0) { y = 0; }\r\n\t this.x = x;\r\n\t this.y = y;\r\n\t }\r\n\t Vector.prototype.initialize = function () {\r\n\t this.x = 0;\r\n\t this.y = 0;\r\n\t };\r\n\t Vector.prototype.length = function () {\r\n\t return Math.sqrt(this.length2());\r\n\t };\r\n\t Vector.prototype.length2 = function () {\r\n\t return this.x * this.x + this.y * this.y;\r\n\t };\r\n\t Vector.prototype.symmetricFromNormalVector = function (normalVector) {\r\n\t var nx2 = normalVector.x * normalVector.x;\r\n\t var ny2 = normalVector.y * normalVector.y;\r\n\t var nxy = normalVector.x * normalVector.y;\r\n\t var tempx = this.x;\r\n\t this.x = (2 * this.y * nxy + this.x * (nx2 - ny2)) / (nx2 + ny2);\r\n\t this.y = (2 * tempx * nxy - this.y * (nx2 - ny2)) / (nx2 + ny2);\r\n\t return this;\r\n\t };\r\n\t Vector.prototype.rotate = function (angle) {\r\n\t var tempx = this.x;\r\n\t this.x = this.x * Math.cos(angle) - this.y * Math.sin(angle);\r\n\t this.y = this.y * Math.cos(angle) + tempx * Math.sin(angle);\r\n\t return this;\r\n\t };\r\n\t Vector.prototype.clone = function () {\r\n\t return new Vector(this.x, this.y);\r\n\t };\r\n\t Vector.prototype.translate = function (x, y) {\r\n\t this.x += x;\r\n\t this.y += y;\r\n\t return this;\r\n\t };\r\n\t Vector.prototype.cross = function () {\r\n\t if (this.x == 0) {\r\n\t if (this.y == 0) ;\r\n\t else {\r\n\t this.x = 1;\r\n\t this.y = 0;\r\n\t }\r\n\t }\r\n\t else {\r\n\t if (this.y == 0) {\r\n\t this.x = 0;\r\n\t this.y = 1;\r\n\t }\r\n\t else {\r\n\t var tempx = this.x;\r\n\t this.x = 1;\r\n\t this.y = -tempx / this.y;\r\n\t }\r\n\t }\r\n\t return this;\r\n\t };\r\n\t Vector.prototype.getMagnitude = function () {\r\n\t return Math.sqrt(Math.pow(this.x, 2) + Math.pow(this.y, 2));\r\n\t };\r\n\t Vector.prototype.add = function (anotherVector) {\r\n\t var v = new Vector();\r\n\t v.x = this.x + anotherVector.x;\r\n\t v.y = this.y + anotherVector.y;\r\n\t return v;\r\n\t };\r\n\t Vector.prototype.subtract = function (anotherVector) {\r\n\t var v = new Vector();\r\n\t v.x = this.x - anotherVector.x;\r\n\t v.y = this.y - anotherVector.y;\r\n\t return v;\r\n\t };\r\n\t Vector.prototype.dotProduct = function (anotherVector) {\r\n\t return this.x * anotherVector.x + this.y * anotherVector.y;\r\n\t };\r\n\t Vector.prototype.edge = function (anotherVector) {\r\n\t return this.subtract(anotherVector);\r\n\t };\r\n\t Vector.prototype.perpendicular = function () {\r\n\t var v = new Vector();\r\n\t v.x = this.y;\r\n\t v.y = 0 - this.x;\r\n\t return v;\r\n\t };\r\n\t Vector.prototype.normalize = function () {\r\n\t var v = new Vector(0, 0);\r\n\t var m = this.getMagnitude();\r\n\t if (m != 0) {\r\n\t v.x = this.x / m;\r\n\t v.y = this.y / m;\r\n\t }\r\n\t return v;\r\n\t };\r\n\t Vector.prototype.perpendicularNormal = function () {\r\n\t var p = this.perpendicular();\r\n\t return p.normalize();\r\n\t };\r\n\t Vector.prototype.parallel = function (vector) {\r\n\t if (Math.abs(this.x * vector.y - this.y * vector.x) < 0.00001) {\r\n\t return true;\r\n\t }\r\n\t else {\r\n\t return false;\r\n\t }\r\n\t };\r\n\t Vector.symmetricVector = function (vector, normalVector) {\r\n\t var nx2 = normalVector.x * normalVector.x;\r\n\t var ny2 = normalVector.y * normalVector.y;\r\n\t var nxy = normalVector.x * normalVector.y;\r\n\t var x = (2 * vector.y * nxy + vector.x * (nx2 - ny2)) / (nx2 + ny2);\r\n\t var y = (2 * vector.x * nxy - vector.y * (nx2 - ny2)) / (nx2 + ny2);\r\n\t return new Vector(x, y);\r\n\t };\r\n\t return Vector;\r\n\t}());\r\n\t//# sourceMappingURL=Vector.js.map\n\n\tvar Projection = (function () {\r\n\t function Projection(min, max) {\r\n\t this.min = min;\r\n\t this.max = max;\r\n\t }\r\n\t Projection.prototype.overlaps = function (projection) {\r\n\t return this.max > projection.min && projection.max > this.min;\r\n\t };\r\n\t return Projection;\r\n\t}());\r\n\t//# sourceMappingURL=Projection.js.map\n\n\tvar Ball = (function () {\r\n\t function Ball(radius, view) {\r\n\t this.collideStatus = 1;\r\n\t this.recoverMark = false;\r\n\t this.velocity = new Vector();\r\n\t this.radius = radius;\r\n\t this.view = view;\r\n\t }\r\n\t Object.defineProperty(Ball.prototype, \"_viewx\", {\r\n\t get: function () {\r\n\t return this.view.x;\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t Object.defineProperty(Ball.prototype, \"_viewy\", {\r\n\t get: function () {\r\n\t return this.view.y;\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t Ball.prototype.project = function (axis) {\r\n\t var scalars = [];\r\n\t var dotProduct = new Vector(this.view.x, this.view.y).dotProduct(axis);\r\n\t scalars.push(dotProduct + this.radius);\r\n\t scalars.push(dotProduct - this.radius);\r\n\t return new Projection(dotProduct - this.radius, dotProduct + this.radius);\r\n\t };\r\n\t return Ball;\r\n\t}());\r\n\t//# sourceMappingURL=Ball.js.map\n\n\tvar createBallItem = function () {\r\n\t var picTex = getTextureByName(\"ball\");\r\n\t var pic = new engine.Image(picTex);\r\n\t pic.mouseEnabled = false;\r\n\t pic.anchorX = pic.width / 2;\r\n\t pic.anchorY = pic.height / 2;\r\n\t var ball = new Ball(BALL_D / 2, pic);\r\n\t return ball;\r\n\t};\r\n\t//# sourceMappingURL=createBall.js.map\n\n\tvar TweenObj = (function () {\r\n\t function TweenObj() {\r\n\t this._instanceId = 0;\r\n\t this._instanceType = \"TweenObj\";\r\n\t this.currentFrame = 0;\r\n\t this.totalFrames = 0;\r\n\t this._isLoop = 0;\r\n\t this._delay = 0;\r\n\t this._isFront = true;\r\n\t this._cParams = null;\r\n\t this._loop = false;\r\n\t this._instanceId = TweenObj._object_id++;\r\n\t }\r\n\t TweenObj.prototype.init = function (target, times, data, isTo) {\r\n\t if (isTo === void 0) { isTo = true; }\r\n\t if (times <= 0 || typeof (times) != \"number\") {\r\n\t throw new Error(\"Tween.to()或者Tween.from()方法的第二个参数一定要是大于0的数字\");\r\n\t }\r\n\t var s = this;\r\n\t s.currentFrame = 1;\r\n\t var tTime = times * 60 >> 0;\r\n\t s.totalFrames = tTime > 0 ? tTime : 1;\r\n\t s.target = target;\r\n\t s._isTo = isTo;\r\n\t s._isLoop = 0;\r\n\t s._startData = {};\r\n\t s._disData = {};\r\n\t s._delay = 0;\r\n\t s._isFront = true;\r\n\t s._ease = null;\r\n\t s._update = null;\r\n\t s._cParams = null;\r\n\t s._loop = false;\r\n\t s._completeFun = null;\r\n\t for (var item in data) {\r\n\t switch (item) {\r\n\t case \"useFrame\":\r\n\t if (data[item] == true) {\r\n\t s.totalFrames = times;\r\n\t }\r\n\t break;\r\n\t case \"yoyo\":\r\n\t if (data[item] === false) {\r\n\t s._isLoop = 0;\r\n\t }\r\n\t else if (data[item] === true) {\r\n\t s._isLoop = Number.MAX_VALUE;\r\n\t }\r\n\t else {\r\n\t s._isLoop = data[item];\r\n\t }\r\n\t break;\r\n\t case \"delay\":\r\n\t if (data.useFrame) {\r\n\t s._delay = data[item];\r\n\t }\r\n\t else {\r\n\t s._delay = data[item] * 60 >> 0;\r\n\t }\r\n\t break;\r\n\t case \"ease\":\r\n\t s._ease = data[item];\r\n\t break;\r\n\t case \"onUpdate\":\r\n\t s._update = data[item];\r\n\t break;\r\n\t case \"onComplete\":\r\n\t s._completeFun = data[item];\r\n\t break;\r\n\t case \"completeParams\":\r\n\t s._cParams = data[item];\r\n\t break;\r\n\t case \"loop\":\r\n\t s._loop = data[item];\r\n\t break;\r\n\t default:\r\n\t if (typeof (data[item]) == \"number\") {\r\n\t if (isTo) {\r\n\t s._startData[item] = target[item];\r\n\t s._disData[item] = data[item] - target[item];\r\n\t }\r\n\t else {\r\n\t s._startData[item] = data[item];\r\n\t s._disData[item] = target[item] - data[item];\r\n\t target[item] = data[item];\r\n\t }\r\n\t }\r\n\t }\r\n\t }\r\n\t };\r\n\t TweenObj.prototype.update = function () {\r\n\t var s = this;\r\n\t if (s._isFront && s._delay > 0) {\r\n\t s._delay--;\r\n\t return;\r\n\t }\r\n\t var per = s.currentFrame / s.totalFrames;\r\n\t if (per < 0 || per > 1)\r\n\t return;\r\n\t if (s._ease) {\r\n\t per = s._ease(per);\r\n\t }\r\n\t var isHave = false;\r\n\t for (var item in s._disData) {\r\n\t isHave = true;\r\n\t s.target[item] = s._startData[item] + s._disData[item] * per;\r\n\t }\r\n\t if (!isHave) {\r\n\t Tween.kill(s.instanceId);\r\n\t return;\r\n\t }\r\n\t if (s._update) {\r\n\t s._update(per);\r\n\t }\r\n\t var cf = s._completeFun;\r\n\t var pm = s._cParams;\r\n\t if (s._isFront) {\r\n\t s.currentFrame++;\r\n\t if (s.currentFrame > s.totalFrames) {\r\n\t if (s._loop) {\r\n\t s.currentFrame = 1;\r\n\t }\r\n\t else {\r\n\t if (s._isLoop > 0) {\r\n\t s._isFront = false;\r\n\t s.currentFrame = s.totalFrames;\r\n\t s._isLoop--;\r\n\t }\r\n\t else {\r\n\t Tween.kill(s.instanceId);\r\n\t }\r\n\t }\r\n\t if (cf) {\r\n\t cf(pm);\r\n\t }\r\n\t }\r\n\t }\r\n\t else {\r\n\t s.currentFrame--;\r\n\t if (s.currentFrame < 0) {\r\n\t if (s._isLoop > 0) {\r\n\t s._isFront = true;\r\n\t s.currentFrame = 1;\r\n\t }\r\n\t else {\r\n\t Tween.kill(s.instanceId);\r\n\t }\r\n\t if (cf) {\r\n\t cf(pm);\r\n\t }\r\n\t }\r\n\t }\r\n\t };\r\n\t Object.defineProperty(TweenObj.prototype, \"instanceId\", {\r\n\t get: function () {\r\n\t return this._instanceId;\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t Object.defineProperty(TweenObj.prototype, \"instanceType\", {\r\n\t get: function () {\r\n\t return this._instanceType;\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t TweenObj.prototype.destroy = function () {\r\n\t var s = this;\r\n\t s._update = null;\r\n\t s._completeFun = null;\r\n\t s._ease = null;\r\n\t };\r\n\t TweenObj._object_id = 0;\r\n\t return TweenObj;\r\n\t}());\r\n\tvar Tween = (function () {\r\n\t function Tween() {\r\n\t }\r\n\t Tween.to = function (target, totalFrame, data) {\r\n\t return Tween.createTween(target, totalFrame, data, true);\r\n\t };\r\n\t Tween.from = function (target, totalFrame, data) {\r\n\t return Tween.createTween(target, totalFrame, data, false);\r\n\t };\r\n\t Tween.createTween = function (target, totalFrame, data, isTo) {\r\n\t var tweenObj;\r\n\t var len = Tween._tweenList.length;\r\n\t for (var i = 0; i < len; i++) {\r\n\t tweenObj = Tween._tweenList[i];\r\n\t if (target == tweenObj.target) {\r\n\t for (var item in tweenObj._startData) {\r\n\t if (data[item] != undefined) {\r\n\t delete tweenObj._startData[item];\r\n\t delete tweenObj._disData[item];\r\n\t }\r\n\t }\r\n\t }\r\n\t }\r\n\t len = Tween._tweenPool.length;\r\n\t if (len > 0) {\r\n\t tweenObj = Tween._tweenPool.shift();\r\n\t tweenObj._instanceId = TweenObj[\"_object_id\"]++;\r\n\t }\r\n\t else {\r\n\t tweenObj = new TweenObj();\r\n\t }\r\n\t Tween._tweenList.push(tweenObj);\r\n\t tweenObj.init(target, totalFrame, data, isTo);\r\n\t return tweenObj.instanceId;\r\n\t };\r\n\t Tween.killAll = function () {\r\n\t var len = Tween._tweenList.length;\r\n\t var tweenObj;\r\n\t for (var i = 0; i < len; i++) {\r\n\t tweenObj = Tween._tweenList[i];\r\n\t tweenObj.target = null;\r\n\t tweenObj._completeFun = null;\r\n\t tweenObj._cParams = null;\r\n\t tweenObj._update = null;\r\n\t tweenObj._ease = null;\r\n\t tweenObj._loop = false;\r\n\t Tween._tweenPool.push(tweenObj);\r\n\t }\r\n\t Tween._tweenList.length = 0;\r\n\t };\r\n\t Tween.kill = function (tweenId) {\r\n\t var len = Tween._tweenList.length;\r\n\t var tweenObj;\r\n\t for (var i = 0; i < len; i++) {\r\n\t tweenObj = Tween._tweenList[i];\r\n\t if (tweenObj.instanceId == tweenId) {\r\n\t tweenObj.target = null;\r\n\t tweenObj._completeFun = null;\r\n\t tweenObj._cParams = null;\r\n\t tweenObj._update = null;\r\n\t tweenObj._ease = null;\r\n\t tweenObj._loop = null;\r\n\t Tween._tweenPool.push(tweenObj);\r\n\t Tween._tweenList.splice(i, 1);\r\n\t break;\r\n\t }\r\n\t }\r\n\t };\r\n\t Tween.quadraticIn = function (k) {\r\n\t return k * k;\r\n\t };\r\n\t Tween.quadraticOut = function (k) {\r\n\t return k * (2 - k);\r\n\t };\r\n\t Tween.quadraticInOut = function (k) {\r\n\t if ((k *= 2) < 1) {\r\n\t return 0.5 * k * k;\r\n\t }\r\n\t return -0.5 * (--k * (k - 2) - 1);\r\n\t };\r\n\t Tween.cubicIn = function (k) {\r\n\t return k * k * k;\r\n\t };\r\n\t Tween.cubicOut = function (k) {\r\n\t return --k * k * k + 1;\r\n\t };\r\n\t Tween.cubicInOut = function (k) {\r\n\t if ((k *= 2) < 1) {\r\n\t return 0.5 * k * k * k;\r\n\t }\r\n\t return 0.5 * ((k -= 2) * k * k + 2);\r\n\t };\r\n\t Tween.quarticIn = function (k) {\r\n\t return k * k * k * k;\r\n\t };\r\n\t Tween.quarticOut = function (k) {\r\n\t return 1 - (--k * k * k * k);\r\n\t };\r\n\t Tween.quarticInOut = function (k) {\r\n\t if ((k *= 2) < 1) {\r\n\t return 0.5 * k * k * k * k;\r\n\t }\r\n\t return -0.5 * ((k -= 2) * k * k * k - 2);\r\n\t };\r\n\t Tween.quinticIn = function (k) {\r\n\t return k * k * k * k * k;\r\n\t };\r\n\t Tween.quinticOut = function (k) {\r\n\t return --k * k * k * k * k + 1;\r\n\t };\r\n\t Tween.quinticInOut = function (k) {\r\n\t if ((k *= 2) < 1) {\r\n\t return 0.5 * k * k * k * k * k;\r\n\t }\r\n\t return 0.5 * ((k -= 2) * k * k * k * k + 2);\r\n\t };\r\n\t Tween.sinusoidalIn = function (k) {\r\n\t return 1 - Math.cos(k * Math.PI / 2);\r\n\t };\r\n\t Tween.sinusoidalOut = function (k) {\r\n\t return Math.sin(k * Math.PI / 2);\r\n\t };\r\n\t Tween.sinusoidalInOut = function (k) {\r\n\t return 0.5 * (1 - Math.cos(Math.PI * k));\r\n\t };\r\n\t Tween.exponentialIn = function (k) {\r\n\t return k === 0 ? 0 : Math.pow(1024, k - 1);\r\n\t };\r\n\t Tween.exponentialOut = function (k) {\r\n\t return k === 1 ? 1 : 1 - Math.pow(2, -10 * k);\r\n\t };\r\n\t Tween.exponentialInOut = function (k) {\r\n\t if (k === 0) {\r\n\t return 0;\r\n\t }\r\n\t if (k === 1) {\r\n\t return 1;\r\n\t }\r\n\t if ((k *= 2) < 1) {\r\n\t return 0.5 * Math.pow(1024, k - 1);\r\n\t }\r\n\t return 0.5 * (-Math.pow(2, -10 * (k - 1)) + 2);\r\n\t };\r\n\t Tween.circularIn = function (k) {\r\n\t return 1 - Math.sqrt(1 - k * k);\r\n\t };\r\n\t Tween.circularOut = function (k) {\r\n\t return Math.sqrt(1 - (--k * k));\r\n\t };\r\n\t Tween.circularInOut = function (k) {\r\n\t if ((k *= 2) < 1) {\r\n\t return -0.5 * (Math.sqrt(1 - k * k) - 1);\r\n\t }\r\n\t return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1);\r\n\t };\r\n\t Tween.elasticIn = function (k) {\r\n\t if (k === 0) {\r\n\t return 0;\r\n\t }\r\n\t if (k === 1) {\r\n\t return 1;\r\n\t }\r\n\t return -Math.pow(2, 10 * (k - 1)) * Math.sin((k - 1.1) * 5 * Math.PI);\r\n\t };\r\n\t Tween.elasticOut = function (k) {\r\n\t if (k === 0) {\r\n\t return 0;\r\n\t }\r\n\t if (k === 1) {\r\n\t return 1;\r\n\t }\r\n\t return Math.pow(2, -10 * k) * Math.sin((k - 0.1) * 5 * Math.PI) + 1;\r\n\t };\r\n\t Tween.elasticInOut = function (k) {\r\n\t if (k === 0) {\r\n\t return 0;\r\n\t }\r\n\t if (k === 1) {\r\n\t return 1;\r\n\t }\r\n\t k *= 2;\r\n\t if (k < 1) {\r\n\t return -0.5 * Math.pow(2, 10 * (k - 1)) * Math.sin((k - 1.1) * 5 * Math.PI);\r\n\t }\r\n\t return 0.5 * Math.pow(2, -10 * (k - 1)) * Math.sin((k - 1.1) * 5 * Math.PI) + 1;\r\n\t };\r\n\t Tween.backIn = function (k) {\r\n\t var s = 1.70158;\r\n\t return k * k * ((s + 1) * k - s);\r\n\t };\r\n\t Tween.backOut = function (k) {\r\n\t var s = 1.70158;\r\n\t return --k * k * ((s + 1) * k + s) + 1;\r\n\t };\r\n\t Tween.backInOut = function (k) {\r\n\t var s = 1.70158 * 1.525;\r\n\t if ((k *= 2) < 1) {\r\n\t return 0.5 * (k * k * ((s + 1) * k - s));\r\n\t }\r\n\t return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2);\r\n\t };\r\n\t Tween.bounceIn = function (k) {\r\n\t return 1 - Tween.bounceOut(1 - k);\r\n\t };\r\n\t Tween.bounceOut = function (k) {\r\n\t if (k < (1 / 2.75)) {\r\n\t return 7.5625 * k * k;\r\n\t }\r\n\t else if (k < (2 / 2.75)) {\r\n\t return 7.5625 * (k -= (1.5 / 2.75)) * k + 0.75;\r\n\t }\r\n\t else if (k < (2.5 / 2.75)) {\r\n\t return 7.5625 * (k -= (2.25 / 2.75)) * k + 0.9375;\r\n\t }\r\n\t else {\r\n\t return 7.5625 * (k -= (2.625 / 2.75)) * k + 0.984375;\r\n\t }\r\n\t };\r\n\t Tween.bounceInOut = function (k) {\r\n\t if (k < 0.5) {\r\n\t return Tween.bounceIn(k * 2) * 0.5;\r\n\t }\r\n\t return Tween.bounceOut(k * 2 - 1) * 0.5 + 0.5;\r\n\t };\r\n\t Tween.flush = function () {\r\n\t var len = Tween._tweenList.length;\r\n\t for (var i = len - 1; i >= 0; i--) {\r\n\t if (Tween._tweenList[i]) {\r\n\t Tween._tweenList[i].update();\r\n\t }\r\n\t else {\r\n\t Tween._tweenList.splice(i, 1);\r\n\t }\r\n\t }\r\n\t };\r\n\t Tween._tweenPool = [];\r\n\t Tween._tweenList = [];\r\n\t return Tween;\r\n\t}());\r\n\t//# sourceMappingURL=Tween.js.map\n\n\tvar Body = (function () {\r\n\t function Body() {\r\n\t this.ladderNums = 1;\r\n\t }\r\n\t Body.prototype.collideBall = function (ball) {\r\n\t };\r\n\t Object.defineProperty(Body.prototype, \"num\", {\r\n\t get: function () {\r\n\t return;\r\n\t },\r\n\t set: function (value) {\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t Object.defineProperty(Body.prototype, \"y\", {\r\n\t set: function (value) { },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t Object.defineProperty(Body.prototype, \"x\", {\r\n\t set: function (value) { },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t return Body;\r\n\t}());\r\n\t//# sourceMappingURL=Body.js.map\n\n\tvar Circle = (function (_super) {\r\n\t tslib.__extends(Circle, _super);\r\n\t function Circle(radius, view) {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.type = \"circle\";\r\n\t _this._x = 0;\r\n\t _this._y = 0;\r\n\t _this.radius = radius;\r\n\t _this.view = view;\r\n\t return _this;\r\n\t }\r\n\t Object.defineProperty(Circle.prototype, \"x\", {\r\n\t get: function () {\r\n\t return this._x;\r\n\t },\r\n\t set: function (value) {\r\n\t if (this._x != value) {\r\n\t this._x = value;\r\n\t this.view.x = value;\r\n\t }\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t Object.defineProperty(Circle.prototype, \"y\", {\r\n\t get: function () {\r\n\t return this._y;\r\n\t },\r\n\t set: function (value) {\r\n\t if (this._y != value) {\r\n\t this._y = value;\r\n\t this.view.y = value;\r\n\t }\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t Object.defineProperty(Circle.prototype, \"num\", {\r\n\t get: function () {\r\n\t return this._num;\r\n\t },\r\n\t set: function (value) {\r\n\t if (this._num != value) {\r\n\t this._num = value;\r\n\t this.view.txt && (this.view.txt.text = value || 2 + \"\");\r\n\t }\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t Object.defineProperty(Circle.prototype, \"_viewx\", {\r\n\t get: function () {\r\n\t return this.view.x;\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t Object.defineProperty(Circle.prototype, \"_viewy\", {\r\n\t get: function () {\r\n\t return this.view.y;\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t Circle.prototype.shake = function () {\r\n\t console.log(\"circle震动1-------\", this.view.bg.x, this.view.bg.y);\r\n\t var startx = -this.view.bg.anchorX;\r\n\t var starty = -this.view.bg.anchorY;\r\n\t this.view.bg.x = startx;\r\n\t this.view.bg.y = starty;\r\n\t console.log(\"circle震动2-------\", this.view.bg.x, this.view.bg.y);\r\n\t Tween.to(this.view.bg, 1, {\r\n\t x: startx + 3,\r\n\t y: starty + 3,\r\n\t yoyo: 2,\r\n\t useFrame: true,\r\n\t onComplete: function () {\r\n\t console.log(\"circle震动3-------\", this.view.bg.x, this.view.bg.y);\r\n\t }\r\n\t });\r\n\t };\r\n\t Circle.prototype.collideBall = function (ball) {\r\n\t var ballax = ball._viewx;\r\n\t var ballay = ball._viewy;\r\n\t var thisax = this._viewx;\r\n\t var thisay = this._viewy;\r\n\t var deltaX = ballax - thisax;\r\n\t var deltaY = ballay - thisay;\r\n\t if (deltaX * deltaX + deltaY * deltaY < (this.radius + ball.radius) * (this.radius + ball.radius)) {\r\n\t var velocity = ball.velocity.clone();\r\n\t var deta = Math.floor(velocity.length() / ball.radius) + 5;\r\n\t var speedX = velocity.x / (deta + 1);\r\n\t var speedY = velocity.y / (deta + 1);\r\n\t for (var i = 0; i <= deta; i++) {\r\n\t var normal = this.nearestCollideNormal({ x: ballax - speedX * (i + 1), y: ballay - speedY * (i + 1) }, ball, deta + 1, i + 1);\r\n\t if (normal) {\r\n\t return normal;\r\n\t }\r\n\t }\r\n\t }\r\n\t else {\r\n\t return false;\r\n\t }\r\n\t };\r\n\t Circle.prototype.nearestCollideNormal = function (position, ball, deta, i) {\r\n\t var thisax = this._viewx;\r\n\t var thisay = this._viewy;\r\n\t var deltaX = position.x - thisax;\r\n\t var deltaY = position.y - thisay;\r\n\t if (deltaX * deltaX + deltaY * deltaY < (this.radius + ball.radius) * (this.radius + ball.radius)) {\r\n\t return false;\r\n\t }\r\n\t else {\r\n\t ball.view.x -= ball.velocity.x / deta * i;\r\n\t ball.view.y -= ball.velocity.y / deta * i;\r\n\t return new Vector(deltaX, deltaY).cross();\r\n\t }\r\n\t };\r\n\t return Circle;\r\n\t}(Body));\r\n\t//# sourceMappingURL=Circle.js.map\n\n\tvar createCircle = (function (that, x, y, num) {\r\n\t var block = that.pool.takeOut(\"circle\");\r\n\t var anchorx = 0;\r\n\t var anchory = 0;\r\n\t if (!block) {\r\n\t var sprite = new engine.Sprite();\r\n\t sprite.mouseEnabled = sprite.mouseChildren = false;\r\n\t var shape = new engine.Image(getTextureByName('circle1'));\r\n\t shape['__resName__'] = 'circle1';\r\n\t var radius = shape.width / 2;\r\n\t var length = radius * 2;\r\n\t shape.anchorX = shape.width / 2;\r\n\t shape.anchorY = shape.height / 2;\r\n\t anchorx = radius;\r\n\t anchory = radius;\r\n\t sprite[\"bg\"] = shape;\r\n\t sprite.addChild(shape);\r\n\t shape.x = -anchorx;\r\n\t shape.y = -anchory;\r\n\t var txt = new engine.TextField();\r\n\t txt.width = length;\r\n\t txt.height = length;\r\n\t txt.anchorX = length / 2;\r\n\t txt.anchorY = length / 2;\r\n\t txt.size = 30;\r\n\t txt.fillColor = 0xffffff;\r\n\t txt.textAlign = engine.TEXT_ALIGN.CENTER;\r\n\t txt.verticalAlign = engine.VERTICAL_ALIGN.MIDDLE;\r\n\t sprite[\"txt\"] = txt;\r\n\t sprite.addChild(txt);\r\n\t txt.x = -anchorx;\r\n\t txt.y = -anchory;\r\n\t block = new Circle(radius, sprite);\r\n\t }\r\n\t that.addChild(block.view);\r\n\t block.x = x;\r\n\t block.y = y;\r\n\t block.num = num;\r\n\t that.blocks.push(block);\r\n\t block.ladderNums = 1;\r\n\t});\r\n\t//# sourceMappingURL=createCircle.js.map\n\n\tvar degToRad = Math.PI / 180;\r\n\tvar radToDeg = 180 / Math.PI;\r\n\tvar sqrt3 = Math.sqrt(3);\r\n\tfunction translateToLocalCor(p, parent) {\r\n\t var th = parent.rotation * degToRad;\r\n\t var xp = p.x - parent.x;\r\n\t var yp = p.y - parent.y;\r\n\t var x = xp * Math.cos(th) + yp * Math.sin(th);\r\n\t var y = yp * Math.cos(th) - xp * Math.sin(th);\r\n\t return { x: x / parent.scaleX, y: y / parent.scaleY };\r\n\t}\r\n\t//# sourceMappingURL=Const.js.map\n\n\tvar RegPolygon = (function (_super) {\r\n\t tslib.__extends(RegPolygon, _super);\r\n\t function RegPolygon(length, view) {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.type = \"regPolygon\";\r\n\t _this._rotation = 0;\r\n\t _this._x = 0;\r\n\t _this._y = 0;\r\n\t _this.linesOri = [];\r\n\t _this.sideNormals = [];\r\n\t _this.pointNormals = [];\r\n\t _this.points = [];\r\n\t _this.axes = [];\r\n\t _this.projects = [];\r\n\t _this.dirty = true;\r\n\t _this.length = length;\r\n\t _this.view = view;\r\n\t _this.calculateNormals();\r\n\t _this.calculatePoints();\r\n\t _this.calculateLines();\r\n\t return _this;\r\n\t }\r\n\t Object.defineProperty(RegPolygon.prototype, \"rotation\", {\r\n\t get: function () {\r\n\t return this._rotation;\r\n\t },\r\n\t set: function (value) {\r\n\t if (this._rotation != value) {\r\n\t this._rotation = value;\r\n\t this.view.rotation = value;\r\n\t this.view.txt.rotation = -value;\r\n\t this.calculateNormals();\r\n\t this.calculatePoints();\r\n\t this.dirty = true;\r\n\t }\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t Object.defineProperty(RegPolygon.prototype, \"x\", {\r\n\t get: function () {\r\n\t return this._x;\r\n\t },\r\n\t set: function (value) {\r\n\t if (this._x != value) {\r\n\t this._x = value;\r\n\t this.view.x = value;\r\n\t this.dirty = true;\r\n\t }\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t Object.defineProperty(RegPolygon.prototype, \"y\", {\r\n\t get: function () {\r\n\t return this._y;\r\n\t },\r\n\t set: function (value) {\r\n\t if (this._y != value) {\r\n\t this._y = value;\r\n\t this.view.y = value;\r\n\t this.dirty = true;\r\n\t }\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t Object.defineProperty(RegPolygon.prototype, \"num\", {\r\n\t get: function () {\r\n\t return this._num;\r\n\t },\r\n\t set: function (value) {\r\n\t if (this._num != value) {\r\n\t this._num = value;\r\n\t this.view.txt.text = value || 3 + \"\";\r\n\t }\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t Object.defineProperty(RegPolygon.prototype, \"_viewx\", {\r\n\t get: function () {\r\n\t return this.view.x;\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t Object.defineProperty(RegPolygon.prototype, \"_viewy\", {\r\n\t get: function () {\r\n\t return this.view.y;\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t RegPolygon.prototype.calculateNormals = function () {\r\n\t };\r\n\t RegPolygon.prototype.calculatePoints = function () {\r\n\t };\r\n\t RegPolygon.prototype.calculateLines = function () {\r\n\t };\r\n\t RegPolygon.prototype.getAxes = function () {\r\n\t var v1 = new Vector();\r\n\t var v2 = new Vector();\r\n\t var axes = [];\r\n\t var thisvx = this._viewx;\r\n\t var thisvy = this._viewy;\r\n\t for (var i = 0; i < this.points.length - 1; i++) {\r\n\t v1.x = this.points[i].x + thisvx;\r\n\t v1.y = this.points[i].y + thisvy;\r\n\t v2.x = this.points[i + 1].x + thisvx;\r\n\t v2.y = this.points[i + 1].y + thisvy;\r\n\t axes.push(v1.edge(v2).perpendicularNormal());\r\n\t }\r\n\t v1.x = this.points[this.points.length - 1].x + thisvx;\r\n\t v1.y = this.points[this.points.length - 1].y + thisvy;\r\n\t v2.x = this.points[0].x + thisvx;\r\n\t v2.y = this.points[0].y + thisvy;\r\n\t axes.push(v1.edge(v2).perpendicularNormal());\r\n\t return axes;\r\n\t };\r\n\t RegPolygon.prototype.project = function (axis) {\r\n\t var scalars = [];\r\n\t var v = new Vector();\r\n\t var thisvx = this._viewx;\r\n\t var thisvy = this._viewy;\r\n\t this.points.forEach(function (point) {\r\n\t v.x = point.x + thisvx;\r\n\t v.y = point.y + thisvy;\r\n\t scalars.push(v.dotProduct(axis));\r\n\t });\r\n\t return new Projection(Math.min.apply(Math, scalars), Math.max.apply(Math, scalars));\r\n\t };\r\n\t RegPolygon.prototype.polygonCollidesWithCircle = function (ball) {\r\n\t var v1;\r\n\t var v2;\r\n\t var ballax = ball._viewx;\r\n\t var ballay = ball._viewy;\r\n\t if (this.dirty) {\r\n\t this.dirty = false;\r\n\t this.axes = this.getAxes();\r\n\t for (var i = 0; i < this.axes.length; i++) {\r\n\t this.projects[i] = this.project(this.axes[i]);\r\n\t }\r\n\t }\r\n\t var axes = this.axes.slice();\r\n\t var closestPoint = this.getPolygonPointClosestToCircle(ball);\r\n\t v1 = new Vector(ballax, ballay);\r\n\t v2 = new Vector(closestPoint.x, closestPoint.y);\r\n\t axes.push(v1.subtract(v2).normalize());\r\n\t return !this.separationOnAxes(axes, ball);\r\n\t };\r\n\t RegPolygon.prototype.getPolygonPointClosestToCircle = function (ball) {\r\n\t var min;\r\n\t var length;\r\n\t var testPoint;\r\n\t var closestPoint;\r\n\t var ballax = ball._viewx;\r\n\t var ballay = ball._viewy;\r\n\t var thisax = this._viewx;\r\n\t var thisay = this._viewy;\r\n\t for (var i = 0; i < this.points.length; i++) {\r\n\t testPoint = new Vector(this.points[i].x + thisax, this.points[i].y + thisay);\r\n\t length = Math.pow(testPoint.x - ballax, 2) + Math.pow(testPoint.y - ballay, 2);\r\n\t if (!min || length < min) {\r\n\t min = length;\r\n\t closestPoint = testPoint;\r\n\t }\r\n\t }\r\n\t return closestPoint;\r\n\t };\r\n\t RegPolygon.prototype.separationOnAxes = function (axes, ball) {\r\n\t var axis;\r\n\t var projection1;\r\n\t var projection2;\r\n\t for (var i = 0; i < axes.length; ++i) {\r\n\t axis = axes[i];\r\n\t projection1 = ball.project(axis);\r\n\t if (i == axes.length - 1) {\r\n\t projection2 = this.project(axis);\r\n\t }\r\n\t else {\r\n\t projection2 = this.projects[i];\r\n\t }\r\n\t if (!projection1.overlaps(projection2)) {\r\n\t return true;\r\n\t }\r\n\t }\r\n\t return false;\r\n\t };\r\n\t RegPolygon.prototype.collideBall = function (ball) {\r\n\t var ballax = ball._viewx;\r\n\t var ballay = ball._viewy;\r\n\t var thisax = this._viewx;\r\n\t var thisay = this._viewy;\r\n\t if (this.polygonCollidesWithCircle(ball)) {\r\n\t var returnP = translateToLocalCor({ x: ballax, y: ballay }, this.view);\r\n\t var velocity = ball.velocity.clone().rotate(-this._rotation * degToRad);\r\n\t var deta = Math.floor(velocity.length() / ball.radius) + 1;\r\n\t var speedX = velocity.x / (deta + 1);\r\n\t var speedY = velocity.y / (deta + 1);\r\n\t for (var i = 0; i <= deta; i++) {\r\n\t this.ballPosition(ball, deta + 1, i + 1);\r\n\t if (!this.polygonCollidesWithCircle(ball)) {\r\n\t var noraml = this.nearestCollideNormal({ x: returnP.x - speedX * (i + 1), y: returnP.y - speedY * (i + 1) });\r\n\t return noraml;\r\n\t }\r\n\t }\r\n\t }\r\n\t else {\r\n\t return false;\r\n\t }\r\n\t };\r\n\t RegPolygon.prototype.nearestCollideNormal = function (returnP) {\r\n\t return;\r\n\t };\r\n\t RegPolygon.prototype.ballPosition = function (ball, deta, i) {\r\n\t ball.view.x -= ball.velocity.x / deta;\r\n\t ball.view.y -= ball.velocity.y / deta;\r\n\t };\r\n\t RegPolygon.prototype.shake = function () {\r\n\t console.log(\"regPolygon震动1----------\", this.view.bg.x, this.view.bg.y);\r\n\t var startx = -this.view.bg.anchorX;\r\n\t var starty = -this.view.bg.anchorY;\r\n\t this.view.bg.x = startx;\r\n\t this.view.bg.y = starty;\r\n\t console.log(\"regPolygon震动2----------\", this.view.bg.x, this.view.bg.y);\r\n\t Tween.to(this.view.bg, 1, {\r\n\t x: startx + 3,\r\n\t y: starty + 3,\r\n\t yoyo: 2,\r\n\t useFrame: true,\r\n\t onComplete: function () {\r\n\t console.log(\"regPolygon震动3----------\", this.view.bg.x, this.view.bg.y);\r\n\t }\r\n\t });\r\n\t };\r\n\t return RegPolygon;\r\n\t}(Body));\r\n\t//# sourceMappingURL=RegPolygon.js.map\n\n\tvar RegTriangle = (function (_super) {\r\n\t tslib.__extends(RegTriangle, _super);\r\n\t function RegTriangle(length, view) {\r\n\t var _this = _super.call(this, length, view) || this;\r\n\t _this.type = \"regTriangle\";\r\n\t _this.pointLength = _this.length * sqrt3 / 3;\r\n\t _this.sideLength = _this.length * sqrt3 / 6;\r\n\t return _this;\r\n\t }\r\n\t RegTriangle.prototype.calculateNormals = function () {\r\n\t if (this._rotation == 0) {\r\n\t this.sideNormals[0] = new Vector(1, -sqrt3);\r\n\t this.sideNormals[1] = new Vector(1, sqrt3);\r\n\t this.sideNormals[2] = new Vector(-1, 0);\r\n\t this.pointNormals[0] = new Vector(1, 0);\r\n\t this.pointNormals[1] = new Vector(-1, sqrt3);\r\n\t this.pointNormals[2] = new Vector(-1, -sqrt3);\r\n\t }\r\n\t else {\r\n\t var rad = this._rotation * degToRad;\r\n\t this.sideNormals[0] = new Vector(1, -sqrt3).rotate(rad);\r\n\t this.sideNormals[1] = new Vector(1, sqrt3).rotate(rad);\r\n\t this.sideNormals[2] = new Vector(-1, 0).rotate(rad);\r\n\t this.pointNormals[0] = new Vector(1, 0).rotate(rad);\r\n\t this.pointNormals[1] = new Vector(-1, sqrt3).rotate(rad);\r\n\t this.pointNormals[2] = new Vector(-1, -sqrt3).rotate(rad);\r\n\t }\r\n\t };\r\n\t RegTriangle.prototype.calculatePoints = function () {\r\n\t if (this._rotation == 0) {\r\n\t this.points[0] = new Vector(0, -this.length * sqrt3 / 3);\r\n\t this.points[1] = new Vector(this.length / 2, this.length * sqrt3 / 6);\r\n\t this.points[2] = new Vector(-this.length / 2, this.length * sqrt3 / 6);\r\n\t }\r\n\t else {\r\n\t var rad = this._rotation * degToRad;\r\n\t this.points[0] = new Vector(0, -this.length * sqrt3 / 3).rotate(rad);\r\n\t this.points[1] = new Vector(this.length / 2, this.length * sqrt3 / 6).rotate(rad);\r\n\t this.points[2] = new Vector(-this.length / 2, this.length * sqrt3 / 6).rotate(rad);\r\n\t }\r\n\t };\r\n\t RegTriangle.prototype.calculateLines = function () {\r\n\t this.linesOri = [\r\n\t { a: -sqrt3, b: -this.length * sqrt3 / 3 },\r\n\t { a: sqrt3, b: -this.length * sqrt3 / 3 },\r\n\t { a: 0, b: this.length * sqrt3 / 6 },\r\n\t ];\r\n\t };\r\n\t RegTriangle.prototype.nearestCollideNormal = function (returnP) {\r\n\t var zero = this.linesOri[0].a * returnP.x + this.linesOri[0].b - returnP.y > 0;\r\n\t var one = this.linesOri[1].a * returnP.x + this.linesOri[1].b - returnP.y > 0;\r\n\t var two = this.linesOri[2].a * returnP.x + this.linesOri[2].b - returnP.y > 0;\r\n\t if (zero && !one && two) {\r\n\t return this.sideNormals[0];\r\n\t }\r\n\t else if (!zero && one && two) {\r\n\t return this.sideNormals[1];\r\n\t }\r\n\t else if (!zero && !one && !two) {\r\n\t return this.sideNormals[2];\r\n\t }\r\n\t else if (zero && one && two) {\r\n\t return this.pointNormals[0];\r\n\t }\r\n\t else if (!zero && one && !two) {\r\n\t return this.pointNormals[1];\r\n\t }\r\n\t else if (zero && !one && !two) {\r\n\t return this.pointNormals[2];\r\n\t }\r\n\t };\r\n\t return RegTriangle;\r\n\t}(RegPolygon));\r\n\t//# sourceMappingURL=RegTriangle.js.map\n\n\tvar createRegTriangle = (function (that, x, y, num) {\r\n\t var block = that.pool.takeOut(\"regTriangle\");\r\n\t var picType = Math.ceil(Math.random() * 2);\r\n\t var pic = new engine.Sprite(getTextureByName(\"tri\" + picType));\r\n\t pic.anchorX = pic.width / 2;\r\n\t pic.anchorY = pic.height / 2;\r\n\t var anchorx = 0;\r\n\t var anchory = 0;\r\n\t anchorx = pic.width / 2;\r\n\t anchory = pic.height / 2;\r\n\t if (!block) {\r\n\t var sprite = new engine.Sprite();\r\n\t sprite.mouseEnabled = sprite.mouseChildren = false;\r\n\t var length = pic.width;\r\n\t var height = pic.height;\r\n\t sprite[\"bg\"] = pic;\r\n\t sprite.addChild(pic);\r\n\t pic.x = -anchorx;\r\n\t pic.y = -anchory;\r\n\t var txt = new engine.TextField();\r\n\t txt.width = length;\r\n\t txt.height = height;\r\n\t txt.anchorX = length / 2;\r\n\t txt.anchorY = height / 2;\r\n\t txt.size = 26;\r\n\t txt.fillColor = 0xffffff;\r\n\t txt.textAlign = engine.TEXT_ALIGN.CENTER;\r\n\t txt.verticalAlign = engine.VERTICAL_ALIGN.MIDDLE;\r\n\t sprite[\"txt\"] = txt;\r\n\t sprite.addChild(txt);\r\n\t txt.x = -anchorx;\r\n\t txt.y = -anchory + (anchorx - anchory) * 2;\r\n\t block = new RegTriangle(length, sprite);\r\n\t }\r\n\t else {\r\n\t if (block.view[\"bg\"]) {\r\n\t block.view.removeChild(block.view[\"bg\"]);\r\n\t block.view[\"bg\"] = pic;\r\n\t block.view.addChild(pic);\r\n\t block.view.addChild(block.view['txt']);\r\n\t pic.x = -anchorx;\r\n\t pic.y = -anchory;\r\n\t block.view['txt'].x = -anchorx;\r\n\t block.view['txt'].y = -anchory + (anchorx - anchory) * 2;\r\n\t }\r\n\t }\r\n\t block.view[\"bg\"]['__resName__'] = \"tri\" + picType;\r\n\t that.addChild(block.view);\r\n\t block.x = x;\r\n\t block.y = y;\r\n\t block.rotation = Math.random() * 360;\r\n\t block.num = num;\r\n\t that.blocks.push(block);\r\n\t block.ladderNums = 1;\r\n\t});\r\n\t//# sourceMappingURL=createRegTriangle.js.map\n\n\tvar createSpecialRegTriangle = (function (that, x, y, length, rotation, key) {\r\n\t if (key === void 0) { key = 'specialRegTriangle'; }\r\n\t var block;\r\n\t var sprite = new engine.Sprite();\r\n\t sprite.visible = false;\r\n\t sprite.alpha = 0.7;\r\n\t sprite.mouseEnabled = sprite.mouseChildren = false;\r\n\t var shape = new engine.Shape();\r\n\t shape.beginFill(0xcccccc);\r\n\t shape.moveTo(0, -length * sqrt3 / 3);\r\n\t shape.lineTo(length / 2, length * sqrt3 / 6);\r\n\t shape.lineTo(-length / 2, length * sqrt3 / 6);\r\n\t shape.endFill();\r\n\t sprite[\"bg\"] = shape;\r\n\t sprite.addChild(shape);\r\n\t var txt = new engine.TextField();\r\n\t txt.width = length;\r\n\t txt.height = length;\r\n\t txt.anchorX = length / 2;\r\n\t txt.anchorY = length / 2;\r\n\t txt.size = 25;\r\n\t txt.fillColor = 0xffffff;\r\n\t txt.textAlign = engine.TEXT_ALIGN.CENTER;\r\n\t txt.verticalAlign = engine.VERTICAL_ALIGN.MIDDLE;\r\n\t sprite[\"txt\"] = txt;\r\n\t sprite.addChild(txt);\r\n\t console.log(\"特殊建筑三角形\", length);\r\n\t block = new RegTriangle(length, sprite);\r\n\t block.type = key;\r\n\t that.addChild(block.view);\r\n\t block.x = x;\r\n\t block.y = y;\r\n\t block.rotation = rotation;\r\n\t that.blocks.push(block);\r\n\t});\n\n\tvar createSpeialCircle = (function (that, x, y, num) {\r\n\t var block = that.pool.takeOut(\"specialCircle\");\r\n\t var radius = getTextureByName('+1').orig.width / 2;\r\n\t if (!block) {\r\n\t var sprite = new engine.Sprite();\r\n\t sprite.mouseEnabled = sprite.mouseChildren = false;\r\n\t var shape = new engine.Sprite(getTextureByName('+1'));\r\n\t shape.anchorX = shape.width / 2;\r\n\t shape.anchorY = shape.height / 2;\r\n\t sprite[\"bg\"] = shape;\r\n\t sprite.addChild(shape);\r\n\t shape.x = -shape.width / 2;\r\n\t shape.y = -shape.height / 2;\r\n\t block = new Circle(radius, sprite);\r\n\t block.type = 'specialCircle';\r\n\t }\r\n\t else {\r\n\t if (block.radius != radius) {\r\n\t block.view.bg.clear();\r\n\t block.view.bg.beginFill(0xcccccc);\r\n\t block.view.bg.drawCircle(0, 0, radius);\r\n\t block.view.bg.endFill();\r\n\t }\r\n\t }\r\n\t that.addChild(block.view);\r\n\t block.x = x;\r\n\t block.y = y;\r\n\t block.num = num;\r\n\t that.blocks.push(block);\r\n\t block.ladderNums = 1;\r\n\t});\r\n\t//# sourceMappingURL=createSpeialCircle.js.map\n\n\tvar Square = (function (_super) {\r\n\t tslib.__extends(Square, _super);\r\n\t function Square(length, view) {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.type = \"square\";\r\n\t _this._x = 0;\r\n\t _this._y = 0;\r\n\t _this._rotation = 0;\r\n\t _this.sideNormals = [\r\n\t new Vector(1, 0),\r\n\t new Vector(0, 1),\r\n\t new Vector(-1, 0),\r\n\t new Vector(0, -1)\r\n\t ];\r\n\t _this.pointNormals = [\r\n\t new Vector(1, -1),\r\n\t new Vector(1, 1),\r\n\t new Vector(-1, 1),\r\n\t new Vector(-1, -1)\r\n\t ];\r\n\t _this.length = length;\r\n\t _this.view = view;\r\n\t return _this;\r\n\t }\r\n\t Object.defineProperty(Square.prototype, \"rotation\", {\r\n\t get: function () {\r\n\t return this._rotation;\r\n\t },\r\n\t set: function (value) {\r\n\t if (this._rotation != value) {\r\n\t this._rotation = value;\r\n\t this.view.rotation = value;\r\n\t this.view.txt.rotation = -value;\r\n\t var rad = value * degToRad;\r\n\t this.sideNormals[0] = new Vector(1, 0).rotate(rad);\r\n\t this.sideNormals[1] = new Vector(0, 1).rotate(rad);\r\n\t this.sideNormals[2] = new Vector(-1, 0).rotate(rad);\r\n\t this.sideNormals[3] = new Vector(0, -1).rotate(rad);\r\n\t this.pointNormals[0] = new Vector(1, -1).rotate(rad);\r\n\t this.pointNormals[1] = new Vector(1, 1).rotate(rad);\r\n\t this.pointNormals[2] = new Vector(-1, 1).rotate(rad);\r\n\t this.pointNormals[3] = new Vector(-1, -1).rotate(rad);\r\n\t }\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t Object.defineProperty(Square.prototype, \"x\", {\r\n\t get: function () {\r\n\t return this._x;\r\n\t },\r\n\t set: function (value) {\r\n\t if (this._x != value) {\r\n\t this._x = value;\r\n\t this.view.x = value;\r\n\t }\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t Object.defineProperty(Square.prototype, \"y\", {\r\n\t get: function () {\r\n\t return this._y;\r\n\t },\r\n\t set: function (value) {\r\n\t if (this._y != value) {\r\n\t this._y = value;\r\n\t this.view.y = value;\r\n\t }\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t Object.defineProperty(Square.prototype, \"num\", {\r\n\t get: function () {\r\n\t return this._num;\r\n\t },\r\n\t set: function (value) {\r\n\t if (this._num != value) {\r\n\t this._num = value;\r\n\t this.view.txt.text = value || 4 + \"\";\r\n\t }\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t Object.defineProperty(Square.prototype, \"_viewx\", {\r\n\t get: function () {\r\n\t return this.view.x;\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t Object.defineProperty(Square.prototype, \"_viewy\", {\r\n\t get: function () {\r\n\t return this.view.y;\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t Square.prototype.collideBall = function (ball) {\r\n\t var returnP = translateToLocalCor({ x: ball._viewx, y: ball._viewy }, this.view);\r\n\t var ox = -this.length / 2;\r\n\t var oy = ox;\r\n\t var nearestX = Math.max(ox, Math.min(returnP.x, ox + this.length));\r\n\t var nearestY = Math.max(oy, Math.min(returnP.y, oy + this.length));\r\n\t var deltaX = returnP.x - nearestX;\r\n\t var deltaY = returnP.y - nearestY;\r\n\t if (deltaX * deltaX + deltaY * deltaY < ball.radius * ball.radius) {\r\n\t var velocity = ball.velocity.clone().rotate(-this._rotation * degToRad);\r\n\t var deta = Math.floor(velocity.length() / ball.radius) + 5;\r\n\t var speedX = velocity.x / (deta + 1);\r\n\t var speedY = velocity.y / (deta + 1);\r\n\t for (var i = 0; i <= deta; i++) {\r\n\t var normal = this.nearestCollideNormal({ x: returnP.x - speedX * (i + 1), y: returnP.y - speedY * (i + 1) }, ball, deta + 1, i + 1);\r\n\t if (normal) {\r\n\t return normal;\r\n\t }\r\n\t }\r\n\t }\r\n\t else {\r\n\t return false;\r\n\t }\r\n\t };\r\n\t Square.prototype.nearestCollideNormal = function (position, ball, deta, i) {\r\n\t var ox = -this.length / 2;\r\n\t var oy = ox;\r\n\t var nearestX = Math.max(ox, Math.min(position.x, ox + this.length));\r\n\t var nearestY = Math.max(oy, Math.min(position.y, oy + this.length));\r\n\t var deltaX = position.x - nearestX;\r\n\t var deltaY = position.y - nearestY;\r\n\t if (deltaX * deltaX + deltaY * deltaY < ball.radius * ball.radius) {\r\n\t return false;\r\n\t }\r\n\t else {\r\n\t ball.view.x -= ball.velocity.x / deta * i;\r\n\t ball.view.y -= ball.velocity.y / deta * i;\r\n\t if (nearestX == ox) {\r\n\t if (nearestY == oy) {\r\n\t return this.pointNormals[0];\r\n\t }\r\n\t else if (nearestY == oy + this.length) {\r\n\t return this.pointNormals[3];\r\n\t }\r\n\t else {\r\n\t return this.sideNormals[3];\r\n\t }\r\n\t }\r\n\t else if (nearestX == ox + this.length) {\r\n\t if (nearestY == oy) {\r\n\t return this.pointNormals[1];\r\n\t }\r\n\t else if (nearestY == oy + this.length) {\r\n\t return this.pointNormals[2];\r\n\t }\r\n\t else {\r\n\t return this.sideNormals[1];\r\n\t }\r\n\t }\r\n\t else {\r\n\t if (nearestY < 0) {\r\n\t return this.sideNormals[0];\r\n\t }\r\n\t else {\r\n\t return this.sideNormals[2];\r\n\t }\r\n\t }\r\n\t }\r\n\t };\r\n\t Square.prototype.shake = function () {\r\n\t console.log(\"square震动1---\", this.view.bg.x, this.view.bg.y);\r\n\t var startx = -this.view.bg.anchorX;\r\n\t var starty = -this.view.bg.anchorY;\r\n\t this.view.bg.x = startx;\r\n\t this.view.bg.y = starty;\r\n\t console.log(\"square震动2---\", this.view.bg.x, this.view.bg.y);\r\n\t Tween.to(this.view.bg, 1, {\r\n\t x: startx + 5,\r\n\t y: starty + 5,\r\n\t yoyo: 3,\r\n\t useFrame: true,\r\n\t onComplete: function () {\r\n\t console.log(\"square震动3---\", this.view.bg.x, this.view.bg.y);\r\n\t }\r\n\t });\r\n\t };\r\n\t return Square;\r\n\t}(Body));\r\n\t//# sourceMappingURL=Square.js.map\n\n\tvar createSquare = (function (that, x, y, num) {\r\n\t var picType = Math.ceil(Math.random() * 4);\r\n\t var pic = new engine.Sprite(getTextureByName(\"sq\" + picType));\r\n\t pic.anchorX = pic.width / 2;\r\n\t pic.anchorY = pic.height / 2;\r\n\t var block = that.pool.takeOut(\"square\");\r\n\t var anchorx = pic.width / 2;\r\n\t var anchory = pic.height / 2;\r\n\t if (!block) {\r\n\t var sprite = new engine.Sprite();\r\n\t sprite.mouseEnabled = sprite.mouseChildren = false;\r\n\t var length = pic.width;\r\n\t sprite[\"bg\"] = pic;\r\n\t sprite.addChild(pic);\r\n\t pic.x = -anchorx;\r\n\t pic.y = -anchory;\r\n\t var txt = new engine.TextField();\r\n\t txt.width = length;\r\n\t txt.height = pic.height;\r\n\t txt.anchorX = length / 2;\r\n\t txt.anchorY = pic.height / 2;\r\n\t txt.size = 30;\r\n\t txt.fillColor = 0xffffff;\r\n\t txt.textAlign = engine.TEXT_ALIGN.CENTER;\r\n\t txt.verticalAlign = engine.VERTICAL_ALIGN.MIDDLE;\r\n\t sprite[\"txt\"] = txt;\r\n\t sprite.addChild(txt);\r\n\t txt.x = -anchorx;\r\n\t txt.y = -anchory;\r\n\t block = new Square(length, sprite);\r\n\t }\r\n\t else {\r\n\t if (block.view[\"bg\"]) {\r\n\t block.view.removeChild(block.view[\"bg\"]);\r\n\t block.view[\"bg\"] = pic;\r\n\t block.view.addChild(pic);\r\n\t block.view.addChild(block.view['txt']);\r\n\t pic.x = -anchorx;\r\n\t pic.y = -anchory;\r\n\t block.view['txt'].x = -anchorx;\r\n\t block.view['txt'].y = -anchory;\r\n\t }\r\n\t }\r\n\t block.view[\"bg\"]['__resName__'] = \"sq\" + picType;\r\n\t that.addChild(block.view);\r\n\t block.x = x;\r\n\t block.y = y;\r\n\t block.num = num;\r\n\t block.rotation = Math.random() * 360;\r\n\t that.blocks.push(block);\r\n\t block.ladderNums = 1;\r\n\t});\r\n\t//# sourceMappingURL=createSquare.js.map\n\n\tvar Pool = (function () {\r\n\t function Pool() {\r\n\t this.pool = {};\r\n\t }\r\n\t Pool.prototype.takeOut = function (name) {\r\n\t if (this.pool[name] && this.pool[name].length) {\r\n\t return this.pool[name].shift();\r\n\t }\r\n\t return false;\r\n\t };\r\n\t Pool.prototype.recover = function (name, obj) {\r\n\t if (!this.pool[name]) {\r\n\t this.pool[name] = [];\r\n\t }\r\n\t this.pool[name].push(obj);\r\n\t };\r\n\t return Pool;\r\n\t}());\r\n\t//# sourceMappingURL=Pool.js.map\n\n\tvar Effect = (function () {\r\n\t function Effect(block, parent) {\r\n\t this.NUMS_MAX = 11;\r\n\t var resName = block.view['bg']['__resName__'];\r\n\t var _loop_1 = function (i) {\r\n\t var data = this_1.createItem(resName);\r\n\t parent.addChild(data.shape);\r\n\t data.shape.x = block.x;\r\n\t data.shape.y = block.y;\r\n\t engine.Tween.get(data.shape).to({ x: data.targetX + block.x, y: block.y + data.targetY, scaleY: 0, scaleX: 0 }, 360).call(function () {\r\n\t data.shape.parent && data.shape.parent.removeChild(data.shape);\r\n\t });\r\n\t };\r\n\t var this_1 = this;\r\n\t for (var i = 0; i < this.NUMS_MAX; i++) {\r\n\t _loop_1();\r\n\t }\r\n\t }\r\n\t Effect.prototype.createItem = function (resName) {\r\n\t var moveDisMax = 100;\r\n\t var squareSize = 100;\r\n\t var shape = new engine.Shape();\r\n\t var shapeType = this.getShapeType(resName);\r\n\t if (shapeType == 'circle') {\r\n\t shape.beginFill(this.getShapeColor(resName));\r\n\t shape.drawCircle(0, 0, squareSize / 2);\r\n\t shape.endFill();\r\n\t }\r\n\t else if (shapeType == 'tri') {\r\n\t shape.beginFill(this.getShapeColor(resName));\r\n\t shape.moveTo(0, -squareSize * sqrt3 / 3);\r\n\t shape.lineTo(squareSize / 2, squareSize * sqrt3 / 6);\r\n\t shape.lineTo(-squareSize / 2, squareSize * sqrt3 / 6);\r\n\t shape.endFill();\r\n\t }\r\n\t else if (shapeType == 'sq') {\r\n\t shape.beginFill(this.getShapeColor(resName));\r\n\t shape.drawRect(-squareSize / 2, -squareSize / 2, squareSize, squareSize);\r\n\t shape.endFill();\r\n\t }\r\n\t var scale = Math.random() * 0.7 + 0.3;\r\n\t var rotation = Math.random() * 360;\r\n\t var angle = Math.random() * Math.PI * 2;\r\n\t var dis = moveDisMax / 2 + moveDisMax / 2 * Math.random();\r\n\t var targetX = Math.sin(angle) * dis;\r\n\t var targetY = Math.cos(angle) * dis;\r\n\t shape.scaleX = shape.scaleY = scale;\r\n\t shape.rotation = rotation;\r\n\t return { shape: shape, targetX: targetX, targetY: targetY };\r\n\t };\r\n\t Effect.prototype.getShapeType = function (resName) {\r\n\t if (resName == 'circle1')\r\n\t return 'circle';\r\n\t if (resName.indexOf('tri') > -1)\r\n\t return 'tri';\r\n\t if (resName.indexOf('sq') > -1)\r\n\t return 'sq';\r\n\t return 'circle';\r\n\t };\r\n\t Effect.prototype.getShapeColor = function (resName) {\r\n\t if (resName == 'circle1')\r\n\t return 0xffca55;\r\n\t if (resName == 'sq1')\r\n\t return 0xfa7782;\r\n\t if (resName == 'sq2')\r\n\t return 0xf677ce;\r\n\t if (resName == 'sq3')\r\n\t return 0xffac84;\r\n\t if (resName == 'sq4')\r\n\t return 0xffca55;\r\n\t if (resName == 'tri1')\r\n\t return 0x2db0ee;\r\n\t if (resName == 'tri2')\r\n\t return 0x86e45f;\r\n\t return 0xffca55;\r\n\t };\r\n\t return Effect;\r\n\t}());\r\n\t//# sourceMappingURL=Effect.js.map\n\n\tvar PlayScene = (function (_super) {\r\n\t tslib.__extends(PlayScene, _super);\r\n\t function PlayScene() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.gravity = 1;\r\n\t _this.timeSpeed = 1;\r\n\t _this.INIT_BALL_NUMS = window['INIT_BALL_NUMS'];\r\n\t _this.balls = [];\r\n\t _this.pool = new Pool();\r\n\t _this.blocks = [];\r\n\t _this.velAmount = 25;\r\n\t _this.directionAngle = 0;\r\n\t _this.canShootTag = true;\r\n\t _this.data = {\r\n\t score: 0,\r\n\t currentBallNums: 5,\r\n\t };\r\n\t _this.reviveTag = 0;\r\n\t _this.INIT_BALL_NUMS = window['INIT_BALL_NUMS'] = 1;\r\n\t _this.initEvents();\r\n\t _this.once(engine.Event.ADDED_TO_STAGE, _this.initScene, _this);\r\n\t return _this;\r\n\t }\r\n\t PlayScene.prototype.initEvents = function () {\r\n\t this.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);\r\n\t this.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onTouchBegin, this);\r\n\t };\r\n\t PlayScene.prototype.removeEvents = function () {\r\n\t this.removeEventListener(engine.MouseEvent.MOUSE_DOWN, this.onTouchBegin, this);\r\n\t this.removeEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);\r\n\t };\r\n\t PlayScene.prototype.reset = function () {\r\n\t var blocks = this.blocks.filter(function (block) { return !isSpecialBody(block); });\r\n\t for (var _i = 0, blocks_1 = blocks; _i < blocks_1.length; _i++) {\r\n\t var block = blocks_1[_i];\r\n\t this.removeEle(block, this.blocks);\r\n\t block.view.parent && block.view.parent.removeChild(block.view);\r\n\t this.pool.recover(block.type, block);\r\n\t }\r\n\t };\r\n\t PlayScene.prototype.start = function () {\r\n\t this.gamescore = 0;\r\n\t this.currentBallNums = props.countDown;\r\n\t this.startGame();\r\n\t };\r\n\t PlayScene.prototype.pausegame = function () {\r\n\t this['pause'] = true;\r\n\t };\r\n\t PlayScene.prototype.resumegame = function () {\r\n\t this['pause'] = false;\r\n\t };\r\n\t Object.defineProperty(PlayScene.prototype, \"currentBallNums\", {\r\n\t get: function () {\r\n\t return this.data.currentBallNums;\r\n\t },\r\n\t set: function (num) {\r\n\t this.data.currentBallNums = num;\r\n\t this.ballNums.text = num;\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t Object.defineProperty(PlayScene.prototype, \"gamescore\", {\r\n\t get: function () {\r\n\t return this.data.score;\r\n\t },\r\n\t set: function (num) {\r\n\t this.data.score = num;\r\n\t this.score.text = num;\r\n\t engine.globalEvent.dispatchEvent('game-score-update', {\r\n\t score: num,\r\n\t });\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t PlayScene.prototype.initScene = function () {\r\n\t this.initUI();\r\n\t this.startGame();\r\n\t engine.Tween.get(this['ele1'], { loop: true }).set({ rotation: 0 }).to({ rotation: -360 }, 3000);\r\n\t engine.Tween.get(this['ele2'], { loop: true }).set({ rotation: 0 }).to({ rotation: 360 }, 3000);\r\n\t createSpecialRegTriangle(this, 60, 250, 200, 55, 'specialRegTriangleTop');\r\n\t createSpecialRegTriangle(this, 750 - 60, 250, 200, -55, 'specialRegTriangleTop');\r\n\t createSpecialRegTriangle(this, 150, 90, 500, 4, 'specialRegTriangleTop');\r\n\t createSpecialRegTriangle(this, 750 - 150, 90, 500, -4, 'specialRegTriangleTop');\r\n\t createSpecialRegTriangle(this, 230, 250, 40, 0, 'specialRegTriangleTop');\r\n\t createSpecialRegTriangle(this, 750 - 230 + 5, 250, 40, 0, 'specialRegTriangleTop');\r\n\t createSpecialRegTriangle(this, 170, 1271, 400, 52);\r\n\t createSpecialRegTriangle(this, 750 - 170, 1271, 400, -52);\r\n\t createSpecialRegTriangle(this, 232, 1351 - 3 - 5 - 3, 400, 30);\r\n\t createSpecialRegTriangle(this, 750 - 232, 1351 - 3 - 5 - 3, 400, -30);\r\n\t };\r\n\t PlayScene.prototype.initUI = function () {\r\n\t this.score = new engine.Label();\r\n\t this.score.x = 118;\r\n\t this.score.y = 13;\r\n\t this.score.size = 24;\r\n\t this.score.fillColor = 0xffffff;\r\n\t this.addChild(this.score);\r\n\t this.ground = this.createSprite(\"\", 0, 1130);\r\n\t this.ground.visible = true;\r\n\t this.addChild(this.ground);\r\n\t this.door = this.createSprite(\"door\", 0, 68);\r\n\t this.addChild(this.door);\r\n\t this.ele1 = this.createSprite(\"风扇\", 56, 1130, 20, 21);\r\n\t this.addChild(this.ele1);\r\n\t this.ele2 = this.createSprite(\"风扇\", 698, 1130, 20, 21);\r\n\t this.addChild(this.ele2);\r\n\t var ele1_t = this.createSprite(\"风扇1\", 54, 1078);\r\n\t this.addChild(ele1_t);\r\n\t var ele2_t = this.createSprite(\"风扇1\", 693, 1078);\r\n\t this.addChild(ele2_t);\r\n\t this.shooter = this.createSprite(\"\", 375, 222, 40, 40);\r\n\t this.addChild(this.shooter);\r\n\t this.ballNums = new engine.Label();\r\n\t this.ballNums.x = 333;\r\n\t this.ballNums.y = 203;\r\n\t this.ballNums.width = 85;\r\n\t this.ballNums.height = 43;\r\n\t this.ballNums.textAlign = engine.TEXT_ALIGN.CENTER;\r\n\t this.ballNums.verticalAlign = engine.VERTICAL_ALIGN.MIDDLE;\r\n\t this.ballNums.size = 38;\r\n\t this.ballNums.fillColor = 0x00ff00;\r\n\t this.addChild(this.ballNums);\r\n\t this.line = this.createSprite(\"shootline\", 375, 222, 5, -74);\r\n\t this.addChild(this.line);\r\n\t };\r\n\t PlayScene.prototype.createSprite = function (tname, x, y, anchorx, anchory) {\r\n\t if (anchorx === void 0) { anchorx = 0; }\r\n\t if (anchory === void 0) { anchory = 0; }\r\n\t var sp = new engine.Image(getTextureByName(tname));\r\n\t sp.x = x - anchorx;\r\n\t sp.y = y - anchory;\r\n\t sp.anchorX = anchorx;\r\n\t sp.anchorY = anchory;\r\n\t return sp;\r\n\t };\r\n\t PlayScene.prototype.setWindowData = function () {\r\n\t window['numsP'] = 0.5;\r\n\t window['INIT_BALL_NUMS'] = 1;\r\n\t };\r\n\t PlayScene.prototype.startGame = function () {\r\n\t this.setWindowData();\r\n\t this['pause'] = false;\r\n\t this.reviveTag = 0;\r\n\t resetCounter();\r\n\t this.gamescore = 0;\r\n\t this.ballCountAll = this.INIT_BALL_NUMS;\r\n\t this.currentBallNums = this.ballCountAll;\r\n\t this.balls.forEach(function (ball) { return ball.view.parent && ball.view.parent.removeChild(ball); });\r\n\t this.balls = new Array();\r\n\t for (var i = 0; i < this.INIT_BALL_NUMS; i++) {\r\n\t var ball = createBallItem();\r\n\t this.addChild(ball.view);\r\n\t ball.view.y = this.shooter.y + 90 + this.shooter.anchorY - ball.view.anchorY;\r\n\t ball.view.x = this.shooter.x + this.shooter.anchorX - ball.view.anchorX;\r\n\t ball.view.visible = false;\r\n\t this.balls.push(ball);\r\n\t }\r\n\t this.onShootEnd();\r\n\t };\r\n\t PlayScene.prototype.onGuildeTap = function () {\r\n\t this['guide'].visible = false;\r\n\t localStorage.setItem('guide', '1');\r\n\t };\r\n\t PlayScene.prototype.genBlocks = function () {\r\n\t var _a = getBlocks(this.ballCountAll), blocksInfo = _a.blocksInfo, specialBallPosition = _a.specialBallPosition;\r\n\t if (specialBallPosition > -1) {\r\n\t createSpeialCircle(this, getLadderHPosition(specialBallPosition), getLadderPosition(LADDER_NUMS - 1), 0);\r\n\t }\r\n\t console.log(\"创建障碍物\", blocksInfo, specialBallPosition);\r\n\t for (var _i = 0, blocksInfo_1 = blocksInfo; _i < blocksInfo_1.length; _i++) {\r\n\t var block = blocksInfo_1[_i];\r\n\t var position = block.position, type = block.type, nums = block.nums;\r\n\t if (type == 1) {\r\n\t createSquare(this, getLadderHPosition(position), getLadderPosition(LADDER_NUMS - 1), nums);\r\n\t }\r\n\t else if (type == 2) {\r\n\t createRegTriangle(this, getLadderHPosition(position), getLadderPosition(LADDER_NUMS - 1), nums);\r\n\t }\r\n\t else {\r\n\t createCircle(this, getLadderHPosition(position), getLadderPosition(LADDER_NUMS - 1), nums);\r\n\t }\r\n\t }\r\n\t };\r\n\t PlayScene.prototype.onTouchMove = function (e) {\r\n\t var detaX = e.localX - 375;\r\n\t var detaY = e.localY - 0;\r\n\t if (detaY != 0) {\r\n\t var angle = Math.atan(detaX / detaY);\r\n\t if (angle > Math.PI / 180 * 75)\r\n\t angle = Math.PI / 180 * 75;\r\n\t if (angle < -Math.PI / 180 * 75)\r\n\t angle = -Math.PI / 180 * 75;\r\n\t this.line.rotation = this.shooter.rotation = -angle * radToDeg;\r\n\t this.directionAngle = angle;\r\n\t this.updateLine();\r\n\t }\r\n\t };\r\n\t PlayScene.prototype.updateLine = function () {\r\n\t this.line.scaleY = (1 - Math.abs(this.line.rotation) / 90 * 0.5);\r\n\t };\r\n\t PlayScene.prototype.onTouchEnd = function (e) {\r\n\t if (this['pause'])\r\n\t return;\r\n\t this.removeEventListener(engine.MouseEvent.MOUSE_MOVE, this.onTouchMove, this);\r\n\t this.canShootTag = false;\r\n\t this.ballCount = 0;\r\n\t this.ballShoot();\r\n\t };\r\n\t PlayScene.prototype.onTouchBegin = function (e) {\r\n\t if (this['pause'])\r\n\t return;\r\n\t if (!this.canShootTag)\r\n\t return;\r\n\t this.line.visible = true;\r\n\t this.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onTouchMove, this);\r\n\t this.once(engine.MouseEvent.MOUSE_UP, this.onTouchEnd, this);\r\n\t var detaX = e.localX - 375;\r\n\t var detaY = e.localY - 0;\r\n\t if (detaY != 0) {\r\n\t var angle = Math.atan(detaX / detaY);\r\n\t if (angle > Math.PI / 180 * 75)\r\n\t angle = Math.PI / 180 * 75;\r\n\t if (angle < -Math.PI / 180 * 75)\r\n\t angle = -Math.PI / 180 * 75;\r\n\t this.line.rotation = this.shooter.rotation = -angle * radToDeg;\r\n\t this.directionAngle = angle;\r\n\t this.updateLine();\r\n\t }\r\n\t };\r\n\t PlayScene.prototype.onEnterFrame = function () {\r\n\t Tween.flush();\r\n\t for (var _i = 0, _a = this.balls; _i < _a.length; _i++) {\r\n\t var ball = _a[_i];\r\n\t if (ball.collideStatus == 3) ;\r\n\t else {\r\n\t for (var s = 0; s < this.timeSpeed; s++) {\r\n\t if (ball.collideStatus == 2) {\r\n\t ball.velocity.y += this.gravity;\r\n\t }\r\n\t ball.view.x += ball.velocity.x;\r\n\t ball.view.y += ball.velocity.y;\r\n\t if (ball.view.x < LEFT_GROUND) {\r\n\t ball.velocity.x *= -1 * getBounce();\r\n\t ball.view.x = LEFT_GROUND;\r\n\t ball.collideStatus = 2;\r\n\t }\r\n\t else if (ball.view.x + ball.view.width > RIGHT_GROUND) {\r\n\t ball.velocity.x *= -1 * getBounce();\r\n\t ball.view.x = RIGHT_GROUND - ball.view.width;\r\n\t ball.collideStatus = 2;\r\n\t }\r\n\t if (ball.view.y > 1200) {\r\n\t ball.velocity.x = 0;\r\n\t ball.velocity.y = this.velAmount;\r\n\t if (Math.random() > 0.5) {\r\n\t ball.view.y = 300;\r\n\t ball.view.x = 230 - BALL_D / 2;\r\n\t }\r\n\t else {\r\n\t ball.view.y = 300;\r\n\t ball.view.x = 750 - 230 + 5 - BALL_D / 2;\r\n\t }\r\n\t }\r\n\t for (var j = this.blocks.length - 1; j >= 0; j--) {\r\n\t var block = this.blocks[j];\r\n\t var normal = block.collideBall(ball);\r\n\t if (normal) {\r\n\t if (block instanceof Circle) {\r\n\t ball.velocity.symmetricFromNormalVector(normal);\r\n\t ball.velocity.x *= getBounce();\r\n\t ball.velocity.y *= getBounce();\r\n\t ball.collideStatus = 2;\r\n\t if (block.type == 'specialCircle')\r\n\t console.log('special circle');\r\n\t else\r\n\t console.log('normal Circle');\r\n\t }\r\n\t else if (block instanceof RegTriangle) {\r\n\t if (block.type == 'specialRegTriangle') {\r\n\t ball.collideStatus = 3;\r\n\t this.recoverPath(ball);\r\n\t }\r\n\t else {\r\n\t ball.velocity.symmetricFromNormalVector(normal);\r\n\t ball.velocity.x *= getBounce();\r\n\t ball.velocity.y *= getBounce();\r\n\t ball.collideStatus = 2;\r\n\t }\r\n\t }\r\n\t else {\r\n\t ball.velocity.symmetricFromNormalVector(normal);\r\n\t ball.velocity.x *= getBounce();\r\n\t ball.velocity.y *= getBounce();\r\n\t ball.collideStatus = 2;\r\n\t }\r\n\t if (isSpecialBody(block)) {\r\n\t if (isSpecialCircle(block)) {\r\n\t this.ballCountAll++;\r\n\t playSound(SoundType.good);\r\n\t var newball = createBallItem();\r\n\t this.addChild(newball.view);\r\n\t newball.view.y = ball.view.y = block.y;\r\n\t newball.view.x = ball.view.x = block.x;\r\n\t newball.collideStatus = 2;\r\n\t this.balls.push(newball);\r\n\t ball.velocity.x = 5;\r\n\t newball.velocity.x = -5;\r\n\t ball.velocity.y = newball.velocity.y = -20;\r\n\t this.removeEle(block, this.blocks);\r\n\t this.removeChild(block.view);\r\n\t this.pool.recover(block.type, block);\r\n\t }\r\n\t }\r\n\t else {\r\n\t this.shake(block);\r\n\t this.gamescore++;\r\n\t block.num = block.num - 1;\r\n\t playSound(SoundType.bounce);\r\n\t if (block.num <= 0) {\r\n\t new Effect(block, this);\r\n\t engine.Tween.removeTweens(block.view);\r\n\t block.view.alpha = 1;\r\n\t this.removeEle(block, this.blocks);\r\n\t this.removeChild(block.view);\r\n\t this.pool.recover(block.type, block);\r\n\t }\r\n\t }\r\n\t }\r\n\t }\r\n\t }\r\n\t }\r\n\t }\r\n\t };\r\n\t PlayScene.prototype.removeEle = function (e, arr) {\r\n\t var index = arr.indexOf(e);\r\n\t if (index >= 0) {\r\n\t arr.splice(index, 1);\r\n\t }\r\n\t };\r\n\t PlayScene.prototype.shake = function (block) {\r\n\t var startx = -block.view.bg.anchorX;\r\n\t var starty = -block.view.bg.anchorY;\r\n\t block.view.bg.x = startx - 2;\r\n\t block.view.bg.y = starty - 2;\r\n\t Tween.to(block.view.bg, 1, {\r\n\t x: startx + 2,\r\n\t y: starty + 2,\r\n\t yoyo: 3,\r\n\t useFrame: true,\r\n\t onComplete: function () {\r\n\t block.view.bg.x = startx;\r\n\t block.view.bg.y = starty;\r\n\t }\r\n\t });\r\n\t };\r\n\t PlayScene.prototype.recoverPath = function (ball) {\r\n\t var _this = this;\r\n\t var time, targX;\r\n\t if (ball.view.x > 375) {\r\n\t var detaX = (RIGHT_GROUND - ball.view.x) / 20;\r\n\t time = detaX < 1 ? 1 : detaX;\r\n\t targX = RIGHT_GROUND;\r\n\t }\r\n\t else {\r\n\t var detaX = (ball.view.x - LEFT_GROUND) / 20;\r\n\t time = detaX < 1 ? 1 : detaX;\r\n\t targX = LEFT_GROUND - BALL_D;\r\n\t }\r\n\t ball.view.alpha = 0.80;\r\n\t Tween.to(ball.view, time, {\r\n\t x: targX,\r\n\t y: 1155,\r\n\t useFrame: true,\r\n\t onComplete: function () {\r\n\t ball.view.x = targX;\r\n\t playSound(SoundType.recover);\r\n\t Tween.to(ball.view, 20, {\r\n\t y: 313.4 - 100,\r\n\t useFrame: true,\r\n\t onComplete: function () {\r\n\t var middlex = 375;\r\n\t var p0 = { x: ball.view.x, y: ball.view.y };\r\n\t var p1 = { x: (ball.view.x + middlex) / 2, y: ball.view.y - 500 };\r\n\t var p2 = { x: middlex, y: ball.view.y };\r\n\t Tween.to(ball.view, 20, {\r\n\t useFrame: true,\r\n\t __xx__: 100,\r\n\t onUpdate: function (value) {\r\n\t ball.view.x = (1 - value) * (1 - value) * p0.x + 2 * value * (1 - value) * p1.x + value * value * p2.x;\r\n\t ball.view.y = (1 - value) * (1 - value) * p0.y + 2 * value * (1 - value) * p1.y + value * value * p2.y;\r\n\t },\r\n\t onComplete: function () {\r\n\t _this.currentBallNums++;\r\n\t _this.ballCount++;\r\n\t ball.view.visible = false;\r\n\t ball.view.alpha = 1;\r\n\t if (_this.ballCount == _this.ballCountAll) {\r\n\t _this.canShootTag = true;\r\n\t _this.onShootEnd();\r\n\t }\r\n\t }\r\n\t });\r\n\t }\r\n\t });\r\n\t }\r\n\t });\r\n\t };\r\n\t PlayScene.prototype.ballShoot = function () {\r\n\t var _this = this;\r\n\t this.onShootBegin();\r\n\t var speedX = this.velAmount * Math.sin(this.directionAngle);\r\n\t var speedY = this.velAmount * Math.cos(this.directionAngle);\r\n\t var count = 0;\r\n\t var timer = setInterval(function () {\r\n\t count++;\r\n\t playSound(SoundType.shoot);\r\n\t _this.currentBallNums--;\r\n\t if (_this.data.currentBallNums < 0)\r\n\t _this.currentBallNums = 0;\r\n\t if (count == _this.ballCountAll) {\r\n\t clearInterval(timer);\r\n\t _this['aceleTimer'] = setTimeout(function () {\r\n\t _this.timeSpeed = 3;\r\n\t _this['aceleTimer'] = 0;\r\n\t }, ACELE_DELAY);\r\n\t }\r\n\t _this.balls[count - 1].collideStatus = 1;\r\n\t _this.balls[count - 1].velocity.x = speedX;\r\n\t _this.balls[count - 1].velocity.y = speedY;\r\n\t var r = 90;\r\n\t var rad = (_this.shooter.rotation * degToRad);\r\n\t _this.balls[count - 1].view.x = _this.shooter.x - Math.sin(rad) * r + _this.shooter.anchorX - _this.balls[count - 1].view.anchorX;\r\n\t _this.balls[count - 1].view.y = _this.shooter.y + Math.cos(rad) * r + _this.shooter.anchorY - _this.balls[count - 1].view.anchorY;\r\n\t _this.balls[count - 1].view.visible = true;\r\n\t }, 100);\r\n\t };\r\n\t PlayScene.prototype.onShootBegin = function () {\r\n\t this.line.visible = false;\r\n\t };\r\n\t PlayScene.prototype.onShootEnd = function () {\r\n\t if (this['aceleTimer'])\r\n\t clearTimeout(this['aceleTimer']);\r\n\t this.timeSpeed = 1;\r\n\t this.line.visible = false;\r\n\t this.currentBallNums = this.ballCountAll;\r\n\t var blocks = this.blocks.filter(function (block) { return isSpecialCircle(block) || !isSpecialBody(block); });\r\n\t var failed = false;\r\n\t blocks.forEach(function (block) {\r\n\t if (block.ladderNums >= 9) {\r\n\t failed = true;\r\n\t }\r\n\t });\r\n\t if (failed) {\r\n\t this.checkGameOver();\r\n\t }\r\n\t else {\r\n\t blocks.forEach(function (block) {\r\n\t block.y -= getLadderGap();\r\n\t block.ladderNums++;\r\n\t if (block.ladderNums >= 9) {\r\n\t engine.Tween.get(block.view, { loop: true })\r\n\t .to({ alpha: 0 }, 1000 / 6)\r\n\t .to({ alpha: 1 }, 1000 / 6);\r\n\t }\r\n\t });\r\n\t this.genBlocks();\r\n\t }\r\n\t };\r\n\t PlayScene.prototype.checkGameOver = function () {\r\n\t this['pause'] = true;\r\n\t this.gameOver();\r\n\t };\r\n\t PlayScene.prototype.relive = function () {\r\n\t this['pause'] = false;\r\n\t var blocks = this.blocks.filter(function (block) { return (isSpecialCircle(block) || !isSpecialBody(block)) && block.ladderNums >= 5; });\r\n\t for (var _i = 0, blocks_2 = blocks; _i < blocks_2.length; _i++) {\r\n\t var block = blocks_2[_i];\r\n\t this.gamescore += block.num;\r\n\t this.removeEle(block, this.blocks);\r\n\t block.view.parent && this.removeChild(block.view);\r\n\t engine.Tween.removeTweens(block.view);\r\n\t block.view.alpha = 1;\r\n\t this.pool.recover(block.type, block);\r\n\t }\r\n\t };\r\n\t PlayScene.prototype.gameOver = function () {\r\n\t console.log(\"游戏结束\");\r\n\t engine.globalEvent.dispatchEvent('game-over', {});\r\n\t };\r\n\t Object.defineProperty(PlayScene.prototype, \"skinKey\", {\r\n\t get: function () { return 'Play'; },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t PlayScene.prototype.destroy = function () {\r\n\t _super.prototype.destroy.call(this);\r\n\t };\r\n\t return PlayScene;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=PlayScene.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-reset\", _this.reset, _this);\r\n\t engine.globalEvent.addEventListener(\"game-start\", _this.start, _this);\r\n\t engine.globalEvent.addEventListener(\"game-pause\", _this.pause, _this);\r\n\t engine.globalEvent.addEventListener(\"game-resume\", _this.resume, _this);\r\n\t _this.addEventListener(engine.MouseEvent.CLICK, _this.onTap, _this);\r\n\t var gameView = _this._gameView = new PlayScene();\r\n\t _this.addChild(gameView);\r\n\t return _this;\r\n\t }\r\n\t gameWrapper.prototype.reset = function (event) {\r\n\t injectProps(event.data);\r\n\t this._gameView.visible = true;\r\n\t this._gameView.reset();\r\n\t };\r\n\t gameWrapper.prototype.start = function (event) {\r\n\t injectProps(event.data);\r\n\t this._status = 1;\r\n\t this._gameView.start();\r\n\t };\r\n\t gameWrapper.prototype.pause = function () {\r\n\t this._gameView.pausegame();\r\n\t };\r\n\t gameWrapper.prototype.resume = function () {\r\n\t this._gameView.resumegame();\r\n\t };\r\n\t gameWrapper.prototype.clear = function () {\r\n\t this._gameView.visible = false;\r\n\t };\r\n\t gameWrapper.prototype.onTap = function (event) {\r\n\t };\r\n\t return gameWrapper;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=gameWrapper.js.map\n\n\tfunction index (props) {\r\n\t prepareProps();\r\n\t injectProps(props);\r\n\t var instance = new gameWrapper();\r\n\t return instance;\r\n\t}\r\n\t//# sourceMappingURL=index.js.map\n\n\treturn index;\n\n})));\n"
}
......@@ -12,6 +12,7 @@
function injectProps(p) {
engine.injectProp(props, p);
}
//# sourceMappingURL=props.js.map
function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
......@@ -24,6 +25,7 @@
inst.source = 'asset://' + engine.getAssetByName(name).uuid;
return inst;
}
//# sourceMappingURL=utils.js.map
var Goods = (function (_super) {
tslib.__extends(Goods, _super);
......@@ -92,6 +94,7 @@
});
return Goods;
}(engine.Container));
//# sourceMappingURL=Goods.js.map
var ObjectPool = engine.ObjectPool;
var PoolName = 'goods';
......@@ -100,6 +103,7 @@
}, function (item, data) {
item.reset();
});
//# sourceMappingURL=object-pool-init.js.map
var ObjectPool$1 = engine.ObjectPool;
var GameView = (function (_super) {
......@@ -299,6 +303,7 @@
};
return GameView;
}(engine.Container));
//# sourceMappingURL=GameView.js.map
var GameWrapper = (function (_super) {
tslib.__extends(GameWrapper, _super);
......@@ -341,6 +346,7 @@
};
return GameWrapper;
}(engine.Container));
//# sourceMappingURL=GameWrapper.js.map
function index (props) {
prepareProps();
......@@ -348,6 +354,7 @@
var instance = new GameWrapper();
return instance;
}
//# sourceMappingURL=index.js.map
return index;
......
{"version":3,"file":"index.js","sources":["src/custom/food-fell/src/props.ts","src/custom/food-fell/src/game/utils.ts","src/custom/food-fell/src/game/Goods.ts","src/custom/food-fell/src/game/object-pool-init.ts","src/custom/food-fell/src/game/GameView.ts","src/custom/food-fell/src/game/GameWrapper.ts","src/custom/food-fell/src/index.ts"],"sourcesContent":["/**\n * Created by rockyl on 2020-01-21.\n */\n\nexport let props: any = {};\n\nexport function prepareProps() {\n\tlet metaProps = getProps();\n\n\tengine.injectProp(props, metaProps);\n}\n\nexport function injectProps(p) {\n\tengine.injectProp(props, p);\n}\n","/**\n * Created by rockyl on 2020-01-21.\n */\n\nexport function getTexture(uuid) {\n\treturn engine.Texture.from(getAssetByUUID(uuid).uuid);\n}\n\nexport function getTextureByName(name) {\n\treturn getTexture(engine.getAssetByName(name).uuid);\n}\n\nexport function playSound(name) {\n\tengine.playSound(engine.getAssetByName(name).uuid, {keep: true});\n}\nexport function createSvga(name, anchorName?) {\n\tlet inst = new svga.Svga();\n\tinst.source = 'asset://' + engine.getAssetByName(name).uuid;\n\treturn inst;\n}","/**\n * Created by rockyl on 2020-02-02.\n *\n * 掉落物品\n */\nimport {getTextureByName} from \"./utils\";\nimport {props} from \"../props\";\n\nexport class Goods extends engine.Container {\n\tprivate _body:engine.Rect\n\tprivate _toY;\n\n\tconstructor() {\n\t\tsuper();\n\n\t\tlet body\n\t\tbody = this._body =new engine.Rect()\n\t\t\n\t\t\n\t\tlet rain = new engine.Sprite(getTextureByName('雨滴'));\n\t\train[\"npcType\"]=\"rain\"\n\t\tlet stone = new engine.Sprite(getTextureByName('石块'));\n\t\tstone[\"npcType\"]=\"stone\"\n\t\tlet boom = new engine.Sprite(getTextureByName('炸弹'));\n\t\tboom[\"npcType\"]=\"boom\"\n\n\t\train.visible=false;\n\t\tstone.visible=false;\n\t\tboom.visible=false;\n\t\tbody.addChild(rain)\n\t\tbody.addChild(stone)\n\t\tbody.addChild(boom)\n\t\t\n\t\tthis.addChild(body);\n\t\tbody.width=.0001;\n\t\tbody.height=.0001;\n\t\tbody.mouseEnabled=false;\n\t}\n\n\n\tgetRandomNumberByRange(start, end) {\n\t\treturn Math.floor(Math.random() * (end - start) + start)\n\t}\n\n\treset() {\n\t\tthis.visible = true;\n\t\tthis.rotation = 0;\n\t\tthis.anchorOffsetY = 0;\n\t\tthis.y = 0;\n\t\tthis.x = (750-120)*Math.random()+30;\n\t\tthis.rotation = 0;\n\t\tlet random=Math.random()\n\n\t\tif(random<props.goodsProbability[0]){\n\t\t\tthis.showNpc(\"rain\")\n\t\t}else if(random>=props.goodsProbability[0]&&random<=(props.goodsProbability[0]+props.goodsProbability[1])){\n\t\t\tthis.showNpc(\"stone\")\n\t\t}else if(random>(props.goodsProbability[0]+props.goodsProbability[1])){\n\t\t\tthis.showNpc(\"boom\")\n\t\t}\n\t}\n\n\n\tshowNpc(type){\n\t\tfor(let i=0;i<this._body.children.length;i++){\n\t\t\tthis._body.children[i].visible=false;\n\t\t\tthis._body.children[i].mouseEnabled=false;\n\t\t}\n\n\t\tfor(let i=0;i<this._body.children.length;i++){\n\t\t\tif(this._body.children[i][\"npcType\"]==type){\n\t\t\t\tthis[\"npcType\"]=type\n\t\t\t\tthis._body.children[i].visible=true;\n\t\t\t\tthis._body.children[i].mouseEnabled=false;\n\t\t\t}\n\t\t}\n\t\t\n\t}\n\n\tset anchorOffsetY(v) {\n\t\tthis._body.y = v;\n\t}\n}\n","/**\n * Created by rockyl on 2020-02-03.\n */\n\nimport {Goods} from \"./Goods\";\nimport ObjectPool = engine.ObjectPool;\n\nexport const PoolName: string = 'goods';\n\nObjectPool.registerPool(PoolName, function () {\n\treturn new Goods();\n}, function (item: Goods, data) {\n\titem.reset();\n});\n","/**\n * Created by rockyl on 2018/8/16.\n */\n\nimport { props } from \"../props\";\nimport { playSound, createSvga } from \"./utils\";\nimport ObjectPool = engine.ObjectPool;\nimport { getTextureByName } from \"./utils\";\nimport { Goods } from \"./Goods\";\nimport { PoolName } from \"./object-pool-init\";\n\n\n\nexport default class GameView extends engine.Container {\n\n\tprivate _hasSetup;\n\n\t//玩家\n\tprivate player: engine.Container;\n\t//触摸层\n\tprivate rectBg: engine.Rect;\n\t//npc层\n\tprivate NpcBg: engine.Container;\n\n\t//当前分数\n\tprivate score\n\n\t//游戏状态\n\tprivate gameIng;\n\n\t//npc出身计时器\n\tprivate timer\n\t//倒计时计时器\n\tprivate countdownTimer: any\n\t//倒计时\n\tprivate countdown: number\n\n\t//当前速度\n\tprivate speed: number\n\n\t// 当前场景上面的物品\n\tprivate goodsItems = []\n\n\n\tprivate _goods: Goods;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.once(engine.Event.ADDED_TO_STAGE, this.setup, this);\n\t}\n\n\tprivate waterSvga\n\tprivate boomSvga\n\tprivate playerSvga\n\n\tsetup() {\n\t\tif (this._hasSetup) {\n\t\t\treturn;\n\t\t}\n\t\tthis._hasSetup = true;\n\t\tthis.NpcBg = new engine.Container();\n\t\tthis.NpcBg.alpha = 1;\n\t\tthis.NpcBg.width = 0;\n\t\tthis.NpcBg.height = 0;\n\t\tthis.addChild(this.NpcBg)\n\n\t\n\n\t\tthis.player = new engine.Container();\n\t\tthis.player.mouseEnabled = false;\n\t//\tthis.player.fillColor=\"rgba(0, 0, 0,1)\"\n\t\t//console.log(this.player.fillColor)\n\t\n\t\tthis.addChild(this.player);\n\n\t\tthis.waterSvga=createSvga(\"水花\")\n\t\tthis.playerSvga=createSvga(\"玩家\")\n\t\tthis.boomSvga=createSvga(\"炸弹svga\")\n\t\tthis.player.addChild(this.playerSvga);\n\t\tthis.player.addChild(this.waterSvga);\n\t\tthis.player.addChild(this.boomSvga);\n\t\tthis.playerSvga.gotoAndPlay(1);\n\n\t\tthis.visible=false;\n\t\tsetTimeout(()=>{\n\t\t\tthis.visible=true;\n\t\t\t// this.player.width=this.playerSvga.width;\n\t\t\t// this.player.height=this.playerSvga.height;\n\t\t\tthis.player.anchorY = this.player.height / 2;\n\t\t\tthis.player.anchorX = this.player.width / 2;\n\t\t\tconsole.log(this.player.width)\n\t\t\tconsole.log(this.playerSvga.width)\n\t\t\tthis.player.x = 375 - this.player.width / 2;\n\t\t\tthis.player.y = props.playerPositionY;\n\t\t},300)\n\n\t\t\n\t\tthis.rectBg = new engine.Rect();\n\t\tthis.rectBg.alpha = 0;\n\t\tthis.rectBg.width = 750;\n\t\tthis.rectBg.height = 1624;\n\t\tthis.addChild(this.rectBg)\n\n\t\tthis.rectBg.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDownStage, this);\n\t\tthis.rectBg.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMoveStage, this);\n\t\tthis.rectBg.addEventListener(engine.MouseEvent.MOUSE_OUT, this.onOutStage, this);\n\n\t\n\t}\n\n\n\t/**\n\t * 重置场景\n\t */\n\treset() {\n\t\tthis.recycleGoods()\n\t}\n\n\t/**\n\t * 开始\n\t */\n\tstart() {\n\t\tthis.score = 0;\n\t\tthis.speed = 1\n\t\tthis.gameIng = true;\n\t\tthis.creatNpc()\n\t\tthis.beginNpc()\n\t\tthis.countdown = props.countDown;\n\t\t\n\t\tthis.countdownTimer = setInterval(() => {\n\t\t\tif (this.gameIng) {\n\t\t\t\tif (this.countdown > 0) {\n\t\t\t\t\tengine.globalEvent.dispatchEvent('food-fell-time-update', {\n\t\t\t\t\t\ttime: this.countdown,\n\t\t\t\t\t});\n\t\t\t\t\tthis.countdown -= 1\n\t\t\t\t} else {\n\t\t\t\t\tengine.globalEvent.dispatchEvent('food-fell-game-over', {\n\t\t\t\t\t\tscore: this.score,\n\t\t\t\t\t\treason: 1\n\t\t\t\t\t});\n\t\t\t\t\tthis.died()\n\t\t\t\t}\n\t\t\t}\n\t\t}, 1000)\n\t}\n\n\t/**\n\t * npc开始掉落\n\t */\n\tbeginNpc() {\n\t\tthis.timer = setTimeout(() => {\n\t\t\tif (this.gameIng) {\n\t\t\t\tthis.speed += props.acceleratedSpeed;\n\t\t\t\tthis.creatNpc()\n\t\t\t}\n\t\t\t//递归执行\n\t\t\tthis.beginNpc()\n\t\t}, 2000 / this.speed)\n\t}\n\n\t/**\n\t * 暂停\n\t */\n\tpause() {\n\t\tthis.gameIng = false;\n\t}\n\n\t/**\n\t * 恢复\n\t */\n\trevive() {\n\t\tthis.gameIng = true;\n\t}\n\n\t/**\n\t * 重新开始\n\t */\n\tresume() {\n\t\tthis.reset()\n\t\tthis.start()\n\t}\n\n\t/**\n\t * 创建NPC\n\t */\n\tprivate creatNpc() {\n\t\tlet goods = this._goods = <Goods>ObjectPool.getObject(PoolName);\n\t\tthis.goodsItems.push(goods)\n\t\tthis.NpcBg.addChild(goods);\n\t\tgoods.addEventListener(engine.Event.ENTER_FRAME, goods[\"onGoodsEnter\"] = () => {\n\t\t\tif (goods.y > 1624) {\n\t\t\t\tthis.removeNpc(goods)\n\t\t\t} else {\n\t\t\t\tif (this.gameIng) {\n\t\t\t\t\t//速度叠加\n\t\t\t\t\tgoods.y += (4 * this.speed)\n\t\t\t\t\t//如果玩家和物品发生碰撞\n\t\t\t\t\tif (this.hasHit(this.player, goods)) {\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (goods[\"npcType\"] == \"rain\") {\n\t\t\t\t\t\t\tconsole.log(\"碰到雨滴\")\n\t\t\t\t\t\t\tthis.score += props.rainScore\n\t\t\t\t\t\t\tthis.waterSvga.visible=true;\n\t\t\t\t\t\t\tthis.waterSvga.play(false, false)\n\t\t\t\t\t\t\tthis.waterSvga.once(engine.Event.END_FRAME, ()=>{\n\t\t\t\t\t\t\t\tthis.waterSvga.visible=false;\n\t\t\t\t\t\t\t}, this);\n\t\t\t\t\t\t} else if (goods[\"npcType\"] == \"stone\") {\n\t\t\t\t\t\t\tconsole.log(\"碰到石头\")\n\t\t\t\t\t\t\tthis.score += props.stoneScore\n\t\t\t\t\t\t} else if (goods[\"npcType\"] == \"boom\") {\n\t\t\t\t\t\t\tconsole.log(\"碰到炸弹\")\n\t\t\t\t\t\t\tthis.boomSvga.visible=true;\n\t\t\t\t\t\t\tthis.boomSvga.play(false, false)\n\t\t\t\t\t\t\tthis.boomSvga.once(engine.Event.END_FRAME, ()=>{\n\t\t\t\t\t\t\t\tthis.boomSvga.visible=false;\n\t\t\t\t\t\t\t}, this);\n\t\t\t\t\t\t\tengine.globalEvent.dispatchEvent('food-fell-game-over', {\n\t\t\t\t\t\t\t\tscore: this.score,\n\t\t\t\t\t\t\t\treason: 2\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tthis.died()\n\t\t\t\t\t\t}\n\t\t\t\t\t\tengine.globalEvent.dispatchEvent('food-fell-score-update', {\n\t\t\t\t\t\t\tscore: this.score,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tthis.removeNpc(goods)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t}, this);\n\t}\n\n\t/**\n\t * 玩家死亡\n\t */\n\tprivate died() {\n\t\tthis.score = 0\n\t\tthis.pause()\n\t}\n\n\t/**\n\t * 回收指定物品\n\t * @param goods 物品\n\t */\n\tprivate removeNpc(goods) {\n\t\tthis.NpcBg.removeChild(goods);\n\t\tObjectPool.recycleObject(PoolName, goods);\n\t\tgoods.removeEventListener(engine.Event.ENTER_FRAME, goods[\"onGoodsEnter\"], this);\n\t\tlet index = this.goodsItems.indexOf(goods);\n\t\tif (index > -1) {\n\t\t\tthis.goodsItems.splice(index, 1);\n\t\t}\n\t}\n\n\t/**\n\t * 回收对象\n\t */\n\tprivate recycleGoods() {\n\t\tclearTimeout(this.timer)\n\t\tclearInterval(this.countdownTimer)\n\t\tfor (let goods of this.goodsItems) {\n\t\t\tif (goods) {\n\t\t\t\tthis.removeChild(goods);\n\t\t\t\tObjectPool.recycleObject(PoolName, goods);\n\t\t\t\tgoods.removeEventListener(engine.Event.ENTER_FRAME, goods[\"onGoodsEnter\"], this);\n\t\t\t}\n\t\t}\n\t\tthis.goodsItems = []\n\t}\n\n\tprivate moveCatchX = 0\n\tprivate playerCatchX = 0\n\n\t/**\n\t * 碰撞检测\n\t * @param a a盒子\n\t * @param b b盒子\n\t */\n\tprivate hasHit(a, b) {\n\t\tif (\n\t\t\tMath.abs((a.x + a.width / 2) - (b.x + b.width / 2)) < a.width / 2 + b.width / 2\n\t\t\t&&\n\t\t\tMath.abs((a.y + a.height / 2) - (b.y + b.height / 2)) < a.height / 2 + b.height / 2\n\t\t) {\n\t\t\treturn true;\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tprivate onDownStage = (e) => {\n\t\tthis.moveCatchX = e.localX;\n\t\tthis.playerCatchX = this.player.x\n\t}\n\n\tprivate onMoveStage = (e) => {\n\t\tif (this.gameIng) {\n\t\t\tthis.player.x = this.playerCatchX + (e.localX - this.moveCatchX)\n\t\t}\n\t}\n\n\tprivate onOutStage = (e) => {\n\t\tthis.moveCatchX = 0\n\t}\n}\n","/**\n * Created by rockyl on 2020-01-09.\n */\n\nimport GameView from \"./GameView\";\nimport {injectProps} from \"../props\";\n\n\nexport class GameWrapper extends engine.Container {\n\tprivate _status;\n\tprivate _gameView: GameView;\n\n\n\n\n\n\tconstructor() {\n\t\tsuper();\n\t\tengine.globalEvent.addEventListener('food-fell-reset', this.reset, this);\n\t\tengine.globalEvent.addEventListener('food-fell-start', this.start, this);\n\t\tengine.globalEvent.addEventListener('food-fell-pause', this.pause, this);\n\t\tengine.globalEvent.addEventListener('food-fell-resume', this.resume, this);\n\t\tengine.globalEvent.addEventListener('food-fell-revive', this.revive, this);\n\t\tengine.globalEvent.addEventListener('food-fell-clear', this.clear, this);\n\n\t\tthis.addEventListener(engine.MouseEvent.CLICK, this.onTap, this);\n\n\t\tlet gameView = this._gameView = new GameView();\n\t\tthis.addChild(gameView);\n\t\t// gameView.reset()\n\t\t// gameView.start()\n\t}\n\n\treset(event: engine.Event) {\t\t\n\t\tinjectProps(event.data);\n\t\tthis._gameView.visible = true;\n\t\tthis._gameView.reset();\n\t}\n\n\tstart(event: engine.Event) {\n\t\tinjectProps(event.data);\n\t\tthis._status = 1;\n\t\tthis._gameView.start();\n\t}\n\n\tpause() {\n\t\tthis._gameView.pause();\n\t}\n\n\tresume() {\n\t\tthis._gameView.resume();\n\t}\n\n\trevive() {\n\t\tthis._gameView.revive();\n\t}\n\n\tclear() {\n\t\tthis._gameView.visible = false;\n\t}\n\n\tprivate onTap(event) {\n\t//\tthis._gameView.tap(event);\n\t}\n}\n","/**\n * Created by rockyl on 2019-11-20.\n */\n\nimport {GameWrapper} from \"./game/GameWrapper\";\nimport {injectProps, prepareProps} from \"./props\";\n\nexport default function (props) {\n\tprepareProps();\n\tinjectProps(props);\n\n\tlet instance = new GameWrapper();\n\treturn instance;\n}\n"],"names":["__extends","ObjectPool"],"mappings":";;;;;;CAIO,IAAI,KAAK,GAAQ,EAAE,CAAC;AAE3B,UAAgB,YAAY;KAC3B,IAAI,SAAS,GAAG,QAAQ,EAAE,CAAC;KAE3B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;CACrC,CAAC;AAED,UAAgB,WAAW,CAAC,CAAC;KAC5B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;CAC7B,CAAC;;UCVe,UAAU,CAAC,IAAI;KAC9B,OAA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KAAK,EAAE,CAAC;MACvB;KAED,4BAAM,GAAN;SACC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;MACxB;KAED,4BAAM,GAAN;SACC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;MACxB;KAED,2BAAK,GAAL;SACC,IAAI,CAAC,SAAS,CAAC,OAAO,GAAG,KAAK,CAAC;MAC/B;KAEO,2BAAK,GAAb,UAAc,KAAK;MAElB;KACF,kBAAC;CAAD,CAAC,CAxDgC,MAAM,CAAC,SAAS,GAwDhD;;iBCzDwB,KAAK;KAC7B,YAAY,EAAE,CAAC;KACf,WAAW,CAAC,KAAK,CAAC,CAAC;KAEnB,IAAI,QAAQ,GAAG,IAAI,WAAW,EAAE,CAAC;KACjC,OAAO,QAAQ,CAAC;CACjB,CAAC;;;;;;;;"}
\ No newline at end of file
{"version":3,"file":"index.js","sources":["src/custom/food-fell/src/props.ts","src/custom/food-fell/src/game/utils.ts","src/custom/food-fell/src/game/Goods.ts","src/custom/food-fell/src/game/object-pool-init.ts","src/custom/food-fell/src/game/GameView.ts","src/custom/food-fell/src/game/GameWrapper.ts","src/custom/food-fell/src/index.ts"],"sourcesContent":["/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\n\r\nexport let props: any = {};\r\n\r\nexport function prepareProps() {\r\n\tlet metaProps = getProps();\r\n\r\n\tengine.injectProp(props, metaProps);\r\n}\r\n\r\nexport function injectProps(p) {\r\n\tengine.injectProp(props, p);\r\n}\r\n","/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\n\r\nexport function getTexture(uuid) {\r\n\treturn engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n}\r\n\r\nexport function getTextureByName(name) {\r\n\treturn getTexture(engine.getAssetByName(name).uuid);\r\n}\r\n\r\nexport function playSound(name) {\r\n\tengine.playSound(engine.getAssetByName(name).uuid, {keep: true});\r\n}\r\nexport function createSvga(name, anchorName?) {\r\n\tlet inst = new svga.Svga();\r\n\tinst.source = 'asset://' + engine.getAssetByName(name).uuid;\r\n\treturn inst;\r\n}","/**\r\n * Created by rockyl on 2020-02-02.\r\n *\r\n * 掉落物品\r\n */\r\nimport {getTextureByName} from \"./utils\";\r\nimport {props} from \"../props\";\r\n\r\nexport class Goods extends engine.Container {\r\n\tprivate _body:engine.Rect\r\n\tprivate _toY;\r\n\r\n\tconstructor() {\r\n\t\tsuper();\r\n\r\n\t\tlet body\r\n\t\tbody = this._body =new engine.Rect()\r\n\t\t\r\n\t\t\r\n\t\tlet rain = new engine.Sprite(getTextureByName('雨滴'));\r\n\t\train[\"npcType\"]=\"rain\"\r\n\t\tlet stone = new engine.Sprite(getTextureByName('石块'));\r\n\t\tstone[\"npcType\"]=\"stone\"\r\n\t\tlet boom = new engine.Sprite(getTextureByName('炸弹'));\r\n\t\tboom[\"npcType\"]=\"boom\"\r\n\r\n\t\train.visible=false;\r\n\t\tstone.visible=false;\r\n\t\tboom.visible=false;\r\n\t\tbody.addChild(rain)\r\n\t\tbody.addChild(stone)\r\n\t\tbody.addChild(boom)\r\n\t\t\r\n\t\tthis.addChild(body);\r\n\t\tbody.width=.0001;\r\n\t\tbody.height=.0001;\r\n\t\tbody.mouseEnabled=false;\r\n\t}\r\n\r\n\r\n\tgetRandomNumberByRange(start, end) {\r\n\t\treturn Math.floor(Math.random() * (end - start) + start)\r\n\t}\r\n\r\n\treset() {\r\n\t\tthis.visible = true;\r\n\t\tthis.rotation = 0;\r\n\t\tthis.anchorOffsetY = 0;\r\n\t\tthis.y = 0;\r\n\t\tthis.x = (750-120)*Math.random()+30;\r\n\t\tthis.rotation = 0;\r\n\t\tlet random=Math.random()\r\n\r\n\t\tif(random<props.goodsProbability[0]){\r\n\t\t\tthis.showNpc(\"rain\")\r\n\t\t}else if(random>=props.goodsProbability[0]&&random<=(props.goodsProbability[0]+props.goodsProbability[1])){\r\n\t\t\tthis.showNpc(\"stone\")\r\n\t\t}else if(random>(props.goodsProbability[0]+props.goodsProbability[1])){\r\n\t\t\tthis.showNpc(\"boom\")\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tshowNpc(type){\r\n\t\tfor(let i=0;i<this._body.children.length;i++){\r\n\t\t\tthis._body.children[i].visible=false;\r\n\t\t\tthis._body.children[i].mouseEnabled=false;\r\n\t\t}\r\n\r\n\t\tfor(let i=0;i<this._body.children.length;i++){\r\n\t\t\tif(this._body.children[i][\"npcType\"]==type){\r\n\t\t\t\tthis[\"npcType\"]=type\r\n\t\t\t\tthis._body.children[i].visible=true;\r\n\t\t\t\tthis._body.children[i].mouseEnabled=false;\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t}\r\n\r\n\tset anchorOffsetY(v) {\r\n\t\tthis._body.y = v;\r\n\t}\r\n}\r\n","/**\r\n * Created by rockyl on 2020-02-03.\r\n */\r\n\r\nimport {Goods} from \"./Goods\";\r\nimport ObjectPool = engine.ObjectPool;\r\n\r\nexport const PoolName: string = 'goods';\r\n\r\nObjectPool.registerPool(PoolName, function () {\r\n\treturn new Goods();\r\n}, function (item: Goods, data) {\r\n\titem.reset();\r\n});\r\n","/**\r\n * Created by rockyl on 2018/8/16.\r\n */\r\n\r\nimport { props } from \"../props\";\r\nimport { playSound, createSvga } from \"./utils\";\r\nimport ObjectPool = engine.ObjectPool;\r\nimport { getTextureByName } from \"./utils\";\r\nimport { Goods } from \"./Goods\";\r\nimport { PoolName } from \"./object-pool-init\";\r\n\r\n\r\n\r\nexport default class GameView extends engine.Container {\r\n\r\n\tprivate _hasSetup;\r\n\r\n\t//玩家\r\n\tprivate player: engine.Container;\r\n\t//触摸层\r\n\tprivate rectBg: engine.Rect;\r\n\t//npc层\r\n\tprivate NpcBg: engine.Container;\r\n\r\n\t//当前分数\r\n\tprivate score\r\n\r\n\t//游戏状态\r\n\tprivate gameIng;\r\n\r\n\t//npc出身计时器\r\n\tprivate timer\r\n\t//倒计时计时器\r\n\tprivate countdownTimer: any\r\n\t//倒计时\r\n\tprivate countdown: number\r\n\r\n\t//当前速度\r\n\tprivate speed: number\r\n\r\n\t// 当前场景上面的物品\r\n\tprivate goodsItems = []\r\n\r\n\r\n\tprivate _goods: Goods;\r\n\r\n\tconstructor() {\r\n\t\tsuper();\r\n\t\tthis.once(engine.Event.ADDED_TO_STAGE, this.setup, this);\r\n\t}\r\n\r\n\tprivate waterSvga\r\n\tprivate boomSvga\r\n\tprivate playerSvga\r\n\r\n\tsetup() {\r\n\t\tif (this._hasSetup) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tthis._hasSetup = true;\r\n\t\tthis.NpcBg = new engine.Container();\r\n\t\tthis.NpcBg.alpha = 1;\r\n\t\tthis.NpcBg.width = 0;\r\n\t\tthis.NpcBg.height = 0;\r\n\t\tthis.addChild(this.NpcBg)\r\n\r\n\t\r\n\r\n\t\tthis.player = new engine.Container();\r\n\t\tthis.player.mouseEnabled = false;\r\n\t//\tthis.player.fillColor=\"rgba(0, 0, 0,1)\"\r\n\t\t//console.log(this.player.fillColor)\r\n\t\r\n\t\tthis.addChild(this.player);\r\n\r\n\t\tthis.waterSvga=createSvga(\"水花\")\r\n\t\tthis.playerSvga=createSvga(\"玩家\")\r\n\t\tthis.boomSvga=createSvga(\"炸弹svga\")\r\n\t\tthis.player.addChild(this.playerSvga);\r\n\t\tthis.player.addChild(this.waterSvga);\r\n\t\tthis.player.addChild(this.boomSvga);\r\n\t\tthis.playerSvga.gotoAndPlay(1);\r\n\r\n\t\tthis.visible=false;\r\n\t\tsetTimeout(()=>{\r\n\t\t\tthis.visible=true;\r\n\t\t\t// this.player.width=this.playerSvga.width;\r\n\t\t\t// this.player.height=this.playerSvga.height;\r\n\t\t\tthis.player.anchorY = this.player.height / 2;\r\n\t\t\tthis.player.anchorX = this.player.width / 2;\r\n\t\t\tconsole.log(this.player.width)\r\n\t\t\tconsole.log(this.playerSvga.width)\r\n\t\t\tthis.player.x = 375 - this.player.width / 2;\r\n\t\t\tthis.player.y = props.playerPositionY;\r\n\t\t},300)\r\n\r\n\t\t\r\n\t\tthis.rectBg = new engine.Rect();\r\n\t\tthis.rectBg.alpha = 0;\r\n\t\tthis.rectBg.width = 750;\r\n\t\tthis.rectBg.height = 1624;\r\n\t\tthis.addChild(this.rectBg)\r\n\r\n\t\tthis.rectBg.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDownStage, this);\r\n\t\tthis.rectBg.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMoveStage, this);\r\n\t\tthis.rectBg.addEventListener(engine.MouseEvent.MOUSE_OUT, this.onOutStage, this);\r\n\r\n\t\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * 重置场景\r\n\t */\r\n\treset() {\r\n\t\tthis.recycleGoods()\r\n\t}\r\n\r\n\t/**\r\n\t * 开始\r\n\t */\r\n\tstart() {\r\n\t\tthis.score = 0;\r\n\t\tthis.speed = 1\r\n\t\tthis.gameIng = true;\r\n\t\tthis.creatNpc()\r\n\t\tthis.beginNpc()\r\n\t\tthis.countdown = props.countDown;\r\n\t\t\r\n\t\tthis.countdownTimer = setInterval(() => {\r\n\t\t\tif (this.gameIng) {\r\n\t\t\t\tif (this.countdown > 0) {\r\n\t\t\t\t\tengine.globalEvent.dispatchEvent('food-fell-time-update', {\r\n\t\t\t\t\t\ttime: this.countdown,\r\n\t\t\t\t\t});\r\n\t\t\t\t\tthis.countdown -= 1\r\n\t\t\t\t} else {\r\n\t\t\t\t\tengine.globalEvent.dispatchEvent('food-fell-game-over', {\r\n\t\t\t\t\t\tscore: this.score,\r\n\t\t\t\t\t\treason: 1\r\n\t\t\t\t\t});\r\n\t\t\t\t\tthis.died()\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}, 1000)\r\n\t}\r\n\r\n\t/**\r\n\t * npc开始掉落\r\n\t */\r\n\tbeginNpc() {\r\n\t\tthis.timer = setTimeout(() => {\r\n\t\t\tif (this.gameIng) {\r\n\t\t\t\tthis.speed += props.acceleratedSpeed;\r\n\t\t\t\tthis.creatNpc()\r\n\t\t\t}\r\n\t\t\t//递归执行\r\n\t\t\tthis.beginNpc()\r\n\t\t}, 2000 / this.speed)\r\n\t}\r\n\r\n\t/**\r\n\t * 暂停\r\n\t */\r\n\tpause() {\r\n\t\tthis.gameIng = false;\r\n\t}\r\n\r\n\t/**\r\n\t * 恢复\r\n\t */\r\n\trevive() {\r\n\t\tthis.gameIng = true;\r\n\t}\r\n\r\n\t/**\r\n\t * 重新开始\r\n\t */\r\n\tresume() {\r\n\t\tthis.reset()\r\n\t\tthis.start()\r\n\t}\r\n\r\n\t/**\r\n\t * 创建NPC\r\n\t */\r\n\tprivate creatNpc() {\r\n\t\tlet goods = this._goods = <Goods>ObjectPool.getObject(PoolName);\r\n\t\tthis.goodsItems.push(goods)\r\n\t\tthis.NpcBg.addChild(goods);\r\n\t\tgoods.addEventListener(engine.Event.ENTER_FRAME, goods[\"onGoodsEnter\"] = () => {\r\n\t\t\tif (goods.y > 1624) {\r\n\t\t\t\tthis.removeNpc(goods)\r\n\t\t\t} else {\r\n\t\t\t\tif (this.gameIng) {\r\n\t\t\t\t\t//速度叠加\r\n\t\t\t\t\tgoods.y += (4 * this.speed)\r\n\t\t\t\t\t//如果玩家和物品发生碰撞\r\n\t\t\t\t\tif (this.hasHit(this.player, goods)) {\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tif (goods[\"npcType\"] == \"rain\") {\r\n\t\t\t\t\t\t\tconsole.log(\"碰到雨滴\")\r\n\t\t\t\t\t\t\tthis.score += props.rainScore\r\n\t\t\t\t\t\t\tthis.waterSvga.visible=true;\r\n\t\t\t\t\t\t\tthis.waterSvga.play(false, false)\r\n\t\t\t\t\t\t\tthis.waterSvga.once(engine.Event.END_FRAME, ()=>{\r\n\t\t\t\t\t\t\t\tthis.waterSvga.visible=false;\r\n\t\t\t\t\t\t\t}, this);\r\n\t\t\t\t\t\t} else if (goods[\"npcType\"] == \"stone\") {\r\n\t\t\t\t\t\t\tconsole.log(\"碰到石头\")\r\n\t\t\t\t\t\t\tthis.score += props.stoneScore\r\n\t\t\t\t\t\t} else if (goods[\"npcType\"] == \"boom\") {\r\n\t\t\t\t\t\t\tconsole.log(\"碰到炸弹\")\r\n\t\t\t\t\t\t\tthis.boomSvga.visible=true;\r\n\t\t\t\t\t\t\tthis.boomSvga.play(false, false)\r\n\t\t\t\t\t\t\tthis.boomSvga.once(engine.Event.END_FRAME, ()=>{\r\n\t\t\t\t\t\t\t\tthis.boomSvga.visible=false;\r\n\t\t\t\t\t\t\t}, this);\r\n\t\t\t\t\t\t\tengine.globalEvent.dispatchEvent('food-fell-game-over', {\r\n\t\t\t\t\t\t\t\tscore: this.score,\r\n\t\t\t\t\t\t\t\treason: 2\r\n\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\tthis.died()\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tengine.globalEvent.dispatchEvent('food-fell-score-update', {\r\n\t\t\t\t\t\t\tscore: this.score,\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t\tthis.removeNpc(goods)\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t}, this);\r\n\t}\r\n\r\n\t/**\r\n\t * 玩家死亡\r\n\t */\r\n\tprivate died() {\r\n\t\tthis.score = 0\r\n\t\tthis.pause()\r\n\t}\r\n\r\n\t/**\r\n\t * 回收指定物品\r\n\t * @param goods 物品\r\n\t */\r\n\tprivate removeNpc(goods) {\r\n\t\tthis.NpcBg.removeChild(goods);\r\n\t\tObjectPool.recycleObject(PoolName, goods);\r\n\t\tgoods.removeEventListener(engine.Event.ENTER_FRAME, goods[\"onGoodsEnter\"], this);\r\n\t\tlet index = this.goodsItems.indexOf(goods);\r\n\t\tif (index > -1) {\r\n\t\t\tthis.goodsItems.splice(index, 1);\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * 回收对象\r\n\t */\r\n\tprivate recycleGoods() {\r\n\t\tclearTimeout(this.timer)\r\n\t\tclearInterval(this.countdownTimer)\r\n\t\tfor (let goods of this.goodsItems) {\r\n\t\t\tif (goods) {\r\n\t\t\t\tthis.removeChild(goods);\r\n\t\t\t\tObjectPool.recycleObject(PoolName, goods);\r\n\t\t\t\tgoods.removeEventListener(engine.Event.ENTER_FRAME, goods[\"onGoodsEnter\"], this);\r\n\t\t\t}\r\n\t\t}\r\n\t\tthis.goodsItems = []\r\n\t}\r\n\r\n\tprivate moveCatchX = 0\r\n\tprivate playerCatchX = 0\r\n\r\n\t/**\r\n\t * 碰撞检测\r\n\t * @param a a盒子\r\n\t * @param b b盒子\r\n\t */\r\n\tprivate hasHit(a, b) {\r\n\t\tif (\r\n\t\t\tMath.abs((a.x + a.width / 2) - (b.x + b.width / 2)) < a.width / 2 + b.width / 2\r\n\t\t\t&&\r\n\t\t\tMath.abs((a.y + a.height / 2) - (b.y + b.height / 2)) < a.height / 2 + b.height / 2\r\n\t\t) {\r\n\t\t\treturn true;\r\n\t\t} else {\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\tprivate onDownStage = (e) => {\r\n\t\tthis.moveCatchX = e.localX;\r\n\t\tthis.playerCatchX = this.player.x\r\n\t}\r\n\r\n\tprivate onMoveStage = (e) => {\r\n\t\tif (this.gameIng) {\r\n\t\t\tthis.player.x = this.playerCatchX + (e.localX - this.moveCatchX)\r\n\t\t}\r\n\t}\r\n\r\n\tprivate onOutStage = (e) => {\r\n\t\tthis.moveCatchX = 0\r\n\t}\r\n}\r\n","/**\r\n * Created by rockyl on 2020-01-09.\r\n */\r\n\r\nimport GameView from \"./GameView\";\r\nimport {injectProps} from \"../props\";\r\n\r\n\r\nexport class GameWrapper extends engine.Container {\r\n\tprivate _status;\r\n\tprivate _gameView: GameView;\r\n\r\n\r\n\r\n\r\n\r\n\tconstructor() {\r\n\t\tsuper();\r\n\t\tengine.globalEvent.addEventListener('food-fell-reset', this.reset, this);\r\n\t\tengine.globalEvent.addEventListener('food-fell-start', this.start, this);\r\n\t\tengine.globalEvent.addEventListener('food-fell-pause', this.pause, this);\r\n\t\tengine.globalEvent.addEventListener('food-fell-resume', this.resume, this);\r\n\t\tengine.globalEvent.addEventListener('food-fell-revive', this.revive, this);\r\n\t\tengine.globalEvent.addEventListener('food-fell-clear', this.clear, this);\r\n\r\n\t\tthis.addEventListener(engine.MouseEvent.CLICK, this.onTap, this);\r\n\r\n\t\tlet gameView = this._gameView = new GameView();\r\n\t\tthis.addChild(gameView);\r\n\t\t// gameView.reset()\r\n\t\t// gameView.start()\r\n\t}\r\n\r\n\treset(event: engine.Event) {\t\t\r\n\t\tinjectProps(event.data);\r\n\t\tthis._gameView.visible = true;\r\n\t\tthis._gameView.reset();\r\n\t}\r\n\r\n\tstart(event: engine.Event) {\r\n\t\tinjectProps(event.data);\r\n\t\tthis._status = 1;\r\n\t\tthis._gameView.start();\r\n\t}\r\n\r\n\tpause() {\r\n\t\tthis._gameView.pause();\r\n\t}\r\n\r\n\tresume() {\r\n\t\tthis._gameView.resume();\r\n\t}\r\n\r\n\trevive() {\r\n\t\tthis._gameView.revive();\r\n\t}\r\n\r\n\tclear() {\r\n\t\tthis._gameView.visible = false;\r\n\t}\r\n\r\n\tprivate onTap(event) {\r\n\t//\tthis._gameView.tap(event);\r\n\t}\r\n}\r\n","/**\r\n * Created by rockyl on 2019-11-20.\r\n */\r\n\r\nimport {GameWrapper} from \"./game/GameWrapper\";\r\nimport {injectProps, prepareProps} from \"./props\";\r\n\r\nexport default function (props) {\r\n\tprepareProps();\r\n\tinjectProps(props);\r\n\r\n\tlet instance = new GameWrapper();\r\n\treturn instance;\r\n}\r\n"],"names":["__extends","ObjectPool"],"mappings":";;;;;;CAIO,IAAI,KAAK,GAAQ,EAAE,CAAC;AAE3B,UAAgB,YAAY;KAC3B,IAAI,SAAS,GAAG,QAAQ,EAAE,CAAC;KAE3B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;CACrC,CAAC;AAED,UAAgB,WAAW,CAAC,CAAC;KAC5B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,C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,CAAC;MACvB;KAED,2BAAK,GAAL;SACC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;MACvB;KAED,4BAAM,GAAN;SACC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;MACxB;KAED,4BAAM,GAAN;SACC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;MACxB;KAED,2BAAK,GAAL;SACC,IAAI,CAAC,SAAS,CAAC,OAAO,GAAG,KAAK,CAAC;MAC/B;KAEO,2BAAK,GAAb,UAAc,KAAK;MAElB;KACF,kBAAC;CAAD,CAAC,CAxDgC,MAAM,CAAC,SAAS,GAwDhD;;;iBCzDwB,KAAK;KAC7B,YAAY,EAAE,CAAC;KACf,WAAW,CAAC,KAAK,CAAC,CAAC;KAEnB,IAAI,QAAQ,GAAG,IAAI,WAAW,EAAE,CAAC;KACjC,OAAO,QAAQ,CAAC;CACjB,CAAC;;;;;;;;;"}
\ No newline at end of file
/**
* Created by renjianfeng on 2020-03-13.
*/
const customId = 'tanqiu';
(async function () {
let customModule = await fetch(`../meta.json`);
customModule = await customModule.json();
console.log(customModule);
await loadAssets(customModule.assets);
launchWithCustomModule(customModule);
})();
function launchWithCustomModule(customModule) {
//engine.registerCustomCodeModule(customModule);
engine.registerCustomModule(customId, window[customId]);
const {props: propsOption, assets} = customModule;
let props = engine.computeProps(customModuleProps, propsOption);
const customModuleIns = {
id: customId,
props,
assets,
};
engine.registerCustomModules([customModuleIns]);
engine.launchWithConfig({
options: {
entrySceneView: 'entry',
},
assets: [],
views: [{
name: 'entry',
type: 'node',
properties: {
x: 0,
y: 0,
}
}],
}, null, function () {
setTimeout(() => {
engine.addCustomModule(customId, engine.gameStage.sceneContainer.getChildAt(0));
}, 100);
setTimeout(() => {
engine.globalEvent.dispatchEvent('food-fell-reset', {
"goodsProbability": [0.8,0.1,0.1],
"countDown": 30,
"acceleratedSpeed":0.1
});
engine.globalEvent.dispatchEvent('food-fell-start');
}, 500);
});
engine.globalEvent.addEventListener('food-fell-time-update', (e) => {
console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('food-fell-score-update', (e) => {
console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('food-fell-game-over', (e) => {
console.log(e.type, e.data);
});
}
function getAssetByUUID(uuid) {
return engine.resolveCustomAsset(customId, uuid);
}
function getProps() {
return engine.getProps(customId);
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>弹球</title>
<meta name="viewport"
content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="full-screen" content="true"/>
<meta name="screen-orientation" content="portrait"/>
<meta name="x5-fullscreen" content="true"/>
<meta name="360-fullscreen" content="true"/>
<style>
html,
body {
padding: 0;
margin: 0;
border: 0;
width: 100%;
height: 100%;
overflow: hidden;
position: absolute;
background-color: red;
}
</style>
</head>
<body>
<div id="game-container" style="line-height:0;font-size:0"></div>
<script crossorigin="anonymous" src="//yun.duiba.com.cn/editor/zeroing/libs/engine.50cdcef6ebe4e8c0fbc624f9d4fbf225102c5750.js"></script>
<script crossorigin="anonymous" src="//yun.duiba.com.cn/editor/zeroing/libs/svga.fd3923ae6e664251ca7981801a65809cc5f36bc3.js"></script>
<!-- <script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.ebc906f6b50b8da0a669f77027981d5f3cb560ce.js"></script> -->
<!-- <script src="http://localhost:4002/debug/engine.js"></script>
<script src="http://localhost:4003/debug/engine-svga.js"></script> -->
<!--<script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.9a9dbfda4cb2dd5508ecddfe3d95dfd88063f7b5.js"></script>-->
<script src="app.js"></script>
<script src="props.js"></script>
<script src="load-assets.js"></script>
<script src="main.js"></script>
<script>
</script>
</body>
\ No newline at end of file
/**
* Created by rockyl on 2020-01-21.
*/
const assets = [
{
"name": "玩家icon",
"url": "//yun.duiba.com.cn/aurora/assets/50a7212a113175fa18c866b005d98f07c558dc77.png",
"uuid": "66f23d13-82a5-4cec-9496-301ec240d087",
"ext": ".png"
},
{
"name": "雨滴",
"url": "//yun.duiba.com.cn/aurora/assets/8564c8c9be3aead71b05a0bab8d7d07ac3f778a1.png",
"uuid": "264a6192-d7bf-45e8-8f15-6ba2c439a532",
"ext": ".png"
},
{
"name": "炸弹",
"url": "//yun.duiba.com.cn/aurora/assets/171e92283cd13c013ee1b76d28d252ff08815d47.png",
"uuid": "eb88b42d-e151-4c1b-94b9-7c16f7bfac29",
"ext": ".png"
},
{
"name": "石块",
"url": "//yun.duiba.com.cn/aurora/assets/99b0af0c59fe79a415a3f032149cfacc27e3ac2c.png",
"uuid": "ab1bdabc-21ba-46bf-9299-6c638f766c88",
"ext": ".png"
},
{
"name": "水花",
"url": "//yun.duiba.com.cn/aurora/assets/93d37b4a0e367e80e375308a6b4414d72d7666fc.svga",
"uuid": "b521bf94-20e1-44dd-8eca-d24996cbaeae",
"ext": ".svga"
},
{
"name": "炸弹",
"url": "//yun.duiba.com.cn/aurora/assets/4dd18f0689c663bbcf710a7afc4d929084d97d36.svga",
"uuid": "322edf39-805b-4e84-9d07-5573dfeebc0e",
"ext": ".svga"
},
{
"name": "玩家",
"url": "//yun.duiba.com.cn/aurora/assets/b66300c5d4f27134b0aac3dc90a3220e8ae572eb.svga",
"uuid": "71d8dcbc-3931-471a-b585-b3ae01b25aa6",
"ext": ".svga"
}
];
function loadAssets(customModuleAssets, onProgress, onComplete){
return engine.loadAssets(assets.concat(...customModuleAssets), onProgress, onComplete);
}
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :
typeof define === 'function' && define.amd ? define(['tslib'], factory) :
(global = global || self, global.tanqiu = factory(global.tslib));
}(this, (function (tslib) { 'use strict';
var props = {};
function prepareProps() {
var metaProps = getProps();
engine.injectProp(props, metaProps);
}
function injectProps(p) {
engine.injectProp(props, p);
}
//# sourceMappingURL=props.js.map
var BALL_D = 34;
var LEFT_GROUND = 80;
var RIGHT_GROUND = 675;
var LADDER_START = 350 - 100;
var LADDER_END = 1150;
var LADDER_NUMS = 10;
var LADDER_H_START = 130;
var LADDER_H_END = 710;
var LADDER_H_NUMS = 7;
var ACELE_DELAY = 4000;
//# sourceMappingURL=gameconsts.js.map
var SoundType;
(function (SoundType) {
SoundType["click"] = "click";
SoundType["bounce"] = "bounce";
SoundType["good"] = "good";
SoundType["recover"] = "recover";
SoundType["shoot"] = "shoot";
})(SoundType || (SoundType = {}));
var isSpecialBody = function (body) {
return body.type != 'circle' && body.type != 'square' && body.type != 'regTriangle';
};
var isSpecialCircle = function (body) {
return body.type === 'specialCircle';
};
var ladderHeight = LADDER_END - LADDER_START;
var getLadderPosition = function (i) {
return ladderHeight / LADDER_NUMS * i + LADDER_START;
};
var ladderWidth = LADDER_H_END - LADDER_H_START;
var getLadderHPosition = function (i) {
return ladderWidth / LADDER_H_NUMS * i + LADDER_H_START;
};
var getLadderGap = function () {
return ladderHeight / LADDER_NUMS;
};
var getBounce = function () {
return 0.9 + Math.random() * 0.09;
};
var shuffle = function (array) {
var _array = array.concat();
for (var i = _array.length; i--;) {
var j = Math.floor(Math.random() * (i + 1));
var temp = _array[i];
_array[i] = _array[j];
_array[j] = temp;
}
return _array;
};
function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
function playSound(name) {
return;
}
//# sourceMappingURL=utils.js.map
var counter;
var resetCounter = function () {
counter = 1;
};
var getBlockShape = function () {
var list = shuffle([1, 2, 3]);
return list[0];
};
var random = function (start, end) {
return start + (end - start) * Math.random();
};
var getNums = function (currBallNums) {
return Math.ceil(currBallNums * random(1 * window['numsP'], 3.5 * window['numsP']));
};
var getNums2 = function (currBallNums) {
return Math.ceil(currBallNums * random(4 * window['numsP'], 7 * window['numsP']));
};
var getSpecialNumBlocksNums = function (currBallNums) {
if (currBallNums < 20)
return 1;
if (currBallNums < 50)
return 2;
return 3;
};
var getBlocks = function (currBallNums) {
var blockNums = Math.random() > 0.3 ? 3 : 2;
var specialBall = 0;
if (counter % 3 === 0) {
specialBall = 1;
}
var list = [];
for (var i = 0; i < LADDER_H_NUMS; i++) {
list.push(i);
}
list = shuffle(list);
var blockPositions = list.slice(0, blockNums);
var specialBallPosition = list[list.length - 1];
var blocksInfo = [];
for (var j = 0; j < blockPositions.length; j++) {
var p = blockPositions[j];
var nums = getNums(currBallNums);
var specialNumBlocksNums = getSpecialNumBlocksNums(currBallNums);
if (Math.random() < 0.3 && j < specialNumBlocksNums) {
nums = getNums2(currBallNums);
}
if (currBallNums >= 50)
nums = getNums2(currBallNums);
blocksInfo.push({
position: p,
type: getBlockShape(),
nums: nums || 2
});
}
counter++;
return {
blocksInfo: blocksInfo,
specialBallPosition: specialBall ? specialBallPosition : -1
};
};
//# sourceMappingURL=blockGen.js.map
var Vector = (function () {
function Vector(x, y) {
if (x === void 0) { x = 0; }
if (y === void 0) { y = 0; }
this.x = x;
this.y = y;
}
Vector.prototype.initialize = function () {
this.x = 0;
this.y = 0;
};
Vector.prototype.length = function () {
return Math.sqrt(this.length2());
};
Vector.prototype.length2 = function () {
return this.x * this.x + this.y * this.y;
};
Vector.prototype.symmetricFromNormalVector = function (normalVector) {
var nx2 = normalVector.x * normalVector.x;
var ny2 = normalVector.y * normalVector.y;
var nxy = normalVector.x * normalVector.y;
var tempx = this.x;
this.x = (2 * this.y * nxy + this.x * (nx2 - ny2)) / (nx2 + ny2);
this.y = (2 * tempx * nxy - this.y * (nx2 - ny2)) / (nx2 + ny2);
return this;
};
Vector.prototype.rotate = function (angle) {
var tempx = this.x;
this.x = this.x * Math.cos(angle) - this.y * Math.sin(angle);
this.y = this.y * Math.cos(angle) + tempx * Math.sin(angle);
return this;
};
Vector.prototype.clone = function () {
return new Vector(this.x, this.y);
};
Vector.prototype.translate = function (x, y) {
this.x += x;
this.y += y;
return this;
};
Vector.prototype.cross = function () {
if (this.x == 0) {
if (this.y == 0) ;
else {
this.x = 1;
this.y = 0;
}
}
else {
if (this.y == 0) {
this.x = 0;
this.y = 1;
}
else {
var tempx = this.x;
this.x = 1;
this.y = -tempx / this.y;
}
}
return this;
};
Vector.prototype.getMagnitude = function () {
return Math.sqrt(Math.pow(this.x, 2) + Math.pow(this.y, 2));
};
Vector.prototype.add = function (anotherVector) {
var v = new Vector();
v.x = this.x + anotherVector.x;
v.y = this.y + anotherVector.y;
return v;
};
Vector.prototype.subtract = function (anotherVector) {
var v = new Vector();
v.x = this.x - anotherVector.x;
v.y = this.y - anotherVector.y;
return v;
};
Vector.prototype.dotProduct = function (anotherVector) {
return this.x * anotherVector.x + this.y * anotherVector.y;
};
Vector.prototype.edge = function (anotherVector) {
return this.subtract(anotherVector);
};
Vector.prototype.perpendicular = function () {
var v = new Vector();
v.x = this.y;
v.y = 0 - this.x;
return v;
};
Vector.prototype.normalize = function () {
var v = new Vector(0, 0);
var m = this.getMagnitude();
if (m != 0) {
v.x = this.x / m;
v.y = this.y / m;
}
return v;
};
Vector.prototype.perpendicularNormal = function () {
var p = this.perpendicular();
return p.normalize();
};
Vector.prototype.parallel = function (vector) {
if (Math.abs(this.x * vector.y - this.y * vector.x) < 0.00001) {
return true;
}
else {
return false;
}
};
Vector.symmetricVector = function (vector, normalVector) {
var nx2 = normalVector.x * normalVector.x;
var ny2 = normalVector.y * normalVector.y;
var nxy = normalVector.x * normalVector.y;
var x = (2 * vector.y * nxy + vector.x * (nx2 - ny2)) / (nx2 + ny2);
var y = (2 * vector.x * nxy - vector.y * (nx2 - ny2)) / (nx2 + ny2);
return new Vector(x, y);
};
return Vector;
}());
//# sourceMappingURL=Vector.js.map
var Projection = (function () {
function Projection(min, max) {
this.min = min;
this.max = max;
}
Projection.prototype.overlaps = function (projection) {
return this.max > projection.min && projection.max > this.min;
};
return Projection;
}());
//# sourceMappingURL=Projection.js.map
var Ball = (function () {
function Ball(radius, view) {
this.collideStatus = 1;
this.recoverMark = false;
this.velocity = new Vector();
this.radius = radius;
this.view = view;
}
Object.defineProperty(Ball.prototype, "_viewx", {
get: function () {
return this.view.x;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Ball.prototype, "_viewy", {
get: function () {
return this.view.y;
},
enumerable: true,
configurable: true
});
Ball.prototype.project = function (axis) {
var scalars = [];
var dotProduct = new Vector(this.view.x, this.view.y).dotProduct(axis);
scalars.push(dotProduct + this.radius);
scalars.push(dotProduct - this.radius);
return new Projection(dotProduct - this.radius, dotProduct + this.radius);
};
return Ball;
}());
//# sourceMappingURL=Ball.js.map
var createBallItem = function () {
var picTex = getTextureByName("ball");
var pic = new engine.Image(picTex);
pic.mouseEnabled = false;
pic.anchorX = pic.width / 2;
pic.anchorY = pic.height / 2;
var ball = new Ball(BALL_D / 2, pic);
return ball;
};
//# sourceMappingURL=createBall.js.map
var TweenObj = (function () {
function TweenObj() {
this._instanceId = 0;
this._instanceType = "TweenObj";
this.currentFrame = 0;
this.totalFrames = 0;
this._isLoop = 0;
this._delay = 0;
this._isFront = true;
this._cParams = null;
this._loop = false;
this._instanceId = TweenObj._object_id++;
}
TweenObj.prototype.init = function (target, times, data, isTo) {
if (isTo === void 0) { isTo = true; }
if (times <= 0 || typeof (times) != "number") {
throw new Error("Tween.to()或者Tween.from()方法的第二个参数一定要是大于0的数字");
}
var s = this;
s.currentFrame = 1;
var tTime = times * 60 >> 0;
s.totalFrames = tTime > 0 ? tTime : 1;
s.target = target;
s._isTo = isTo;
s._isLoop = 0;
s._startData = {};
s._disData = {};
s._delay = 0;
s._isFront = true;
s._ease = null;
s._update = null;
s._cParams = null;
s._loop = false;
s._completeFun = null;
for (var item in data) {
switch (item) {
case "useFrame":
if (data[item] == true) {
s.totalFrames = times;
}
break;
case "yoyo":
if (data[item] === false) {
s._isLoop = 0;
}
else if (data[item] === true) {
s._isLoop = Number.MAX_VALUE;
}
else {
s._isLoop = data[item];
}
break;
case "delay":
if (data.useFrame) {
s._delay = data[item];
}
else {
s._delay = data[item] * 60 >> 0;
}
break;
case "ease":
s._ease = data[item];
break;
case "onUpdate":
s._update = data[item];
break;
case "onComplete":
s._completeFun = data[item];
break;
case "completeParams":
s._cParams = data[item];
break;
case "loop":
s._loop = data[item];
break;
default:
if (typeof (data[item]) == "number") {
if (isTo) {
s._startData[item] = target[item];
s._disData[item] = data[item] - target[item];
}
else {
s._startData[item] = data[item];
s._disData[item] = target[item] - data[item];
target[item] = data[item];
}
}
}
}
};
TweenObj.prototype.update = function () {
var s = this;
if (s._isFront && s._delay > 0) {
s._delay--;
return;
}
var per = s.currentFrame / s.totalFrames;
if (per < 0 || per > 1)
return;
if (s._ease) {
per = s._ease(per);
}
var isHave = false;
for (var item in s._disData) {
isHave = true;
s.target[item] = s._startData[item] + s._disData[item] * per;
}
if (!isHave) {
Tween.kill(s.instanceId);
return;
}
if (s._update) {
s._update(per);
}
var cf = s._completeFun;
var pm = s._cParams;
if (s._isFront) {
s.currentFrame++;
if (s.currentFrame > s.totalFrames) {
if (s._loop) {
s.currentFrame = 1;
}
else {
if (s._isLoop > 0) {
s._isFront = false;
s.currentFrame = s.totalFrames;
s._isLoop--;
}
else {
Tween.kill(s.instanceId);
}
}
if (cf) {
cf(pm);
}
}
}
else {
s.currentFrame--;
if (s.currentFrame < 0) {
if (s._isLoop > 0) {
s._isFront = true;
s.currentFrame = 1;
}
else {
Tween.kill(s.instanceId);
}
if (cf) {
cf(pm);
}
}
}
};
Object.defineProperty(TweenObj.prototype, "instanceId", {
get: function () {
return this._instanceId;
},
enumerable: true,
configurable: true
});
Object.defineProperty(TweenObj.prototype, "instanceType", {
get: function () {
return this._instanceType;
},
enumerable: true,
configurable: true
});
TweenObj.prototype.destroy = function () {
var s = this;
s._update = null;
s._completeFun = null;
s._ease = null;
};
TweenObj._object_id = 0;
return TweenObj;
}());
var Tween = (function () {
function Tween() {
}
Tween.to = function (target, totalFrame, data) {
return Tween.createTween(target, totalFrame, data, true);
};
Tween.from = function (target, totalFrame, data) {
return Tween.createTween(target, totalFrame, data, false);
};
Tween.createTween = function (target, totalFrame, data, isTo) {
var tweenObj;
var len = Tween._tweenList.length;
for (var i = 0; i < len; i++) {
tweenObj = Tween._tweenList[i];
if (target == tweenObj.target) {
for (var item in tweenObj._startData) {
if (data[item] != undefined) {
delete tweenObj._startData[item];
delete tweenObj._disData[item];
}
}
}
}
len = Tween._tweenPool.length;
if (len > 0) {
tweenObj = Tween._tweenPool.shift();
tweenObj._instanceId = TweenObj["_object_id"]++;
}
else {
tweenObj = new TweenObj();
}
Tween._tweenList.push(tweenObj);
tweenObj.init(target, totalFrame, data, isTo);
return tweenObj.instanceId;
};
Tween.killAll = function () {
var len = Tween._tweenList.length;
var tweenObj;
for (var i = 0; i < len; i++) {
tweenObj = Tween._tweenList[i];
tweenObj.target = null;
tweenObj._completeFun = null;
tweenObj._cParams = null;
tweenObj._update = null;
tweenObj._ease = null;
tweenObj._loop = false;
Tween._tweenPool.push(tweenObj);
}
Tween._tweenList.length = 0;
};
Tween.kill = function (tweenId) {
var len = Tween._tweenList.length;
var tweenObj;
for (var i = 0; i < len; i++) {
tweenObj = Tween._tweenList[i];
if (tweenObj.instanceId == tweenId) {
tweenObj.target = null;
tweenObj._completeFun = null;
tweenObj._cParams = null;
tweenObj._update = null;
tweenObj._ease = null;
tweenObj._loop = null;
Tween._tweenPool.push(tweenObj);
Tween._tweenList.splice(i, 1);
break;
}
}
};
Tween.quadraticIn = function (k) {
return k * k;
};
Tween.quadraticOut = function (k) {
return k * (2 - k);
};
Tween.quadraticInOut = function (k) {
if ((k *= 2) < 1) {
return 0.5 * k * k;
}
return -0.5 * (--k * (k - 2) - 1);
};
Tween.cubicIn = function (k) {
return k * k * k;
};
Tween.cubicOut = function (k) {
return --k * k * k + 1;
};
Tween.cubicInOut = function (k) {
if ((k *= 2) < 1) {
return 0.5 * k * k * k;
}
return 0.5 * ((k -= 2) * k * k + 2);
};
Tween.quarticIn = function (k) {
return k * k * k * k;
};
Tween.quarticOut = function (k) {
return 1 - (--k * k * k * k);
};
Tween.quarticInOut = function (k) {
if ((k *= 2) < 1) {
return 0.5 * k * k * k * k;
}
return -0.5 * ((k -= 2) * k * k * k - 2);
};
Tween.quinticIn = function (k) {
return k * k * k * k * k;
};
Tween.quinticOut = function (k) {
return --k * k * k * k * k + 1;
};
Tween.quinticInOut = function (k) {
if ((k *= 2) < 1) {
return 0.5 * k * k * k * k * k;
}
return 0.5 * ((k -= 2) * k * k * k * k + 2);
};
Tween.sinusoidalIn = function (k) {
return 1 - Math.cos(k * Math.PI / 2);
};
Tween.sinusoidalOut = function (k) {
return Math.sin(k * Math.PI / 2);
};
Tween.sinusoidalInOut = function (k) {
return 0.5 * (1 - Math.cos(Math.PI * k));
};
Tween.exponentialIn = function (k) {
return k === 0 ? 0 : Math.pow(1024, k - 1);
};
Tween.exponentialOut = function (k) {
return k === 1 ? 1 : 1 - Math.pow(2, -10 * k);
};
Tween.exponentialInOut = function (k) {
if (k === 0) {
return 0;
}
if (k === 1) {
return 1;
}
if ((k *= 2) < 1) {
return 0.5 * Math.pow(1024, k - 1);
}
return 0.5 * (-Math.pow(2, -10 * (k - 1)) + 2);
};
Tween.circularIn = function (k) {
return 1 - Math.sqrt(1 - k * k);
};
Tween.circularOut = function (k) {
return Math.sqrt(1 - (--k * k));
};
Tween.circularInOut = function (k) {
if ((k *= 2) < 1) {
return -0.5 * (Math.sqrt(1 - k * k) - 1);
}
return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1);
};
Tween.elasticIn = function (k) {
if (k === 0) {
return 0;
}
if (k === 1) {
return 1;
}
return -Math.pow(2, 10 * (k - 1)) * Math.sin((k - 1.1) * 5 * Math.PI);
};
Tween.elasticOut = function (k) {
if (k === 0) {
return 0;
}
if (k === 1) {
return 1;
}
return Math.pow(2, -10 * k) * Math.sin((k - 0.1) * 5 * Math.PI) + 1;
};
Tween.elasticInOut = function (k) {
if (k === 0) {
return 0;
}
if (k === 1) {
return 1;
}
k *= 2;
if (k < 1) {
return -0.5 * Math.pow(2, 10 * (k - 1)) * Math.sin((k - 1.1) * 5 * Math.PI);
}
return 0.5 * Math.pow(2, -10 * (k - 1)) * Math.sin((k - 1.1) * 5 * Math.PI) + 1;
};
Tween.backIn = function (k) {
var s = 1.70158;
return k * k * ((s + 1) * k - s);
};
Tween.backOut = function (k) {
var s = 1.70158;
return --k * k * ((s + 1) * k + s) + 1;
};
Tween.backInOut = function (k) {
var s = 1.70158 * 1.525;
if ((k *= 2) < 1) {
return 0.5 * (k * k * ((s + 1) * k - s));
}
return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2);
};
Tween.bounceIn = function (k) {
return 1 - Tween.bounceOut(1 - k);
};
Tween.bounceOut = function (k) {
if (k < (1 / 2.75)) {
return 7.5625 * k * k;
}
else if (k < (2 / 2.75)) {
return 7.5625 * (k -= (1.5 / 2.75)) * k + 0.75;
}
else if (k < (2.5 / 2.75)) {
return 7.5625 * (k -= (2.25 / 2.75)) * k + 0.9375;
}
else {
return 7.5625 * (k -= (2.625 / 2.75)) * k + 0.984375;
}
};
Tween.bounceInOut = function (k) {
if (k < 0.5) {
return Tween.bounceIn(k * 2) * 0.5;
}
return Tween.bounceOut(k * 2 - 1) * 0.5 + 0.5;
};
Tween.flush = function () {
var len = Tween._tweenList.length;
for (var i = len - 1; i >= 0; i--) {
if (Tween._tweenList[i]) {
Tween._tweenList[i].update();
}
else {
Tween._tweenList.splice(i, 1);
}
}
};
Tween._tweenPool = [];
Tween._tweenList = [];
return Tween;
}());
//# sourceMappingURL=Tween.js.map
var Body = (function () {
function Body() {
this.ladderNums = 1;
}
Body.prototype.collideBall = function (ball) {
};
Object.defineProperty(Body.prototype, "num", {
get: function () {
return;
},
set: function (value) {
},
enumerable: true,
configurable: true
});
Object.defineProperty(Body.prototype, "y", {
set: function (value) { },
enumerable: true,
configurable: true
});
Object.defineProperty(Body.prototype, "x", {
set: function (value) { },
enumerable: true,
configurable: true
});
return Body;
}());
//# sourceMappingURL=Body.js.map
var Circle = (function (_super) {
tslib.__extends(Circle, _super);
function Circle(radius, view) {
var _this = _super.call(this) || this;
_this.type = "circle";
_this._x = 0;
_this._y = 0;
_this.radius = radius;
_this.view = view;
return _this;
}
Object.defineProperty(Circle.prototype, "x", {
get: function () {
return this._x;
},
set: function (value) {
if (this._x != value) {
this._x = value;
this.view.x = value;
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(Circle.prototype, "y", {
get: function () {
return this._y;
},
set: function (value) {
if (this._y != value) {
this._y = value;
this.view.y = value;
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(Circle.prototype, "num", {
get: function () {
return this._num;
},
set: function (value) {
if (this._num != value) {
this._num = value;
this.view.txt && (this.view.txt.text = value || 2 + "");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(Circle.prototype, "_viewx", {
get: function () {
return this.view.x;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Circle.prototype, "_viewy", {
get: function () {
return this.view.y;
},
enumerable: true,
configurable: true
});
Circle.prototype.shake = function () {
console.log("circle震动1-------", this.view.bg.x, this.view.bg.y);
var startx = -this.view.bg.anchorX;
var starty = -this.view.bg.anchorY;
this.view.bg.x = startx;
this.view.bg.y = starty;
console.log("circle震动2-------", this.view.bg.x, this.view.bg.y);
Tween.to(this.view.bg, 1, {
x: startx + 3,
y: starty + 3,
yoyo: 2,
useFrame: true,
onComplete: function () {
console.log("circle震动3-------", this.view.bg.x, this.view.bg.y);
}
});
};
Circle.prototype.collideBall = function (ball) {
var ballax = ball._viewx;
var ballay = ball._viewy;
var thisax = this._viewx;
var thisay = this._viewy;
var deltaX = ballax - thisax;
var deltaY = ballay - thisay;
if (deltaX * deltaX + deltaY * deltaY < (this.radius + ball.radius) * (this.radius + ball.radius)) {
var velocity = ball.velocity.clone();
var deta = Math.floor(velocity.length() / ball.radius) + 5;
var speedX = velocity.x / (deta + 1);
var speedY = velocity.y / (deta + 1);
for (var i = 0; i <= deta; i++) {
var normal = this.nearestCollideNormal({ x: ballax - speedX * (i + 1), y: ballay - speedY * (i + 1) }, ball, deta + 1, i + 1);
if (normal) {
return normal;
}
}
}
else {
return false;
}
};
Circle.prototype.nearestCollideNormal = function (position, ball, deta, i) {
var thisax = this._viewx;
var thisay = this._viewy;
var deltaX = position.x - thisax;
var deltaY = position.y - thisay;
if (deltaX * deltaX + deltaY * deltaY < (this.radius + ball.radius) * (this.radius + ball.radius)) {
return false;
}
else {
ball.view.x -= ball.velocity.x / deta * i;
ball.view.y -= ball.velocity.y / deta * i;
return new Vector(deltaX, deltaY).cross();
}
};
return Circle;
}(Body));
//# sourceMappingURL=Circle.js.map
var createCircle = (function (that, x, y, num) {
var block = that.pool.takeOut("circle");
var anchorx = 0;
var anchory = 0;
if (!block) {
var sprite = new engine.Sprite();
sprite.mouseEnabled = sprite.mouseChildren = false;
var shape = new engine.Image(getTextureByName('circle1'));
shape['__resName__'] = 'circle1';
var radius = shape.width / 2;
var length = radius * 2;
shape.anchorX = shape.width / 2;
shape.anchorY = shape.height / 2;
anchorx = radius;
anchory = radius;
sprite["bg"] = shape;
sprite.addChild(shape);
shape.x = -anchorx;
shape.y = -anchory;
var txt = new engine.TextField();
txt.width = length;
txt.height = length;
txt.anchorX = length / 2;
txt.anchorY = length / 2;
txt.size = 30;
txt.fillColor = 0xffffff;
txt.textAlign = engine.TEXT_ALIGN.CENTER;
txt.verticalAlign = engine.VERTICAL_ALIGN.MIDDLE;
sprite["txt"] = txt;
sprite.addChild(txt);
txt.x = -anchorx;
txt.y = -anchory;
block = new Circle(radius, sprite);
}
that.addChild(block.view);
block.x = x;
block.y = y;
block.num = num;
that.blocks.push(block);
block.ladderNums = 1;
});
//# sourceMappingURL=createCircle.js.map
var degToRad = Math.PI / 180;
var radToDeg = 180 / Math.PI;
var sqrt3 = Math.sqrt(3);
function translateToLocalCor(p, parent) {
var th = parent.rotation * degToRad;
var xp = p.x - parent.x;
var yp = p.y - parent.y;
var x = xp * Math.cos(th) + yp * Math.sin(th);
var y = yp * Math.cos(th) - xp * Math.sin(th);
return { x: x / parent.scaleX, y: y / parent.scaleY };
}
//# sourceMappingURL=Const.js.map
var RegPolygon = (function (_super) {
tslib.__extends(RegPolygon, _super);
function RegPolygon(length, view) {
var _this = _super.call(this) || this;
_this.type = "regPolygon";
_this._rotation = 0;
_this._x = 0;
_this._y = 0;
_this.linesOri = [];
_this.sideNormals = [];
_this.pointNormals = [];
_this.points = [];
_this.axes = [];
_this.projects = [];
_this.dirty = true;
_this.length = length;
_this.view = view;
_this.calculateNormals();
_this.calculatePoints();
_this.calculateLines();
return _this;
}
Object.defineProperty(RegPolygon.prototype, "rotation", {
get: function () {
return this._rotation;
},
set: function (value) {
if (this._rotation != value) {
this._rotation = value;
this.view.rotation = value;
this.view.txt.rotation = -value;
this.calculateNormals();
this.calculatePoints();
this.dirty = true;
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(RegPolygon.prototype, "x", {
get: function () {
return this._x;
},
set: function (value) {
if (this._x != value) {
this._x = value;
this.view.x = value;
this.dirty = true;
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(RegPolygon.prototype, "y", {
get: function () {
return this._y;
},
set: function (value) {
if (this._y != value) {
this._y = value;
this.view.y = value;
this.dirty = true;
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(RegPolygon.prototype, "num", {
get: function () {
return this._num;
},
set: function (value) {
if (this._num != value) {
this._num = value;
this.view.txt.text = value || 3 + "";
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(RegPolygon.prototype, "_viewx", {
get: function () {
return this.view.x;
},
enumerable: true,
configurable: true
});
Object.defineProperty(RegPolygon.prototype, "_viewy", {
get: function () {
return this.view.y;
},
enumerable: true,
configurable: true
});
RegPolygon.prototype.calculateNormals = function () {
};
RegPolygon.prototype.calculatePoints = function () {
};
RegPolygon.prototype.calculateLines = function () {
};
RegPolygon.prototype.getAxes = function () {
var v1 = new Vector();
var v2 = new Vector();
var axes = [];
var thisvx = this._viewx;
var thisvy = this._viewy;
for (var i = 0; i < this.points.length - 1; i++) {
v1.x = this.points[i].x + thisvx;
v1.y = this.points[i].y + thisvy;
v2.x = this.points[i + 1].x + thisvx;
v2.y = this.points[i + 1].y + thisvy;
axes.push(v1.edge(v2).perpendicularNormal());
}
v1.x = this.points[this.points.length - 1].x + thisvx;
v1.y = this.points[this.points.length - 1].y + thisvy;
v2.x = this.points[0].x + thisvx;
v2.y = this.points[0].y + thisvy;
axes.push(v1.edge(v2).perpendicularNormal());
return axes;
};
RegPolygon.prototype.project = function (axis) {
var scalars = [];
var v = new Vector();
var thisvx = this._viewx;
var thisvy = this._viewy;
this.points.forEach(function (point) {
v.x = point.x + thisvx;
v.y = point.y + thisvy;
scalars.push(v.dotProduct(axis));
});
return new Projection(Math.min.apply(Math, scalars), Math.max.apply(Math, scalars));
};
RegPolygon.prototype.polygonCollidesWithCircle = function (ball) {
var v1;
var v2;
var ballax = ball._viewx;
var ballay = ball._viewy;
if (this.dirty) {
this.dirty = false;
this.axes = this.getAxes();
for (var i = 0; i < this.axes.length; i++) {
this.projects[i] = this.project(this.axes[i]);
}
}
var axes = this.axes.slice();
var closestPoint = this.getPolygonPointClosestToCircle(ball);
v1 = new Vector(ballax, ballay);
v2 = new Vector(closestPoint.x, closestPoint.y);
axes.push(v1.subtract(v2).normalize());
return !this.separationOnAxes(axes, ball);
};
RegPolygon.prototype.getPolygonPointClosestToCircle = function (ball) {
var min;
var length;
var testPoint;
var closestPoint;
var ballax = ball._viewx;
var ballay = ball._viewy;
var thisax = this._viewx;
var thisay = this._viewy;
for (var i = 0; i < this.points.length; i++) {
testPoint = new Vector(this.points[i].x + thisax, this.points[i].y + thisay);
length = Math.pow(testPoint.x - ballax, 2) + Math.pow(testPoint.y - ballay, 2);
if (!min || length < min) {
min = length;
closestPoint = testPoint;
}
}
return closestPoint;
};
RegPolygon.prototype.separationOnAxes = function (axes, ball) {
var axis;
var projection1;
var projection2;
for (var i = 0; i < axes.length; ++i) {
axis = axes[i];
projection1 = ball.project(axis);
if (i == axes.length - 1) {
projection2 = this.project(axis);
}
else {
projection2 = this.projects[i];
}
if (!projection1.overlaps(projection2)) {
return true;
}
}
return false;
};
RegPolygon.prototype.collideBall = function (ball) {
var ballax = ball._viewx;
var ballay = ball._viewy;
var thisax = this._viewx;
var thisay = this._viewy;
if (this.polygonCollidesWithCircle(ball)) {
var returnP = translateToLocalCor({ x: ballax, y: ballay }, this.view);
var velocity = ball.velocity.clone().rotate(-this._rotation * degToRad);
var deta = Math.floor(velocity.length() / ball.radius) + 1;
var speedX = velocity.x / (deta + 1);
var speedY = velocity.y / (deta + 1);
for (var i = 0; i <= deta; i++) {
this.ballPosition(ball, deta + 1, i + 1);
if (!this.polygonCollidesWithCircle(ball)) {
var noraml = this.nearestCollideNormal({ x: returnP.x - speedX * (i + 1), y: returnP.y - speedY * (i + 1) });
return noraml;
}
}
}
else {
return false;
}
};
RegPolygon.prototype.nearestCollideNormal = function (returnP) {
return;
};
RegPolygon.prototype.ballPosition = function (ball, deta, i) {
ball.view.x -= ball.velocity.x / deta;
ball.view.y -= ball.velocity.y / deta;
};
RegPolygon.prototype.shake = function () {
console.log("regPolygon震动1----------", this.view.bg.x, this.view.bg.y);
var startx = -this.view.bg.anchorX;
var starty = -this.view.bg.anchorY;
this.view.bg.x = startx;
this.view.bg.y = starty;
console.log("regPolygon震动2----------", this.view.bg.x, this.view.bg.y);
Tween.to(this.view.bg, 1, {
x: startx + 3,
y: starty + 3,
yoyo: 2,
useFrame: true,
onComplete: function () {
console.log("regPolygon震动3----------", this.view.bg.x, this.view.bg.y);
}
});
};
return RegPolygon;
}(Body));
//# sourceMappingURL=RegPolygon.js.map
var RegTriangle = (function (_super) {
tslib.__extends(RegTriangle, _super);
function RegTriangle(length, view) {
var _this = _super.call(this, length, view) || this;
_this.type = "regTriangle";
_this.pointLength = _this.length * sqrt3 / 3;
_this.sideLength = _this.length * sqrt3 / 6;
return _this;
}
RegTriangle.prototype.calculateNormals = function () {
if (this._rotation == 0) {
this.sideNormals[0] = new Vector(1, -sqrt3);
this.sideNormals[1] = new Vector(1, sqrt3);
this.sideNormals[2] = new Vector(-1, 0);
this.pointNormals[0] = new Vector(1, 0);
this.pointNormals[1] = new Vector(-1, sqrt3);
this.pointNormals[2] = new Vector(-1, -sqrt3);
}
else {
var rad = this._rotation * degToRad;
this.sideNormals[0] = new Vector(1, -sqrt3).rotate(rad);
this.sideNormals[1] = new Vector(1, sqrt3).rotate(rad);
this.sideNormals[2] = new Vector(-1, 0).rotate(rad);
this.pointNormals[0] = new Vector(1, 0).rotate(rad);
this.pointNormals[1] = new Vector(-1, sqrt3).rotate(rad);
this.pointNormals[2] = new Vector(-1, -sqrt3).rotate(rad);
}
};
RegTriangle.prototype.calculatePoints = function () {
if (this._rotation == 0) {
this.points[0] = new Vector(0, -this.length * sqrt3 / 3);
this.points[1] = new Vector(this.length / 2, this.length * sqrt3 / 6);
this.points[2] = new Vector(-this.length / 2, this.length * sqrt3 / 6);
}
else {
var rad = this._rotation * degToRad;
this.points[0] = new Vector(0, -this.length * sqrt3 / 3).rotate(rad);
this.points[1] = new Vector(this.length / 2, this.length * sqrt3 / 6).rotate(rad);
this.points[2] = new Vector(-this.length / 2, this.length * sqrt3 / 6).rotate(rad);
}
};
RegTriangle.prototype.calculateLines = function () {
this.linesOri = [
{ a: -sqrt3, b: -this.length * sqrt3 / 3 },
{ a: sqrt3, b: -this.length * sqrt3 / 3 },
{ a: 0, b: this.length * sqrt3 / 6 },
];
};
RegTriangle.prototype.nearestCollideNormal = function (returnP) {
var zero = this.linesOri[0].a * returnP.x + this.linesOri[0].b - returnP.y > 0;
var one = this.linesOri[1].a * returnP.x + this.linesOri[1].b - returnP.y > 0;
var two = this.linesOri[2].a * returnP.x + this.linesOri[2].b - returnP.y > 0;
if (zero && !one && two) {
return this.sideNormals[0];
}
else if (!zero && one && two) {
return this.sideNormals[1];
}
else if (!zero && !one && !two) {
return this.sideNormals[2];
}
else if (zero && one && two) {
return this.pointNormals[0];
}
else if (!zero && one && !two) {
return this.pointNormals[1];
}
else if (zero && !one && !two) {
return this.pointNormals[2];
}
};
return RegTriangle;
}(RegPolygon));
//# sourceMappingURL=RegTriangle.js.map
var createRegTriangle = (function (that, x, y, num) {
var block = that.pool.takeOut("regTriangle");
var picType = Math.ceil(Math.random() * 2);
var pic = new engine.Sprite(getTextureByName("tri" + picType));
pic.anchorX = pic.width / 2;
pic.anchorY = pic.height / 2;
var anchorx = 0;
var anchory = 0;
anchorx = pic.width / 2;
anchory = pic.height / 2;
if (!block) {
var sprite = new engine.Sprite();
sprite.mouseEnabled = sprite.mouseChildren = false;
var length = pic.width;
var height = pic.height;
sprite["bg"] = pic;
sprite.addChild(pic);
pic.x = -anchorx;
pic.y = -anchory;
var txt = new engine.TextField();
txt.width = length;
txt.height = height;
txt.anchorX = length / 2;
txt.anchorY = height / 2;
txt.size = 26;
txt.fillColor = 0xffffff;
txt.textAlign = engine.TEXT_ALIGN.CENTER;
txt.verticalAlign = engine.VERTICAL_ALIGN.MIDDLE;
sprite["txt"] = txt;
sprite.addChild(txt);
txt.x = -anchorx;
txt.y = -anchory + (anchorx - anchory) * 2;
block = new RegTriangle(length, sprite);
}
else {
if (block.view["bg"]) {
block.view.removeChild(block.view["bg"]);
block.view["bg"] = pic;
block.view.addChild(pic);
block.view.addChild(block.view['txt']);
pic.x = -anchorx;
pic.y = -anchory;
block.view['txt'].x = -anchorx;
block.view['txt'].y = -anchory + (anchorx - anchory) * 2;
}
}
block.view["bg"]['__resName__'] = "tri" + picType;
that.addChild(block.view);
block.x = x;
block.y = y;
block.rotation = Math.random() * 360;
block.num = num;
that.blocks.push(block);
block.ladderNums = 1;
});
//# sourceMappingURL=createRegTriangle.js.map
var createSpecialRegTriangle = (function (that, x, y, length, rotation, key) {
if (key === void 0) { key = 'specialRegTriangle'; }
var block;
var sprite = new engine.Sprite();
sprite.visible = false;
sprite.alpha = 0.7;
sprite.mouseEnabled = sprite.mouseChildren = false;
var shape = new engine.Shape();
shape.beginFill(0xcccccc);
shape.moveTo(0, -length * sqrt3 / 3);
shape.lineTo(length / 2, length * sqrt3 / 6);
shape.lineTo(-length / 2, length * sqrt3 / 6);
shape.endFill();
sprite["bg"] = shape;
sprite.addChild(shape);
var txt = new engine.TextField();
txt.width = length;
txt.height = length;
txt.anchorX = length / 2;
txt.anchorY = length / 2;
txt.size = 25;
txt.fillColor = 0xffffff;
txt.textAlign = engine.TEXT_ALIGN.CENTER;
txt.verticalAlign = engine.VERTICAL_ALIGN.MIDDLE;
sprite["txt"] = txt;
sprite.addChild(txt);
console.log("特殊建筑三角形", length);
block = new RegTriangle(length, sprite);
block.type = key;
that.addChild(block.view);
block.x = x;
block.y = y;
block.rotation = rotation;
that.blocks.push(block);
});
var createSpeialCircle = (function (that, x, y, num) {
var block = that.pool.takeOut("specialCircle");
var radius = getTextureByName('+1').orig.width / 2;
if (!block) {
var sprite = new engine.Sprite();
sprite.mouseEnabled = sprite.mouseChildren = false;
var shape = new engine.Sprite(getTextureByName('+1'));
shape.anchorX = shape.width / 2;
shape.anchorY = shape.height / 2;
sprite["bg"] = shape;
sprite.addChild(shape);
shape.x = -shape.width / 2;
shape.y = -shape.height / 2;
block = new Circle(radius, sprite);
block.type = 'specialCircle';
}
else {
if (block.radius != radius) {
block.view.bg.clear();
block.view.bg.beginFill(0xcccccc);
block.view.bg.drawCircle(0, 0, radius);
block.view.bg.endFill();
}
}
that.addChild(block.view);
block.x = x;
block.y = y;
block.num = num;
that.blocks.push(block);
block.ladderNums = 1;
});
//# sourceMappingURL=createSpeialCircle.js.map
var Square = (function (_super) {
tslib.__extends(Square, _super);
function Square(length, view) {
var _this = _super.call(this) || this;
_this.type = "square";
_this._x = 0;
_this._y = 0;
_this._rotation = 0;
_this.sideNormals = [
new Vector(1, 0),
new Vector(0, 1),
new Vector(-1, 0),
new Vector(0, -1)
];
_this.pointNormals = [
new Vector(1, -1),
new Vector(1, 1),
new Vector(-1, 1),
new Vector(-1, -1)
];
_this.length = length;
_this.view = view;
return _this;
}
Object.defineProperty(Square.prototype, "rotation", {
get: function () {
return this._rotation;
},
set: function (value) {
if (this._rotation != value) {
this._rotation = value;
this.view.rotation = value;
this.view.txt.rotation = -value;
var rad = value * degToRad;
this.sideNormals[0] = new Vector(1, 0).rotate(rad);
this.sideNormals[1] = new Vector(0, 1).rotate(rad);
this.sideNormals[2] = new Vector(-1, 0).rotate(rad);
this.sideNormals[3] = new Vector(0, -1).rotate(rad);
this.pointNormals[0] = new Vector(1, -1).rotate(rad);
this.pointNormals[1] = new Vector(1, 1).rotate(rad);
this.pointNormals[2] = new Vector(-1, 1).rotate(rad);
this.pointNormals[3] = new Vector(-1, -1).rotate(rad);
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(Square.prototype, "x", {
get: function () {
return this._x;
},
set: function (value) {
if (this._x != value) {
this._x = value;
this.view.x = value;
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(Square.prototype, "y", {
get: function () {
return this._y;
},
set: function (value) {
if (this._y != value) {
this._y = value;
this.view.y = value;
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(Square.prototype, "num", {
get: function () {
return this._num;
},
set: function (value) {
if (this._num != value) {
this._num = value;
this.view.txt.text = value || 4 + "";
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(Square.prototype, "_viewx", {
get: function () {
return this.view.x;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Square.prototype, "_viewy", {
get: function () {
return this.view.y;
},
enumerable: true,
configurable: true
});
Square.prototype.collideBall = function (ball) {
var returnP = translateToLocalCor({ x: ball._viewx, y: ball._viewy }, this.view);
var ox = -this.length / 2;
var oy = ox;
var nearestX = Math.max(ox, Math.min(returnP.x, ox + this.length));
var nearestY = Math.max(oy, Math.min(returnP.y, oy + this.length));
var deltaX = returnP.x - nearestX;
var deltaY = returnP.y - nearestY;
if (deltaX * deltaX + deltaY * deltaY < ball.radius * ball.radius) {
var velocity = ball.velocity.clone().rotate(-this._rotation * degToRad);
var deta = Math.floor(velocity.length() / ball.radius) + 5;
var speedX = velocity.x / (deta + 1);
var speedY = velocity.y / (deta + 1);
for (var i = 0; i <= deta; i++) {
var normal = this.nearestCollideNormal({ x: returnP.x - speedX * (i + 1), y: returnP.y - speedY * (i + 1) }, ball, deta + 1, i + 1);
if (normal) {
return normal;
}
}
}
else {
return false;
}
};
Square.prototype.nearestCollideNormal = function (position, ball, deta, i) {
var ox = -this.length / 2;
var oy = ox;
var nearestX = Math.max(ox, Math.min(position.x, ox + this.length));
var nearestY = Math.max(oy, Math.min(position.y, oy + this.length));
var deltaX = position.x - nearestX;
var deltaY = position.y - nearestY;
if (deltaX * deltaX + deltaY * deltaY < ball.radius * ball.radius) {
return false;
}
else {
ball.view.x -= ball.velocity.x / deta * i;
ball.view.y -= ball.velocity.y / deta * i;
if (nearestX == ox) {
if (nearestY == oy) {
return this.pointNormals[0];
}
else if (nearestY == oy + this.length) {
return this.pointNormals[3];
}
else {
return this.sideNormals[3];
}
}
else if (nearestX == ox + this.length) {
if (nearestY == oy) {
return this.pointNormals[1];
}
else if (nearestY == oy + this.length) {
return this.pointNormals[2];
}
else {
return this.sideNormals[1];
}
}
else {
if (nearestY < 0) {
return this.sideNormals[0];
}
else {
return this.sideNormals[2];
}
}
}
};
Square.prototype.shake = function () {
console.log("square震动1---", this.view.bg.x, this.view.bg.y);
var startx = -this.view.bg.anchorX;
var starty = -this.view.bg.anchorY;
this.view.bg.x = startx;
this.view.bg.y = starty;
console.log("square震动2---", this.view.bg.x, this.view.bg.y);
Tween.to(this.view.bg, 1, {
x: startx + 5,
y: starty + 5,
yoyo: 3,
useFrame: true,
onComplete: function () {
console.log("square震动3---", this.view.bg.x, this.view.bg.y);
}
});
};
return Square;
}(Body));
//# sourceMappingURL=Square.js.map
var createSquare = (function (that, x, y, num) {
var picType = Math.ceil(Math.random() * 4);
var pic = new engine.Sprite(getTextureByName("sq" + picType));
pic.anchorX = pic.width / 2;
pic.anchorY = pic.height / 2;
var block = that.pool.takeOut("square");
var anchorx = pic.width / 2;
var anchory = pic.height / 2;
if (!block) {
var sprite = new engine.Sprite();
sprite.mouseEnabled = sprite.mouseChildren = false;
var length = pic.width;
sprite["bg"] = pic;
sprite.addChild(pic);
pic.x = -anchorx;
pic.y = -anchory;
var txt = new engine.TextField();
txt.width = length;
txt.height = pic.height;
txt.anchorX = length / 2;
txt.anchorY = pic.height / 2;
txt.size = 30;
txt.fillColor = 0xffffff;
txt.textAlign = engine.TEXT_ALIGN.CENTER;
txt.verticalAlign = engine.VERTICAL_ALIGN.MIDDLE;
sprite["txt"] = txt;
sprite.addChild(txt);
txt.x = -anchorx;
txt.y = -anchory;
block = new Square(length, sprite);
}
else {
if (block.view["bg"]) {
block.view.removeChild(block.view["bg"]);
block.view["bg"] = pic;
block.view.addChild(pic);
block.view.addChild(block.view['txt']);
pic.x = -anchorx;
pic.y = -anchory;
block.view['txt'].x = -anchorx;
block.view['txt'].y = -anchory;
}
}
block.view["bg"]['__resName__'] = "sq" + picType;
that.addChild(block.view);
block.x = x;
block.y = y;
block.num = num;
block.rotation = Math.random() * 360;
that.blocks.push(block);
block.ladderNums = 1;
});
//# sourceMappingURL=createSquare.js.map
var Pool = (function () {
function Pool() {
this.pool = {};
}
Pool.prototype.takeOut = function (name) {
if (this.pool[name] && this.pool[name].length) {
return this.pool[name].shift();
}
return false;
};
Pool.prototype.recover = function (name, obj) {
if (!this.pool[name]) {
this.pool[name] = [];
}
this.pool[name].push(obj);
};
return Pool;
}());
//# sourceMappingURL=Pool.js.map
var Effect = (function () {
function Effect(block, parent) {
this.NUMS_MAX = 11;
var resName = block.view['bg']['__resName__'];
var _loop_1 = function (i) {
var data = this_1.createItem(resName);
parent.addChild(data.shape);
data.shape.x = block.x;
data.shape.y = block.y;
engine.Tween.get(data.shape).to({ x: data.targetX + block.x, y: block.y + data.targetY, scaleY: 0, scaleX: 0 }, 360).call(function () {
data.shape.parent && data.shape.parent.removeChild(data.shape);
});
};
var this_1 = this;
for (var i = 0; i < this.NUMS_MAX; i++) {
_loop_1();
}
}
Effect.prototype.createItem = function (resName) {
var moveDisMax = 100;
var squareSize = 100;
var shape = new engine.Shape();
var shapeType = this.getShapeType(resName);
if (shapeType == 'circle') {
shape.beginFill(this.getShapeColor(resName));
shape.drawCircle(0, 0, squareSize / 2);
shape.endFill();
}
else if (shapeType == 'tri') {
shape.beginFill(this.getShapeColor(resName));
shape.moveTo(0, -squareSize * sqrt3 / 3);
shape.lineTo(squareSize / 2, squareSize * sqrt3 / 6);
shape.lineTo(-squareSize / 2, squareSize * sqrt3 / 6);
shape.endFill();
}
else if (shapeType == 'sq') {
shape.beginFill(this.getShapeColor(resName));
shape.drawRect(-squareSize / 2, -squareSize / 2, squareSize, squareSize);
shape.endFill();
}
var scale = Math.random() * 0.7 + 0.3;
var rotation = Math.random() * 360;
var angle = Math.random() * Math.PI * 2;
var dis = moveDisMax / 2 + moveDisMax / 2 * Math.random();
var targetX = Math.sin(angle) * dis;
var targetY = Math.cos(angle) * dis;
shape.scaleX = shape.scaleY = scale;
shape.rotation = rotation;
return { shape: shape, targetX: targetX, targetY: targetY };
};
Effect.prototype.getShapeType = function (resName) {
if (resName == 'circle1')
return 'circle';
if (resName.indexOf('tri') > -1)
return 'tri';
if (resName.indexOf('sq') > -1)
return 'sq';
return 'circle';
};
Effect.prototype.getShapeColor = function (resName) {
if (resName == 'circle1')
return 0xffca55;
if (resName == 'sq1')
return 0xfa7782;
if (resName == 'sq2')
return 0xf677ce;
if (resName == 'sq3')
return 0xffac84;
if (resName == 'sq4')
return 0xffca55;
if (resName == 'tri1')
return 0x2db0ee;
if (resName == 'tri2')
return 0x86e45f;
return 0xffca55;
};
return Effect;
}());
//# sourceMappingURL=Effect.js.map
var PlayScene = (function (_super) {
tslib.__extends(PlayScene, _super);
function PlayScene() {
var _this = _super.call(this) || this;
_this.gravity = 1;
_this.timeSpeed = 1;
_this.INIT_BALL_NUMS = window['INIT_BALL_NUMS'];
_this.balls = [];
_this.pool = new Pool();
_this.blocks = [];
_this.velAmount = 25;
_this.directionAngle = 0;
_this.canShootTag = true;
_this.data = {
score: 0,
currentBallNums: 5,
};
_this.reviveTag = 0;
_this.INIT_BALL_NUMS = window['INIT_BALL_NUMS'] = 1;
_this.initEvents();
_this.once(engine.Event.ADDED_TO_STAGE, _this.initScene, _this);
return _this;
}
PlayScene.prototype.initEvents = function () {
this.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);
this.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onTouchBegin, this);
};
PlayScene.prototype.removeEvents = function () {
this.removeEventListener(engine.MouseEvent.MOUSE_DOWN, this.onTouchBegin, this);
this.removeEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);
};
PlayScene.prototype.reset = function () {
var blocks = this.blocks.filter(function (block) { return !isSpecialBody(block); });
for (var _i = 0, blocks_1 = blocks; _i < blocks_1.length; _i++) {
var block = blocks_1[_i];
this.removeEle(block, this.blocks);
block.view.parent && block.view.parent.removeChild(block.view);
this.pool.recover(block.type, block);
}
};
PlayScene.prototype.start = function () {
this.gamescore = 0;
this.currentBallNums = props.countDown;
this.startGame();
};
PlayScene.prototype.pausegame = function () {
this['pause'] = true;
};
PlayScene.prototype.resumegame = function () {
this['pause'] = false;
};
Object.defineProperty(PlayScene.prototype, "currentBallNums", {
get: function () {
return this.data.currentBallNums;
},
set: function (num) {
this.data.currentBallNums = num;
this.ballNums.text = num;
},
enumerable: true,
configurable: true
});
Object.defineProperty(PlayScene.prototype, "gamescore", {
get: function () {
return this.data.score;
},
set: function (num) {
this.data.score = num;
this.score.text = num;
engine.globalEvent.dispatchEvent('game-score-update', {
score: num,
});
},
enumerable: true,
configurable: true
});
PlayScene.prototype.initScene = function () {
this.initUI();
this.startGame();
engine.Tween.get(this['ele1'], { loop: true }).set({ rotation: 0 }).to({ rotation: -360 }, 3000);
engine.Tween.get(this['ele2'], { loop: true }).set({ rotation: 0 }).to({ rotation: 360 }, 3000);
createSpecialRegTriangle(this, 60, 250, 200, 55, 'specialRegTriangleTop');
createSpecialRegTriangle(this, 750 - 60, 250, 200, -55, 'specialRegTriangleTop');
createSpecialRegTriangle(this, 150, 90, 500, 4, 'specialRegTriangleTop');
createSpecialRegTriangle(this, 750 - 150, 90, 500, -4, 'specialRegTriangleTop');
createSpecialRegTriangle(this, 230, 250, 40, 0, 'specialRegTriangleTop');
createSpecialRegTriangle(this, 750 - 230 + 5, 250, 40, 0, 'specialRegTriangleTop');
createSpecialRegTriangle(this, 170, 1271, 400, 52);
createSpecialRegTriangle(this, 750 - 170, 1271, 400, -52);
createSpecialRegTriangle(this, 232, 1351 - 3 - 5 - 3, 400, 30);
createSpecialRegTriangle(this, 750 - 232, 1351 - 3 - 5 - 3, 400, -30);
};
PlayScene.prototype.initUI = function () {
this.score = new engine.Label();
this.score.x = 118;
this.score.y = 13;
this.score.size = 24;
this.score.fillColor = 0xffffff;
this.addChild(this.score);
this.ground = this.createSprite("地", 0, 1130);
this.ground.visible = true;
this.addChild(this.ground);
this.door = this.createSprite("door", 0, 68);
this.addChild(this.door);
this.ele1 = this.createSprite("风扇", 56, 1130, 20, 21);
this.addChild(this.ele1);
this.ele2 = this.createSprite("风扇", 698, 1130, 20, 21);
this.addChild(this.ele2);
var ele1_t = this.createSprite("风扇1", 54, 1078);
this.addChild(ele1_t);
var ele2_t = this.createSprite("风扇1", 693, 1078);
this.addChild(ele2_t);
this.shooter = this.createSprite("炮", 375, 222, 40, 40);
this.addChild(this.shooter);
this.ballNums = new engine.Label();
this.ballNums.x = 333;
this.ballNums.y = 203;
this.ballNums.width = 85;
this.ballNums.height = 43;
this.ballNums.textAlign = engine.TEXT_ALIGN.CENTER;
this.ballNums.verticalAlign = engine.VERTICAL_ALIGN.MIDDLE;
this.ballNums.size = 38;
this.ballNums.fillColor = 0x00ff00;
this.addChild(this.ballNums);
this.line = this.createSprite("shootline", 375, 222, 5, -74);
this.addChild(this.line);
};
PlayScene.prototype.createSprite = function (tname, x, y, anchorx, anchory) {
if (anchorx === void 0) { anchorx = 0; }
if (anchory === void 0) { anchory = 0; }
var sp = new engine.Image(getTextureByName(tname));
sp.x = x - anchorx;
sp.y = y - anchory;
sp.anchorX = anchorx;
sp.anchorY = anchory;
return sp;
};
PlayScene.prototype.setWindowData = function () {
window['numsP'] = 0.5;
window['INIT_BALL_NUMS'] = 1;
};
PlayScene.prototype.startGame = function () {
this.setWindowData();
this['pause'] = false;
this.reviveTag = 0;
resetCounter();
this.gamescore = 0;
this.ballCountAll = this.INIT_BALL_NUMS;
this.currentBallNums = this.ballCountAll;
this.balls.forEach(function (ball) { return ball.view.parent && ball.view.parent.removeChild(ball); });
this.balls = new Array();
for (var i = 0; i < this.INIT_BALL_NUMS; i++) {
var ball = createBallItem();
this.addChild(ball.view);
ball.view.y = this.shooter.y + 90 + this.shooter.anchorY - ball.view.anchorY;
ball.view.x = this.shooter.x + this.shooter.anchorX - ball.view.anchorX;
ball.view.visible = false;
this.balls.push(ball);
}
this.onShootEnd();
};
PlayScene.prototype.onGuildeTap = function () {
this['guide'].visible = false;
localStorage.setItem('guide', '1');
};
PlayScene.prototype.genBlocks = function () {
var _a = getBlocks(this.ballCountAll), blocksInfo = _a.blocksInfo, specialBallPosition = _a.specialBallPosition;
if (specialBallPosition > -1) {
createSpeialCircle(this, getLadderHPosition(specialBallPosition), getLadderPosition(LADDER_NUMS - 1), 0);
}
console.log("创建障碍物", blocksInfo, specialBallPosition);
for (var _i = 0, blocksInfo_1 = blocksInfo; _i < blocksInfo_1.length; _i++) {
var block = blocksInfo_1[_i];
var position = block.position, type = block.type, nums = block.nums;
if (type == 1) {
createSquare(this, getLadderHPosition(position), getLadderPosition(LADDER_NUMS - 1), nums);
}
else if (type == 2) {
createRegTriangle(this, getLadderHPosition(position), getLadderPosition(LADDER_NUMS - 1), nums);
}
else {
createCircle(this, getLadderHPosition(position), getLadderPosition(LADDER_NUMS - 1), nums);
}
}
};
PlayScene.prototype.onTouchMove = function (e) {
var detaX = e.localX - 375;
var detaY = e.localY - 0;
if (detaY != 0) {
var angle = Math.atan(detaX / detaY);
if (angle > Math.PI / 180 * 75)
angle = Math.PI / 180 * 75;
if (angle < -Math.PI / 180 * 75)
angle = -Math.PI / 180 * 75;
this.line.rotation = this.shooter.rotation = -angle * radToDeg;
this.directionAngle = angle;
this.updateLine();
}
};
PlayScene.prototype.updateLine = function () {
this.line.scaleY = (1 - Math.abs(this.line.rotation) / 90 * 0.5);
};
PlayScene.prototype.onTouchEnd = function (e) {
if (this['pause'])
return;
this.removeEventListener(engine.MouseEvent.MOUSE_MOVE, this.onTouchMove, this);
this.canShootTag = false;
this.ballCount = 0;
this.ballShoot();
};
PlayScene.prototype.onTouchBegin = function (e) {
if (this['pause'])
return;
if (!this.canShootTag)
return;
this.line.visible = true;
this.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onTouchMove, this);
this.once(engine.MouseEvent.MOUSE_UP, this.onTouchEnd, this);
var detaX = e.localX - 375;
var detaY = e.localY - 0;
if (detaY != 0) {
var angle = Math.atan(detaX / detaY);
if (angle > Math.PI / 180 * 75)
angle = Math.PI / 180 * 75;
if (angle < -Math.PI / 180 * 75)
angle = -Math.PI / 180 * 75;
this.line.rotation = this.shooter.rotation = -angle * radToDeg;
this.directionAngle = angle;
this.updateLine();
}
};
PlayScene.prototype.onEnterFrame = function () {
Tween.flush();
for (var _i = 0, _a = this.balls; _i < _a.length; _i++) {
var ball = _a[_i];
if (ball.collideStatus == 3) ;
else {
for (var s = 0; s < this.timeSpeed; s++) {
if (ball.collideStatus == 2) {
ball.velocity.y += this.gravity;
}
ball.view.x += ball.velocity.x;
ball.view.y += ball.velocity.y;
if (ball.view.x < LEFT_GROUND) {
ball.velocity.x *= -1 * getBounce();
ball.view.x = LEFT_GROUND;
ball.collideStatus = 2;
}
else if (ball.view.x + ball.view.width > RIGHT_GROUND) {
ball.velocity.x *= -1 * getBounce();
ball.view.x = RIGHT_GROUND - ball.view.width;
ball.collideStatus = 2;
}
if (ball.view.y > 1200) {
ball.velocity.x = 0;
ball.velocity.y = this.velAmount;
if (Math.random() > 0.5) {
ball.view.y = 300;
ball.view.x = 230 - BALL_D / 2;
}
else {
ball.view.y = 300;
ball.view.x = 750 - 230 + 5 - BALL_D / 2;
}
}
for (var j = this.blocks.length - 1; j >= 0; j--) {
var block = this.blocks[j];
var normal = block.collideBall(ball);
if (normal) {
if (block instanceof Circle) {
ball.velocity.symmetricFromNormalVector(normal);
ball.velocity.x *= getBounce();
ball.velocity.y *= getBounce();
ball.collideStatus = 2;
if (block.type == 'specialCircle')
console.log('special circle');
else
console.log('normal Circle');
}
else if (block instanceof RegTriangle) {
if (block.type == 'specialRegTriangle') {
ball.collideStatus = 3;
this.recoverPath(ball);
}
else {
ball.velocity.symmetricFromNormalVector(normal);
ball.velocity.x *= getBounce();
ball.velocity.y *= getBounce();
ball.collideStatus = 2;
}
}
else {
ball.velocity.symmetricFromNormalVector(normal);
ball.velocity.x *= getBounce();
ball.velocity.y *= getBounce();
ball.collideStatus = 2;
}
if (isSpecialBody(block)) {
if (isSpecialCircle(block)) {
this.ballCountAll++;
playSound(SoundType.good);
var newball = createBallItem();
this.addChild(newball.view);
newball.view.y = ball.view.y = block.y;
newball.view.x = ball.view.x = block.x;
newball.collideStatus = 2;
this.balls.push(newball);
ball.velocity.x = 5;
newball.velocity.x = -5;
ball.velocity.y = newball.velocity.y = -20;
this.removeEle(block, this.blocks);
this.removeChild(block.view);
this.pool.recover(block.type, block);
}
}
else {
this.shake(block);
this.gamescore++;
block.num = block.num - 1;
playSound(SoundType.bounce);
if (block.num <= 0) {
new Effect(block, this);
engine.Tween.removeTweens(block.view);
block.view.alpha = 1;
this.removeEle(block, this.blocks);
this.removeChild(block.view);
this.pool.recover(block.type, block);
}
}
}
}
}
}
}
};
PlayScene.prototype.removeEle = function (e, arr) {
var index = arr.indexOf(e);
if (index >= 0) {
arr.splice(index, 1);
}
};
PlayScene.prototype.shake = function (block) {
var startx = -block.view.bg.anchorX;
var starty = -block.view.bg.anchorY;
block.view.bg.x = startx - 2;
block.view.bg.y = starty - 2;
Tween.to(block.view.bg, 1, {
x: startx + 2,
y: starty + 2,
yoyo: 3,
useFrame: true,
onComplete: function () {
block.view.bg.x = startx;
block.view.bg.y = starty;
}
});
};
PlayScene.prototype.recoverPath = function (ball) {
var _this = this;
var time, targX;
if (ball.view.x > 375) {
var detaX = (RIGHT_GROUND - ball.view.x) / 20;
time = detaX < 1 ? 1 : detaX;
targX = RIGHT_GROUND;
}
else {
var detaX = (ball.view.x - LEFT_GROUND) / 20;
time = detaX < 1 ? 1 : detaX;
targX = LEFT_GROUND - BALL_D;
}
ball.view.alpha = 0.80;
Tween.to(ball.view, time, {
x: targX,
y: 1155,
useFrame: true,
onComplete: function () {
ball.view.x = targX;
playSound(SoundType.recover);
Tween.to(ball.view, 20, {
y: 313.4 - 100,
useFrame: true,
onComplete: function () {
var middlex = 375;
var p0 = { x: ball.view.x, y: ball.view.y };
var p1 = { x: (ball.view.x + middlex) / 2, y: ball.view.y - 500 };
var p2 = { x: middlex, y: ball.view.y };
Tween.to(ball.view, 20, {
useFrame: true,
__xx__: 100,
onUpdate: function (value) {
ball.view.x = (1 - value) * (1 - value) * p0.x + 2 * value * (1 - value) * p1.x + value * value * p2.x;
ball.view.y = (1 - value) * (1 - value) * p0.y + 2 * value * (1 - value) * p1.y + value * value * p2.y;
},
onComplete: function () {
_this.currentBallNums++;
_this.ballCount++;
ball.view.visible = false;
ball.view.alpha = 1;
if (_this.ballCount == _this.ballCountAll) {
_this.canShootTag = true;
_this.onShootEnd();
}
}
});
}
});
}
});
};
PlayScene.prototype.ballShoot = function () {
var _this = this;
this.onShootBegin();
var speedX = this.velAmount * Math.sin(this.directionAngle);
var speedY = this.velAmount * Math.cos(this.directionAngle);
var count = 0;
var timer = setInterval(function () {
count++;
playSound(SoundType.shoot);
_this.currentBallNums--;
if (_this.data.currentBallNums < 0)
_this.currentBallNums = 0;
if (count == _this.ballCountAll) {
clearInterval(timer);
_this['aceleTimer'] = setTimeout(function () {
_this.timeSpeed = 3;
_this['aceleTimer'] = 0;
}, ACELE_DELAY);
}
_this.balls[count - 1].collideStatus = 1;
_this.balls[count - 1].velocity.x = speedX;
_this.balls[count - 1].velocity.y = speedY;
var r = 90;
var rad = (_this.shooter.rotation * degToRad);
_this.balls[count - 1].view.x = _this.shooter.x - Math.sin(rad) * r + _this.shooter.anchorX - _this.balls[count - 1].view.anchorX;
_this.balls[count - 1].view.y = _this.shooter.y + Math.cos(rad) * r + _this.shooter.anchorY - _this.balls[count - 1].view.anchorY;
_this.balls[count - 1].view.visible = true;
}, 100);
};
PlayScene.prototype.onShootBegin = function () {
this.line.visible = false;
};
PlayScene.prototype.onShootEnd = function () {
if (this['aceleTimer'])
clearTimeout(this['aceleTimer']);
this.timeSpeed = 1;
this.line.visible = false;
this.currentBallNums = this.ballCountAll;
var blocks = this.blocks.filter(function (block) { return isSpecialCircle(block) || !isSpecialBody(block); });
var failed = false;
blocks.forEach(function (block) {
if (block.ladderNums >= 9) {
failed = true;
}
});
if (failed) {
this.checkGameOver();
}
else {
blocks.forEach(function (block) {
block.y -= getLadderGap();
block.ladderNums++;
if (block.ladderNums >= 9) {
engine.Tween.get(block.view, { loop: true })
.to({ alpha: 0 }, 1000 / 6)
.to({ alpha: 1 }, 1000 / 6);
}
});
this.genBlocks();
}
};
PlayScene.prototype.checkGameOver = function () {
this['pause'] = true;
this.gameOver();
};
PlayScene.prototype.relive = function () {
this['pause'] = false;
var blocks = this.blocks.filter(function (block) { return (isSpecialCircle(block) || !isSpecialBody(block)) && block.ladderNums >= 5; });
for (var _i = 0, blocks_2 = blocks; _i < blocks_2.length; _i++) {
var block = blocks_2[_i];
this.gamescore += block.num;
this.removeEle(block, this.blocks);
block.view.parent && this.removeChild(block.view);
engine.Tween.removeTweens(block.view);
block.view.alpha = 1;
this.pool.recover(block.type, block);
}
};
PlayScene.prototype.gameOver = function () {
console.log("游戏结束");
engine.globalEvent.dispatchEvent('game-over', {});
};
Object.defineProperty(PlayScene.prototype, "skinKey", {
get: function () { return 'Play'; },
enumerable: true,
configurable: true
});
PlayScene.prototype.destroy = function () {
_super.prototype.destroy.call(this);
};
return PlayScene;
}(engine.Container));
//# sourceMappingURL=PlayScene.js.map
var gameWrapper = (function (_super) {
tslib.__extends(gameWrapper, _super);
function gameWrapper() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener("game-reset", _this.reset, _this);
engine.globalEvent.addEventListener("game-start", _this.start, _this);
engine.globalEvent.addEventListener("game-pause", _this.pause, _this);
engine.globalEvent.addEventListener("game-resume", _this.resume, _this);
_this.addEventListener(engine.MouseEvent.CLICK, _this.onTap, _this);
var gameView = _this._gameView = new PlayScene();
_this.addChild(gameView);
return _this;
}
gameWrapper.prototype.reset = function (event) {
injectProps(event.data);
this._gameView.visible = true;
this._gameView.reset();
};
gameWrapper.prototype.start = function (event) {
injectProps(event.data);
this._status = 1;
this._gameView.start();
};
gameWrapper.prototype.pause = function () {
this._gameView.pausegame();
};
gameWrapper.prototype.resume = function () {
this._gameView.resumegame();
};
gameWrapper.prototype.clear = function () {
this._gameView.visible = false;
};
gameWrapper.prototype.onTap = function (event) {
};
return gameWrapper;
}(engine.Container));
//# sourceMappingURL=gameWrapper.js.map
function index (props) {
prepareProps();
injectProps(props);
var instance = new gameWrapper();
return instance;
}
//# sourceMappingURL=index.js.map
return index;
})));
//# sourceMappingURL=main.js.map
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
/**
* Created by rockyl on 2020-01-21.
*/
let customModuleProps = {
};
{
"name": "弹球",
"desc": "弹球模块",
"props": {
"addscore": {
"alias": "消除一个数字加的分数",
"type": "number",
"default": 1
}
},
"assets": [
{
"name": "door",
"url": "//yun.duiba.com.cn/aurora/assets/a6dd9ac99733adbe0f175397dc1f94ee16301847.png",
"uuid": "fc8ca082-90b7-4c22-85cf-9165ffaf47bf",
"ext": ".png"
},
{
"name": "地",
"url": "//yun.duiba.com.cn/aurora/assets/45fca6ffa65282fc61587442c9847b23006c49b0.png",
"uuid": "995b0f29-885a-425d-bb4e-c9f829df4e7d",
"ext": ".png"
},
{
"name": "炮",
"url": "//yun.duiba.com.cn/aurora/assets/c5fd86a2360a34e13bf09600fb1f5742719489db.png",
"uuid": "2a1b3f6e-5bf5-41d1-b6be-39a77728b230",
"ext": ".png"
},
{
"name": "shootline",
"url": "//yun.duiba.com.cn/aurora/assets/ac3bc89a4eccadfa48d3a8abfc834973d6db0aad.png",
"uuid": "0f2c1ee9-c965-4780-82f2-2d8595173952",
"ext": ".png"
},
{
"name": "sq1",
"url": "//yun.duiba.com.cn/aurora/assets/ba9cd3fc1859d4046b6368a45d95f80b35e3fa6e.png",
"uuid": "7b97ea0d-fb86-4842-9fc7-06e6b5ae3882",
"ext": ".png"
},
{
"name": "sq2",
"url": "//yun.duiba.com.cn/aurora/assets/ba6368eb586671cd4045d09126456229dd8dd503.png",
"uuid": "a171bf2c-c6fd-4ba2-aaff-bc8c91a04fe9",
"ext": ".png"
},
{
"name": "sq3",
"url": "//yun.duiba.com.cn/aurora/assets/7960d9aa4b0502c5c791490f575234a66706b63d.png",
"uuid": "d057cc19-66fe-46f6-91c8-cba2686e8d5d",
"ext": ".png"
},
{
"name": "sq4",
"url": "//yun.duiba.com.cn/aurora/assets/e9e31a95fd93bb2941e98156dc08aaa75b7671bf.png",
"uuid": "1865ae57-f5a3-4794-9c43-0b6aa812f971",
"ext": ".png"
},
{
"name": "tri1",
"url": "//yun.duiba.com.cn/aurora/assets/1b4103f506db3ab6739213a30fb3a7d2abc33f3f.png",
"uuid": "b33457fb-4237-4fca-b48c-bc6074bbe29a",
"ext": ".png"
},
{
"name": "tri2",
"url": "//yun.duiba.com.cn/aurora/assets/56b8a873aafed8241f761061204f5f5f890d2a32.png",
"uuid": "738d6649-6e7f-4006-83cc-0b8a904ec071",
"ext": ".png"
},
{
"name": "风扇",
"url": "//yun.duiba.com.cn/aurora/assets/9f5cf7feac84bc6000bea0a038c7df419f3d5dfb.png",
"uuid": "f26b8a49-f8ee-49ac-a24d-4c83858f5c92",
"ext": ".png"
},
{
"name": "风扇1",
"url": "//yun.duiba.com.cn/aurora/assets/48bc2d0380c7a47defad851d5feaf58cd54e7465.png",
"uuid": "e7363682-e025-49ac-a4ef-fc1a61560014",
"ext": ".png"
},
{
"name": "ball",
"url": "//yun.duiba.com.cn/aurora/assets/28dcf9632e585903c87cb234b09d60244d253dde.png",
"uuid": "8a580ff7-2ece-413e-b87a-11b47f2a28ea",
"ext": ".png"
},
{
"name": "circle1",
"url": "//yun.duiba.com.cn/aurora/assets/3c0c22f57ff647f83fbb8811e9e4437c8a1ad0b4.png",
"uuid": "9af5e780-9701-4cb0-afab-9f4aec42a9ca",
"ext": ".png"
},
{
"name": "+1",
"url": "//yun.duiba.com.cn/aurora/assets/d4013a0ed9f5a367ec20be286ba26581c680b20f.png",
"uuid": "aae627c9-dd32-4ae7-b580-baaefdb77a88",
"ext": ".png"
}
],
"events": {
"in": {
"game-reset": {
"alias": "重置"
},
"game-start": {
"alias": "开始",
"data":{
"ballNums":"初始球的数量"
}
},
"game-pause": {
"alias": "暂停"
},
"game-resume": {
"alias": "恢复"
}
},
"out": {
"game-score-update": {
"alias": "分数更新",
"data": {
"score":"分数"
}
},
"game-over": {
"alias": "游戏结束",
"data": {
}
}
}
}
}
\ No newline at end of file
import Body from "./physics/Body";
import { sqrt3 } from "./physics/Const";
export default class Effect {
NUMS_MAX = 11;
_parent: engine.Container;
constructor(block: Body, parent: engine.Container) {
const resName = block.view['bg']['__resName__']
for (let i = 0; i < this.NUMS_MAX; i++) {
const data = this.createItem(resName);
parent.addChild(data.shape);
data.shape.x = block.x;
data.shape.y = block.y;
engine.Tween.get(data.shape).to({ x: data.targetX + block.x, y: block.y + data.targetY, scaleY: 0, scaleX: 0 }, 360).call(() => {
data.shape.parent && data.shape.parent.removeChild(data.shape);
});
}
}
createItem(resName: string) {
const moveDisMax = 100;
const squareSize = 100;
const shape = new engine.Shape();
const shapeType = this.getShapeType(resName);
if (shapeType == 'circle') {
shape.beginFill(this.getShapeColor(resName));
shape.drawCircle(0, 0, squareSize / 2);
shape.endFill();
} else if (shapeType == 'tri') {
shape.beginFill(this.getShapeColor(resName));
shape.moveTo(0, -squareSize * sqrt3 / 3);
shape.lineTo(squareSize / 2, squareSize * sqrt3 / 6);
shape.lineTo(-squareSize / 2, squareSize * sqrt3 / 6);
shape.endFill();
} else if (shapeType == 'sq') {
shape.beginFill(this.getShapeColor(resName));
shape.drawRect(-squareSize / 2, -squareSize / 2, squareSize, squareSize);
shape.endFill();
}
const scale = Math.random() * 0.7 + 0.3;
const rotation = Math.random() * 360;
const angle = Math.random() * Math.PI * 2;
const dis = moveDisMax / 2 + moveDisMax / 2 * Math.random();
const targetX = Math.sin(angle) * dis;
const targetY = Math.cos(angle) * dis;
shape.scaleX = shape.scaleY = scale;
shape.rotation = rotation;
return { shape: shape, targetX: targetX, targetY: targetY };
}
getShapeType(resName: string) {
if (resName == 'circle1')
return 'circle';
if (resName.indexOf('tri') > -1)
return 'tri';
if (resName.indexOf('sq') > -1)
return 'sq';
return 'circle'
}
getShapeColor(resName: string) {
if (resName == 'circle1')
return 0xffca55;
if (resName == 'sq1')
return 0xfa7782;
if (resName == 'sq2')
return 0xf677ce;
if (resName == 'sq3')
return 0xffac84;
if (resName == 'sq4')
return 0xffca55;
if (resName == 'tri1')
return 0x2db0ee;
if (resName == 'tri2')
return 0x86e45f;
return 0xffca55
}
}
\ No newline at end of file
import { props } from "../props";
import { getBlocks, resetCounter } from "./blockGen";
import { createBallItem } from "./factory/createBall";
import createCircle from "./factory/createCircle";
import createRegTriangle from "./factory/createRegTriangle";
import createSpecialRegTriangle from "./factory/createSpecialRegTriangle";
import createSpeialCircle from "./factory/createSpeialCircle";
import createSquare from "./factory/createSquare";
import { ACELE_DELAY, BALL_D, LADDER_NUMS, LEFT_GROUND, RIGHT_GROUND } from "./gameconsts";
import { Ball } from "./physics/Ball";
import Body from "./physics/Body";
import { Circle } from "./physics/Circle";
import { degToRad, radToDeg } from "./physics/Const";
import { RegTriangle } from "./physics/RegTriangle";
import Pool from "./Pool";
import { getBounce, getLadderGap, getLadderHPosition, getLadderPosition, isSpecialBody, isSpecialCircle, playSound, SoundType, getTextureByName } from "./utils";
import Effect from "./Effect";
import { Tween } from "./tween/Tween";
export default class PlayScene extends engine.Container {
initEvents() {
this.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);
this.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onTouchBegin, this);
}
protected removeEvents() {
this.removeEventListener(engine.MouseEvent.MOUSE_DOWN, this.onTouchBegin, this);
this.removeEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);
}
/** 重力因子,默认1 */
private gravity = 1;
/** 物理时间缩放因子 */
private timeSpeed = 1;
/** 初始的球数 */
private INIT_BALL_NUMS = window['INIT_BALL_NUMS'];
/** 当前的球列表 */
private balls: Ball[] = [];
/** 对象池 */
pool = new Pool();
/** 砖块列表 */
blocks: Body[] = [];
/** 发射参考线 */
line: engine.Sprite;
shooter: engine.Sprite;
/** 发射的球的数量,在碰到增加道具的时候数值应该增加 */
private ballCountAll;
/** 球的发射速度,默认30 */
private velAmount = 25;
/** 球的投射角度 */
private directionAngle = 0;
/** false代表正在发射,无法再次发射。所有的球回收后置为true 。默认true*/
canShootTag = true;
/** 已经回收的球的数量,只有全部回收了才可以继续发射。发射后置为0.默认0. */
ballCount: number;
//游戏数据
data:any = {
score:0,
currentBallNums:5,
};
constructor(){
super();
// this.pausegame();
this.INIT_BALL_NUMS = window['INIT_BALL_NUMS'] = 1;
this.initEvents();
this.once(engine.Event.ADDED_TO_STAGE, this.initScene, this);
}
reset(){
const blocks = this.blocks.filter(block=>!isSpecialBody(block));
for(const block of blocks){
this.removeEle(block,this.blocks);
block.view.parent&&block.view.parent.removeChild(block.view);
this.pool.recover(block.type,block);
}
}
start(){
this.gamescore = 0;
this.currentBallNums = props.countDown;
this.startGame();
}
pausegame(){
this['pause'] = true;
}
resumegame(){
this['pause'] = false;
}
get currentBallNums(){
return this.data.currentBallNums;
}
set currentBallNums(num){
this.data.currentBallNums = num;
this.ballNums.text = num;
}
get gamescore(){
return this.data.score;
}
set gamescore(num){
this.data.score = num;
this.score.text = num;
engine.globalEvent.dispatchEvent('game-score-update', {
score: num,
});
}
initScene(){
// console.log(this.stage.width,this.stage.height);
this.initUI();
this.startGame();
engine.Tween.get(this['ele1'], { loop: true }).set({ rotation: 0 }).to({ rotation: -360 }, 3000);
engine.Tween.get(this['ele2'], { loop: true }).set({ rotation: 0 }).to({ rotation: 360 }, 3000);
createSpecialRegTriangle(this, 60, 250, 200, 55, 'specialRegTriangleTop');//2只鸡
createSpecialRegTriangle(this, 750 - 60, 250, 200, -55, 'specialRegTriangleTop');//2只鸡
createSpecialRegTriangle(this, 150, 90, 500, 4, 'specialRegTriangleTop');//顶部两根棍子
createSpecialRegTriangle(this, 750 - 150, 90, 500, -4, 'specialRegTriangleTop');//顶部两根棍子
createSpecialRegTriangle(this, 230, 250, 40, 0, 'specialRegTriangleTop');//2个发射筒
createSpecialRegTriangle(this, 750 - 230 + 5, 250, 40, 0, 'specialRegTriangleTop');//2个发射筒
createSpecialRegTriangle(this, 170, 1271, 400, 52);//2块斜面地面
createSpecialRegTriangle(this, 750 - 170, 1271, 400, -52);//2块斜面地面
createSpecialRegTriangle(this, 232, 1351 - 3 - 5 - 3, 400, 30);//2块斜面地面2
createSpecialRegTriangle(this, 750 - 232, 1351 - 3 - 5 - 3, 400, -30);//2块斜面地面2
}
score:engine.Label;
ground:engine.Sprite;
door:engine.Sprite;
ele1:engine.Sprite;
ele2:engine.Sprite;
ballNums:engine.Label;
initUI(){
this.score = new engine.Label();
this.score.x = 118;
this.score.y = 13;
this.score.size = 24;
this.score.fillColor = 0xffffff;
this.addChild(this.score);
this.ground = this.createSprite("地",0,1130);
this.ground.visible = true;
this.addChild(this.ground);
this.door = this.createSprite("door",0,68);
this.addChild(this.door);
this.ele1 = this.createSprite("风扇",56,1130,20,21);
this.addChild(this.ele1);
this.ele2 = this.createSprite("风扇",698,1130,20,21);
this.addChild(this.ele2);
var ele1_t = this.createSprite("风扇1",54,1078);
this.addChild(ele1_t);
var ele2_t = this.createSprite("风扇1",693,1078);
this.addChild(ele2_t);
this.shooter = this.createSprite("炮",375,222,40,40);
this.addChild(this.shooter);
this.ballNums = new engine.Label();
this.ballNums.x = 333;
this.ballNums.y = 203;
this.ballNums.width = 85;
this.ballNums.height = 43;
this.ballNums.textAlign = engine.TEXT_ALIGN.CENTER;
this.ballNums.verticalAlign = engine.VERTICAL_ALIGN.MIDDLE;
this.ballNums.size = 38;
this.ballNums.fillColor = 0x00ff00;
this.addChild(this.ballNums);
this.line = this.createSprite("shootline",375,222,5,-74);
this.addChild(this.line);
}
createSprite(tname:string,x,y,anchorx=0,anchory=0){
var sp = new engine.Image(getTextureByName(tname));
sp.x = x-anchorx;
sp.y = y-anchory;
sp.anchorX = anchorx;
sp.anchorY = anchory;
return sp;
}
//原来部分挂载在window下的变量
setWindowData(){
window['numsP'] = 0.5;
window['INIT_BALL_NUMS']=1;
}
private startGame() {
this.setWindowData();
this['pause'] = false;
this.reviveTag = 0;
resetCounter();
this.gamescore = 0;
this.ballCountAll = this.INIT_BALL_NUMS
this.currentBallNums = this.ballCountAll;
this.balls.forEach(ball => ball.view.parent && ball.view.parent.removeChild(ball));
this.balls = new Array();
for (let i = 0; i < this.INIT_BALL_NUMS; i++) {
const ball = createBallItem()
this.addChild(ball.view);
ball.view.y = this.shooter.y + 90+this.shooter.anchorY-ball.view.anchorY;
ball.view.x = this.shooter.x+this.shooter.anchorX-ball.view.anchorX;
ball.view.visible = false;
this.balls.push(ball);
}
this.onShootEnd();
// this['guide'].visible = localStorage.getItem('guide') !== '1';
// this['guide'].once(engine.MouseEvent.MOUSE_DOWN, this.onGuildeTap, this);
}
onGuildeTap() {
this['guide'].visible = false;
localStorage.setItem('guide', '1');
}
private genBlocks() {
const { blocksInfo, specialBallPosition } = getBlocks(this.ballCountAll);
if (specialBallPosition > -1) {
createSpeialCircle(this, getLadderHPosition(specialBallPosition), getLadderPosition(LADDER_NUMS - 1), 0);
}
console.log("创建障碍物",blocksInfo,specialBallPosition);
for (const block of blocksInfo) {
const { position, type, nums } = block;
if (type == 1) {
createSquare(this, getLadderHPosition(position), getLadderPosition(LADDER_NUMS - 1), nums);
}
else if (type == 2) {
createRegTriangle(this, getLadderHPosition(position), getLadderPosition(LADDER_NUMS - 1), nums);
}
else {
createCircle(this, getLadderHPosition(position), getLadderPosition(LADDER_NUMS - 1), nums);
}
}
}
onTouchMove(e: engine.MouseEvent) {
const detaX = e.localX - 375;
const detaY = e.localY - 0;
if (detaY != 0) {
let angle = Math.atan(detaX / detaY);
if (angle > Math.PI / 180 * 75)
angle = Math.PI / 180 * 75;
if (angle < -Math.PI / 180 * 75)
angle = -Math.PI / 180 * 75;
this.line.rotation = this.shooter.rotation = -angle * radToDeg;
this.directionAngle = angle;
this.updateLine();
}
}
updateLine() {
this.line.scaleY = (1 - Math.abs(this.line.rotation) / 90 * 0.5);
}
onTouchEnd(e: engine.MouseEvent) {
if (this['pause']) return;
this.removeEventListener(engine.MouseEvent.MOUSE_MOVE, this.onTouchMove, this);
this.canShootTag = false;
this.ballCount = 0;
this.ballShoot();
}
onTouchBegin(e: engine.MouseEvent) {
if (this['pause']) return;
if (!this.canShootTag) return;
this.line.visible = true;
//连线起始点到手指
this.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onTouchMove, this);
this.once(engine.MouseEvent.MOUSE_UP, this.onTouchEnd, this);
const detaX = e.localX - 375;
const detaY = e.localY - 0;
if (detaY != 0) {
let angle = Math.atan(detaX / detaY);
if (angle > Math.PI / 180 * 75)
angle = Math.PI / 180 * 75;
if (angle < -Math.PI / 180 * 75)
angle = -Math.PI / 180 * 75;
this.line.rotation = this.shooter.rotation = -angle * radToDeg;
this.directionAngle = angle;
this.updateLine();
}
}
// tslint:disable-next-line:cyclomatic-complexity
private onEnterFrame() {//物理循环计算
Tween.flush();
for (const ball of this.balls) {
if (ball.collideStatus == 3) { //回收阶段(不应用重力,不应用检测,以最快速度回到初始位置)
//回收用Tween onComplete后加,collideStatus=1;
} else {
//计算次数
for (let s = 0; s < this.timeSpeed; s++) {
if (ball.collideStatus == 2) {//重力计算
ball.velocity.y += this.gravity;
}
ball.view.x += ball.velocity.x;
ball.view.y += ball.velocity.y;
// console.log("移动",ball.velocity.x,ball.velocity.y,ball.collideStatus);
//两壁碰撞检测,防左右墙壁穿透
if (ball.view.x < LEFT_GROUND) {
ball.velocity.x *= -1 * getBounce();
ball.view.x = LEFT_GROUND;//位置矫正
ball.collideStatus = 2;
} else if (ball.view.x+ball.view.width > RIGHT_GROUND) {
ball.velocity.x *= -1 * getBounce();
ball.view.x = RIGHT_GROUND-ball.view.width;//位置矫正
ball.collideStatus = 2;
}
if (ball.view.y > 1200) {
ball.velocity.x = 0;
ball.velocity.y = this.velAmount;
if (Math.random() > 0.5) {
ball.view.y = 300;
ball.view.x = 230-BALL_D/2;
} else {
ball.view.y = 300;
ball.view.x = 750 - 230 + 5 - BALL_D/2;
}
}
for (let j = this.blocks.length - 1; j >= 0; j--) {
const block: Body = this.blocks[j];
const normal = block.collideBall(ball);//对每个球和砖块进行碰撞检测
// console.log("碰撞检测",normal);
if (normal) {
//碰撞类型检测
if (block instanceof Circle) {//如果是圆形,那么要判断是否是特殊球
ball.velocity.symmetricFromNormalVector(normal);
ball.velocity.x *= getBounce();
ball.velocity.y *= getBounce();
ball.collideStatus = 2;
if (block.type == 'specialCircle')
console.log('special circle')
else
console.log('normal Circle')
}
else if (block instanceof RegTriangle) {
if (block.type == 'specialRegTriangle') {
ball.collideStatus = 3;
this.recoverPath(ball);
} else {
ball.velocity.symmetricFromNormalVector(normal);
ball.velocity.x *= getBounce();
ball.velocity.y *= getBounce();
ball.collideStatus = 2;
}
} else {
ball.velocity.symmetricFromNormalVector(normal);
ball.velocity.x *= getBounce();
ball.velocity.y *= getBounce();
ball.collideStatus = 2;
}
if (isSpecialBody(block)) {
//如果是其他特殊的,不处理
if (isSpecialCircle(block)) {//如果是特殊的圆,那么创建一个新的球,移除特殊圆
this.ballCountAll++;
playSound(SoundType.good);
const newball = createBallItem()
this.addChild(newball.view);
newball.view.y = ball.view.y = block.y;
newball.view.x = ball.view.x = block.x;
newball.collideStatus = 2;
this.balls.push(newball);
ball.velocity.x = 5;
newball.velocity.x = -5;
ball.velocity.y = newball.velocity.y = -20;
this.removeEle(block, this.blocks);
this.removeChild(block.view);
this.pool.recover(block.type, block);
}
} else {
this.shake(block);
this.gamescore++;
block.num = block.num - 1;
playSound(SoundType.bounce);
if (block.num <= 0) {
new Effect(block, this);
//回收加动效
engine.Tween.removeTweens(block.view);
block.view.alpha = 1;
this.removeEle(block, this.blocks);
this.removeChild(block.view);
this.pool.recover(block.type, block);
}
}
}
}
}
// if(ball.view.visible){
// console.log("移动",ball.view.x,ball.view.y,
// ball.velocity.x,ball.velocity.y,
// ball.collideStatus);
// }
}
}
}
private removeEle(e, arr) {
const index = arr.indexOf(e);
if (index >= 0) {
arr.splice(index, 1)
}
}
private shake(block) {
// console.log("playScene震动1---------",block.view.bg.x,block.view.bg.y);
var startx = -block.view.bg.anchorX;
var starty = -block.view.bg.anchorY;
block.view.bg.x = startx-2;
block.view.bg.y = starty-2;
// console.log("playScene震动2---------",block.view.bg.x,block.view.bg.y);
Tween.to(block.view.bg, 1, {
x: startx+2,
y: starty+2,
yoyo: 3,
useFrame: true,
onComplete: () => {
block.view.bg.x = startx;
block.view.bg.y = starty;
// console.log("playScene震动3---------",block.view.bg.x,block.view.bg.y);
}
})
}
//回收路径
private recoverPath(ball) {
let time, targX;
//右边
if (ball.view.x > 375) {
const detaX = (RIGHT_GROUND - ball.view.x) / 20;
time = detaX < 1 ? 1 : detaX;
targX = RIGHT_GROUND;// + BALL_D;
}
//左边
else {
const detaX = (ball.view.x - LEFT_GROUND) / 20;
time = detaX < 1 ? 1 : detaX;
targX = LEFT_GROUND - BALL_D;
}
ball.view.alpha = 0.80;
Tween.to(ball.view, time, {
x: targX,
y: 1155,
useFrame: true,
onComplete: () => {
ball.view.x = targX;
playSound(SoundType.recover);
Tween.to(ball.view, 20, {
y: 313.4 - 100,
useFrame: true,
onComplete: () => {
const middlex = 375;
const p0 = { x: ball.view.x, y: ball.view.y };
const p1 = { x: (ball.view.x + middlex) / 2, y: ball.view.y - 500 };
const p2 = { x: middlex, y: ball.view.y };
Tween.to(ball.view, 20, {
useFrame: true,
__xx__: 100,
onUpdate: (value) => {
ball.view.x = (1 - value) * (1 - value) * p0.x + 2 * value * (1 - value) * p1.x + value * value * p2.x;
ball.view.y = (1 - value) * (1 - value) * p0.y + 2 * value * (1 - value) * p1.y + value * value * p2.y;
},
onComplete: () => {
this.currentBallNums++;
this.ballCount++;
ball.view.visible = false;
ball.view.alpha = 1;
if (this.ballCount == this.ballCountAll) {
this.canShootTag = true;
this.onShootEnd();
}
}
})
// ball.view.visible = false;
// Tween.to(ball.view, 15, {
// x: this.line.x,
// useFrame: true,
// onComplete: () => {
// this.data.currentBallNums++;
// this.ballCount++;
// if (this.ballCount == this.ballCountAll) {
// this.canShootTag = true;
// this.onShootEnd();
// }
// }
// })
}
})
}
})
}
/**
* 发射球
*/
private ballShoot() {
this.onShootBegin();
//切分速度向量
const speedX = this.velAmount * Math.sin(this.directionAngle);
const speedY = this.velAmount * Math.cos(this.directionAngle);
let count = 0;
const timer = setInterval(() => {
count++;
playSound(SoundType.shoot);
this.currentBallNums--;
if (this.data.currentBallNums < 0)
this.currentBallNums = 0;
if (count == this.ballCountAll) {
clearInterval(timer);
this['aceleTimer'] = setTimeout(() => {
this.timeSpeed = 3;
this['aceleTimer'] = 0;
}, ACELE_DELAY);
}
this.balls[count - 1].collideStatus = 1;
this.balls[count - 1].velocity.x = speedX;
this.balls[count - 1].velocity.y = speedY;
const r = 90;
const rad = (this.shooter.rotation * degToRad);
this.balls[count - 1].view.x = this.shooter.x - Math.sin(rad) * r+this.shooter.anchorX-this.balls[count - 1].view.anchorX;
this.balls[count - 1].view.y = this.shooter.y + Math.cos(rad) * r+this.shooter.anchorY-this.balls[count - 1].view.anchorY;
this.balls[count - 1].view.visible = true;
}, 100)
}
onShootBegin() {
this.line.visible = false;
}
onShootEnd() {
if (this['aceleTimer']) clearTimeout(this['aceleTimer']);
this.timeSpeed = 1;
this.line.visible = false;
this.currentBallNums = this.ballCountAll;
const blocks = this.blocks.filter(block => isSpecialCircle(block) || !isSpecialBody(block));
let failed = false;
blocks.forEach(block => {
// if (block.ladderNums >= 1) {
if (block.ladderNums >= 9) {
failed = true;
}
});
if (failed) {
this.checkGameOver();
} else {
blocks.forEach(block => {
block.y -= getLadderGap();
block.ladderNums++;
if (block.ladderNums >= 9) {
engine.Tween.get(block.view, { loop: true })
.to({ alpha: 0 }, 1000 / 6)
.to({ alpha: 1 }, 1000 / 6)
// .to({ rotation: block.view.rotation + 15 }, 1000 / 6)
// .to({ rotation: block.view.rotation }, 1000 / 6)
// Tween.to(block.view, 10, { useFrame: true, yoyo: true, rotation: block.view.rotation+ })
}
});
this.genBlocks();
}
}
reviveTag = 0;
checkGameOver() {
this['pause'] = true;
const num = window['revivePlugId'];
// if (this.reviveTag || userCredits < costCredits) { //已经复活过了或者钱不够直接死
this.gameOver();
// }
// else {
// const panel = PanelCtrl.instance.show(ModuleTypes.RELIVE_PANEL);
// panel.once('onSure', () => {
// this.relive();
// this.reviveTag = 1;
// }, this);
// panel.once('onCancel', () => {
// this.gameOver();
// }, this);
// }
}
relive() {
this['pause'] = false;
const blocks = this.blocks.filter(block => (isSpecialCircle(block) || !isSpecialBody(block)) && block.ladderNums >= 5);
for (const block of blocks) {
this.gamescore += block.num;
this.removeEle(block, this.blocks);
block.view.parent && this.removeChild(block.view);
engine.Tween.removeTweens(block.view);
block.view.alpha = 1;
this.pool.recover(block.type, block);
}
}
gameOver() {
console.log("游戏结束");
engine.globalEvent.dispatchEvent('game-over', {
});
// Loading.instace.show();
// submit((success) => {
// Loading.instace.hide();
// if (!success) return;
// let panel: Panel;
// const getOrderStatus = DataManager.ins.getCustomOrderStatusData
// if (getOrderStatus.lottery) {
// panel = PanelCtrl.instance.show(ModuleTypes.PRIZE_PANEL)
// } else {
// panel = PanelCtrl.instance.show(ModuleTypes.NO_PRIZE_PANEL)
// }
// }, this.data.score)
}
get skinKey() { return 'Play' }
destroy() {
super.destroy();
}
}
\ No newline at end of file
export default class Pool {
pool;
constructor() {
this.pool = {};
}
takeOut(name) {
if (this.pool[name] && this.pool[name].length) {
return this.pool[name].shift();
}
return false;
}
recover(name, obj) {
if (!this.pool[name]) {
this.pool[name] = [];
}
this.pool[name].push(obj);
}
}
\ No newline at end of file
import { LADDER_H_NUMS } from "./gameconsts";
import { shuffle } from "./utils";
let counter;
export const resetCounter = () => {
counter = 1;
}
export const getCounter = () => counter;
const getBlockShape = () => {
const list = shuffle([1, 2, 3]);
return list[0];
}
const random = (start: number, end: number) => {
return start + (end - start) * Math.random();
}
const getNums = (currBallNums: number) => {
return Math.ceil(currBallNums * random(1 * window['numsP'], 3.5 * window['numsP']));
}
const getNums2 = (currBallNums: number) => {
return Math.ceil(currBallNums * random(4 * window['numsP'], 7 * window['numsP']));
}
const getSpecialNumBlocksNums = (currBallNums: number) => {
if (currBallNums < 20) return 1;
if (currBallNums < 50) return 2;
return 3;
}
export const getBlocks = (currBallNums: number) => {
const blockNums = Math.random() > 0.3 ? 3 : 2;
let specialBall = 0;
if (counter % 3 === 0) { // 每隔3行出现一个+球buff
specialBall = 1;
}
let list = [];
for (let i = 0; i < LADDER_H_NUMS; i++) {
list.push(i);
}
list = shuffle(list);
const blockPositions = list.slice(0, blockNums);
const specialBallPosition = list[list.length - 1];
const blocksInfo = [];
for (let j = 0; j < blockPositions.length; j++) {
const p = blockPositions[j];
let nums = getNums(currBallNums);
const specialNumBlocksNums = getSpecialNumBlocksNums(currBallNums);
if (Math.random() < 0.3 && j < specialNumBlocksNums) {
nums = getNums2(currBallNums);
}
if (currBallNums >= 50)
nums = getNums2(currBallNums);
// console.log("添加nums",nums);
blocksInfo.push({
position: p,
type: getBlockShape(),
nums: nums||2
});
}
counter++;
return {
blocksInfo: blocksInfo,
specialBallPosition: specialBall ? specialBallPosition : -1
};
}
\ No newline at end of file
import { BALL_D } from "../gameconsts";
import { Ball } from "../physics/Ball";
import { getTextureByName } from "../utils";
export default () => {
}
export const createBallItem = () => {
const picTex = getTextureByName("ball");
const pic = new engine.Image(picTex);
pic.mouseEnabled = false;
pic.anchorX = pic.width / 2;
pic.anchorY = pic.height / 2;
const ball = new Ball(BALL_D / 2, pic);
return ball;
}
\ No newline at end of file
import { Circle } from "../physics/Circle";
import PlayScene from "../PlayScene";
import { getTextureByName } from "../utils";
export default (that: PlayScene, x, y, num) => {
let block = that.pool.takeOut("circle");
//位置偏移
var anchorx = 0;
var anchory = 0;
if (!block) {
const sprite = new engine.Sprite();
sprite.mouseEnabled = sprite.mouseChildren = false;
//背景
const shape = new engine.Image(getTextureByName('circle1'));
shape['__resName__'] = 'circle1';
const radius = shape.width / 2;
const length = radius * 2;
shape.anchorX = shape.width / 2;
shape.anchorY = shape.height / 2;
anchorx = radius;
anchory = radius;
sprite["bg"] = shape;
sprite.addChild(shape);
shape.x = -anchorx;
shape.y = -anchory;
//数字
const txt = new engine.TextField();
txt.width = length;
txt.height = length;
txt.anchorX = length / 2;
txt.anchorY = length / 2;
txt.size = 30;
txt.fillColor = 0xffffff;
txt.textAlign = engine.TEXT_ALIGN.CENTER;
txt.verticalAlign = engine.VERTICAL_ALIGN.MIDDLE;
sprite["txt"] = txt;
sprite.addChild(txt);
txt.x = -anchorx;
txt.y = -anchory;
block = new Circle(radius, sprite);
}
that.addChild(block.view)
block.x = x;
block.y = y;
// console.log("圆形偏移",anchorx,anchory);
block.num = num;
that.blocks.push(block);
block.ladderNums = 1;
}
\ No newline at end of file
import { RegTriangle } from "../physics/RegTriangle";
import PlayScene from "../PlayScene";
import { getTextureByName } from "../utils";
export default (that: PlayScene, x, y, num) => {
let block = that.pool.takeOut("regTriangle");
const picType = Math.ceil(Math.random() * 2);
const pic = new engine.Sprite(getTextureByName(`tri${picType}`));
pic.anchorX = pic.width / 2;
pic.anchorY = pic.height/2;// * .65;
//位置偏移
var anchorx = 0;
var anchory = 0;
anchorx = pic.width/2;
anchory = pic.height/2;//*0.65;
if (!block) {
const sprite = new engine.Sprite();
sprite.mouseEnabled = sprite.mouseChildren = false;
//背景
const length = pic.width;
const height = pic.height;
// console.log("三角形的文字偏移",pic.width,pic.height);
sprite["bg"] = pic;
sprite.addChild(pic);
pic.x = -anchorx;
pic.y = -anchory;
//数字
const txt = new engine.TextField();
txt.width = length;
txt.height = height;
txt.anchorX = length / 2;
txt.anchorY = height /2;//*0.65;
txt.size = 26;
txt.fillColor = 0xffffff;
txt.textAlign = engine.TEXT_ALIGN.CENTER;
txt.verticalAlign = engine.VERTICAL_ALIGN.MIDDLE;
sprite["txt"] = txt;
sprite.addChild(txt);
txt.x = -anchorx;
txt.y = -anchory+(anchorx-anchory)*2;
block = new RegTriangle(length, sprite);
} else {
if (block.view["bg"]) {
block.view.removeChild(block.view["bg"]);
block.view["bg"] = pic;
block.view.addChild(pic);
block.view.addChild(block.view['txt']);
pic.x = -anchorx;
pic.y = -anchory;
block.view['txt'].x = -anchorx;
block.view['txt'].y = -anchory+(anchorx-anchory)*2;
}
}
block.view["bg"]['__resName__'] = `tri${picType}`;
that.addChild(block.view)
block.x = x;
block.y = y;
// console.log("三角形偏移",anchorx,anchory);
block.rotation = Math.random() * 360;
block.num = num;
that.blocks.push(block);
block.ladderNums = 1;
}
\ No newline at end of file
import { sqrt3 } from "../physics/Const";
import { RegTriangle } from "../physics/RegTriangle";
import PlayScene from "../PlayScene";
export default (that: PlayScene, x, y, length, rotation, key = 'specialRegTriangle') => {
let block: RegTriangle;
const sprite = new engine.Sprite();
sprite.visible = false;//window['debugPhysics'];
sprite.alpha = 0.7;
sprite.mouseEnabled = sprite.mouseChildren = false;
// console.log("显示",window['debugPhysics'])
//背景
const shape = new engine.Shape();
shape.beginFill(0xcccccc);
shape.moveTo(0, -length * sqrt3 / 3);
shape.lineTo(length / 2, length * sqrt3 / 6);
shape.lineTo(-length / 2, length * sqrt3 / 6);
shape.endFill();
sprite["bg"] = shape;
sprite.addChild(shape);
//数字
const txt = new engine.TextField();
txt.width = length;
txt.height = length;
txt.anchorX = length / 2;
txt.anchorY = length / 2;
txt.size = 25;
txt.fillColor = 0xffffff;
txt.textAlign = engine.TEXT_ALIGN.CENTER;
txt.verticalAlign = engine.VERTICAL_ALIGN.MIDDLE;
sprite["txt"] = txt;
sprite.addChild(txt);
console.log("特殊建筑三角形",length);
block = new RegTriangle(length, sprite);
block.type = key;
that.addChild(block.view)
block.x = x;
block.y = y;
block.rotation = rotation;
// block.num = num
that.blocks.push(block);
}
\ No newline at end of file
import { Circle } from "../physics/Circle";
import PlayScene from "../PlayScene";
import { getTextureByName } from "../utils";
export default (that: PlayScene, x, y, num) => {
let block: Circle = that.pool.takeOut("specialCircle");
const radius = (getTextureByName('+1') as engine.Texture).orig.width / 2;
const length = radius * 2;
if (!block) {
const sprite = new engine.Sprite();
sprite.mouseEnabled = sprite.mouseChildren = false;
//背景
const shape = new engine.Sprite(getTextureByName('+1'));
shape.anchorX = shape.width / 2;
shape.anchorY = shape.height / 2;
sprite["bg"] = shape;
sprite.addChild(shape);
shape.x = -shape.width/2;
shape.y = -shape.height/2;
block = new Circle(radius, sprite);
block.type = 'specialCircle';
} else {
if (block.radius != radius) {
block.view.bg.clear();
block.view.bg.beginFill(0xcccccc);
block.view.bg.drawCircle(0, 0, radius);
block.view.bg.endFill();
}
}
that.addChild(block.view)
block.x = x;
block.y = y;
block.num = num;
that.blocks.push(block);
block.ladderNums = 1;
}
\ No newline at end of file
import { Square } from "../physics/Square";
import PlayScene from "../PlayScene";
import { getTextureByName } from "../utils";
export default (that: PlayScene, x, y, num) => {
const picType = Math.ceil(Math.random() * 4);
const pic = new engine.Sprite(getTextureByName(`sq${picType}`));
pic.anchorX = pic.width / 2;
pic.anchorY = pic.height / 2;
let block: Square = that.pool.takeOut("square");
//位置偏移
var anchorx = pic.width/2;
var anchory = pic.height/2;
if (!block) {
const sprite = new engine.Sprite();
sprite.mouseEnabled = sprite.mouseChildren = false;
//背景
const length = pic.width;
sprite["bg"] = pic;
sprite.addChild(pic);
pic.x = -anchorx;
pic.y = -anchory;
//数字
const txt = new engine.TextField();
txt.width = length;
txt.height = pic.height;
txt.anchorX = length / 2;
txt.anchorY = pic.height / 2;
txt.size = 30;
txt.fillColor = 0xffffff;
txt.textAlign = engine.TEXT_ALIGN.CENTER;
txt.verticalAlign = engine.VERTICAL_ALIGN.MIDDLE;
sprite["txt"] = txt;
sprite.addChild(txt);
txt.x = -anchorx;
txt.y = -anchory;
// that.view.addChild(sprite)
block = new Square(length, sprite);
}
//初始化
else {
if (block.view["bg"]) {
block.view.removeChild(block.view["bg"]);
block.view["bg"] = pic;
block.view.addChild(pic);
block.view.addChild(block.view['txt']);
pic.x = -anchorx;
pic.y = -anchory;
block.view['txt'].x = -anchorx;
block.view['txt'].y = -anchory;
}
}
block.view["bg"]['__resName__'] = `sq${picType}`;
that.addChild(block.view)
// console.log("方形偏移",anchorx,anchory);
block.x = x;
block.y = y;
block.num = num;
block.rotation = Math.random() * 360;
// block.rotation = Math.random()>0.5 ? 0 : 45;
that.blocks.push(block);
block.ladderNums = 1;
}
\ No newline at end of file
import { injectProps } from "../props";
import PlayScene from "./PlayScene";
export class gameWrapper extends engine.Container{
private _status;
private _gameView: PlayScene;
constructor() {
super();
engine.globalEvent.addEventListener("game-reset", this.reset, this);
engine.globalEvent.addEventListener("game-start", this.start, this);
engine.globalEvent.addEventListener("game-pause", this.pause, this);
engine.globalEvent.addEventListener("game-resume", this.resume, this);
this.addEventListener(engine.MouseEvent.CLICK, this.onTap, this);
let gameView = this._gameView = new PlayScene();
this.addChild(gameView);
// gameView.reset()
// gameView.start()
}
reset(event: engine.Event) {
injectProps(event.data);
this._gameView.visible = true;
this._gameView.reset();
}
start(event: engine.Event) {
injectProps(event.data);
this._status = 1;
this._gameView.start();
}
pause() {
this._gameView.pausegame();
}
resume() {
this._gameView.resumegame();
}
// revive() {
// this._gameView.revive();
// }
clear() {
this._gameView.visible = false;
}
private onTap(event) {
// this._gameView.tap(event);
}
}
\ No newline at end of file
export const BALL_D = 34;//球大小
export const LEFT_GROUND = 80;//左侧墙壁
export const RIGHT_GROUND = 675;//右侧墙壁
export const LADDER_START = 350-100;//
export const LADDER_END = 1150;
export const LADDER_NUMS = 10;
export const LADDER_H_START = 130;
export const LADDER_H_END = 710;
export const LADDER_H_NUMS = 7;
export const bounceStart = 0.9;
export const bounceEnd = 0.99;
export const ACELE_DELAY = 4000;
\ No newline at end of file
// tslint:disable:prefer-const
// tslint:disable:no-var-keyword
import { Vector } from "./Vector";
import { Projection } from "./Projection";
export class Ball {
type;
collideNormal;
isCollide;
/**
* 1:射出阶段(应用碰撞检测,不应用重力,可根据加速,碰壁或bloc变为2,碰底后变为3)。
* 2:碰撞阶段(应用重力和检测,可根据加速)。
* 3:回收阶段(不应用重力,不应用检测,以最快速度回到初始位置) */
collideStatus = 1;
recoverDirection; //false为左,true为右
recoverMark = false;
radius;
view;
velocity = new Vector();
constructor(radius, view) {
this.radius = radius;
this.view = view;
}
//新增,矫正偏移
get _viewx(){
return this.view.x;//+this.view.anchorX;
}
get _viewy(){
return this.view.y;//+this.view.anchorY;
}
//圆形在投影轴上的投影对象
project(axis) {
var scalars = []; //用于存放在投影轴上的投影
var dotProduct = new Vector(this.view.x, this.view.y).dotProduct(axis); //得到圆心向量在投影轴上的投影
// scalars.push(dotProduct);
scalars.push(dotProduct + this.radius);
scalars.push(dotProduct - this.radius);
//得到圆投影对象的最大值与最小值
// return new Projection(Math.min.apply(Math, scalars), Math.max.apply(Math, scalars));
return new Projection(dotProduct - this.radius, dotProduct + this.radius)
};
}
\ No newline at end of file
import { Ball } from "./Ball";
export default class Body {
type: string;
userData: any;
view:any;
ladderNums = 1;
collideBall(ball:Ball):any {
}
get num():number {
return
}
set num(value) {
}
set y(value) {}
set x(value) {}
}
\ No newline at end of file
// tslint:disable:only-arrow-functions
// tslint:disable:no-conditional-assignment
// tslint:disable:prefer-const
// tslint:disable:no-var-keyword
// tslint:disable:no-inferrable-types
import { Vector } from "./Vector";
import { Tween } from "../tween/Tween";
import Body from "./Body";
export class Circle extends Body {
public type = "circle";
public view;
public radius;
_num;
_x = 0;
_y = 0;
constructor(radius, view) {
super();
this.radius = radius;
this.view = view;
}
get x() {
return this._x;
}
set x(value) {
if (this._x != value) {
this._x = value;
this.view.x = value;
}
}
get y() {
return this._y;
}
set y(value) {
if (this._y != value) {
this._y = value;
this.view.y = value;
}
}
get num() {
return this._num;
}
set num(value) {
if (this._num != value) {
this._num = value;
// console.log("圆形value",value);
this.view.txt&&(this.view.txt.text = value||2+"");
}
}
//新增,矫正偏移
get _viewx(){
return this.view.x;//+this.view.anchorX;
}
get _viewy(){
return this.view.y;//+this.view.anchorY;
}
public shake() {
console.log("circle震动1-------",this.view.bg.x,this.view.bg.y);
var startx = -this.view.bg.anchorX;
var starty = -this.view.bg.anchorY;
this.view.bg.x = startx;
this.view.bg.y = starty;
console.log("circle震动2-------",this.view.bg.x,this.view.bg.y);
Tween.to(this.view.bg, 1, {
x: startx+3,
y: starty+3,
yoyo: 2,
useFrame: true,
onComplete: function () {
console.log("circle震动3-------",this.view.bg.x,this.view.bg.y);
}
})
}
collideBall(ball) {
var ballax = ball._viewx;
var ballay = ball._viewy;
var thisax = this._viewx;
var thisay = this._viewy;
var deltaX = ballax - thisax;
var deltaY = ballay - thisay;
//碰撞
if (deltaX * deltaX + deltaY * deltaY < (this.radius + ball.radius)*(this.radius + ball.radius)) {
var velocity = ball.velocity.clone();
var deta = Math.floor(velocity.length() / ball.radius)+5 //deta就是插值数量,如为0,则直接取上一帧的法向量
var speedX = velocity.x / (deta + 1);
var speedY = velocity.y / (deta + 1);
for (var i = 0; i <= deta; i++) {
var normal = this.nearestCollideNormal({ x: ballax - speedX * (i + 1), y: ballay - speedY * (i + 1) }, ball, deta + 1, i + 1)
if (normal) {
return normal
}
}
} else {
return false
//提前给出要碰撞的法向量
// return new Vector(deltaX,deltaY).cross();
}
}
private nearestCollideNormal(position, ball, deta, i) {
var thisax = this._viewx;
var thisay = this._viewy;
var deltaX = position.x-thisax ;
var deltaY = position.y-thisay;
if (deltaX * deltaX + deltaY * deltaY < (this.radius + ball.radius)*(this.radius + ball.radius)) {
return false;
} else {
//直接更改球的位置为最接近碰撞的位置
ball.view.x -= ball.velocity.x / deta * i;
ball.view.y -= ball.velocity.y / deta * i;
//提前给出要碰撞的法向量
return new Vector(deltaX, deltaY).cross();
}
}
}
\ No newline at end of file
// tslint:disable:only-arrow-functions
// tslint:disable:no-conditional-assignment
// tslint:disable:prefer-const
// tslint:disable:no-var-keyword
// tslint:disable:no-inferrable-types
export const degToRad = Math.PI / 180;
export const radToDeg = 180 / Math.PI;
export const sqrt3 = Math.sqrt(3);
export function translateToLocalCor(p, parent) {
var th = parent.rotation * degToRad;
//平移
var xp = p.x - parent.x;
var yp = p.y - parent.y;
//旋转
var x = xp * Math.cos(th) + yp * Math.sin(th);
var y = yp * Math.cos(th) - xp * Math.sin(th);
return { x: x / parent.scaleX, y: y / parent.scaleY }
}
export function translateToGlobalCor(p, parent) {
var th = -parent.rotation * degToRad;
var x = p.x * Math.cos(th) + p.y * Math.sin(th) + parent.x;
var y = p.y * Math.cos(th) - p.x * Math.sin(th) + parent.y;
return { x: x / parent.scaleX, y: y / parent.scaleY }
}
/**
* 以水平向左即x正方向为0,顺时针为正,返回弧度
* @param pointFixed 固定点
* @param point
*/
export function twoPointsAngleDis(pointFixed, point) {
var detaX = point.x - pointFixed.x;
var detaY = point.y - pointFixed.y;
var dis = Math.sqrt(detaX * detaX + detaY * detaY);
var angleH = Math.acos(detaX / dis);
if (detaY < 0) {
angleH = Math.PI * 2 - angleH;
}
return { angle: angleH, dis: dis };
}
\ No newline at end of file
export class Projection {
min: any;
max: any;
constructor(min, max) {
this.min = min;
this.max = max;
}
//检测两个多边形在同一个投影轴上的投影是否有重合,重叠返回true
overlaps(projection) {
return this.max > projection.min && projection.max > this.min;
}
}
\ No newline at end of file
// tslint:disable:only-arrow-functions
// tslint:disable:no-conditional-assignment
// tslint:disable:prefer-const
// tslint:disable:no-var-keyword
// tslint:disable:no-inferrable-types
import { Vector } from "./Vector";
import { degToRad, translateToLocalCor, sqrt3, twoPointsAngleDis, radToDeg } from "./Const";
import { Projection } from "./Projection";
import { Tween } from "../tween/Tween";
import Body from "./Body";
//正三角形
export class RegPolygon extends Body {
public type = "regPolygon";
public view;
public length;
public _rotation = 0; //顺时针为正方向,角度制
_x = 0;
_y = 0;
_num;
//各边的直线方程,以a,b记录
linesOri = [];
//原始各点的坐标 考虑是否需要
// pointsOri;
//记录边的方向向量顺时针,从左上边开始 未归一
sideNormals = [];
//记录点的法向量,顺时针,从上开始 未归一
pointNormals = [];
//旋转后的点
points = [];
// //中心点到各点长度
// pointLength;
// //中心点到各边长度
// sideLength;
axes = [];
projects = [];
dirty = true;
constructor(length, view) {
super();
this.length = length;
this.view = view;
this.calculateNormals();
this.calculatePoints();
this.calculateLines()
}
get rotation() {
return this._rotation
}
set rotation(value) {
if (this._rotation != value) {
this._rotation = value;
this.view.rotation = value;
this.view.txt.rotation = -value;
//计算四条边得方向向量,避免每帧计算 暂时不考虑优化90度
var rad = value * degToRad;
this.calculateNormals();
this.calculatePoints();
this.dirty = true;
}
}
get x() {
return this._x;
}
set x(value) {
if (this._x != value) {
this._x = value;
this.view.x = value;
//
this.dirty = true;
}
}
get y() {
return this._y;
}
set y(value) {
if (this._y != value) {
this._y = value;
this.view.y = value;
//
this.dirty = true;
}
}
get num() {
return this._num;
}
set num(value) {
if (this._num != value) {
this._num = value;
// console.log("regPolygon-value",value);
this.view.txt.text = value||3 + "";
}
}
//新增,矫正偏移
get _viewx(){
return this.view.x;
}
get _viewy(){
return this.view.y;
}
//根据继承重写
calculateNormals() {
}
//根据继承重写
calculatePoints() {
}
calculateLines() {
}
getAxes() {
var v1 = new Vector(); //代表多边形的相邻两点
var v2 = new Vector();
var axes = [];
var thisvx = this._viewx
var thisvy = this._viewy;
for (var i = 0; i < this.points.length - 1; i++) { //遍历多边形所有相邻的点得去所有的投影轴
v1.x = this.points[i].x + thisvx;
v1.y = this.points[i].y + thisvy;
v2.x = this.points[i + 1].x +thisvx;
v2.y = this.points[i + 1].y + thisvy;
axes.push(v1.edge(v2).perpendicularNormal());
// console.log(1)
};
//将收尾两点的投影轴也加入
v1.x = this.points[this.points.length - 1].x + thisvx;
v1.y = this.points[this.points.length - 1].y + thisvy;
v2.x = this.points[0].x + thisvx;
v2.y = this.points[0].y + thisvy;
axes.push(v1.edge(v2).perpendicularNormal());
// console.log(axes)
return axes;
};
//得到多边形各个点在某一条投影轴上投影,并得到投影两端点值,传递给投影对象Projection返回投影对象
project(axis) {
var scalars = []; //用于存放所有点向量在投影轴向量上的点积集合,注意点积集合是数量不是向量
var v = new Vector();
var self = this;
var thisvx = this._viewx;
var thisvy = this._viewy;
this.points.forEach(function (point) {
v.x = point.x + thisvx;
v.y = point.y + thisvy;
scalars.push(v.dotProduct(axis));
});
return new Projection(Math.min.apply(Math, scalars), Math.max.apply(Math, scalars));
};
polygonCollidesWithCircle(ball) {
//console.log('多边形与圆形碰撞检测');
var v1;
var v2;
var ballax = ball._viewx;
var ballay = ball._viewy;
// var axes = this.getAxes();
if (this.dirty) {
this.dirty = false;
this.axes = this.getAxes();
for (var i = 0; i < this.axes.length; i++) {
this.projects[i] = this.project(this.axes[i])
}
}
var axes = this.axes.slice();
var closestPoint = this.getPolygonPointClosestToCircle(ball);
v1 = new Vector(ballax, ballay);
v2 = new Vector(closestPoint.x, closestPoint.y);
axes.push(v1.subtract(v2).normalize());
return !this.separationOnAxes(axes, ball);
}
//得到多边形距离圆形最近点
getPolygonPointClosestToCircle(ball) {
var min;
var length;
var testPoint;
var closestPoint;
var ballax = ball._viewx;
var ballay = ball._viewy;
var thisax = this._viewx;
var thisay = this._viewy;
// tslint:disable-next-line:prefer-for-of
for (var i = 0; i < this.points.length; i++) {
testPoint = new Vector(this.points[i].x + thisax, this.points[i].y + thisay);
length = Math.pow(testPoint.x - ballax, 2) + Math.pow(testPoint.y - ballay, 2);
if (!min || length < min) {
min = length;
closestPoint = testPoint;
}
};
// console.log(closestPoint)
return closestPoint;
};
//检测在投影轴上投影是否有分离
separationOnAxes(axes, ball) {
var axis;
var projection1;
var projection2;
for (var i = 0; i < axes.length; ++i) {
axis = axes[i];
projection1 = ball.project(axis); //得到形状在当前投影轴上的投影
if (i == axes.length - 1) {
projection2 = this.project(axis); //得到当前拖拽形状在当前投影轴上的投影
} else {
projection2 = this.projects[i]
}
if (!projection1.overlaps(projection2)) { //检测两个投影在当前投影轴上是否重叠,分离返回false
return true; //在当前投影轴上分离返回true,表示两个形状肯定没有碰撞,不需在检测后面的投影轴了,
}
};
return false; //检测完全部的投影轴上的投影没和一个分离的,返回false;
}
//
collideBall(ball) {
var ballax = ball._viewx;
var ballay = ball._viewy;
var thisax = this._viewx;
var thisay = this._viewy;
if (this.polygonCollidesWithCircle(ball)) {
//如果碰撞。
//先转换坐标,
var returnP = translateToLocalCor({ x: ballax, y: ballay }, this.view);
var velocity = ball.velocity.clone().rotate(-this._rotation * degToRad);
var deta = Math.floor(velocity.length() / ball.radius) + 1 //deta就是插值数量,如为0,则直接取上一帧的法向量
var speedX = velocity.x / (deta + 1);
var speedY = velocity.y / (deta + 1);
// console.log(this.nearestCollideNormal({ x: returnP.x - velocity.x, y: returnP.y - velocity.y }, ball,deta+1,i+1))
for (var i = 0; i <= deta; i++) {
this.ballPosition(ball, deta + 1, i + 1)
if (!this.polygonCollidesWithCircle(ball)) {
//算此时的球的位置所对应碰撞的法向量
var noraml = this.nearestCollideNormal({ x: returnP.x - speedX * (i + 1), y: returnP.y - speedY * (i + 1) });
//如果normal和速度方向一致则判断不碰撞,还原球的位置 暂时没用,去掉
// if(!noraml) console.log(noraml)
// if(noraml.parallel(velocity)){
// console.log(2322)
// ball.view.x += ball.velocity.x / (deta + 1) * (i + 1);
// ball.view.y += ball.velocity.y / (deta + 1) * (i + 1);
// return false
// }else{
return noraml
// }
}
}
} else {
return false
}
}
//同样可以进行碰撞检测,考虑之 继承时重写
nearestCollideNormal(returnP): Vector {
return
}
private ballPosition(ball, deta, i) {
ball.view.x -= ball.velocity.x / deta;
ball.view.y -= ball.velocity.y / deta;
}
public shake() {
console.log("regPolygon震动1----------",this.view.bg.x,this.view.bg.y);
var startx = -this.view.bg.anchorX;
var starty = -this.view.bg.anchorY;
this.view.bg.x = startx;
this.view.bg.y = starty;
console.log("regPolygon震动2----------",this.view.bg.x,this.view.bg.y);
Tween.to(this.view.bg, 1, {
x: startx+3,
y: starty+3,
yoyo: 2,
useFrame: true,
onComplete: function () {
console.log("regPolygon震动3----------",this.view.bg.x,this.view.bg.y);
}
})
}
}
\ No newline at end of file
// tslint:disable:only-arrow-functions
// tslint:disable:no-conditional-assignment
// tslint:disable:prefer-const
// tslint:disable:no-var-keyword
// tslint:disable:no-inferrable-types
import { sqrt3, degToRad } from "./Const";
import { RegPolygon } from "./RegPolygon";
import { Vector } from "./Vector";
export class RegTriangle extends RegPolygon {
//中心点到各点长度
pointLength;
//中心点到各边长度
sideLength;
constructor(length, view) {
super(length, view);
this.type="regTriangle";
this.pointLength = this.length * sqrt3 / 3;
this.sideLength = this.length * sqrt3 / 6;
}
calculateNormals() {
if (this._rotation == 0) {
this.sideNormals[0] = new Vector(1, -sqrt3)
this.sideNormals[1] = new Vector(1, sqrt3)
this.sideNormals[2] = new Vector(-1, 0)
this.pointNormals[0] = new Vector(1, 0)
this.pointNormals[1] = new Vector(-1, sqrt3)
this.pointNormals[2] = new Vector(-1, -sqrt3)
} else {
var rad = this._rotation * degToRad;
this.sideNormals[0] = new Vector(1, -sqrt3).rotate(rad);
this.sideNormals[1] = new Vector(1, sqrt3).rotate(rad);
this.sideNormals[2] = new Vector(-1, 0).rotate(rad);
this.pointNormals[0] = new Vector(1, 0).rotate(rad);
this.pointNormals[1] = new Vector(-1, sqrt3).rotate(rad);
this.pointNormals[2] = new Vector(-1, -sqrt3).rotate(rad);
}
}
calculatePoints() {
if (this._rotation == 0) {
this.points[0] = new Vector(0, -this.length * sqrt3 / 3);
this.points[1] = new Vector(this.length / 2, this.length * sqrt3 / 6);
this.points[2] = new Vector(-this.length / 2, this.length * sqrt3 / 6);
} else {
var rad = this._rotation * degToRad;
this.points[0] = new Vector(0, -this.length * sqrt3 / 3).rotate(rad);
this.points[1] = new Vector(this.length / 2, this.length * sqrt3 / 6).rotate(rad);
this.points[2] = new Vector(-this.length / 2, this.length * sqrt3 / 6).rotate(rad);
}
}
calculateLines() {
//三边线的方程 左上开始
this.linesOri = [
{ a: -sqrt3, b: -this.length * sqrt3 / 3 },
{ a: sqrt3, b: -this.length * sqrt3 / 3 },
{ a: 0, b: this.length * sqrt3 / 6 },
]
}
nearestCollideNormal(returnP) {
//算出点在三条线的方向 ,在上为true,在下为false
var zero = this.linesOri[0].a * returnP.x + this.linesOri[0].b - returnP.y > 0;
var one = this.linesOri[1].a * returnP.x + this.linesOri[1].b - returnP.y > 0;
var two = this.linesOri[2].a * returnP.x + this.linesOri[2].b - returnP.y > 0;
// console.log(this.linesOri[0].a * returnP.x + this.linesOri[0].b,returnP.y)
// console.log(zero,one,two)
//左上边
if (zero && !one && two) {
return this.sideNormals[0];
}
//右上边
else if (!zero && one && two) {
return this.sideNormals[1];
}
//下边
else if (!zero && !one && !two) {
return this.sideNormals[2];
}
//上点
else if (zero && one && two) {
return this.pointNormals[0];
}
//右点
else if (!zero && one && !two) {
return this.pointNormals[1];
}
//左点
else if (zero && !one && !two) {
return this.pointNormals[2];
}
}
}
\ No newline at end of file
// tslint:disable:only-arrow-functions
// tslint:disable:no-conditional-assignment
// tslint:disable:prefer-const
// tslint:disable:no-var-keyword
// tslint:disable:no-inferrable-types
import { Vector } from "./Vector";
import { degToRad, translateToLocalCor } from "./Const";
import { Tween } from "../tween/Tween";
import Body from "./Body";
export class Square extends Body {
public type = "square"
public view;
_num;
_x = 0;
_y = 0;
/**
* 边长
*/
public length;
public _rotation = 0; //顺时针为正方向,角度制
//记录四条边的方向向量顺时针,从上边开始
sideNormals = [
new Vector(1, 0),
new Vector(0, 1),
new Vector(-1, 0),
new Vector(0, -1)
];
//记录四点的法向量,顺时针,从左上开始 未归一
pointNormals = [
new Vector(1, -1),
new Vector(1, 1),
new Vector(-1, 1),
new Vector(-1, -1)
]
// points = [
// new Vector(1, -1),
// new Vector(1, 1),
// new Vector(-1, 1),
// new Vector(-1, -1)
// ]
constructor(length, view) {
super();
this.length = length;
this.view = view;
}
get rotation() {
return this._rotation
}
set rotation(value) {
if (this._rotation != value) {
this._rotation = value;
this.view.rotation = value;
this.view.txt.rotation=-value;
//计算四条边得方向向量,避免每帧计算 暂时不考虑优化90度
var rad = value * degToRad;
this.sideNormals[0] = new Vector(1, 0).rotate(rad);
this.sideNormals[1] = new Vector(0, 1).rotate(rad);
this.sideNormals[2] = new Vector(-1, 0).rotate(rad);
this.sideNormals[3] = new Vector(0, -1).rotate(rad);
this.pointNormals[0] = new Vector(1, -1).rotate(rad);
this.pointNormals[1] = new Vector(1, 1).rotate(rad);
this.pointNormals[2] = new Vector(-1, 1).rotate(rad);
this.pointNormals[3] = new Vector(-1, -1).rotate(rad);
}
}
get x() {
return this._x;
}
set x(value) {
if (this._x != value) {
this._x = value;
this.view.x = value;
}
}
get y() {
return this._y;
}
set y(value) {
if (this._y != value) {
this._y = value;
this.view.y = value;
}
}
get num() {
return this._num;
}
set num(value) {
if (this._num != value) {
this._num = value;
// console.log("square-vale",value);
this.view.txt.text = value||4 + "";
}
}
//新增,矫正偏移
get _viewx(){
return this.view.x;//+this.view.anchorX;
}
get _viewy(){
return this.view.y;//+this.view.anchorY;
}
//碰撞,先转换球坐标到局部 在四个点时考虑要不要预先计算四个点的坐标,通过xyr set时确定;
collideBall(ball) {
var returnP = translateToLocalCor({ x: ball._viewx, y: ball._viewy }, this.view);
//正方形左上角点
var ox = - this.length / 2;
var oy = ox;
var nearestX = Math.max(ox, Math.min(returnP.x, ox + this.length));
var nearestY = Math.max(oy, Math.min(returnP.y, oy + this.length));
var deltaX = returnP.x - nearestX;
var deltaY = returnP.y - nearestY;
//碰撞 则根据速度插值给上一帧的碰撞法向量 考虑是否直接按速度大小进行插值,还是用分量
if (deltaX * deltaX + deltaY * deltaY < ball.radius * ball.radius) {
var velocity = ball.velocity.clone().rotate(-this._rotation * degToRad);
var deta = Math.floor(velocity.length() / ball.radius) + 5 //deta就是插值数量,如为0,则直接取上一帧的法向量
var speedX = velocity.x / (deta + 1);
var speedY = velocity.y / (deta + 1);
// console.log(this.nearestCollideNormal({ x: returnP.x - velocity.x, y: returnP.y - velocity.y }, ball,deta+1,i+1))
for (var i = 0; i <= deta; i++) {
var normal = this.nearestCollideNormal({ x: returnP.x - speedX * (i + 1), y: returnP.y - speedY * (i + 1) }, ball, deta + 1, i + 1)
if (normal) {
return normal
}
}
// return false; //意味着碰撞
}
//未碰撞
else {
return false
}
}
private nearestCollideNormal(position, ball, deta, i) {
var ox = - this.length / 2;
var oy = ox;
var nearestX = Math.max(ox, Math.min(position.x, ox + this.length));
var nearestY = Math.max(oy, Math.min(position.y, oy + this.length));
var deltaX = position.x - nearestX;
var deltaY = position.y - nearestY;
if (deltaX * deltaX + deltaY * deltaY < ball.radius * ball.radius) {
return false;
} else {
//直接更改球的位置为最接近碰撞的位置
ball.view.x -= ball.velocity.x / deta * i;
ball.view.y -= ball.velocity.y / deta * i;
//左边
if (nearestX == ox) {
if (nearestY == oy) {
return this.pointNormals[0];
}
else if (nearestY == oy + this.length) {
return this.pointNormals[3];
} else {
return this.sideNormals[3];
}
}
//右边
else if (nearestX == ox + this.length) {
if (nearestY == oy) {
return this.pointNormals[1];
}
else if (nearestY == oy + this.length) {
return this.pointNormals[2];
} else {
return this.sideNormals[1];
}
}
//中间
else {
if (nearestY < 0) {
return this.sideNormals[0];
} else {
return this.sideNormals[2];
}
}
}
}
public shake() {
console.log("square震动1---",this.view.bg.x,this.view.bg.y);
var startx = -this.view.bg.anchorX;
var starty = -this.view.bg.anchorY;
this.view.bg.x = startx;
this.view.bg.y = starty;
console.log("square震动2---",this.view.bg.x,this.view.bg.y);
Tween.to(this.view.bg, 1, {
x: startx+5,
y: starty+5,
yoyo: 3,
useFrame: true,
onComplete: function () {
console.log("square震动3---",this.view.bg.x,this.view.bg.y);
}
})
}
}
\ No newline at end of file
// tslint:disable:only-arrow-functions
// tslint:disable:no-conditional-assignment
// tslint:disable:prefer-const
// tslint:disable:no-var-keyword
// tslint:disable:no-inferrable-types
export class Vector {
public x;
public y
constructor(x = 0, y = 0) {
this.x = x;
this.y = y;
}
initialize() {
this.x = 0;
this.y = 0;
}
length() {
return Math.sqrt(this.length2());
}
length2() {
return this.x * this.x + this.y * this.y
}
symmetricFromNormalVector(normalVector) {
var nx2 = normalVector.x * normalVector.x;
var ny2 = normalVector.y * normalVector.y;
var nxy = normalVector.x * normalVector.y;
var tempx = this.x;
this.x = (2 * this.y * nxy + this.x * (nx2 - ny2)) / (nx2 + ny2);
this.y = (2 * tempx * nxy - this.y * (nx2 - ny2)) / (nx2 + ny2);
return this;
}
//参数弧度
rotate(angle) {
var tempx = this.x;
this.x = this.x * Math.cos(angle) - this.y * Math.sin(angle)
this.y = this.y * Math.cos(angle) + tempx * Math.sin(angle);
return this;
// function aaa(x,y){
// this.x=x;
// this.y=y;
// this.rotate=function(angle){
// var tempx=this.x;
// this.x=this.x*Math.cos(angle)-this.y*Math.sin(angle)
// this.y=this.y*Math.cos(angle)+tempx*Math.sin(angle);
// return this;
// }
// }
}
clone() {
return new Vector(this.x, this.y);
}
translate(x, y) {
this.x += x;
this.y += y;
return this;
}
//求垂直向量,未归一
cross() {
if (this.x == 0) {
if (this.y == 0) {
} else {
this.x = 1;
this.y = 0;
}
} else {
if (this.y == 0) {
this.x = 0;
this.y = 1
} else {
var tempx = this.x
this.x = 1;
this.y = -tempx / this.y;
}
}
return this;
}
//得到向量的长度
getMagnitude() {
return Math.sqrt(Math.pow(this.x, 2) + Math.pow(this.y, 2));
}
//两向量相加得到的新向量
add(anotherVector) {
var v = new Vector();
v.x = this.x + anotherVector.x;
v.y = this.y + anotherVector.y;
return v;
}
//两向量相减,得到边缘法向量 OA-OB = BA;
subtract(anotherVector) {
var v = new Vector();
v.x = this.x - anotherVector.x;
v.y = this.y - anotherVector.y;
return v;
}
//两向量的点积,一个向量在别一处向量上的投影,得到的不是一个向量,是投影的长度
dotProduct(anotherVector) {
return this.x * anotherVector.x + this.y * anotherVector.y;
}
//得到多边形的边缘向量,即多边形,相邻两点的向量
edge(anotherVector) {
return this.subtract(anotherVector);
}
//得到垂直于边缘向量的边缘法向量,即投影轴向量
perpendicular() {
var v = new Vector();
v.x = this.y;
v.y = 0 - this.x;
return v;
}
//得去某向量的单位向量,即方向相同,长度为1的向量,单位向量主要是用来指示方向的
normalize() {
var v = new Vector(0, 0);
var m = this.getMagnitude();
if (m != 0) { //避免向量为0
v.x = this.x / m;
v.y = this.y / m;
}
return v;
}
//得去边缘法向量的单位向量,即投影轴向量的单位方向,表示投影轴的方向
perpendicularNormal() {
var p = this.perpendicular();
return p.normalize();
}
//判断向量平行
parallel(vector) {
if (Math.abs(this.x * vector.y - this.y * vector.x) < 0.00001) {
return true
} else {
return false
}
}
/**
* 求与法向量对称的向量
* @param vector 原向量
* @param normalVector 法向量
*/
static symmetricVector(vector, normalVector) {
var nx2 = normalVector.x * normalVector.x;
var ny2 = normalVector.y * normalVector.y;
var nxy = normalVector.x * normalVector.y;
var x = (2 * vector.y * nxy + vector.x * (nx2 - ny2)) / (nx2 + ny2);
var y = (2 * vector.x * nxy - vector.y * (nx2 - ny2)) / (nx2 + ny2);
return new Vector(x, y);
}
}
\ No newline at end of file
// import { NetManager } from "../../libs/tw/manager/NetManager";
// import { DataManager } from "../../libs/tw/manager/DataManager";
// import Loading from "../../libs/new_wx/components/Loading";
// export default (cb) => {
// Loading.instace.show();
// NetManager.ins.doJoinPlugDraw((isSuccess) => {
// Loading.instace.hide();
// if (isSuccess) {
// Loading.instace.show();
// NetManager.ins.getPlugOrderStatus((success) => {
// Loading.instace.hide();
// if (success) {
// NetManager.ins.getCredits(() => { });
// cb && cb();
// }
// }, DataManager.ins.doJoinPlugDrawData.orderId,
// () => DataManager.ins.getPlugOrderStatusData.result == 0
// )
// }
// }, window['revivePlugId'], true);
// }
// tslint:disable:no-conditional-assignment
// tslint:disable:prefer-const
// tslint:disable:no-var-keyword
// tslint:disable:no-inferrable-types
/**
* 无继承AObject
*/
export class TweenObj{
protected _instanceId: number = 0;
protected _instanceType: string = "TweenObj";
protected static _object_id = 0;
public constructor() {
this._instanceId = TweenObj._object_id++;
}
public currentFrame: number = 0;
public totalFrames: number = 0;
protected _startData: any;
protected _disData: any;
public target: any;
private _isTo: boolean;
private _isLoop: number = 0;
private _delay: number = 0;
public _update: Function;
public _completeFun: Function;
public _ease: Function;
private _isFront: boolean = true;
private _cParams: any = null;
private _loop: boolean = false;
/**
* 初始化数据
* @method init
* @param target
* @param times
* @param data
* @param isTo
* @public
* @since 1.0.0
*/
public init(target: any, times: number, data: any, isTo: boolean = true): void {
if (times <= 0 || typeof (times) != "number") {
throw new Error("Tween.to()或者Tween.from()方法的第二个参数一定要是大于0的数字");
}
let s = this;
s.currentFrame = 1;
let tTime: number = times * 60 >> 0;
s.totalFrames = tTime > 0 ? tTime : 1;
s.target = target;
s._isTo = isTo;
s._isLoop = 0;
s._startData = {};
s._disData = {};
s._delay = 0;
s._isFront = true;
s._ease = null;
s._update = null;
s._cParams = null;
s._loop = false;
s._completeFun = null;
for (let item in data) {
switch (item) {
case "useFrame":
if (data[item] == true) {
s.totalFrames = times;
}
break;
case "yoyo":
if (data[item] === false) {
s._isLoop = 0;
} else if (data[item] === true) {
s._isLoop = Number.MAX_VALUE;
} else {
s._isLoop = data[item];
}
break;
case "delay":
if (data.useFrame) {
s._delay = data[item];
} else {
s._delay = data[item] * 60 >> 0;
}
break;
case "ease":
s._ease = data[item];
break;
case "onUpdate":
s._update = data[item];
break;
case "onComplete":
s._completeFun = data[item];
break;
case "completeParams":
s._cParams = data[item];
break;
case "loop":
s._loop = data[item];
break;
default:
if (typeof (data[item]) == "number") {
if (isTo) {
s._startData[item] = target[item];
s._disData[item] = data[item] - target[item];
} else {
s._startData[item] = data[item];
s._disData[item] = target[item] - data[item];
target[item] = data[item];
}
}
}
}
}
/**
* 更新数据
* @method update
* @since 1.0.0
* @public
*/
public update(): void {
let s = this;
if (s._isFront && s._delay > 0) {
s._delay--;
return;
}
//更新数据
let per = s.currentFrame / s.totalFrames;
if (per < 0 || per > 1) return;
if (s._ease) {
per = s._ease(per);
}
var isHave: boolean = false;
for (let item in s._disData) {
isHave = true;
s.target[item] = s._startData[item] + s._disData[item] * per;
}
if (!isHave) {
//如果发现tween被全新的tween全部给替换了,那就直接回收这个
Tween.kill(s.instanceId);
return;
}
if (s._update) {
s._update(per);
}
let cf = s._completeFun;
let pm = s._cParams;
if (s._isFront) {
s.currentFrame++;
if (s.currentFrame > s.totalFrames) {
if (s._loop) {
s.currentFrame = 1;
} else {
if (s._isLoop > 0) {
s._isFront = false;
s.currentFrame = s.totalFrames;
s._isLoop--;
} else {
Tween.kill(s.instanceId);
}
}
if (cf) {
cf(pm);
}
}
} else {
s.currentFrame--;
if (s.currentFrame < 0) {
if (s._isLoop > 0) {
s._isFront = true;
s.currentFrame = 1;
} else {
Tween.kill(s.instanceId);
}
if (cf) {
cf(pm);
}
}
}
}
/**
* 每一个对象都会有一个唯一的id码。
* @property instanceId
* @public
* @since 1.0.0
* @return {number}
* @readonly
* @example
* //获取对象唯一码
* trace(this.instanceId);
*/
public get instanceId(): number {
return this._instanceId;
}
/**
* 每一个类都有一个实例类型字符串,通过这个字符串,你能知道这个实例是从哪个类实例而来
* @property instanceType
* @since 1.0.3
* @public
* @return {string}
* @readonly
*/
public get instanceType(): string {
return this._instanceType;
}
destroy(): void {
let s = this;
s._update = null;
s._completeFun = null;
s._ease = null;
}
}
/**
* 全局静态单列类,不要实例化此类
* @class Tween
* @public
* @since 1.0.0
*/
let isUpdateTween =true;
export class Tween {
/**
* 将target对象的属性数值渐变到data中对应属性指定的数值
* @method to
* @static
* @param {Object} target
* @param {number} totalFrame 总时间长度 如果data.useFrame为true 这里就是帧数,如果data.useFrame为false则这里就是时间
* @param {Object} data 包含target对象的各种数字类型属性及其他一些方法属性
* @param {number:boolean} data.yoyo 是否向摆钟一样来回循环,默认为false.设置为true则会无限循环,或想只运行指定的摆动次数,将此参数设置为数字就行了。
* @param {number:boolean} data.loop 是否循环播放。
* @param {Function} data.onComplete 完成函数. 默认为null
* @param {Array} data.completeParams 完成函数参数. 默认为null,可以给完成函数里传参数
* @param {Function} data.onUpdate 进入每帧后执行函数,回传参数是当前的Tween时间比.默认为null
* @param {Function} data.ease 缓动类型方法
* @param {boolean} data.useFrame 为false用时间秒值;为true则是以帧为单位,默认以秒为单位
* @param {number} data.delay 延时,useFrame为true以帧为单位 useFrame为false以秒为单位
* @public
* @since 1.0.0
*/
public static to(target: any, totalFrame: number, data: Object): number {
return Tween.createTween(target, totalFrame, data, true);
}
/**
* 将target对象从data中指定的属性数值渐变到target属性当前的数值
* @method from
* @static
* @param {Object} target
* @param {number} totalFrame 总时间长度 如果data.useFrame为true 这里就是帧数,如果data.useFrame为false则这里就是时间
* @param {Object} data 包含target对象的各种数字类型属性及其他一些方法属性
* @param {number:boolean} data.yoyo 是否向摆钟一样来回循环,默认为false.设置为true则会无限循环,或想只运行指定的摆动次数,将此参数设置为数字就行了。
* @param {number:boolean} data.loop 是否循环播放。
* @param {Function} data.onComplete 完成结束函数. 默认为null
* @param {Array} data.completeParams 完成函数参数. 默认为null,可以给完成函数里传参数
* @param {Function} data.onUpdate 进入每帧后执行函数,回传参数是当前的Tween时间比.默认为null
* @param {Function} data.ease 缓动类型方法
* @param {boolean} data.useFrame 为false用时间秒值;为true则是以帧为单位
* @param {number} data.delay 延时,useFrame为true以帧为单位 useFrame为false以秒为单位
* @public
* @since 1.0.0
*/
public static from(target: any, totalFrame: number, data: Object): number {
return Tween.createTween(target, totalFrame, data, false);
}
private static createTween(target: any, totalFrame: number, data: any, isTo: boolean): number {
let tweenObj: Tween | any;
let len = Tween._tweenList.length;
for (let i = 0; i < len; i++) {
tweenObj = Tween._tweenList[i];
if (target == tweenObj.target) {
for (let item in tweenObj._startData) {
if (data[item] != undefined) {
delete tweenObj._startData[item];
delete tweenObj._disData[item];
}
}
}
}
len = Tween._tweenPool.length;
if (len > 0) {
tweenObj = Tween._tweenPool.shift();
//考虑到对象池回收后需要变更id
tweenObj._instanceId = TweenObj["_object_id"]++;
} else {
tweenObj = new TweenObj();
}
Tween._tweenList.push(tweenObj);
tweenObj.init(target, totalFrame, data, isTo);
return tweenObj.instanceId;
}
/**
* 销毁所有正在运行的Tween对象
* @method killAll
* @static
* @public
* @since 1.0.0
*/
public static killAll(): void {
let len: number = Tween._tweenList.length;
let tweenObj: any;
for (let i = 0; i < len; i++) {
tweenObj = Tween._tweenList[i];
tweenObj.target = null;
tweenObj._completeFun = null;
tweenObj._cParams = null;
tweenObj._update = null;
tweenObj._ease = null;
tweenObj._loop = false;
Tween._tweenPool.push(tweenObj);
}
Tween._tweenList.length = 0;
}
/**
* @通过创建Tween对象返回时的唯一id来销毁对应的Tween对象
* @method kill
* @static
* @public
* @param {Tween} tween
* @since 1.0.0
*/
public static kill(tweenId: number): void {
let len: number = Tween._tweenList.length;
let tweenObj: any;
for (let i = 0; i < len; i++) {
tweenObj = Tween._tweenList[i];
if (tweenObj.instanceId == tweenId) {
tweenObj.target = null;
tweenObj._completeFun = null;
tweenObj._cParams = null;
tweenObj._update = null;
tweenObj._ease = null;
tweenObj._loop = null;
Tween._tweenPool.push(tweenObj);
Tween._tweenList.splice(i, 1);
break;
}
}
}
private static _tweenPool: Array<TweenObj> = [];
private static _tweenList: Array<TweenObj> = [];
/**
* quadraticIn缓动类型
* @method quadraticIn
* @static
* @public
* @since 1.0.0
* @param {number}k
* @return {number}
*/
public static quadraticIn(k: number): number {
return k * k;
}
/**
* quadraticOut 缓动类型
* @method quadraticOut
* @static
* @public
* @since 1.0.0
* @param {number}k
* @return {number}
*/
public static quadraticOut(k: number): number {
return k * (2 - k);
}
/**
* quadraticInOut 缓动类型
* @method quadraticInOut
* @static
* @public
* @since 1.0.0
* @param {number}k
* @return {number}
*/
public static quadraticInOut(k: number): number {
if ((k *= 2) < 1) {
return 0.5 * k * k;
}
return -0.5 * (--k * (k - 2) - 1);
}
/**
* cubicIn 缓动类型
* @method cubicIn
* @static
* @public
* @since 1.0.0
* @param {number}k
* @return {number}
*/
public static cubicIn(k: number): number {
return k * k * k;
}
/**
* cubicOut 缓动类型
* @method cubicOut
* @static
* @public
* @since 1.0.0
* @param {number}k
* @return {number}
*/
public static cubicOut(k: number): number {
return --k * k * k + 1;
}
/**
* cubicInOut 缓动类型
* @method cubicInOut
* @static
* @public
* @since 1.0.0
* @param {number}k
* @return {number}
*/
public static cubicInOut(k: number): number {
if ((k *= 2) < 1) {
return 0.5 * k * k * k;
}
return 0.5 * ((k -= 2) * k * k + 2);
}
/**
* quarticIn 缓动类型
* @method quarticIn
* @static
* @public
* @since 1.0.0
* @param {number}k
* @return {number}
*/
public static quarticIn(k: number): number {
return k * k * k * k;
}
/**
* quarticOut 缓动类型
* @method quarticOut
* @static
* @public
* @since 1.0.0
* @param {number}k
* @return {number}
*/
public static quarticOut(k: number): number {
return 1 - (--k * k * k * k);
}
/**
* quarticInOut 缓动类型
* @method quarticInOut
* @static
* @public
* @since 1.0.0
* @param {number}k
* @return {number}
*/
public static quarticInOut(k: number): number {
if ((k *= 2) < 1) {
return 0.5 * k * k * k * k;
}
return -0.5 * ((k -= 2) * k * k * k - 2);
}
/**
* quinticIn 缓动类型
* @method quinticIn
* @static
* @public
* @since 1.0.0
* @param {number}k
* @return {number}
*/
public static quinticIn(k: number): number {
return k * k * k * k * k;
}
/**
* quinticOut 缓动类型
* @method quinticOut
* @static
* @public
* @since 1.0.0
* @param {number}k
* @return {number}
*/
public static quinticOut(k: number): number {
return --k * k * k * k * k + 1;
}
/**
* quinticInOut 缓动类型
* @method quinticInOut
* @static
* @public
* @since 1.0.0
* @param {number}k
* @return {number}
*/
public static quinticInOut(k: number): number {
if ((k *= 2) < 1) {
return 0.5 * k * k * k * k * k;
}
return 0.5 * ((k -= 2) * k * k * k * k + 2);
}
/**
* sinusoidalIn 缓动类型
* @method sinusoidalIn
* @static
* @public
* @since 1.0.0
* @param {number}k
* @return {number}
*/
public static sinusoidalIn(k: number): number {
return 1 - Math.cos(k * Math.PI / 2);
}
/**
* sinusoidalOut 缓动类型
* @method sinusoidalOut
* @static
* @public
* @since 1.0.0
* @param {number}k
* @return {number}
*/
public static sinusoidalOut(k: number): number {
return Math.sin(k * Math.PI / 2);
}
/**
* sinusoidalInOut 缓动类型
* @method sinusoidalInOut
* @static
* @public
* @since 1.0.0
* @param {number}k
* @return {number}
*/
public static sinusoidalInOut(k: number): number {
return 0.5 * (1 - Math.cos(Math.PI * k));
}
/**
* exponentialIn 缓动类型
* @method exponentialIn
* @static
* @public
* @since 1.0.0
* @param {number}k
* @return {number}
*/
public static exponentialIn(k: number): number {
return k === 0 ? 0 : Math.pow(1024, k - 1);
}
/**
* exponentialOut 缓动类型
* @method exponentialOut
* @static
* @public
* @since 1.0.0
* @param {number}k
* @return {number}
*/
public static exponentialOut(k: number): number {
return k === 1 ? 1 : 1 - Math.pow(2, -10 * k);
}
/**
* exponentialInOut 缓动类型
* @method exponentialInOut
* @static
* @public
* @since 1.0.0
* @param {number}k
* @return {number}
*/
public static exponentialInOut(k: number): number {
if (k === 0) {
return 0;
}
if (k === 1) {
return 1;
}
if ((k *= 2) < 1) {
return 0.5 * Math.pow(1024, k - 1);
}
return 0.5 * (-Math.pow(2, -10 * (k - 1)) + 2);
}
/**
* circularIn 缓动类型
* @method circularIn
* @static
* @public
* @since 1.0.0
* @param {number}k
* @return {number}
*/
public static circularIn(k: number): number {
return 1 - Math.sqrt(1 - k * k);
}
/**
* circularOut 缓动类型
* @method circularOut
* @static
* @public
* @since 1.0.0
* @param {number}k
* @return {number}
*/
public static circularOut(k: number): number {
return Math.sqrt(1 - (--k * k));
}
/**
* circularInOut 缓动类型
* @method circularInOut
* @static
* @public
* @since 1.0.0
* @param {number}k
* @return {number}
*/
public static circularInOut(k: number): number {
if ((k *= 2) < 1) {
return -0.5 * (Math.sqrt(1 - k * k) - 1);
}
return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1);
}
/**
* elasticIn 缓动类型
* @method elasticIn
* @static
* @public
* @since 1.0.0
* @param {number}k
* @return {number}
*/
public static elasticIn(k: number): number {
if (k === 0) {
return 0;
}
if (k === 1) {
return 1;
}
return -Math.pow(2, 10 * (k - 1)) * Math.sin((k - 1.1) * 5 * Math.PI);
}
/**
* elasticOut 缓动类型
* @method elasticOut
* @static
* @public
* @since 1.0.0
* @param {number}k
* @return {number}
*/
public static elasticOut(k: number): number {
if (k === 0) {
return 0;
}
if (k === 1) {
return 1;
}
return Math.pow(2, -10 * k) * Math.sin((k - 0.1) * 5 * Math.PI) + 1;
}
/**
* elasticInOut 缓动类型
* @method elasticInOut
* @static
* @public
* @since 1.0.0
* @param {number}k
* @return {number}
*/
public static elasticInOut(k: number): number {
if (k === 0) {
return 0;
}
if (k === 1) {
return 1;
}
k *= 2;
if (k < 1) {
return -0.5 * Math.pow(2, 10 * (k - 1)) * Math.sin((k - 1.1) * 5 * Math.PI);
}
return 0.5 * Math.pow(2, -10 * (k - 1)) * Math.sin((k - 1.1) * 5 * Math.PI) + 1;
}
/**
* backIn 缓动类型
* @method backIn
* @static
* @public
* @since 1.0.0
* @param {number}k
* @return {number}
*/
public static backIn(k: number): number {
let s = 1.70158;
return k * k * ((s + 1) * k - s);
}
/**
* backOut 缓动类型
* @method backOut
* @static
* @public
* @since 1.0.0
* @param {number}k
* @return {number}
*/
public static backOut(k: number): number {
let s = 1.70158;
return --k * k * ((s + 1) * k + s) + 1;
}
/**
* backInOut 缓动类型
* @method backInOut
* @static
* @public
* @since 1.0.0
* @param {number}k
* @return {number}
*/
public static backInOut(k: number): number {
let s = 1.70158 * 1.525;
if ((k *= 2) < 1) {
return 0.5 * (k * k * ((s + 1) * k - s));
}
return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2);
}
/**
* bounceIn 缓动类型
* @method bounceIn
* @static
* @public
* @since 1.0.0
* @param {number}k
* @return {number}
*/
public static bounceIn(k: number): number {
return 1 - Tween.bounceOut(1 - k);
}
/**
* bounceOut 缓动类型
* @method bounceOut
* @static
* @public
* @since 1.0.0
* @param {number}k
* @return {number}
*/
public static bounceOut(k: number): number {
if (k < (1 / 2.75)) {
return 7.5625 * k * k;
} else if (k < (2 / 2.75)) {
return 7.5625 * (k -= (1.5 / 2.75)) * k + 0.75;
} else if (k < (2.5 / 2.75)) {
return 7.5625 * (k -= (2.25 / 2.75)) * k + 0.9375;
} else {
return 7.5625 * (k -= (2.625 / 2.75)) * k + 0.984375;
}
}
/**
* bounceInOut 缓动类型
* @method bounceInOut
* @static
* @public
* @since 1.0.0
* @param {number}k
* @return {number}
*/
public static bounceInOut(k: number): number {
if (k < 0.5) {
return Tween.bounceIn(k * 2) * 0.5;
}
return Tween.bounceOut(k * 2 - 1) * 0.5 + 0.5;
}
/**
* 这里之所有要独立运行,是因为可能存在多个stage,不能把这个跟其中任何一个stage放在一起update
* @method flush
* @private
* @since 1.0.0
*/
public static flush(): void {
// if (isUpdateTween) {
let len: number = Tween._tweenList.length;
for (let i = len - 1; i >= 0; i--) {
if (Tween._tweenList[i]) {
Tween._tweenList[i].update();
} else {
Tween._tweenList.splice(i, 1);
}
}
// }
// isUpdateTween = !isUpdateTween;
}
}
export enum SoundType {
click = 'click',
bounce = 'bounce',
good = 'good',
recover = 'recover',
shoot = 'shoot',
}
import Body from "./physics/Body";
import { LADDER_START, LADDER_END, LADDER_NUMS, LADDER_H_START, LADDER_H_END, LADDER_H_NUMS } from "./gameconsts";
export const isSpecialBody = (body: Body) => {
return body.type != 'circle' && body.type != 'square' && body.type != 'regTriangle'
}
export const isSpecialCircle = (body: Body)=>{
return body.type ==='specialCircle'
}
const ladderHeight = LADDER_END - LADDER_START;
export const getLadderPosition = (i: number) => {
return ladderHeight / LADDER_NUMS * i + LADDER_START;
}
const ladderWidth = LADDER_H_END - LADDER_H_START;
export const getLadderHPosition = (i: number) => {
return ladderWidth / LADDER_H_NUMS * i + LADDER_H_START;
}
export const getLadderGap = ()=>{
return ladderHeight / LADDER_NUMS
}
export const getBounce = () => {
return 0.9 + Math.random() * 0.09;
}
export const shuffle = (array) => {
const _array = array.concat();
for (let i = _array.length; i--;) {
const j = Math.floor(Math.random() * (i + 1));
const temp = _array[i];
_array[i] = _array[j];
_array[j] = temp;
}
return _array;
}
export function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
export function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
export function playSound(name) {
return;
engine.playSound(engine.getAssetByName(name).uuid, {keep: true});
}
export function createSvga(name, anchorName?) {
let inst = new svga.Svga();
inst.source = 'asset://' + engine.getAssetByName(name).uuid;
return inst;
}
\ No newline at end of file
/**
* Created by rockyl on 2019-11-20.
*/
import {injectProps, prepareProps} from "./props";
import PlayScene from "./game/PlayScene";
import { gameWrapper } from "./game/gameWrapper";
export default function (props) {
prepareProps();
injectProps(props);
let instance = new gameWrapper();
return instance;
}
/**
* Created by rockyl on 2020-01-21.
*/
export let props: any = {};
export function prepareProps() {
let metaProps = getProps();
engine.injectProp(props, metaProps);
}
export function injectProps(p) {
engine.injectProp(props, p);
}
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