Commit 2f353245 authored by rockyl's avatar rockyl

提交一波

parent e4726a61
......@@ -30,8 +30,9 @@
<body>
<div id="game-container" style="line-height:0;font-size:0"></div>
<script src="//res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
<!--script src="http://localhost:4002/debug/engine.js"></script-->
<script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.9a9dbfda4cb2dd5508ecddfe3d95dfd88063f7b5.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>
......
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "静音",
"desc": "静音",
"props": {
"muted": {
"alias": "是否静音",
"type": "boolean",
"default": true
}
},
"output": [
"complete"
],
"id": "mute-sound",
"script": "var muted = engine.findVariable('muted', args, props);\nengine.mute(muted);\nnext('complete');\n",
"group": "base",
"type": "builtin"
}
......@@ -9,13 +9,17 @@
"target": {
"type": "node",
"alias": "目标节点"
},
"props": {
"type": "map",
"alias": "配置属性"
}
},
"output": [
"complete"
],
"id": "add-custom-module",
"script": "engine.addCustomModule(props.id, props.target || target);\nnext('complete');\n",
"script": "var p = engine.findVariable('props', args, props);\nengine.addCustomModule(props.id, props.target || target, p);\nnext('complete');\n",
"group": "view",
"type": "builtin"
}
......@@ -5,13 +5,18 @@
"viewName": {
"alias": "目标视图名",
"type": "string"
},
"replace": {
"alias": "是否替换场景",
"type": "boolean",
"default": false
}
},
"output": [
"complete"
],
"id": "push-scene",
"script": "if (!props.viewName) {\n console.log('没有设置视图名');\n next('exception', '没有设置视图名');\n}\nelse {\n var gameStage = engine.gameStage;\n var view = gameStage.instantiateView(props.viewName);\n if (view) {\n gameStage.sceneContainer.push(view);\n }\n next('complete');\n}\n",
"script": "var replace = engine.findVariable('replace', args, props);\nif (!props.viewName) {\n console.log('没有设置视图名');\n next('exception', '没有设置视图名');\n}\nelse {\n var gameStage = engine.gameStage;\n var view = gameStage.instantiateView(props.viewName);\n if (view) {\n if (replace) {\n gameStage.sceneContainer.replace(view);\n }\n else {\n gameStage.sceneContainer.push(view);\n }\n }\n next('complete');\n}\n",
"group": "view",
"type": "builtin"
}
......@@ -17,17 +17,17 @@
"default": "0.0.0.0"
},
"autoExposure": {
"alias": "自动曝光",
"alias": "曝光自动触发",
"type": "boolean",
"default": true
},
"onceAutoExposure": {
"alias": "单次自动曝光",
"alias": "单次曝光",
"type": "boolean",
"default": true
},
"autoExposureType": {
"alias": "自动曝光方式",
"alias": "曝光触发方式",
"type": "enum",
"enum": [
"visible",
......@@ -36,7 +36,7 @@
"default": "visible"
},
"autoClick": {
"alias": "自动点击",
"alias": "点击自动触发",
"type": "boolean",
"default": true
}
......
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var props_1 = require("../props");
var Block = (function (_super) {
__extends(Block, _super);
function Block() {
var _this = _super.call(this) || this;
var body = _this.body = new svga.Svga();
body.x = -props_1.props.blockWidth / 2;
body.y = -props_1.props.blockHitHeight - props_1.props.blockPaddingTop;
_this.addChild(body);
return _this;
}
Block.prototype.reset = function (_a) {
var type = _a.type;
this.dir = Math.random() > 0.5 ? 1 : -1;
if (this.type != type) {
this.type = type;
var asset_1 = utils_1.getBlockAsset(type);
this.body.source = 'asset://' + asset_1.uuid;
}
this.scaleX = this.dir;
this.body.gotoAndStop(1);
};
Block.prototype.playEnter = function (index, animation) {
var _this = this;
this.visible = true;
this.x = this.dir * this.stage.width;
var _a = props_1.props.blockDurationRange, min = _a[0], max = _a[1];
var duration = Math.max(max - index * props_1.props.blockDurationStep, min);
duration = duration + max * Math.random() * props_1.props.blockDurationRandom * (Math.random() > 0.5 ? 1 : -1);
return new Promise(function (resolve) {
if (animation) {
engine.Tween.get(_this, null, null, true)
.to({ x: 0, }, duration)
.call(resolve);
}
else {
_this.x = 0;
setTimeout(function () {
console.log(_this.body);
}, 200);
resolve();
}
});
};
Block.prototype.playLeave = function () {
this.visible = false;
};
Block.prototype.playEffect = function () {
var body = this.body;
body.play(true, false);
body.once(engine.Event.END_FRAME, function () {
body.gotoAndStop(1);
}, this);
};
Block.prototype.stop = function () {
engine.Tween.removeTweens(this);
};
return Block;
}(engine.Container));
exports.default = Block;
This diff is collapsed.
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var props_1 = require("../props");
var utils_1 = require("./utils");
var GoldBag = (function (_super) {
__extends(GoldBag, _super);
function GoldBag() {
var _this = _super.call(this) || this;
_this.setup();
return _this;
}
GoldBag.prototype.setup = function () {
var avatar = this.avatar = new engine.Sprite(utils_1.getTextureByName('钱袋-静态'));
avatar.x = -props_1.props.goldPackAvatarAnchor.x;
avatar.y = -props_1.props.goldPackAvatarAnchor.y;
this.addChild(avatar);
var svga = this.svga = utils_1.createSvga('钱袋', 'goldPackAnchor');
svga.visible = false;
this.addChild(svga);
};
GoldBag.prototype.reset = function (data) {
this.y = data.y;
this.avatar.visible = true;
this.svga.visible = false;
this.svga.gotoAndStop(1);
this.remain = data.remain;
};
GoldBag.prototype.playOpen = function () {
var _this = this;
this.avatar.visible = false;
this.svga.visible = true;
return new Promise(function (resolve) {
_this.svga.play(true, false);
_this.svga.once(engine.Event.END_FRAME, function () {
this.svga.visible = false;
resolve();
}, _this);
});
};
return GoldBag;
}(engine.Container));
exports.GoldBag = GoldBag;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var GameView_1 = require("./GameView");
var props_1 = require("../props");
var JumpHigh = (function (_super) {
__extends(JumpHigh, _super);
function JumpHigh() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('jump-high-reset', _this.reset, _this);
engine.globalEvent.addEventListener('jump-high-start', _this.start, _this);
engine.globalEvent.addEventListener('jump-high-pause', _this.pause, _this);
engine.globalEvent.addEventListener('jump-high-resume', _this.resume, _this);
engine.globalEvent.addEventListener('jump-high-revive', _this.revive, _this);
_this.addEventListener(engine.MouseEvent.MOUSE_DOWN, _this.onTap, _this);
var gameView = _this._gameView = new GameView_1.default();
_this.addChild(gameView);
return _this;
}
JumpHigh.prototype.reset = function () {
this._gameView.reset();
};
JumpHigh.prototype.start = function (event) {
if ('jump-high-start') {
props_1.injectProps(event.data);
}
this._status = 1;
this._gameView.start();
};
JumpHigh.prototype.pause = function () {
this._gameView.pause();
};
JumpHigh.prototype.resume = function () {
this._gameView.resume();
};
JumpHigh.prototype.revive = function () {
this._gameView.revive();
};
JumpHigh.prototype.onTap = function (event) {
this._gameView.jump();
};
return JumpHigh;
}(engine.Container));
exports.JumpHigh = JumpHigh;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var props_1 = require("../props");
var utils_1 = require("./utils");
var svgaAssets = {
aniReady: { name: '准备立正', dir: 1 },
aniJump: { name: '跳上升', dir: 1 },
aniFall: { name: '跳下落', dir: 1 },
aniLandNormal: { name: '普通着地', dir: 1 },
aniLandSide: { name: '边缘着地', dir: -1 },
aniHit: { name: '被撞开', dir: -1 },
aniParachute: { name: '降落', dir: -1 },
};
var Player = (function (_super) {
__extends(Player, _super);
function Player() {
var _this = _super.call(this) || this;
_this.g = props_1.props.gravity;
_this.addEventListener(engine.Event.ENTER_FRAME, _this.onEnterFrame, _this);
return _this;
}
Player.prototype.switchAni = function (name, dir, play, loop) {
var _this = this;
if (dir === void 0) { dir = 1; }
if (play === void 0) { play = true; }
if (loop === void 0) { loop = false; }
return new Promise(function (resolve) {
_this.scaleX = dir;
if (_this._aniName !== name) {
_this._aniName = name;
var oldAni = _this.removeChild(_this.getChildByName('body'));
if (oldAni) {
oldAni.stop();
}
var ani = _this._currentAni = _this['ani' + name];
_this.addChild(ani);
if (play) {
ani.play(false, loop);
if (loop) {
resolve();
}
else {
ani.once(engine.Event.END_FRAME, resolve);
}
}
else {
ani.gotoAndStop(1);
resolve();
}
}
});
};
Player.prototype.setup = function () {
this.prefectEffect = utils_1.createSvga('完美着地特效', 'playerLandPrefectAnchor');
this.landEffect = utils_1.createSvga('着地特效', 'playerLandEffectAnchor');
for (var key_1 in svgaAssets) {
var _a = svgaAssets[key_1], name_1 = _a.name, dir = _a.dir;
var body = this[key_1] = utils_1.createSvga(name_1, key_1.replace('ani', 'player') + 'Anchor');
body.name = 'body';
body.scaleX = dir;
}
};
Player.prototype.reset = function (revive) {
this.x = 0;
this.rotation = 0;
this.scaleX = this.scaleY = 1;
this._prefectLandCounting = 0;
engine.Tween.removeTweens(this);
if (revive) {
this.switchAni('Jump', 1, false);
}
};
Player.prototype.playReady = function () {
var _this = this;
return new Promise(function (resolve) {
_this.switchAni('Ready', 1);
_this._currentAni.once(engine.Event.END_FRAME, function () {
this.switchAni('Jump', 1, false);
resolve();
}, _this);
});
};
Player.prototype.onEnterFrame = function (event) {
if (!this.playing) {
return;
}
this.vy += this.g;
this.y += this.vy;
if (this.vy > 0 && this._aniName !== 'Fall') {
this.dispatchEvent('jump-on-top');
this.switchAni('Fall');
}
if (this.y > this.baseY) {
this.y = this.baseY;
this.playing = false;
this.jumpPromise && this.jumpPromise({
aboveBlock: this.aboveBlock,
});
this.jumpPromise = null;
}
};
Player.prototype.changeBaseY = function (v) {
if (this.baseY == v) {
return;
}
this.aboveBlock = true;
this.baseY = v;
};
Player.prototype.jump = function () {
var _this = this;
utils_1.playSound('跳起音效');
this.switchAni('Jump', 1, false);
this._currentAni.play(false, false);
this.aboveBlock = false;
this.playing = true;
this.baseY = this.y;
this.vy = -props_1.props.jumpSpeed;
return new Promise(function (resolve) {
_this.jumpPromise = resolve;
});
};
Player.prototype.playLand = function (type, dir) {
return __awaiter(this, void 0, void 0, function () {
var _a, prefectEffect_1, landEffect_1;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = type;
switch (_a) {
case 0: return [3, 1];
case 1: return [3, 3];
case 2: return [3, 3];
case 3: return [3, 4];
}
return [3, 5];
case 1:
this._prefectLandCounting++;
utils_1.playSound('完美落地音效' + Math.min(4, this._prefectLandCounting));
prefectEffect_1 = this.prefectEffect;
this.addChildAt(prefectEffect_1, 0);
prefectEffect_1.gotoAndPlay(1);
prefectEffect_1.once(engine.Event.END_FRAME, function () {
this.removeChild(prefectEffect_1);
}, this);
landEffect_1 = this.landEffect;
this.addChildAt(landEffect_1, 0);
landEffect_1.gotoAndPlay(1);
landEffect_1.once(engine.Event.END_FRAME, function () {
this.removeChild(landEffect_1);
}, this);
return [4, this.switchAni('LandNormal')];
case 2:
_b.sent();
return [3, 5];
case 3:
this._prefectLandCounting = 0;
utils_1.playSound('普通落地音效');
this.switchAni('LandNormal');
return [3, 5];
case 4:
this._prefectLandCounting = 0;
utils_1.playSound('边缘落地音效');
this.switchAni('LandSide', dir);
return [3, 5];
case 5: return [2];
}
});
});
};
Player.prototype.hitAway = function (dir) {
return __awaiter(this, void 0, void 0, function () {
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
this.jumpPromise && this.jumpPromise();
this.jumpPromise = null;
utils_1.playSound('被撞开音效');
this.switchAni('Hit', dir);
this.vy = 0;
return [4, new Promise(function (resolve) {
engine.Tween.get(_this)
.to({
x: -dir * props_1.props.hitAwayDistance.x,
}, props_1.props.hitAwayDuration, engine.Ease.quartOut);
engine.Tween.get(_this)
.to({
y: _this.y + props_1.props.hitAwayDistance.y,
}, props_1.props.hitAwayDuration, engine.Ease.cubicOut)
.call(resolve);
})];
case 1:
_a.sent();
return [2];
}
});
});
};
Player.prototype.parachute = function (dir) {
var _this = this;
this.switchAni('Parachute', dir);
return new Promise(function (resolve) {
engine.Tween.get(_this)
.wait(200)
.call(function () {
utils_1.playSound('降落伞下落音效');
})
.wait(300)
.to({ y: _this.y + props_1.props.parachuteDistance }, props_1.props.parachuteDuration)
.set({ anchorOffsetY: 0 })
.call(resolve);
});
};
return Player;
}(engine.Container));
exports.default = Player;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var props_1 = require("../props");
function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
exports.getTexture = getTexture;
function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
exports.getTextureByName = getTextureByName;
function getBlockAsset(type) {
return engine.getAssetByName(props_1.props.blockAssets[type]);
}
exports.getBlockAsset = getBlockAsset;
function createSvga(name, anchorName) {
var inst = new svga.Svga();
inst.source = 'asset://' + engine.getAssetByName(name).uuid;
var anchor = props_1.props[(anchorName)];
if (anchor) {
inst.x = -anchor.x;
inst.y = -anchor.y;
inst.anchorX = anchor.x;
inst.anchorY = anchor.y;
}
return inst;
}
exports.createSvga = createSvga;
function playSound(name) {
engine.playSound(engine.getAssetByName(name).uuid, { keep: true });
}
exports.playSound = playSound;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var JumpHigh_1 = require("./game/JumpHigh");
var props_1 = require("./props");
function default_1(props) {
props_1.prepareProps();
props_1.injectProps(props);
var instance = new JumpHigh_1.JumpHigh();
return instance;
}
exports.default = default_1;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var Background = (function (_super) {
__extends(Background, _super);
function Background() {
return _super.call(this) || this;
}
Background.prototype.setup = function () {
var _a = this.stage, width = _a.width, height = _a.height;
var bg = this._bg = new engine.Image(utils_1.getTextureByName('背景图'));
bg.anchorX = bg.width / 2;
bg.anchorY = bg.height / 2;
bg.x = -(bg.width - width) / 2;
bg.y = -(bg.height - height) / 2;
this.addChild(bg);
this._minScale = width / bg.width;
};
Background.prototype.playZoom = function (type, duration) {
var _this = this;
if (duration === void 0) { duration = 700; }
return new Promise(function (resolve) {
var scale = type === 'in' ? 1 : _this._minScale;
engine.Tween.get(_this._bg, null, null, true)
.to({ scaleX: scale, scaleY: scale }, duration, engine.Ease.cubicInOut)
.call(resolve);
});
};
return Background;
}(engine.Container));
exports.Background = Background;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var props_1 = require("../props");
var Base = (function (_super) {
__extends(Base, _super);
function Base() {
return _super.call(this, utils_1.getTextureByName('底座')) || this;
}
Base.prototype.setup = function () {
this.x = -(this.width) / 2;
};
Base.prototype.reset = function () {
this.y = -props_1.props.baseOffset;
};
return Base;
}(engine.Image));
exports.Base = Base;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var props_1 = require("../props");
var Block = (function (_super) {
__extends(Block, _super);
function Block() {
var _this = _super.call(this) || this;
var body = _this.body = new svga.Svga();
body.x = -props_1.props.blockWidth / 2;
body.y = -props_1.props.blockHitHeight - props_1.props.blockPaddingTop;
_this.addChild(body);
return _this;
}
Block.prototype.reset = function (_a) {
var type = _a.type;
this.dir = Math.random() > 0.5 ? 1 : -1;
if (this.type != type) {
this.type = type;
var asset_1 = utils_1.getBlockAsset(type);
this.body.source = 'asset://' + asset_1.uuid;
}
this.scaleX = this.dir;
this.body.gotoAndStop(1);
};
Block.prototype.playEnter = function (index, animation) {
var _this = this;
this.visible = true;
this.x = this.dir * this.stage.width;
var _a = props_1.props.blockSpeedRange, min = _a[0], max = _a[1];
var duration = Math.max(max - index * 10, min);
return new Promise(function (resolve) {
if (animation) {
engine.Tween.get(_this, null, null, true)
.to({ x: 0, }, duration)
.call(resolve);
}
else {
_this.x = 0;
setTimeout(function () {
console.log(_this.body);
}, 200);
resolve();
}
});
};
Block.prototype.playLeave = function () {
this.visible = false;
};
Block.prototype.playEffect = function () {
this.body.play(true, false);
};
Block.prototype.stop = function () {
engine.Tween.removeTweens(this);
};
return Block;
}(engine.Container));
exports.default = Block;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var props_1 = require("../props");
var BreakUpPart = (function (_super) {
__extends(BreakUpPart, _super);
function BreakUpPart(turntable, from, to) {
var _this = _super.call(this) || this;
var body = _this._body = new engine.Image();
_this.addChild(body);
var mask = _this._body.mask = new engine.Graphics();
_this.addChild(mask);
_this._turntable = turntable;
_this._from = from;
_this._to = to;
_this._fromR = from * Math.PI / 180;
_this._toR = to * Math.PI / 180;
return _this;
}
BreakUpPart.prototype.updateMask = function () {
var mask = this._body.mask;
mask.beginFill(0xff0000);
mask.moveTo(0, 0);
mask.arc(0, 0, this._turntable.radius + 5, this._fromR, this._toR);
mask.endFill();
var _a = props_1.props.breakUpDistanceRange, min = _a[0], max = _a[1];
var mid = (this._toR - this._fromR) / 2 + this._fromR;
this.x = Math.cos(mid) * Math.random() * max + min;
this.y = Math.sin(mid) * Math.random() * max + min;
this.alpha = 1;
this.rotation = 0;
};
BreakUpPart.prototype.playFall = function (rotation) {
var _this = this;
this._body.rotation = rotation;
return new Promise(function (resolve) {
var angle = (_this._to - _this._from) / 2 + _this._from;
var rotation = (angle > 270 ? 360 : 0) + 90 - angle;
engine.Tween.get(_this, null, null, true)
.to({ y: _this.y + props_1.props.turntableFallDistance, alpha: 0, rotation: rotation }, props_1.props.turntableFallDuration, engine.Ease.cubicIn)
.call(resolve);
});
};
Object.defineProperty(BreakUpPart.prototype, "body", {
get: function () {
return this._body;
},
enumerable: true,
configurable: true
});
return BreakUpPart;
}(engine.Container));
exports.BreakUpPart = BreakUpPart;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var props_1 = require("../props");
var GuideLayer_1 = require("./GuideLayer");
var ObjectPool = engine.ObjectPool;
var Turntable_1 = require("./Turntable");
var object_pool_init_1 = require("./object-pool-init");
var GameView = (function (_super) {
__extends(GameView, _super);
function GameView() {
var _this = _super.call(this) || this;
_this.countDownStep = function (decrease) {
if (decrease === void 0) { decrease = true; }
if (decrease) {
_this._countdown--;
if (_this._countdown <= 0) {
_this.stopCountDown();
_this.onTimeout();
}
}
engine.globalEvent.dispatchEvent('lipstick-turntable-countdown', {
second: _this._countdown,
});
};
_this.onHit = function () { return __awaiter(_this, void 0, void 0, function () {
var stick;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
stick = this._stick;
if (!this.turntable.addStick(stick)) return [3, 2];
this.stopCountDown();
return [4, stick.playFall()];
case 1:
_a.sent();
engine.globalEvent.dispatchEvent('lipstick-turntable-game-failed', {
reason: 2,
});
return [3, 5];
case 2:
this._counting--;
engine.globalEvent.dispatchEvent('lipstick-turntable-hit', {
remain: this._counting,
});
if (!(this._counting === 0)) return [3, 4];
this.turntable.hideSticks();
this.stopCountDown();
return [4, this.turntable.playBreakUp()];
case 3:
_a.sent();
engine.globalEvent.dispatchEvent('lipstick-turntable-game-success');
return [3, 5];
case 4:
this.prepareStick();
_a.label = 5;
case 5: return [2];
}
});
}); };
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
return _this;
}
GameView.prototype.setup = function () {
if (this._hasSetup) {
return;
}
this._hasSetup = true;
var turntable = this.turntable = new Turntable_1.Turntable();
this.addChild(turntable);
var guideLayer = this.guideLayer = new GuideLayer_1.GuideLayer();
this.addChild(guideLayer);
};
GameView.prototype.reset = function (revive, options) {
if (revive === void 0) { revive = false; }
if (options === void 0) { options = null; }
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
if (options) {
this.turntable.reset(options);
this.recycleStick();
}
else {
this.prepareStick();
}
return [2];
});
});
};
GameView.prototype.start = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
this._countdown = props_1.props.countDown;
this._counting = props_1.props.lipstickCount;
this.turntable.start();
this.prepareStick();
this.countDownStep(false);
this.startCountDown();
return [2];
});
});
};
GameView.prototype.startCountDown = function () {
this._timer = setInterval(this.countDownStep, 1000);
};
GameView.prototype.stopCountDown = function () {
if (this._timer) {
clearInterval(this._timer);
this._timer = null;
}
};
GameView.prototype.prepareStick = function () {
var stick = this._stick = ObjectPool.getObject(object_pool_init_1.PoolName);
stick.y = props_1.props.stickDistance;
this.addChildAt(stick, 0);
this._touchEnabled = true;
};
GameView.prototype.recycleStick = function () {
var stick = this._stick;
if (stick) {
this._stick = null;
this.removeChild(stick);
ObjectPool.recycleObject(object_pool_init_1.PoolName, stick);
}
};
GameView.prototype.pause = function () {
this.turntable.pause();
this._stick.stopSend();
this._stick.playFall();
this.stopCountDown();
};
GameView.prototype.resume = function () {
this.recycleStick();
this.turntable.resume();
this.startCountDown();
};
GameView.prototype.revive = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
this.recycleStick();
this.prepareStick();
this.turntable.resume();
return [2];
});
});
};
GameView.prototype.onTimeout = function () {
this.pause();
this._touchEnabled = false;
engine.globalEvent.dispatchEvent('lipstick-turntable-game-failed', {
reason: 1,
});
};
GameView.prototype.tap = function (e) {
if (!this._touchEnabled) {
return;
}
this._touchEnabled = false;
this._stick.playSend(this.turntable.radius - props_1.props.stickInsertDepth, this.onHit);
};
return GameView;
}(engine.Container));
exports.default = GameView;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var GameView_1 = require("./GameView");
var props_1 = require("../props");
var GameWrapper = (function (_super) {
__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('lipstick-turntable-reset', _this.reset, _this);
engine.globalEvent.addEventListener('lipstick-turntable-start', _this.start, _this);
engine.globalEvent.addEventListener('lipstick-turntable-pause', _this.pause, _this);
engine.globalEvent.addEventListener('lipstick-turntable-resume', _this.resume, _this);
engine.globalEvent.addEventListener('lipstick-turntable-revive', _this.revive, _this);
engine.globalEvent.addEventListener('lipstick-turntable-clear', _this.clear, _this);
_this.addEventListener(engine.MouseEvent.CLICK, _this.onTap, _this);
var gameView = _this._gameView = new GameView_1.default();
_this.addChild(gameView);
return _this;
}
GameWrapper.prototype.reset = function (event) {
props_1.injectProps(event.data);
this._gameView.visible = true;
this._gameView.reset(false, event.data);
};
GameWrapper.prototype.start = function (event) {
props_1.injectProps(event.data);
this._status = 1;
this._gameView.start();
};
GameWrapper.prototype.pause = function () {
this._gameView.pause();
};
GameWrapper.prototype.resume = function () {
this._gameView.resume();
};
GameWrapper.prototype.revive = function () {
this._gameView.revive();
};
GameWrapper.prototype.clear = function () {
this._gameView.visible = false;
};
GameWrapper.prototype.onTap = function (event) {
this._gameView.tap(event);
};
return GameWrapper;
}(engine.Container));
exports.GameWrapper = GameWrapper;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var GoldBag = (function (_super) {
__extends(GoldBag, _super);
function GoldBag() {
var _this = _super.call(this) || this;
_this.setup();
return _this;
}
GoldBag.prototype.setup = function () {
var svga = this.svga = utils_1.createSvga('钱袋', 'goldPackAnchor');
this.addChild(svga);
};
GoldBag.prototype.reset = function (data) {
this.y = data.y;
this.svga.visible = true;
this.svga.gotoAndStop(1);
};
GoldBag.prototype.playOpen = function () {
var _this = this;
return new Promise(function (resolve) {
_this.svga.play(true, false);
_this.svga.once(engine.Event.END_FRAME, function () {
this.svga.visible = false;
resolve();
}, _this);
});
};
return GoldBag;
}(engine.Container));
exports.GoldBag = GoldBag;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var props_1 = require("../props");
var utils_1 = require("./utils");
var GuideLayer = (function (_super) {
__extends(GuideLayer, _super);
function GuideLayer() {
var _this = _super.call(this) || this;
_this.setup();
return _this;
}
GuideLayer.prototype.setup = function () {
};
GuideLayer.prototype.show = function (id, options) {
var _this = this;
return new Promise(function (resolve) {
_this.visible = true;
if (!_this.guideMask) {
var _a = _this.stage, width = _a.width, height = _a.height;
var guideMask = _this.guideMask = new engine.Container();
var guideHole = new engine.Image(utils_1.getTextureByName('引导遮罩'));
guideHole.x = (width - guideHole.width) / 2;
guideHole.y = options.y;
guideMask.addChild(guideHole);
_this.createRect(guideMask, 0, 0, width, guideHole.y);
_this.createRect(guideMask, 0, guideHole.y, guideHole.x, guideHole.height);
_this.createRect(guideMask, guideHole.x + guideHole.width, guideHole.y, width - guideHole.x - guideHole.width, guideHole.height);
_this.createRect(guideMask, 0, guideHole.y + guideHole.height, width, height - guideHole.y - guideHole.height);
var label = _this.label = new engine.Label();
label.fillColor = 'white';
label.size = 25;
label.text = props_1.props.guideText;
label.x = (width - label.width) / 2;
label.y = guideHole.y + guideHole.height + 50;
guideMask.addChild(label);
_this.addChild(guideMask);
}
_this.once(engine.MouseEvent.CLICK, function () {
this.visible = false;
resolve();
}, _this);
});
};
GuideLayer.prototype.createRect = function (container, x, y, width, height) {
var rect = new engine.Rect();
rect.x = x;
rect.y = y;
rect.width = width;
rect.height = height;
rect.fillColor = 'black';
rect.alpha = 0.7;
container.addChild(rect);
};
return GuideLayer;
}(engine.Container));
exports.GuideLayer = GuideLayer;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var GameView_1 = require("./GameView");
var props_1 = require("../props");
var JumpHigh = (function (_super) {
__extends(JumpHigh, _super);
function JumpHigh() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('jump-high-reset', _this.reset, _this);
engine.globalEvent.addEventListener('jump-high-start', _this.start, _this);
engine.globalEvent.addEventListener('jump-high-pause', _this.pause, _this);
engine.globalEvent.addEventListener('jump-high-resume', _this.resume, _this);
engine.globalEvent.addEventListener('jump-high-revive', _this.revive, _this);
_this.addEventListener(engine.MouseEvent.CLICK, _this.onTap, _this);
var gameView = _this._gameView = new GameView_1.default();
_this.addChild(gameView);
return _this;
}
JumpHigh.prototype.reset = function () {
this._gameView.reset();
};
JumpHigh.prototype.start = function (event) {
if ('jump-high-start') {
props_1.injectProps(event.data);
}
this._status = 1;
this._gameView.start();
};
JumpHigh.prototype.pause = function () {
this._gameView.pause();
};
JumpHigh.prototype.resume = function () {
this._gameView.resume();
};
JumpHigh.prototype.revive = function () {
this._gameView.revive();
};
JumpHigh.prototype.onTap = function (event) {
this._gameView.jump();
};
return JumpHigh;
}(engine.Container));
exports.JumpHigh = JumpHigh;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var GameView_1 = require("./GameView");
var props_1 = require("../props");
var LipstickTurntable = (function (_super) {
__extends(LipstickTurntable, _super);
function LipstickTurntable() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('lipstick-turntable-reset', _this.reset, _this);
engine.globalEvent.addEventListener('lipstick-turntable-start', _this.start, _this);
engine.globalEvent.addEventListener('lipstick-turntable-pause', _this.pause, _this);
engine.globalEvent.addEventListener('lipstick-turntable-resume', _this.resume, _this);
engine.globalEvent.addEventListener('lipstick-turntable-revive', _this.revive, _this);
_this.addEventListener(engine.MouseEvent.CLICK, _this.onTap, _this);
var gameView = _this._gameView = new GameView_1.default();
_this.addChild(gameView);
return _this;
}
LipstickTurntable.prototype.reset = function () {
this._gameView.reset();
};
LipstickTurntable.prototype.start = function (event) {
if ('lipstick-turntable-start') {
props_1.injectProps(event.data);
}
this._status = 1;
this._gameView.start();
};
LipstickTurntable.prototype.pause = function () {
this._gameView.pause();
};
LipstickTurntable.prototype.resume = function () {
this._gameView.resume();
};
LipstickTurntable.prototype.revive = function () {
this._gameView.revive();
};
LipstickTurntable.prototype.onTap = function (event) {
this._gameView.jump();
};
return LipstickTurntable;
}(engine.Container));
exports.LipstickTurntable = LipstickTurntable;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var GameView_1 = require("./GameView");
var props_1 = require("../props");
var LispstickTurntable = (function (_super) {
__extends(LispstickTurntable, _super);
function LispstickTurntable() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('jump-high-reset', _this.reset, _this);
engine.globalEvent.addEventListener('jump-high-start', _this.start, _this);
engine.globalEvent.addEventListener('jump-high-pause', _this.pause, _this);
engine.globalEvent.addEventListener('jump-high-resume', _this.resume, _this);
engine.globalEvent.addEventListener('jump-high-revive', _this.revive, _this);
_this.addEventListener(engine.MouseEvent.CLICK, _this.onTap, _this);
var gameView = _this._gameView = new GameView_1.default();
_this.addChild(gameView);
return _this;
}
LispstickTurntable.prototype.reset = function () {
this._gameView.reset();
};
LispstickTurntable.prototype.start = function (event) {
if ('jump-high-start') {
props_1.injectProps(event.data);
}
this._status = 1;
this._gameView.start();
};
LispstickTurntable.prototype.pause = function () {
this._gameView.pause();
};
LispstickTurntable.prototype.resume = function () {
this._gameView.resume();
};
LispstickTurntable.prototype.revive = function () {
this._gameView.revive();
};
LispstickTurntable.prototype.onTap = function (event) {
this._gameView.jump();
};
return LispstickTurntable;
}(engine.Container));
exports.LispstickTurntable = LispstickTurntable;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var GameView_1 = require("./GameView");
var props_1 = require("../props");
var LisptickTurntable = (function (_super) {
__extends(LisptickTurntable, _super);
function LisptickTurntable() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('jump-high-reset', _this.reset, _this);
engine.globalEvent.addEventListener('jump-high-start', _this.start, _this);
engine.globalEvent.addEventListener('jump-high-pause', _this.pause, _this);
engine.globalEvent.addEventListener('jump-high-resume', _this.resume, _this);
engine.globalEvent.addEventListener('jump-high-revive', _this.revive, _this);
_this.addEventListener(engine.MouseEvent.CLICK, _this.onTap, _this);
var gameView = _this._gameView = new GameView_1.default();
_this.addChild(gameView);
return _this;
}
LisptickTurntable.prototype.reset = function () {
this._gameView.reset();
};
LisptickTurntable.prototype.start = function (event) {
if ('jump-high-start') {
props_1.injectProps(event.data);
}
this._status = 1;
this._gameView.start();
};
LisptickTurntable.prototype.pause = function () {
this._gameView.pause();
};
LisptickTurntable.prototype.resume = function () {
this._gameView.resume();
};
LisptickTurntable.prototype.revive = function () {
this._gameView.revive();
};
LisptickTurntable.prototype.onTap = function (event) {
this._gameView.jump();
};
return LisptickTurntable;
}(engine.Container));
exports.LisptickTurntable = LisptickTurntable;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var props_1 = require("../props");
var utils_1 = require("./utils");
var svgaAssets = {
aniJump: { name: '跳上升', dir: 1 },
aniFall: { name: '跳下落', dir: 1 },
aniLandNormal: { name: '普通着地', dir: 1 },
aniLandPrefect: { name: '完美着地', dir: 1 },
aniLandSide: { name: '边缘着地', dir: -1 },
aniHit: { name: '被撞开', dir: -1 },
aniParachute: { name: '降落', dir: 1 },
};
var Player = (function (_super) {
__extends(Player, _super);
function Player() {
var _this = _super.call(this) || this;
_this.g = props_1.props.gravity;
_this.addEventListener(engine.Event.ENTER_FRAME, _this.onEnterFrame, _this);
return _this;
}
Player.prototype.switchAni = function (name, dir, play, loop) {
var _this = this;
if (dir === void 0) { dir = 1; }
if (play === void 0) { play = true; }
if (loop === void 0) { loop = false; }
return new Promise(function (resolve) {
_this.scaleX = dir;
if (_this._aniName !== name) {
_this._aniName = name;
var oldAni = _this.removeChild(_this.getChildByName('body'));
if (oldAni) {
oldAni.stop();
}
var ani = _this._currentAni = _this['ani' + name];
_this.addChildAt(ani, 0);
if (play) {
ani.play(false, loop);
if (loop) {
resolve();
}
else {
ani.once(engine.Event.END_FRAME, resolve);
}
}
else {
ani.gotoAndStop(1);
resolve();
}
}
});
};
Player.prototype.setup = function () {
for (var key_1 in svgaAssets) {
var _a = svgaAssets[key_1], name_1 = _a.name, dir = _a.dir;
var body = this[key_1] = utils_1.createSvga(name_1, key_1.replace('ani', 'player') + 'Anchor');
body.name = 'body';
body.scaleX = dir;
}
};
Player.prototype.reset = function () {
this.x = 0;
this.rotation = 0;
this.scaleX = this.scaleY = 1;
this._prefectLandCounting = 0;
engine.Tween.removeTweens(this);
this.switchAni('Jump', 1, false);
};
Player.prototype.onEnterFrame = function (event) {
if (!this.playing) {
return;
}
this.vy += this.g;
this.y += this.vy;
if (this.vy > 0 && this._aniName !== 'Fall') {
this.dispatchEvent('jump-on-top');
this.switchAni('Fall');
}
if (this.y > this.baseY) {
this.y = this.baseY;
this.playing = false;
this.jumpPromise && this.jumpPromise({
aboveBlock: this.aboveBlock,
});
this.jumpPromise = null;
}
};
Player.prototype.changeBaseY = function (v) {
if (this.baseY == v) {
return;
}
this.aboveBlock = true;
this.baseY = v;
};
Player.prototype.jump = function () {
var _this = this;
utils_1.playSound('跳起音效');
this.switchAni('Jump', 1, false);
this._currentAni.play(false, false);
this.aboveBlock = false;
this.playing = true;
this.baseY = this.y;
this.vy = -props_1.props.jumpSpeed;
return new Promise(function (resolve) {
_this.jumpPromise = resolve;
});
};
Player.prototype.playLand = function (type, dir) {
return __awaiter(this, void 0, void 0, function () {
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = type;
switch (_a) {
case 0: return [3, 1];
case 1: return [3, 3];
case 2: return [3, 4];
}
return [3, 5];
case 1:
this._prefectLandCounting++;
utils_1.playSound('完美落地音效' + Math.min(4, this._prefectLandCounting));
return [4, this.switchAni('LandPrefect')];
case 2:
_b.sent();
this.switchAni('Jump', 1, false);
return [3, 5];
case 3:
this._prefectLandCounting = 0;
utils_1.playSound('普通落地音效');
this.switchAni('LandNormal');
return [3, 5];
case 4:
this._prefectLandCounting = 0;
utils_1.playSound('边缘落地音效');
this.switchAni('LandSide', dir);
return [3, 5];
case 5: return [2];
}
});
});
};
Player.prototype.hitAway = function (dir) {
return __awaiter(this, void 0, void 0, function () {
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
this.jumpPromise && this.jumpPromise();
this.jumpPromise = null;
utils_1.playSound('被撞开音效');
this.switchAni('Hit', dir);
this.vy = 0;
return [4, new Promise(function (resolve) {
engine.Tween.get(_this)
.to({
x: -dir * props_1.props.hitAwayDistance.x,
}, props_1.props.hitAwayDuration, engine.Ease.quartOut);
engine.Tween.get(_this)
.to({
y: _this.y + props_1.props.hitAwayDistance.y,
}, props_1.props.hitAwayDuration, engine.Ease.cubicOut)
.call(resolve);
})];
case 1:
_a.sent();
return [2];
}
});
});
};
Player.prototype.parachute = function () {
var _this = this;
utils_1.playSound('降落伞下落音效');
this.switchAni('Parachute');
return new Promise(function (resolve) {
engine.Tween.get(_this)
.to({ y: _this.y + props_1.props.parachuteDistance }, props_1.props.parachuteDuration)
.set({ anchorOffsetY: 0 })
.call(resolve);
});
};
return Player;
}(engine.Container));
exports.default = Player;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var props_1 = require("../props");
var Stick = (function (_super) {
__extends(Stick, _super);
function Stick() {
var _this = _super.call(this) || this;
var body = _this._body = new engine.Sprite(utils_1.getTextureByName('口红素材'));
body.anchorY = _this._body.height / 2;
body.x = -body.width / 2;
_this.addChild(body);
return _this;
}
Stick.prototype.reset = function () {
this.visible = true;
this.rotation = 0;
this.anchorOffsetY = 0;
var body = this._body;
body.y = 0;
body.rotation = 0;
};
Stick.prototype.playSend = function (y, callback) {
this._toY = y;
engine.Tween.get(this)
.to({ y: y }, props_1.props.stickSendDuration)
.call(callback);
};
Stick.prototype.stopSend = function () {
engine.Tween.removeTweens(this);
};
Stick.prototype.playFall = function () {
var _this = this;
return new Promise(function (resolve) {
engine.Tween.get(_this, null, null, true)
.to({ rotation: 30, y: _this._toY + props_1.props.stickFallDistance }, 500, engine.Ease.cubicOut)
.call(resolve);
});
};
Object.defineProperty(Stick.prototype, "anchorOffsetY", {
set: function (v) {
this._body.y = v;
},
enumerable: true,
configurable: true
});
return Stick;
}(engine.Container));
exports.Stick = Stick;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var props_1 = require("../props");
var ObjectPool = engine.ObjectPool;
var object_pool_init_1 = require("./object-pool-init");
var BreakUpPart_1 = require("./BreakUpPart");
var Turntable = (function (_super) {
__extends(Turntable, _super);
function Turntable() {
var _this = _super.call(this) || this;
_this._items = [];
var wrapper = _this._wrapper = new engine.Container();
_this.addChild(wrapper);
var stickContainer = _this._stickContainer = new engine.Container();
wrapper.addChild(stickContainer);
var body = _this._body = new engine.Image();
wrapper.addChild(body);
var breakUpContainer = _this._breakUpContainer = new engine.Container();
for (var i = 0, li = props_1.props.breakUpRatios.length - 1; i < li; i++) {
var part = new BreakUpPart_1.BreakUpPart(_this, props_1.props.breakUpRatios[i], props_1.props.breakUpRatios[i + 1]);
breakUpContainer.addChild(part);
}
breakUpContainer.visible = false;
_this.addChild(breakUpContainer);
return _this;
}
Turntable.prototype.resetAsset = function (body, asset) {
body.source = asset;
body.x = -body.width / 2;
body.y = -body.height / 2;
body.anchorX = -body.x;
body.anchorY = -body.y;
};
Turntable.prototype.reset = function (options) {
var turntableAssetName = options.turntableAssetName;
this.rotationRange = props_1.props.rotationRange;
var body = this._body;
body.visible = true;
this.resetAsset(body, turntableAssetName);
this._radius = body.width / 2;
this.hideSticks();
for (var _i = 0, _a = this._breakUpContainer.children; _i < _a.length; _i++) {
var part = _a[_i];
this.resetAsset(part.body, turntableAssetName);
part.updateMask();
}
this._breakUpContainer.visible = false;
};
Object.defineProperty(Turntable.prototype, "radius", {
get: function () {
return this._radius;
},
enumerable: true,
configurable: true
});
Turntable.prototype.start = function () {
this._dir = 1;
this._items.splice(0);
this.rotateOnce();
};
Turntable.prototype.pause = function () {
engine.Tween.pauseTweens(this._wrapper);
};
Turntable.prototype.resume = function () {
engine.Tween.resumeTweens(this._wrapper);
};
Turntable.prototype.addStick = function (stick) {
var angle = this.parseAngle(this._wrapper.rotation);
var minDis = props_1.props.stickAngle * 2;
var hitOn = false;
for (var _i = 0, _a = this._items; _i < _a.length; _i++) {
var item = _a[_i];
if (Math.abs(item - angle) < minDis) {
hitOn = true;
break;
}
}
if (hitOn) {
this.pause();
}
else {
this._items.push(angle);
stick.anchorOffsetY = stick.y;
stick.y = 0;
stick.rotation = -this._wrapper.rotation;
this._stickContainer.addChild(stick);
this.shake();
}
return hitOn;
};
Turntable.prototype.parseAngle = function (r) {
var round = r % 360;
if (round < 0) {
round += 360;
}
return round;
};
Turntable.prototype.hideSticks = function () {
for (var _i = 0, _a = this._stickContainer.children; _i < _a.length; _i++) {
var stick = _a[_i];
ObjectPool.recycleObject(object_pool_init_1.PoolName, stick);
}
this._stickContainer.removeChildren();
};
Turntable.prototype.playBreakUp = function () {
return __awaiter(this, void 0, void 0, function () {
var p, _i, _a, part;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
this.pause();
this._body.visible = false;
this._breakUpContainer.visible = true;
for (_i = 0, _a = this._breakUpContainer.children; _i < _a.length; _i++) {
part = _a[_i];
p = part.playFall(this._wrapper.rotation);
}
return [4, p];
case 1:
_b.sent();
return [2];
}
});
});
};
Turntable.prototype.shake = function () {
engine.Tween.get(this, null, null, true)
.to({ y: this.y - 5 }, 50)
.to({ y: this.y }, 50);
};
Turntable.prototype.rotateOnce = function () {
var _a = this.rotationRange, min = _a[0], max = _a[1];
var dealtRotation = Math.random() * max + min;
var duration = dealtRotation * (Math.random() * props_1.props.rotationDurationMultipleRandom + props_1.props.rotationDurationMultipleBase);
var rotation = this._wrapper.rotation + this._dir * dealtRotation;
this._dir *= -1;
engine.Tween.get(this._wrapper, null, null, true)
.to({ rotation: rotation }, duration)
.call(this.rotateOnce, this);
};
return Turntable;
}(engine.Container));
exports.Turntable = Turntable;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Stick_1 = require("./Stick");
var ObjectPool = engine.ObjectPool;
exports.PoolName = 'stick';
ObjectPool.registerPool(exports.PoolName, function () {
return new Stick_1.Stick();
}, function (item, data) {
item.reset();
});
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
exports.getTexture = getTexture;
function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
exports.getTextureByName = getTextureByName;
function playSound(name) {
engine.playSound(engine.getAssetByName(name).uuid, { keep: true });
}
exports.playSound = playSound;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var GameWrapper_1 = require("./game/GameWrapper");
var props_1 = require("./props");
function default_1(props) {
props_1.prepareProps();
props_1.injectProps(props);
var instance = new GameWrapper_1.GameWrapper();
return instance;
}
exports.default = default_1;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.props = {};
function prepareProps() {
var metaProps = getProps();
engine.injectProp(exports.props, metaProps);
}
exports.prepareProps = prepareProps;
function injectProps(p) {
engine.injectProp(exports.props, p);
}
exports.injectProps = injectProps;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var GameObject_1 = require("./GameObject");
var Collider_1 = require("../Phycics/Collider");
var MConst_1 = require("../Global/MConst");
var Bullet_1 = require("./Bullet");
var SoundMgr_1 = require("../Mgr/SoundMgr");
var MTimer_1 = require("../Global/MTimer");
var props_1 = require("../../props");
var DataMgr_1 = require("../Mgr/DataMgr");
var utils_1 = require("../utils");
var Car = (function (_super) {
__extends(Car, _super);
function Car() {
var _this = _super.call(this) || this;
_this.imgParticel = null;
_this.fireTimer = null;
_this.touchWall = 0;
_this.isDied = false;
_this.fireParticleTimer = 0;
_this.invincible = false;
_this.rowBulletNum = 1;
_this.fireSpeed = MConst_1.MConst.BulletFireSpeed.min;
var carCollidePaddingX = props_1.props.carCollidePaddingX, carCollidePaddingY = props_1.props.carCollidePaddingY;
var sprite = new engine.Sprite(utils_1.getTexture("ddf5128e-be66-4c00-8505-e4167aac37bc"));
sprite.x = 0;
sprite.y = 16;
_this.addChild(sprite);
var particle = new engine.Sprite(utils_1.getTexture("d8daa113-0d75-4139-9e81-c54b7522c890"));
particle.x = (sprite.width - particle.width) / 2;
particle.y = 0;
_this.addChild(particle);
_this.imgParticel = particle;
MTimer_1.default.onFrame("Car", _this.onUpdate, _this);
var collider = _this.collider = _this.addComponent(Collider_1.RectCollider);
collider.setData(carCollidePaddingX, carCollidePaddingY, sprite.width - carCollidePaddingX * 2, sprite.height - carCollidePaddingY * 2);
collider.group = Collider_1.ColliderGroup.Car;
return _this;
}
Car.prototype.fire = function () {
SoundMgr_1.default.instance.playEffect("shoot");
new Bullet_1.BulletGroup(new engine.Point(this.x + this.width / 2, this.y), this.rowBulletNum);
};
Car.prototype.die = function () {
if (this.invincible)
return;
if (this.isDied)
return;
this.isDied = true;
this.onDied && this.onDied();
};
Car.prototype.onCollisionEnter = function (other) {
if (other.group == Collider_1.ColliderGroup.Ball) {
this.die();
}
if (other.group == Collider_1.ColliderGroup.Wall) {
this.touchWall = other.owner.x < 0 ? 1 : -1;
}
};
Car.prototype.onCollisionStay = function (other) {
if (other.group == Collider_1.ColliderGroup.Ball) {
this.die();
}
if (other.group == Collider_1.ColliderGroup.Wall) {
this.touchWall = other.owner.x < 0 ? 1 : -1;
}
};
Car.prototype.onceBlink = function () {
var _this = this;
engine.Tween.get(this)
.to({ alpha: 0 }, 1)
.wait(100)
.to({ alpha: 1 }, 1)
.wait(100)
.call(function () {
_this.onceBlink();
});
};
Car.prototype.revive = function () {
var _this = this;
this.invincible = true;
this.isDied = false;
engine.Tween.removeTweens(this);
this.onceBlink();
MTimer_1.default.setFrameTimer(MConst_1.MConst.ReviveInvincibleDuration * 60, function () {
_this.invincible = false;
_this.alpha = 1;
engine.Tween.removeTweens(_this);
});
};
Car.prototype.move = function (deltaX) {
if (this.touchWall == 1 && deltaX <= 0) {
return;
}
else if (this.touchWall == -1 && deltaX >= 0) {
return;
}
var carCollidePaddingX = props_1.props.carCollidePaddingX;
var _a = this.collider.rect, x = _a.x, width = _a.width;
this.x = Math.max(-x, Math.min(750 - width - carCollidePaddingX, this.x + deltaX));
};
Car.prototype.onCollisionExit = function (other) {
if (other.group == Collider_1.ColliderGroup.Wall) {
this.touchWall = 0;
}
};
Car.prototype.onUpdate = function () {
if (DataMgr_1.DataMgr.game.pause)
return;
var score = DataMgr_1.DataMgr.game.bulletScore;
if (score <= 20) {
var max = MConst_1.MConst.BulletFireSpeed.max;
var min = MConst_1.MConst.BulletFireSpeed.min;
this.fireSpeed = min + (max - min) * (score / 20);
}
else {
this.fireSpeed = MConst_1.MConst.BulletFireSpeed.max;
}
this.rowBulletNum = Math.ceil((utils_1.clamp(score, 15, 140) / 2) / 10);
this.fireTimer += 1 * MTimer_1.default.dtFactor;
if (this.fireTimer >= 60 / this.fireSpeed) {
this.fire();
this.fireTimer = 0;
}
if (this.fireParticleTimer % 3 == 0) {
this.imgParticel.visible = !this.imgParticel.visible;
}
this.fireParticleTimer++;
};
return Car;
}(GameObject_1.default));
exports.default = Car;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var MConfigs_1 = require("../Global/MConfigs");
var MConst_1 = require("../Global/MConst");
var utils_1 = require("../utils");
var props_1 = require("../../props");
var padding = 10;
var GuideMask = (function (_super) {
__extends(GuideMask, _super);
function GuideMask(index, x1, y1) {
var _this = _super.call(this) || this;
var config = MConfigs_1.MConfigs.guide[index];
var mask = new engine.Sprite(utils_1.getTexture("3cc0aa86-0581-4caa-b662-266e58fd39b7"));
var w = mask.width, h = mask.height;
x1 = Math.floor(x1);
y1 = Math.floor(y1);
var x = x1 - w / 2;
var y = y1 - h / 2;
mask.x = x;
mask.y = y;
_this.addChild(mask);
var sw = MConst_1.MConst.DesignResolution.width, sh = MConst_1.MConst.DesignResolution.height;
var color = 0x000000;
var alpha = 0.7;
var top = new engine.Shape();
top.beginFill(color, alpha);
top.drawRect(0, 0, sw, y);
top.endFill();
_this.addChild(top);
var bottom = new engine.Shape();
bottom.beginFill(color, alpha);
bottom.drawRect(x, y + h, w, sh - h - y);
bottom.endFill();
_this.addChild(bottom);
var left = new engine.Shape();
left.beginFill(color, alpha);
left.drawRect(0, y, x, sh - y);
left.endFill();
_this.addChild(left);
var right = new engine.Shape();
right.beginFill(color, alpha);
right.drawRect(x + w, y, sw - x - w, sh - y);
right.endFill();
_this.addChild(right);
var offsetToMask = config.text.offsetToMask;
var label = new engine.Label();
label.text = props_1.props['guideText' + index];
label.size = 24;
label.fillColor = "rgba(255,255,255,1)";
label.x = mask.x + (w - label.width) / 2;
label.y = offsetToMask.y + mask.y;
_this.addChild(label);
if (index == 0) {
var left_1 = new engine.Sprite(utils_1.getTexture("93992a62-e3c4-46d5-99f4-f7ba35fe4f4f"));
left_1.x = x1 + 200;
left_1.y = y1 - left_1.height / 2;
_this.addChild(left_1);
var right_1 = new engine.Sprite(utils_1.getTexture("93992a62-e3c4-46d5-99f4-f7ba35fe4f4f"));
right_1.x = x1 - 200;
right_1.scaleX = -1;
right_1.y = y1 - right_1.height / 2;
_this.addChild(right_1);
}
if (label.x < padding) {
label.x = padding;
}
else if (label.x + label.width > 750 - padding) {
label.x = 750 - label.width - padding;
}
_this.addEventListener(engine.MouseEvent.MOUSE_DOWN, function () {
_this.onClick && _this.onClick(_this);
}, _this);
return _this;
}
return GuideMask;
}(engine.Container));
exports.default = GuideMask;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var MConfigs;
(function (MConfigs) {
function updateConfig() {
var mconfig = window["mconfig"];
if (typeof mconfig != "object")
return;
Object.keys(mconfig).forEach(function (e) {
MConfigs[e] = mconfig[e];
});
}
MConfigs.updateConfig = updateConfig;
MConfigs.size = [0.3125, 0.5357, 0.7321, 1];
MConfigs.drop = [
{
type: "bullet",
value: 1,
textColor: 0x5dcefa,
fileIndex: "0"
},
{
type: "bullet",
value: 2,
textColor: 0x69e7fc,
fileIndex: "1"
},
{
type: "power",
value: 30,
textColor: 0xe83cf7,
fileIndex: "2"
},
{
type: "power",
value: 20,
textColor: 0xeb3924,
fileIndex: "1"
},
{
type: "power",
value: 10,
textColor: 0xfef552,
fileIndex: "0"
}
];
MConfigs.dropPool = {
0: {
num: 3,
factor: {
0: 40,
1: 0,
2: 0,
3: 15,
4: 50
}
},
1: {
num: 2,
factor: {
0: 40,
1: 0,
2: 5,
3: 15,
4: 50
}
},
2: {
num: 1,
factor: {
0: 40,
1: 0,
2: 5,
3: 15,
4: 50
}
}
};
MConfigs.guide = {
0: {
mask: "guide_mask_0_png",
text: {
str: "左右移动炮车进行射击和躲避",
offsetToMask: {
x: 8,
y: 290
}
}
},
1: {
mask: "guide_mask_1_png",
text: {
str: "拾取金币可获得更多的炮弹输出和得分加成",
offsetToMask: {
x: -65,
y: 290
}
}
},
};
})(MConfigs = exports.MConfigs || (exports.MConfigs = {}));
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var props_1 = require("../../props");
var GuideMask_1 = require("../Game/GuideMask");
var DataMgr_1 = require("./DataMgr");
var MConfigs_1 = require("../Global/MConfigs");
var GuideMgr = (function () {
function GuideMgr() {
this.done = [];
this.currentGuideMask = null;
}
Object.defineProperty(GuideMgr, "instance", {
get: function () {
if (!GuideMgr._instance) {
GuideMgr._instance = new GuideMgr();
}
return GuideMgr._instance;
},
enumerable: true,
configurable: true
});
Object.defineProperty(GuideMgr.prototype, "guideFlag", {
get: function () {
return localStorage.getItem("shoot-planet_" + props_1.props.guideFlagKey) != "false";
},
set: function (v) {
localStorage.setItem("shoot-planet_" + props_1.props.guideFlagKey, v ? "true" : "false");
},
enumerable: true,
configurable: true
});
Object.defineProperty(GuideMgr.prototype, "guideDone", {
get: function () {
return !this.guideFlag || this.done.length >= Object.keys(MConfigs_1.MConfigs.guide).length;
},
enumerable: true,
configurable: true
});
GuideMgr.prototype.runGuide = function (index, x, y, end) {
var _this = this;
if (end === void 0) { end = false; }
if (this.done[index] || this.guideFlag == false)
return;
this.done.push(index);
DataMgr_1.DataMgr.game.pause = true;
this.currentGuideMask = new GuideMask_1.default(index, x, y);
this.currentGuideMask.onClick = function (context) {
context.destroy();
DataMgr_1.DataMgr.game.pause = false;
if (_this.done.length >= Object.keys(MConfigs_1.MConfigs.guide).length) {
DataMgr_1.DataMgr.game.onGuideDone();
}
if (end) {
_this.guideFlag = false;
}
};
engine.gameStage.addChild(this.currentGuideMask);
};
GuideMgr._instance = null;
return GuideMgr;
}());
exports.default = GuideMgr;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Game_1 = require("./Game/Game");
var MTimer_1 = require("./Global/MTimer");
var DebugMgr_1 = require("./Mgr/DebugMgr");
var GuideMgr_1 = require("./Mgr/GuideMgr");
var ShootPlanet = (function (_super) {
__extends(ShootPlanet, _super);
function ShootPlanet() {
var _this = _super.call(this) || this;
_this.game = null;
_this.customProperty();
_this.width = 750;
_this.height = 1624;
_this.init();
engine.globalEvent.addEventListener('game-create', _this.onActive, _this);
engine.globalEvent.addEventListener('game-destroy', _this.onSleep, _this);
engine.globalEvent.addEventListener('game-revive', _this.onRevive, _this);
engine.globalEvent.addEventListener('game-pause', _this.onPause, _this);
engine.globalEvent.addEventListener('game-resume', _this.onResume, _this);
return _this;
}
ShootPlanet.prototype.onActive = function () {
this.game = new Game_1.default(this);
if (GuideMgr_1.default.instance.guideFlag == true) {
var car = this.game._car;
GuideMgr_1.default.instance.runGuide(0, car.x + car.width / 2, car.y + car.height / 2);
}
if (GuideMgr_1.default.instance.guideDone) {
this.game.onGuideDone();
}
};
ShootPlanet.prototype.onSleep = function () {
this.game.destroy();
this.game = null;
};
ShootPlanet.prototype.onRevive = function () {
this.game.revive();
};
ShootPlanet.prototype.onPause = function () {
this.game.pause = true;
};
ShootPlanet.prototype.onResume = function () {
this.game.pause = false;
};
ShootPlanet.prototype.init = function () {
MTimer_1.default.init();
DebugMgr_1.default.instance.init(this);
};
ShootPlanet.prototype.customProperty = function () {
Object.defineProperty(engine.Point.prototype, 'length', {
get: function () {
return Math.sqrt(this.x * this.x + this.y * this.y);
}
});
engine.DisplayObject.prototype.destroy = function () {
this.parent.removeChild(this);
};
};
return ShootPlanet;
}(engine.Container));
exports.ShootPlanet = ShootPlanet;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var ShootPlanet_1 = require("./game/ShootPlanet");
var props_1 = require("./props");
function default_1(props) {
props_1.prepareProps();
props_1.injectProps(props);
var instance = new ShootPlanet_1.ShootPlanet();
return instance;
}
exports.default = default_1;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.props = {};
function prepareProps() {
var metaProps = getProps();
engine.injectProp(exports.props, metaProps);
}
exports.prepareProps = prepareProps;
function injectProps(p) {
engine.injectProp(exports.props, p);
}
exports.injectProps = injectProps;
var replace = engine.findVariable('replace', args, props);
if (!props.viewName) {
console.log('没有设置视图名');
next('exception', '没有设置视图名');
}
else {
var gameStage = engine.gameStage;
var view = gameStage.instantiateView(props.viewName);
if (view) {
if (replace) {
gameStage.sceneContainer.replace(view);
}
else {
gameStage.sceneContainer.push(view);
}
}
next('complete');
}
declare module svga {
export class BezierPath {
_d: any;
_transform: any;
_styles: any;
_shape: any;
constructor(d?: any, transform?: any, styles?: any);
}
export class FrameEntity {
alpha: number;
transform: {
a: number;
b: number;
c: number;
d: number;
tx: number;
ty: number;
};
layout: {
x: number;
y: number;
width: number;
height: number;
};
nx: number;
ny: number;
/**
* BezierPath
*/
maskPath: any;
/**
* Object[]
*/
shapes: any[];
constructor(spec: any);
static lastShapes: any;
}
export class SpriteEntity {
/**
* string
*/
matteKey: any;
/**
* string
*/
imageKey: any;
/**
* FrameEntity[]
*/
frames: any[];
constructor(spec: any);
}
export class VideoEntity extends engine.HashObject {
/**
* SVGA 文件版本
*/
version: string;
/**
* 影片尺寸
*/
videoSize: {
width: number;
height: number;
};
/**
* 帧率
*/
FPS: number;
/**
* 帧数
*/
frames: number;
/**
* Bitmaps
*/
images: {};
/**
* 图片是否已被缓存,缓存全局,注意名字覆盖
*/
hasBeenCached: boolean;
/**
* SpriteEntity[]
*/
sprites: SpriteEntity[];
/**
* AudioEntity[]
*/
audios: any[];
constructor(spec: any, images: any);
resetSprites(spec: any): void;
destroy(): void;
}
export class MovieClip extends engine.Container {
/**
* 锁步将按时间间隔来执行动画
*/
lockStep: boolean;
/**
* mc的当前帧,从1开始
* @property currentFrame
* @public
* @since 1.0.0
* @type {number}
* @default 1
* @readonly
*/
get currentFrame(): number;
/**
* @property _curFrame
* @type {number}
* @private
* @since 2.0.0
* @default 1
*/
private _curFrame;
/**
* 当前动画是否处于播放状态
* @property isPlaying
* @readOnly
* @public
* @since 1.0.0
* @type {boolean}
* @default true
* @readonly
*/
get isPlaying(): boolean;
/**
* @property _isPlaying
* @type {boolean}
* @private
* @since 2.0.0
* @default true
*/
private _isPlaying;
/**
* 动画的播放方向,是顺着播还是在倒着播
* @property isFront
* @public
* @since 1.0.0
* @type {boolean}
* @default true
* @readonly
*/
get isFront(): boolean;
/**
* @property _isFront
* @type {boolean}
* @private
* @default true
*/
private _isFront;
/**
* 当前动画的总帧数
* @property totalFrames
* @public
* @since 1.0.0
* @type {number}
* @default 1
* @readonly
*/
totalFrames: number;
loops: number;
/**
* 所有textures缓存
*/
private textures;
/**
* 锁步的时间间隔,按fps定,毫秒
*/
private timeInterval;
/**
* 前提引擎按60设置
*/
private deltaFrame;
/**
* 中间帧计时
*/
private frameCount;
/**
* 构造函数
* @method MovieClip
* @public
* @since 1.0.0
*/
constructor(mv?: VideoEntity);
/**
* 可以手动用init,
* @param mv
*/
init(mv: VideoEntity): void;
private initChildren;
/**
* 用基础属性重置
* @param display
* @param transform
*/
private resetTransform;
/**
* 用基础属性重置所有的待frame的children
* @param frameIndex 帧 1到total
*/
resetTransformAll(frameIndex: number): void;
/**
*
* @param imagekey 对应的imagekey
* @param imageUrl 图片路径,以后考虑支持多种形式
*/
setImage(imagekey: any, imageUrl: string): void;
/**
* 调用止方法将停止当前帧
* @method stop
* @public
* @since 1.0.0
*/
stop(): void;
/**
* 将播放头向后移一帧并停在下一帧,如果本身在最后一帧则不做任何反应
* @method nextFrame
* @since 1.0.0
* @public
*/
nextFrame(): void;
/**
* 将播放头向前移一帧并停在下一帧,如果本身在第一帧则不做任何反应
* @method prevFrame
* @since 1.0.0
* @public
*/
prevFrame(): void;
/**
* 将播放头跳转到指定帧并停在那一帧,如果本身在第一帧则不做任何反应
* @method gotoAndStop
* @public
* @since 1.0.0
* @param {number} frameIndex 批定帧的帧数或指定帧的标签名
*/
gotoAndStop(frameIndex: number): void;
/**
* 如果当前时间轴停在某一帧,调用此方法将继续播放.
* @method play
* @public
* @since 1.0.0
*/
play(isFront?: boolean, loop?: boolean): void;
/**
* @property _lastFrame
* @type {number}
* @private
* @default 0
*/
private _lastFrame;
/**
* 刚执行到的帧数,用于帧监听时判断用,刚好执行到当前帧,而不是之前保留的状态
* 不是60fps的videoItem的中间有几帧curFrame会不变,判断只执行一次监听时会出错,刚好动画满帧60fps时就无所谓
*/
get isInTimeFrame(): boolean;
/**
* 将播放头跳转到指定帧并从那一帧开始继续播放
* @method gotoAndPlay
* @public
* @since 1.0.0
* @param {number} frameIndex 批定帧的帧数或指定帧的标签名
* @param {boolean} isFront 跳到指定帧后是向前播放, 还是向后播放.不设置些参数将默认向前播放
*/
gotoAndPlay(frameIndex: number, isFront?: boolean): void;
/**
* 优先级最高,会覆盖
* @param beginFrame 默认1
* @param endFrame 默认 this.totalFrames
* @param loops 默认1 0
*/
startAniRange(beginFrame?: number, endFrame?: number, loops?: number, callback?: Function): void;
/**
* 开始时间,每次有play的时候就需要重置now
* 锁步思想,设置开始时间,后面每帧实际时间与开始时间相减,得到当前帧数
*
*/
private startTime;
/**
* 开始时的frame
*/
private startFrame;
/**
* 与startFrame相间隔的帧数量,绝对值
*/
private lastDeltaFrame;
/**
* 锁步时的每次end的标识
*/
private _endMark;
commonDeltaTime: number;
updateFrame(): void;
private getCurFrameWhenLockStep;
/**
* 重写刷新
* @method update
* @public
* @since 1.0.0
*/
update(deltaTime: number): void;
destroy(): void;
}
export class Svga extends MovieClip {
private _source;
autoPlay: boolean;
get source(): string;
set source(v: string);
private _setSource;
private _dataInitialized;
}
export class Parser {
/**
* url: 资源路径
* success(VideoEntity videoItem)
*/
load(url, success, failure);
loadViaWorker(url, success, failure);
}
}
......@@ -3,6 +3,8 @@ declare module engine {
export const devicePixelRatio: number;
export function computeProps(props, options);
export let StageScaleMode: {
EXACT_FIT: string;
NO_BORDER: string;
......@@ -10,7 +12,7 @@ declare module engine {
SHOW_ALL: string;
FIXED_WIDTH: string;
FIXED_HEIGHT: string;
}
};
export const osType: string;
......@@ -24,6 +26,8 @@ declare module engine {
export const DEG_TO_RAD: number;
export function transPoint(str, sep = ',');
export enum RENDERER_TYPE {
UNKNOWN = "unknown",
WEBGL = "webgl",
......@@ -8378,6 +8382,8 @@ declare module engine {
export function stopSound(name: any): void;
export function mute(muted: boolean): void;
export function destroySound(name: any): void;
export const _default: {
......
......@@ -6,38 +6,76 @@ const {compile} = require('./rollup-compiler');
const fs = require('fs-extra');
const path = require('path');
const glob = require('glob');
const watchr = require('watchr');
const program = require('commander');
const [_, __, sourcePath, outputPath = 'dist/customs'] = process.argv;
program
.option('-s, --source [string]', 'Source path')
.option('-o, --output [string]', 'Output path', 'dist/customs')
.option('-w, --watch', 'Auto build', false)
.option('-p, --prod', 'Pack with production env', false)
.parse(process.argv);
(async function(){
if (sourcePath) {
await compileProcess(sourcePath, outputPath);
(async function () {
if (program.source) {
await watchWrapper(program.source, program.output);
} else {
const files = glob.sync('*', {cwd: process.cwd() + '/src/custom'});
for (let file of files) {
await compileProcess(file, outputPath);
await compileProcess(file, program.output);
}
}
console.log('complete!');
})();
async function compileProcess(sourcePath, output) {
const id = sourcePath;
const meta = fs.readJsonSync(path.join('src/custom/' + sourcePath, 'meta.json'));
const result = await compile('src/custom/' + sourcePath + '/index.ts', false);
async function watchWrapper(sourcePath, output) {
if (program.watch) {
let srcPath = 'src/custom/' + sourcePath + '/src';
let stalker = watchr.open(srcPath, function (changeType, fullPath, currentStat, previousStat) {
console.log('watch:', fullPath);
compileProcess(sourcePath, output)
}, next);
stalker.setConfig({
interval: 100,
});
compileProcess(sourcePath, output)
} else {
await compileProcess(file, program.output)
}
}
function next(err) {
if (err) return console.log('watch failed on', path, 'with error', err);
}
async function compileProcess(id, output) {
const meta = fs.readJsonSync(path.join('src/custom/' + id, 'meta.json'));
const result = await compile('src/custom/' + id + '/src/index.ts', {
prod: program.prod,
moduleName: id,
});
meta.id = id;
if(result){
let code;
if (result) {
code = result.code;
meta.code = result.code;
}
const outputPath = path.join(output, sourcePath);
const outputPath = path.join(output, id);
console.log(outputPath);
fs.ensureDirSync(path.dirname(outputPath));
fs.writeJsonSync(outputPath + '.json', meta, {spaces: ' '});
/*fs.writeFileSync(outputPath + '.js', result.code);
fs.writeJsonSync(outputPath + '-req.json', {
let debugOutputPath = 'src/custom/' + id + '/debug/main';
if (result && result.map) {
fs.writeFileSync(debugOutputPath + '.js.map', result.map.toString());
code += `\n//# sourceMappingURL=` + 'main' + '.js.map';
}
fs.writeFileSync(debugOutputPath + '.js', code);
/*fs.writeJsonSync(outputPath + '-req.json', {
data: JSON.stringify(meta)
});*/
console.log(`compile custom [${sourcePath}] successfully!`);
console.log(`compile custom [${id}] successfully!`);
}
......@@ -9,8 +9,10 @@ const typescript = require('rollup-plugin-typescript');
const {uglify} = require('rollup-plugin-uglify');
const rollup = require('rollup');
let cache;
exports.compile = async function (file, options) {
const {prod = false} = options;
const {prod = false, moduleName} = options;
let plugins = [
progress(),
......@@ -28,12 +30,19 @@ exports.compile = async function (file, options) {
}
let writeConfig = {
format: 'cjs',
format: prod ? 'cjs' : 'umd',
name: moduleName,
sourcemap: !prod,
globals: {
tslib: 'tslib'
},
};
const bundle = await buildWithCache();
const {output: [result]} = await bundle.generate(writeConfig);
return result;
async function buildWithCache() {
const bundle = await rollup.rollup({
input: file,
plugins,
......@@ -41,7 +50,9 @@ exports.compile = async function (file, options) {
console.log(warning);
},
external: ['tslib'],
cache,
});
const {output: [result]} = await bundle.generate(writeConfig);
return result;
cache = bundle.cache;
return bundle;
}
};
/**
* Created by rockyl on 2019-12-16.
*/
const customId = 'jump-high';
(async function () {
let customModule = await fetch(`../meta.json`);
customModule = await customModule.json();
console.log(customModule);
await loadAssets(customModule.assets);
launchWithCustomModule(customModule);
})();
function launchWithCustomModule(customModule) {
engine.globalEvent.addEventListener('update-game-status', (e) => {
console.log(e.type, e.data);
});
//engine.registerCustomCodeModule(customModule);
engine.registerCustomModule(customId, window[customId]);
const {props: propsOption, assets} = customModule;
let props = engine.computeProps(customModuleProps, propsOption);
const customModuleIns = {
id: customId,
props,
assets,
};
engine.registerCustomModules([customModuleIns]);
engine.launchWithConfig({
options: {
entrySceneView: 'entry',
},
assets: [],
views: [{
name: 'entry',
type: 'node',
}],
}, null, function () {
setTimeout(() => {
engine.addCustomModule(customId, engine.gameStage.sceneContainer.getChildAt(0));
}, 100);
setTimeout(() => {
engine.globalEvent.dispatchEvent('jump-high-start', {level: 1});
}, 500);
});
}
function getAssetByUUID(uuid) {
return engine.resolveCustomAsset(customId, uuid);
}
function getProps() {
return engine.getProps(customId);
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>叠叠高</title>
<meta name="viewport"
content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="full-screen" content="true"/>
<meta name="screen-orientation" content="portrait"/>
<meta name="x5-fullscreen" content="true"/>
<meta name="360-fullscreen" content="true"/>
<style>
html,
body {
padding: 0;
margin: 0;
border: 0;
width: 100%;
height: 100%;
overflow: hidden;
position: absolute;
background-color: transparent;
}
</style>
</head>
<body>
<div id="game-container" style="line-height:0;font-size:0"></div>
<script src="http://localhost:4002/debug/engine.js"></script>
<script 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": "方块素材0",
"url": "//yun.duiba.com.cn/aurora/assets/0307ca8906e9f553e6873c346ae5c6ec3655db59.svga",
"uuid": "4e31f5d7-bd03-41a3-873c-3755fe4862e6",
"ext": '.svga'
}
];
function loadAssets(customModuleAssets, onProgress, onComplete){
return engine.loadAssets(assets.concat(...customModuleAssets), onProgress, onComplete);
}
This diff is collapsed.
This diff is collapsed.
/**
* Created by rockyl on 2020-01-21.
*/
let customModuleProps = {
};
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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