Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zeroing-libs
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
劳工
zeroing-libs
Commits
86efa534
Commit
86efa534
authored
Dec 03, 2020
by
wildfirecode13
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
5c486690
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
144 additions
and
293 deletions
+144
-293
jump-high-3.json
dist/customs/jump-high-3.json
+19
-35
load-assets.js
src/custom/jump-high-3/debug/load-assets.js
+1
-7
main.js
src/custom/jump-high-3/debug/main.js
+37
-92
main.js.map
src/custom/jump-high-3/debug/main.js.map
+1
-1
meta.json
src/custom/jump-high-3/meta.json
+19
-29
Background.ts
src/custom/jump-high-3/src/game/Background.ts
+8
-8
Block.ts
src/custom/jump-high-3/src/game/Block.ts
+11
-57
GameView.ts
src/custom/jump-high-3/src/game/GameView.ts
+14
-38
Player.ts
src/custom/jump-high-3/src/game/Player.ts
+32
-20
utils.ts
src/custom/jump-high-3/src/game/utils.ts
+2
-6
No files found.
dist/customs/jump-high-3.json
View file @
86efa534
...
@@ -47,25 +47,15 @@
...
@@ -47,25 +47,15 @@
"type"
:
"array<string>"
,
"type"
:
"array<string>"
,
"default"
:
"方块素材0"
"default"
:
"方块素材0"
},
},
"blockHitAssets"
:
{
"alias"
:
"方块素材组撞击状态"
,
"type"
:
"array<string>"
,
"default"
:
"方块素材0_hit"
},
"blockHitOffsetY"
:
{
"blockHitOffsetY"
:
{
"alias"
:
"方块素材组撞击状态Y轴锚点"
,
"alias"
:
"方块素材组撞击状态Y轴锚点"
,
"type"
:
"number"
,
"type"
:
"number"
,
"default"
:
75
"default"
:
75
},
},
"blockProfectOffset"
:
{
"alias"
:
"方块素材组完美状态锚点"
,
"type"
:
"vector2"
,
"default"
:
"-100,35"
},
"blockBaseOffset"
:
{
"blockBaseOffset"
:
{
"alias"
:
"初始方块偏移"
,
"alias"
:
"初始方块偏移"
,
"type"
:
"number"
,
"type"
:
"number"
,
"default"
:
-
4
0
"default"
:
-
2
0
},
},
"blockShadowOffset"
:
{
"blockShadowOffset"
:
{
"alias"
:
"初始方块阴影偏移"
,
"alias"
:
"初始方块阴影偏移"
,
...
@@ -110,7 +100,7 @@
...
@@ -110,7 +100,7 @@
"blockHitHeight"
:
{
"blockHitHeight"
:
{
"alias"
:
"方块碰撞高度"
,
"alias"
:
"方块碰撞高度"
,
"type"
:
"number"
,
"type"
:
"number"
,
"default"
:
1
6
0
"default"
:
1
2
0
},
},
"blockPaddingTop"
:
{
"blockPaddingTop"
:
{
"alias"
:
"方块上边距"
,
"alias"
:
"方块上边距"
,
...
@@ -205,42 +195,42 @@
...
@@ -205,42 +195,42 @@
"playerReadyAnchor"
:
{
"playerReadyAnchor"
:
{
"alias"
:
"角色准备锚点"
,
"alias"
:
"角色准备锚点"
,
"type"
:
"vector2"
,
"type"
:
"vector2"
,
"default"
:
"
150,210
"
"default"
:
"
75,122
"
},
},
"playerReady2Anchor"
:
{
"playerReady2Anchor"
:
{
"alias"
:
"角色准备2锚点"
,
"alias"
:
"角色准备2锚点"
,
"type"
:
"vector2"
,
"type"
:
"vector2"
,
"default"
:
"
150,210
"
"default"
:
"
75,122
"
},
},
"playerJumpAnchor"
:
{
"playerJumpAnchor"
:
{
"alias"
:
"角色跳起锚点"
,
"alias"
:
"角色跳起锚点"
,
"type"
:
"vector2"
,
"type"
:
"vector2"
,
"default"
:
"
150,210
"
"default"
:
"
75,122
"
},
},
"playerFallAnchor"
:
{
"playerFallAnchor"
:
{
"alias"
:
"角色下落锚点"
,
"alias"
:
"角色下落锚点"
,
"type"
:
"vector2"
,
"type"
:
"vector2"
,
"default"
:
"
150,210
"
"default"
:
"
75,122
"
},
},
"playerHitAnchor"
:
{
"playerHitAnchor"
:
{
"alias"
:
"角色撞开锚点"
,
"alias"
:
"角色撞开锚点"
,
"type"
:
"vector2"
,
"type"
:
"vector2"
,
"default"
:
"
150,210
"
"default"
:
"
75,122
"
},
},
"playerParachuteAnchor"
:
{
"playerParachuteAnchor"
:
{
"alias"
:
"角色降落锚点"
,
"alias"
:
"角色降落锚点"
,
"type"
:
"vector2"
,
"type"
:
"vector2"
,
"default"
:
"1
50,210
"
"default"
:
"1
26,212
"
},
},
"playerLandNormalAnchor"
:
{
"playerLandNormalAnchor"
:
{
"alias"
:
"角色正常落地锚点"
,
"alias"
:
"角色正常落地锚点"
,
"type"
:
"vector2"
,
"type"
:
"vector2"
,
"default"
:
"
150,210
"
"default"
:
"
75,122
"
},
},
"playerLandPerfectAnchor"
:
{
"playerLandPerfectAnchor"
:
{
"alias"
:
"角色完美落地锚点"
,
"alias"
:
"角色完美落地锚点"
,
"type"
:
"vector2"
,
"type"
:
"vector2"
,
"default"
:
"
150,210
"
"default"
:
"
75,122
"
},
},
"playerLandEffectAnchor"
:
{
"playerLandEffectAnchor"
:
{
"alias"
:
"角色落地特效锚点"
,
"alias"
:
"角色落地特效锚点"
,
...
@@ -250,7 +240,7 @@
...
@@ -250,7 +240,7 @@
"playerLandSideAnchor"
:
{
"playerLandSideAnchor"
:
{
"alias"
:
"角色边缘落地锚点"
,
"alias"
:
"角色边缘落地锚点"
,
"type"
:
"vector2"
,
"type"
:
"vector2"
,
"default"
:
"
150,210
"
"default"
:
"
75,122
"
},
},
"playerLandPrefectAnchor"
:
{
"playerLandPrefectAnchor"
:
{
"alias"
:
"角色完美落地锚点"
,
"alias"
:
"角色完美落地锚点"
,
...
@@ -274,18 +264,6 @@
...
@@ -274,18 +264,6 @@
}
}
},
},
"assets"
:
[
"assets"
:
[
{
"name"
:
"跳跃提示背景"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/93646ba4e8e57adc64350c7ef78a9bff1f8c1aa9.png"
,
"uuid"
:
"ff98fa3d-f37d-4be4-aa4f-0f1322cbd676"
,
"ext"
:
".png"
},
{
"name"
:
"完美方块素材"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/e2150383e8391a2972bc43fd888e4c1250e1933a.svga"
,
"uuid"
:
"7499df87-4155-406b-8c2b-fea972719f39"
,
"ext"
:
".svga"
},
{
{
"name"
:
"背景图"
,
"name"
:
"背景图"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/c90e6bc6718e4cc83d30bf2ce8b9f80a909adbee.jpg"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/c90e6bc6718e4cc83d30bf2ce8b9f80a909adbee.jpg"
,
...
@@ -367,9 +345,15 @@
...
@@ -367,9 +345,15 @@
{
{
"name"
:
"降落"
,
"name"
:
"降落"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/0c33a8285661684f24062af815a38befdbf36a06.svga"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/0c33a8285661684f24062af815a38befdbf36a06.svga"
,
"uuid"
:
"
82b514a9-69c4-425c-a77d-f34efeef1997
"
,
"uuid"
:
"
f234sf
"
,
"ext"
:
".svga"
"ext"
:
".svga"
},
},
{
"name"
:
"降落pic"
,
"url"
:
"////yun.duiba.com.cn/aurora/assets/e42a48c9b4a47dc180523bdeecd6b7305e088e27.png"
,
"uuid"
:
"9sf881289"
,
"ext"
:
".png"
},
{
{
"name"
:
"钱袋-静态"
,
"name"
:
"钱袋-静态"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/c5d04d5caf2dc812baeebdd34ea1abb17d183f44.png"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/c5d04d5caf2dc812baeebdd34ea1abb17d183f44.png"
,
...
@@ -481,5 +465,5 @@
...
@@ -481,5 +465,5 @@
}
}
},
},
"id"
:
"jump-high-3"
,
"id"
:
"jump-high-3"
,
"code"
:
"(function (global, factory) {
\n\t
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :
\n\t
typeof define === 'function' && define.amd ? define(['tslib'], factory) :
\n\t
(global = global || self, global['jump-high-3'] = factory(global.tslib));
\n
}(this, (function (tslib) { 'use strict';
\n\n\t
var props = {};
\n\t
function prepareProps() {
\n\t
var metaProps = getProps();
\n\t
engine.injectProp(props, metaProps);
\n\t
}
\n\t
function injectProps(p) {
\n\t
engine.injectProp(props, p);
\n\t
}
\n\t
//# sourceMappingURL=props.js.map
\n\n\t
function getTexture(uuid) {
\n\t
return engine.Texture.from(getAssetByUUID(uuid).uuid);
\n\t
}
\n\t
function getTextureByName(name) {
\n\t
return getTexture(engine.getAssetByName(name).uuid);
\n\t
}
\n\t
function getBlockAsset(
type) {
\n\t
return engine.getAssetByName(props.blockAssets[type]);
\n\t
}
\n\t
function getBlockHitAsset(type) {
\n\t
console.log(
\"
props.blockHitAssets
\"
, props.blockHitAssets);
\n\t
return engine.getAssetByName(props.blockHitAssets[type]);
\n\t
}
\n\t
function createSvga(name, anchorName) {
\n\t
var inst = new svga.Svga();
\n\t
inst.source = 'asset://' + engine.getAssetByName(name).uuid;
\n\t
var anchor = props[(anchorName)];
\n\t
if (anchor) {
\n\t
inst.x = -anchor.x;
\n\t
inst.y = -anchor.y;
\n\t
inst.anchorX = anchor.x;
\n\t
inst.anchorY = anchor.y;
\n\t
}
\n\t
return inst;
\n\t
}
\n\t
function playSound(name) {
\n\t
engine.playSound(engine.getAssetByName(name).uuid, { keep: true });
\n\t
}
\n\t
//# sourceMappingURL=utils.js.map
\n\n\t
var Background = (function (_super) {
\n\t
tslib.__extends(Background, _super);
\n\t
function Background() {
\n\t
return _super.call(this) || this;
\n\t
}
\n\t
Background.prototype.setup = function () {
\n\t
var _a = this.stage, width = _a.width, height = _a.height;
\n\t
var bg = this._bg = new engine.Image(getTextureByName('背景图'));
\n\t
bg.anchorX = bg.width / 2;
\n\t
bg.anchorY = bg.height / 2;
\n\t
bg.x = -(bg.width - width) / 2;
\n\t
bg.y = -(bg.height - height) / 2;
\n\t
this.addChild(bg);
\n\t
this._minScale = width / bg.width;
\n\t
};
\n\t
Background.prototype.playZoom = function (type, duration) {
\n\t
var _this = this;
\n\t
if (duration === void 0) { duration = 700; }
\n\t
return new Promise(function (resolve) {
\n\t
var scale = type === 'in' ? 1 : _this._minScale;
\n\t
engine.Tween.get(_this._bg, null, null, true)
\n\t
.to({ scaleX: scale, scaleY: scale }, duration, engine.Ease.cubicInOut)
\n\t
.call(resolve);
\n\t
});
\n\t
};
\n\t
return Background;
\n\t
}(engine.Container));
\n\t
//# sourceMappingURL=Background.js.map
\n\n\t
var Base = (function (_super) {
\n\t
tslib.__extends(Base, _super);
\n\t
function Base() {
\n\t
return _super.call(this, getTextureByName('底座')) || this;
\n\t
}
\n\t
Base.prototype.setup = function () {
\n\t
this.x = -(this.width) / 2;
\n\t
};
\n\t
Base.prototype.reset = function () {
\n\t
this.y = -props.baseOffset;
\n\t
};
\n\t
return Base;
\n\t
}(engine.Image));
\n\t
//# sourceMappingURL=Base.js.map
\n\n\t
var Block = (function (_super) {
\n\t
tslib.__extends(Block, _super);
\n\t
function Block() {
\n\t
var _this = _super.call(this) || this;
\n\t
var body = _this.body = new svga.Svga();
\n\t
body.x = -props.blockWidth / 2;
\n\t
body.y = -props.blockHitHeight - props.blockPaddingTop;
\n\t
_this.addChild(body);
\n\t
var bodyHit = _this.bodyHit = new svga.Svga();
\n\t
bodyHit.x = -props.blockWidth / 2;
\n\t
bodyHit.y = -props.blockHitHeight - props.blockPaddingTop + props.blockHitOffsetY;
\n\t
_this.addChild(bodyHit);
\n\t
console.log(
\"
props.blockProfectOffset
\"
, props.blockProfectOffset);
\n\t
var bodyProfect = _this.bodyProfect = new svga.Svga();
\n\t
bodyProfect.x = -props.blockWidth / 2 + props.blockProfectOffset.x;
\n\t
bodyProfect.y = -props.blockHitHeight - props.blockPaddingTop + props.blockProfectOffset.y;
\n\t
_this.addChild(bodyProfect);
\n\t
return _this;
\n\t
}
\n\t
Block.prototype.reset = function (_a) {
\n\t
var type = _a.type;
\n\t
this.dir = Math.random() > 0.5 ? 1 : -1;
\n\t
if (this.type != type) {
\n\t
this.type = type;
\n\t
var asset = getBlockAsset(type);
\n\t
this.body.source = 'asset://' + asset.uuid;
\n\t
var assetHit = getBlockHitAsset(type);
\n\t
console.log(
\"
assetHit
\"
, assetHit);
\n\t
this.bodyHit.source = 'asset://' + assetHit.uuid;
\n\t
}
\n\t
this.bodyProfect.source = 'asset://' + engine.getAssetByName(
\"
完美方块素材
\"
).uuid;
\n\t
this.scaleX = this.dir;
\n\t
this.body.gotoAndStop(1);
\n\t
this.bodyHit.gotoAndStop(1);
\n\t
this.bodyProfect.gotoAndStop(1);
\n\t
this.body.visible = true;
\n\t
this.bodyHit.visible = false;
\n\t
};
\n\t
Block.prototype.playEnter = function (index, animation) {
\n\t
var _this = this;
\n\t
this.visible = true;
\n\t
this.x = this.dir * this.stage.width;
\n\t
var _a = props.blockDurationRange, min = _a[0], max = _a[1];
\n\t
var duration = Math.max(max - index * props.blockDurationStep, min);
\n\t
duration = duration + max * Math.random() * props.blockDurationRandom * (Math.random() > 0.5 ? 1 : -1);
\n\t
return new Promise(function (resolve) {
\n\t
if (animation) {
\n\t
engine.Tween.get(_this, null, null, true)
\n\t
.to({ x: 0, }, duration)
\n\t
.call(resolve);
\n\t
}
\n\t
else {
\n\t
_this.x = 0;
\n\t
setTimeout(function () {
\n\t
console.log(_this.body);
\n\t
}, 200);
\n\t
resolve();
\n\t
}
\n\t
});
\n\t
};
\n\t
Block.prototype.playLeave = function () {
\n\t
this.visible = false;
\n\t
};
\n\t
Block.prototype.playEffect = function () {
\n\t
var body = this.body;
\n\t
body.play(true, false);
\n\t
body.once(engine.Event.END_FRAME, function () {
\n\t
body.gotoAndStop(1);
\n\t
}, this);
\n\t
};
\n\t
Block.prototype.playHit = function () {
\n\t
var bodyHit = this.bodyHit;
\n\t
bodyHit.play(true, false);
\n\t
this.body.visible = false;
\n\t
this.bodyHit.visible = true;
\n\t
bodyHit.once(engine.Event.END_FRAME, function () {
\n\t
this.body.visible = true;
\n\t
this.bodyHit.visible = false;
\n\t
bodyHit.gotoAndStop(1);
\n\t
}, this);
\n\t
};
\n\t
Block.prototype.playProFect = function () {
\n\t
var bodyProfect = this.bodyProfect;
\n\t
bodyProfect.play(true, false);
\n\t
bodyProfect.once(engine.Event.END_FRAME, function () {
\n\t
bodyProfect.gotoAndStop(1);
\n\t
}, this);
\n\t
};
\n\t
Block.prototype.stop = function () {
\n\t
engine.Tween.removeTweens(this);
\n\t
};
\n\t
return Block;
\n\t
}(engine.Container));
\n\t
//# sourceMappingURL=Block.js.map
\n\n\t
var GoldBag = (function (_super) {
\n\t
tslib.__extends(GoldBag, _super);
\n\t
function GoldBag() {
\n\t
var _this = _super.call(this) || this;
\n\t
_this.setup();
\n\t
return _this;
\n\t
}
\n\t
GoldBag.prototype.setup = function () {
\n\t
var avatar = this.avatar = new engine.Sprite(getTextureByName('钱袋-静态'));
\n\t
avatar.x = -props.goldPackAvatarAnchor.x;
\n\t
avatar.y = -props.goldPackAvatarAnchor.y;
\n\t
this.addChild(avatar);
\n\t
var svga = this.svga = createSvga('钱袋', 'goldPackAnchor');
\n\t
svga.visible = false;
\n\t
this.addChild(svga);
\n\t
};
\n\t
GoldBag.prototype.reset = function (data) {
\n\t
this.y = data.y;
\n\t
this.avatar.visible = true;
\n\t
this.svga.visible = false;
\n\t
this.svga.gotoAndStop(1);
\n\t
this.remain = data.remain;
\n\t
};
\n\t
GoldBag.prototype.playOpen = function () {
\n\t
var _this = this;
\n\t
this.avatar.visible = false;
\n\t
this.svga.visible = true;
\n\t
return new Promise(function (resolve) {
\n\t
_this.svga.play(true, false);
\n\t
_this.svga.once(engine.Event.END_FRAME, function () {
\n\t
this.svga.visible = false;
\n\t
resolve();
\n\t
}, _this);
\n\t
});
\n\t
};
\n\t
return GoldBag;
\n\t
}(engine.Container));
\n\t
//# sourceMappingURL=GoldBag.js.map
\n\n\t
var GuideLayer = (function (_super) {
\n\t
tslib.__extends(GuideLayer, _super);
\n\t
function GuideLayer() {
\n\t
var _this = _super.call(this) || this;
\n\t
_this.setup();
\n\t
return _this;
\n\t
}
\n\t
GuideLayer.prototype.setup = function () {
\n\t
};
\n\t
GuideLayer.prototype.show = function (id, options) {
\n\t
var _this = this;
\n\t
return new Promise(function (resolve) {
\n\t
_this.visible = true;
\n\t
if (!_this.guideMask) {
\n\t
var _a = _this.stage, width = _a.width, height = _a.height;
\n\t
var guideMask = _this.guideMask = new engine.Container();
\n\t
var guideHole = new engine.Image(getTextureByName('引导遮罩'));
\n\t
guideHole.x = (width - guideHole.width) / 2;
\n\t
guideHole.y = options.y;
\n\t
guideMask.addChild(guideHole);
\n\t
_this.createRect(guideMask, 0, 0, width, guideHole.y);
\n\t
_this.createRect(guideMask, 0, guideHole.y, guideHole.x, guideHole.height);
\n\t
_this.createRect(guideMask, guideHole.x + guideHole.width, guideHole.y, width - guideHole.x - guideHole.width, guideHole.height);
\n\t
_this.createRect(guideMask, 0, guideHole.y + guideHole.height, width, height - guideHole.y - guideHole.height);
\n\t
var label = _this.label = new engine.Label();
\n\t
label.fillColor = 'white';
\n\t
label.size = 25;
\n\t
label.text = props.guideText;
\n\t
label.x = (width - label.width) / 2;
\n\t
label.y = guideHole.y + guideHole.height + 50;
\n\t
guideMask.addChild(label);
\n\t
_this.addChild(guideMask);
\n\t
}
\n\t
_this.once(engine.MouseEvent.CLICK, function () {
\n\t
this.visible = false;
\n\t
resolve();
\n\t
}, _this);
\n\t
});
\n\t
};
\n\t
GuideLayer.prototype.createRect = function (container, x, y, width, height) {
\n\t
var rect = new engine.Rect();
\n\t
rect.x = x;
\n\t
rect.y = y;
\n\t
rect.width = width;
\n\t
rect.height = height;
\n\t
rect.fillColor = 'black';
\n\t
rect.alpha = 0.7;
\n\t
container.addChild(rect);
\n\t
};
\n\t
return GuideLayer;
\n\t
}(engine.Container));
\n\t
//# sourceMappingURL=GuideLayer.js.map
\n\n\t
var svgaAssets = {
\n\t
aniReady: { name: '准备立正', dir: 1 },
\n\t
aniReady2: { name: '准备立正', dir: 1 },
\n\t
aniJump: { name: '跳上升', dir: 1 },
\n\t
aniFall: { name: '跳下落', dir: 1 },
\n\t
aniLandNormal: { name: '普通着地', dir: 1 },
\n\t
aniLandSide: { name: '边缘着地', dir: -1 },
\n\t
aniHit: { name: '被撞开', dir: -1 },
\n\t
aniParachute: { name: '降落', dir: -1 },
\n\t
aniLandPerfect: { name: '完美着地_笑', dir: 1 },
\n\t
};
\n\t
var Player = (function (_super) {
\n\t
tslib.__extends(Player, _super);
\n\t
function Player() {
\n\t
var _this = _super.call(this) || this;
\n\t
_this.g = props.gravity;
\n\t
_this.addEventListener(engine.Event.ENTER_FRAME, _this.onEnterFrame, _this);
\n\t
return _this;
\n\t
}
\n\t
Player.prototype.switchAni = function (name, dir, play, loop) {
\n\t
var _this = this;
\n\t
if (dir === void 0) { dir = 1; }
\n\t
if (play === void 0) { play = true; }
\n\t
if (loop === void 0) { loop = false; }
\n\t
return new Promise(function (resolve) {
\n\t
_this.scaleX = dir;
\n\t
if (_this._aniName !== name) {
\n\t
_this._aniName = name;
\n\t
var oldAni = _this.removeChild(_this.getChildByName('body'));
\n\t
if (oldAni) {
\n\t
oldAni.stop();
\n\t
}
\n\t
var ani = _this._currentAni = _this['ani' + name];
\n\t
_this.addChild(ani);
\n\t
if (play) {
\n\t
ani.play(false, loop);
\n\t
if (loop) {
\n\t
resolve();
\n\t
}
\n\t
else {
\n\t
ani.once(engine.Event.END_FRAME, resolve);
\n\t
}
\n\t
}
\n\t
else {
\n\t
resolve();
\n\t
}
\n\t
}
\n\t
});
\n\t
};
\n\t
Player.prototype.setup = function () {
\n\t
this.prefectEffect = createSvga('完美着地特效', 'playerLandPrefectAnchor');
\n\t
this.landEffect = createSvga('着地特效', 'playerLandEffectAnchor');
\n\t
for (var key in svgaAssets) {
\n\t
var _a = svgaAssets[key], name = _a.name, dir = _a.dir;
\n\t
var body = this[key] = createSvga(name, key.replace('ani', 'player') + 'Anchor');
\n\t
body.name = 'body';
\n\t
body.scaleX = dir;
\n\t
}
\n\t
};
\n\t
Player.prototype.reset = function (revive) {
\n\t
this.x = 0;
\n\t
this.rotation = 0;
\n\t
this.scaleX = this.scaleY = 1;
\n\t
this._prefectLandCounting = 0;
\n\t
engine.Tween.removeTweens(this);
\n\t
if (revive) {
\n\t
this.switchAni('Jump', 1, false);
\n\t
}
\n\t
};
\n\t
Player.prototype.playReady = function () {
\n\t
var _this = this;
\n\t
return new Promise(function (resolve) {
\n\t
_this.switchAni('Ready', 1);
\n\t
_this._currentAni.once(engine.Event.END_FRAME, function () {
\n\t
this.switchAni('Ready2', 1, true, true);
\n\t
resolve();
\n\t
}, _this);
\n\t
});
\n\t
};
\n\t
Player.prototype.onEnterFrame = function (event) {
\n\t
if (!this.playing) {
\n\t
return;
\n\t
}
\n\t
this.vy += this.g;
\n\t
this.y += this.vy;
\n\t
if (this.vy > 0 && this._aniName !== 'Fall') {
\n\t
this.dispatchEvent('jump-on-top');
\n\t
this.switchAni('Fall');
\n\t
}
\n\t
if (this.y > this.baseY) {
\n\t
this.y = this.baseY;
\n\t
this.playing = false;
\n\t
this.jumpPromise && this.jumpPromise({
\n\t
aboveBlock: this.aboveBlock,
\n\t
});
\n\t
this.jumpPromise = null;
\n\t
}
\n\t
};
\n\t
Player.prototype.changeBaseY = function (v) {
\n\t
if (this.baseY == v) {
\n\t
return;
\n\t
}
\n\t
this.aboveBlock = true;
\n\t
this.baseY = v;
\n\t
};
\n\t
Player.prototype.jump = function () {
\n\t
var _this = this;
\n\t
playSound('跳起音效');
\n\t
this.switchAni('Jump', 1, false);
\n\t
this._currentAni.play(false, false);
\n\t
this.aboveBlock = false;
\n\t
this.playing = true;
\n\t
this.baseY = this.y;
\n\t
this.vy = -props.jumpSpeed;
\n\t
return new Promise(function (resolve) {
\n\t
_this.jumpPromise = resolve;
\n\t
});
\n\t
};
\n\t
Player.prototype.playLand = function (type, dir) {
\n\t
return tslib.__awaiter(this, void 0, void 0, function () {
\n\t
var _a, prefectEffect_1, landEffect_1;
\n\t
return tslib.__generator(this, function (_b) {
\n\t
switch (_b.label) {
\n\t
case 0:
\n\t
_a = type;
\n\t
switch (_a) {
\n\t
case 0: return [3, 1];
\n\t
case 1: return [3, 4];
\n\t
case 2: return [3, 4];
\n\t
case 3: return [3, 5];
\n\t
}
\n\t
return [3, 6];
\n\t
case 1:
\n\t
this._prefectLandCounting++;
\n\t
playSound('完美落地音效' + Math.min(4, this._prefectLandCounting));
\n\t
prefectEffect_1 = this.prefectEffect;
\n\t
this.addChildAt(prefectEffect_1, 0);
\n\t
prefectEffect_1.gotoAndPlay(1);
\n\t
prefectEffect_1.once(engine.Event.END_FRAME, function () {
\n\t
this.removeChild(prefectEffect_1);
\n\t
}, this);
\n\t
landEffect_1 = this.landEffect;
\n\t
this.addChildAt(landEffect_1, 0);
\n\t
landEffect_1.gotoAndPlay(1);
\n\t
landEffect_1.once(engine.Event.END_FRAME, function () {
\n\t
this.removeChild(landEffect_1);
\n\t
}, this);
\n\t
return [4, this.switchAni('LandPerfect')];
\n\t
case 2:
\n\t
_b.sent();
\n\t
return [4, this.switchAni('Ready2', 1, true, true)];
\n\t
case 3:
\n\t
_b.sent();
\n\t
return [3, 6];
\n\t
case 4:
\n\t
this._prefectLandCounting = 0;
\n\t
playSound('普通落地音效');
\n\t
this.switchAni('Ready2', 1, true, true);
\n\t
return [3, 6];
\n\t
case 5:
\n\t
this._prefectLandCounting = 0;
\n\t
playSound('边缘落地音效');
\n\t
this.switchAni('LandSide', dir);
\n\t
return [3, 6];
\n\t
case 6: return [2];
\n\t
}
\n\t
});
\n\t
});
\n\t
};
\n\t
Player.prototype.hitAway = function (dir) {
\n\t
return tslib.__awaiter(this, void 0, void 0, function () {
\n\t
var _this = this;
\n\t
return tslib.__generator(this, function (_a) {
\n\t
switch (_a.label) {
\n\t
case 0:
\n\t
this.jumpPromise && this.jumpPromise();
\n\t
this.jumpPromise = null;
\n\t
playSound('被撞开音效');
\n\t
this.switchAni('Hit', dir);
\n\t
this.vy = 0;
\n\t
return [4, new Promise(function (resolve) {
\n\t
engine.Tween.get(_this)
\n\t
.to({
\n\t
x: -dir * props.hitAwayDistance.x,
\n\t
}, props.hitAwayDuration, engine.Ease.quartOut);
\n\t
engine.Tween.get(_this)
\n\t
.to({
\n\t
y: _this.y + props.hitAwayDistance.y,
\n\t
}, props.hitAwayDuration, engine.Ease.cubicOut)
\n\t
.call(resolve);
\n\t
})];
\n\t
case 1:
\n\t
_a.sent();
\n\t
return [2];
\n\t
}
\n\t
});
\n\t
});
\n\t
};
\n\t
Player.prototype.parachute = function (dir) {
\n\t
var _this = this;
\n\t
this.switchAni('Parachute', dir);
\n\t
return new Promise(function (resolve) {
\n\t
engine.Tween.get(_this)
\n\t
.call(function () {
\n\t
playSound('降落伞下落音效');
\n\t
})
\n\t
.to({ y: _this.y + props.parachuteDistance }, props.parachuteDuration)
\n\t
.set({ anchorOffsetY: 0 })
\n\t
.call(resolve);
\n\t
});
\n\t
};
\n\t
return Player;
\n\t
}(engine.Container));
\n\n\t
var ObjectPool = engine.ObjectPool;
\n\t
var PoolName = 'gold-bag';
\n\t
ObjectPool.registerPool(PoolName, function () {
\n\t
return new GoldBag();
\n\t
}, function (item, data) {
\n\t
item.reset(data);
\n\t
});
\n\t
var GameView = (function (_super) {
\n\t
tslib.__extends(GameView, _super);
\n\t
function GameView() {
\n\t
var _this = _super.call(this) || this;
\n\t
_this.index = -1;
\n\t
_this.goldBags = [];
\n\t
_this.baseOffset = -props.baseOffset + props.playerOffset;
\n\t
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
\n\t
return _this;
\n\t
}
\n\t
GameView.prototype.setup = function () {
\n\t
if (this._hasSetup) {
\n\t
return;
\n\t
}
\n\t
this._hasSetup = true;
\n\t
var _a = this.stage, width = _a.width, height = _a.height;
\n\t
var background = this.background = new Background();
\n\t
this.addChild(background);
\n\t
background.setup();
\n\t
var frontContainer = this.frontContainer = new engine.Container();
\n\t
frontContainer.x = width / 2;
\n\t
this.addChild(frontContainer);
\n\t
var guideLayer = this.guideLayer = new GuideLayer();
\n\t
this.addChild(guideLayer);
\n\t
var base = this.base = new Base();
\n\t
frontContainer.addChild(base);
\n\t
base.setup();
\n\t
var blockContainer = this.blockContainer = new engine.Container();
\n\t
frontContainer.addChild(blockContainer);
\n\t
var player = this.player = new Player();
\n\t
frontContainer.addChild(player);
\n\t
player.setup();
\n\t
player.addEventListener('jump-on-top', this.onPlayerJumpOnTop, this);
\n\t
var scoreAddTipsContainer = this.scoreAddTipsContainer = new engine.Container();
\n\t
scoreAddTipsContainer.width = 750;
\n\t
scoreAddTipsContainer.anchorX = scoreAddTipsContainer.width / 2;
\n\t
scoreAddTipsContainer.anchorY = scoreAddTipsContainer.height / 2;
\n\t
var scoreAddTips = this.scoreAddTips = new engine.Label();
\n\t
scoreAddTips.width = 750;
\n\t
scoreAddTips.fillColor = props.scoreAddFontColor;
\n\t
scoreAddTips.textAlign = engine.TEXT_ALIGN.CENTER;
\n\t
scoreAddTips.size = props.scoreAddFontSize;
\n\t
scoreAddTips.alpha = 0;
\n\t
scoreAddTips.text =
\"
+0
\"
;
\n\t
scoreAddTips.x = this.player.x - scoreAddTips.width / 2;
\n\t
scoreAddTipsContainer.addChild(scoreAddTips);
\n\t
frontContainer.addChild(player);
\n\t
frontContainer.addChild(scoreAddTipsContainer);
\n\t
ObjectPool.recycleObject(PoolName, ObjectPool.getObject(PoolName, {
\n\t
y: 0,
\n\t
remain: 0,
\n\t
}));
\n\t
this.hitEffect = createSvga('被撞烟雾', 'hitEffectAnchor');
\n\t
this.pos = 0;
\n\t
this.background.setup();
\n\t
this.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);
\n\t
this.reset();
\n\t
};
\n\t
GameView.prototype.setScoreText = function (score) {
\n\t
return tslib.__awaiter(this, void 0, void 0, function () {
\n\t
var _this = this;
\n\t
return tslib.__generator(this, function (_a) {
\n\t
return [2, new Promise(function (resolve) {
\n\t
_this.scoreAddTips.text = score;
\n\t
_this.scoreAddTips.y = 0;
\n\t
_this.scoreAddTips.alpha = 1;
\n\t
engine.Tween.get(_this.scoreAddTips, null, null, true)
\n\t
.to({ y: -100, alpha: 0 }, 500, engine.Ease.cubicInOut)
\n\t
.call(resolve);
\n\t
})];
\n\t
});
\n\t
});
\n\t
};
\n\t
GameView.prototype.reset = function (revive) {
\n\t
if (revive === void 0) { revive = false; }
\n\t
return tslib.__awaiter(this, void 0, void 0, function () {
\n\t
var blockContainer, i, li, block, i, i, li, goldBag;
\n\t
return tslib.__generator(this, function (_a) {
\n\t
switch (_a.label) {
\n\t
case 0:
\n\t
this.base.reset();
\n\t
this.index = -1;
\n\t
this._score = 0;
\n\t
if (revive) ;
\n\t
else {
\n\t
this.pos = 0;
\n\t
blockContainer = this.blockContainer;
\n\t
for (i = 0, li = blockContainer.children.length; i < li; i++) {
\n\t
block = blockContainer.getChildAt(i);
\n\t
block.playLeave();
\n\t
}
\n\t
}
\n\t
for (i = 0; i < props.initBlockCount; i++) {
\n\t
this.addBlock(false);
\n\t
}
\n\t
for (i = 0, li = this.goldBags.length; i < li; i++) {
\n\t
goldBag = this.goldBags[i];
\n\t
this.frontContainer.removeChild(goldBag);
\n\t
ObjectPool.recycleObject(PoolName, goldBag);
\n\t
}
\n\t
this.goldBags.splice(0);
\n\t
this.playZoom('in');
\n\t
return [4, this.resetPlayer(revive)];
\n\t
case 1:
\n\t
_a.sent();
\n\t
return [2];
\n\t
}
\n\t
});
\n\t
});
\n\t
};
\n\t
GameView.prototype.resetPlayer = function (revive) {
\n\t
if (revive === void 0) { revive = false; }
\n\t
return tslib.__awaiter(this, void 0, void 0, function () {
\n\t
return tslib.__generator(this, function (_a) {
\n\t
this.player.reset(revive);
\n\t
this.player.y = this.baseOffset - (this.index + 1) * props.blockHitHeight + props.blockBaseOffset;
\n\t
return [2];
\n\t
});
\n\t
});
\n\t
};
\n\t
GameView.prototype.start = function (revive) {
\n\t
if (revive === void 0) { revive = false; }
\n\t
return tslib.__awaiter(this, void 0, void 0, function () {
\n\t
var guideFlagKey, guideFlag;
\n\t
var _this = this;
\n\t
return tslib.__generator(this, function (_a) {
\n\t
switch (_a.label) {
\n\t
case 0:
\n\t
this.scoreAddTipsContainer.y = this.player.y + props.scoreAddTipsOffset;
\n\t
if (!!revive) return [3, 2];
\n\t
return [4, this.player.playReady()];
\n\t
case 1:
\n\t
_a.sent();
\n\t
_a.label = 2;
\n\t
case 2:
\n\t
console.log(
\"
开始
\"
);
\n\t
guideFlagKey = 'jump-high-guide_' + props.guideFlagKey;
\n\t
guideFlag = localStorage.getItem(guideFlagKey);
\n\t
if (!!guideFlag) return [3, 4];
\n\t
localStorage.setItem(guideFlagKey, '1');
\n\t
return [4, this.guideLayer.show('', { y: this.stage.height + this.player.y - 280 })];
\n\t
case 3:
\n\t
_a.sent();
\n\t
_a.label = 4;
\n\t
case 4:
\n\t
this.lastLandType = 0;
\n\t
this._remainToShowGoldBag = props.goldBagScoreMultiple - props.goldBagScoreSubtraction;
\n\t
this._touchEnabled = true;
\n\t
setTimeout(function () {
\n\t
_this.addBlock();
\n\t
}, 100);
\n\t
engine.globalEvent.dispatchEvent('jump-high-game-start');
\n\t
return [2];
\n\t
}
\n\t
});
\n\t
});
\n\t
};
\n\t
GameView.prototype.pause = function () {
\n\t
if (this.currentBlock) {
\n\t
engine.Tween.pauseTweens(this.currentBlock);
\n\t
}
\n\t
engine.Tween.pauseTweens(this.player);
\n\t
};
\n\t
GameView.prototype.resume = function () {
\n\t
if (this.currentBlock) {
\n\t
engine.Tween.resumeTweens(this.currentBlock);
\n\t
}
\n\t
engine.Tween.resumeTweens(this.player);
\n\t
};
\n\t
GameView.prototype.revive = function () {
\n\t
return tslib.__awaiter(this, void 0, void 0, function () {
\n\t
return tslib.__generator(this, function (_a) {
\n\t
switch (_a.label) {
\n\t
case 0:
\n\t
this.blockContainer.getChildAt(this.index).visible = false;
\n\t
this.index--;
\n\t
return [4, this.resetPlayer(true)];
\n\t
case 1:
\n\t
_a.sent();
\n\t
return [4, this.playZoom('in')];
\n\t
case 2:
\n\t
_a.sent();
\n\t
this.start(true);
\n\t
return [2];
\n\t
}
\n\t
});
\n\t
});
\n\t
};
\n\t
GameView.prototype.addBlock = function (animation) {
\n\t
var _this = this;
\n\t
if (animation === void 0) { animation = true; }
\n\t
this.index++;
\n\t
var blockContainer = this.blockContainer;
\n\t
var block;
\n\t
if (blockContainer.children.length > this.index) {
\n\t
block = blockContainer.getChildAt(this.index);
\n\t
block.visible = true;
\n\t
}
\n\t
else {
\n\t
block = new Block();
\n\t
blockContainer.addChildAt(block, 0);
\n\t
}
\n\t
blockContainer.addChildAt(block, 0);
\n\t
block.reset({
\n\t
type: Math.floor(Math.random() * props.blockAssets.length),
\n\t
});
\n\t
block.y = this.baseOffset - this.index * props.blockHitHeight + props.blockBaseOffset;
\n\t
this.blockComplete = false;
\n\t
block.playEnter(this.index, animation).then(function (data) {
\n\t
_this.blockComplete = true;
\n\t
});
\n\t
if (animation) {
\n\t
this.needHitTest = true;
\n\t
}
\n\t
this.currentBlock = block;
\n\t
};
\n\t
GameView.prototype.addGoldBag = function () {
\n\t
var goldBag = ObjectPool.getObject(PoolName, {
\n\t
y: this.baseOffset - (this.blockCount + props.goldBagDistance + props.goldBagJumpSubtraction) * props.blockHitHeight,
\n\t
remain: props.goldBagDistance,
\n\t
});
\n\t
this.frontContainer.addChild(goldBag);
\n\t
this.goldBags.push(goldBag);
\n\t
};
\n\t
GameView.prototype.playOpenGoldBag = function () {
\n\t
return tslib.__awaiter(this, void 0, void 0, function () {
\n\t
var i, li, goldBag;
\n\t
return tslib.__generator(this, function (_a) {
\n\t
switch (_a.label) {
\n\t
case 0:
\n\t
i = 0, li = this.goldBags.length;
\n\t
_a.label = 1;
\n\t
case 1:
\n\t
if (!(i < li)) return [3, 4];
\n\t
goldBag = this.goldBags[i];
\n\t
goldBag.remain--;
\n\t
if (!(goldBag.remain <= 0)) return [3, 3];
\n\t
this.goldBags.splice(i, 1);
\n\t
i--;
\n\t
li--;
\n\t
this.nextToUpdateScore = true;
\n\t
return [4, goldBag.playOpen()];
\n\t
case 2:
\n\t
_a.sent();
\n\t
this.frontContainer.removeChild(goldBag);
\n\t
ObjectPool.recycleObject(PoolName, goldBag);
\n\t
_a.label = 3;
\n\t
case 3:
\n\t
i++;
\n\t
return [3, 1];
\n\t
case 4: return [2];
\n\t
}
\n\t
});
\n\t
});
\n\t
};
\n\t
GameView.prototype.onPlayerJumpOnTop = function () {
\n\t
if (this.nextToUpdateScore) {
\n\t
this.nextToUpdateScore = false;
\n\t
this.scoreChange(4);
\n\t
playSound('撞击钱袋音效');
\n\t
}
\n\t
};
\n\t
Object.defineProperty(GameView.prototype,
\"
blockCount
\"
, {
\n\t
get: function () {
\n\t
return this.index - props.initBlockCount + 1;
\n\t
},
\n\t
enumerable: false,
\n\t
configurable: true
\n\t
});
\n\t
Object.defineProperty(GameView.prototype,
\"
pos
\"
, {
\n\t
get: function () {
\n\t
return this._pos;
\n\t
},
\n\t
set: function (v) {
\n\t
this._pos = v;
\n\t
this.updatePos();
\n\t
},
\n\t
enumerable: false,
\n\t
configurable: true
\n\t
});
\n\t
GameView.prototype.updatePos = function () {
\n\t
this.frontContainer.y = this.stage.height + this._pos;
\n\t
};
\n\t
GameView.prototype.onEnterFrame = function (event) {
\n\t
if (this.needHitTest) {
\n\t
if (this.currentBlock) {
\n\t
var _a = this.currentBlock, bx = _a.x, by = _a.y, dir = _a.dir;
\n\t
var _b = this.player, px = _b.x, py = _b.y;
\n\t
var blockHitWidth = props.blockHitWidth, blockHitHeight = props.blockHitHeight, playerWidth = props.playerWidth;
\n\t
var hitOn = false;
\n\t
if (Math.abs(px - bx) < (blockHitWidth + playerWidth) / 2) {
\n\t
this.player.changeBaseY(by - blockHitHeight);
\n\t
if (py > by - blockHitHeight) {
\n\t
hitOn = true;
\n\t
}
\n\t
}
\n\t
if (hitOn) {
\n\t
this.onHitOn(dir);
\n\t
}
\n\t
}
\n\t
}
\n\t
};
\n\t
GameView.prototype.onHitOn = function (dir) {
\n\t
return tslib.__awaiter(this, void 0, void 0, function () {
\n\t
return tslib.__generator(this, function (_a) {
\n\t
switch (_a.label) {
\n\t
case 0:
\n\t
this._touchEnabled = false;
\n\t
this.needHitTest = false;
\n\t
clearInterval(this.timer);
\n\t
this.currentBlock.playHit();
\n\t
return [4, this.player.hitAway(dir)];
\n\t
case 1:
\n\t
_a.sent();
\n\t
return [4, this.player.parachute(dir)];
\n\t
case 2:
\n\t
_a.sent();
\n\t
console.log('jump-high-game-end');
\n\t
engine.globalEvent.dispatchEvent('jump-high-game-end');
\n\t
return [2];
\n\t
}
\n\t
});
\n\t
});
\n\t
};
\n\t
GameView.prototype.jump = function () {
\n\t
return tslib.__awaiter(this, void 0, void 0, function () {
\n\t
var result, pos, type, lastLandType;
\n\t
var _this = this;
\n\t
return tslib.__generator(this, function (_a) {
\n\t
switch (_a.label) {
\n\t
case 0:
\n\t
if (!this._touchEnabled) {
\n\t
return [2];
\n\t
}
\n\t
this._touchEnabled = false;
\n\t
this.playOpenGoldBag();
\n\t
return [4, this.player.jump()];
\n\t
case 1:
\n\t
result = _a.sent();
\n\t
if (!result) return [3, 5];
\n\t
if (!result.aboveBlock) return [3, 4];
\n\t
pos = Math.abs(this.currentBlock.x);
\n\t
type = 0;
\n\t
if (pos > 0) {
\n\t
type = pos > 0 && pos < props.scoreThreshold ? 2 : 3;
\n\t
}
\n\t
lastLandType = this.lastLandType;
\n\t
this.lastLandType = type;
\n\t
if (type === 0) {
\n\t
if (lastLandType !== type) {
\n\t
type = 1;
\n\t
}
\n\t
}
\n\t
if (type < 3) {
\n\t
this.currentBlock.playEffect();
\n\t
}
\n\t
if (type === 0) {
\n\t
this.currentBlock.playProFect();
\n\t
}
\n\t
this.player.playLand(type, this.currentBlock.dir);
\n\t
this.currentBlock.stop();
\n\t
this.scoreChange(type);
\n\t
return [4, this.playShake()];
\n\t
case 2:
\n\t
_a.sent();
\n\t
return [4, new Promise(function (resolve) {
\n\t
engine.Tween.get(_this, null, null, true)
\n\t
.to({ pos: props.blockHitHeight * _this.index }, 300, engine.Ease.cubicOut)
\n\t
.call(resolve);
\n\t
})];
\n\t
case 3:
\n\t
_a.sent();
\n\t
this.addBlock();
\n\t
_a.label = 4;
\n\t
case 4:
\n\t
this._touchEnabled = true;
\n\t
_a.label = 5;
\n\t
case 5: return [2];
\n\t
}
\n\t
});
\n\t
});
\n\t
};
\n\t
GameView.prototype.scoreChange = function (type) {
\n\t
var scoreAdd = props.scoreWeights[type];
\n\t
this._score += scoreAdd;
\n\t
this._remainToShowGoldBag -= scoreAdd;
\n\t
var score = this._score;
\n\t
engine.globalEvent.dispatchEvent('jump-high-score', {
\n\t
type: type,
\n\t
score: score,
\n\t
scoreAdd: scoreAdd,
\n\t
});
\n\t
this.scoreAddTipsContainer.y = this.player.y + props.scoreAddTipsOffset;
\n\t
this.setScoreText(
\"
+
\"
+ scoreAdd);
\n\t
console.log(score, this._remainToShowGoldBag);
\n\t
if (this._remainToShowGoldBag <= 0) {
\n\t
this._remainToShowGoldBag += props.goldBagScoreMultiple;
\n\t
this.addGoldBag();
\n\t
console.log('addGoldBag');
\n\t
}
\n\t
};
\n\t
GameView.prototype.playHitEffect = function (dir) {
\n\t
var hitEffect = this.hitEffect;
\n\t
hitEffect.scaleX = dir;
\n\t
hitEffect.y = this.player.y - props.hitEffectAnchor.y;
\n\t
hitEffect.play(true, false);
\n\t
hitEffect.once(engine.Event.END_FRAME, function () {
\n\t
this.frontContainer.removeChild(hitEffect);
\n\t
}, this);
\n\t
this.frontContainer.addChild(hitEffect);
\n\t
};
\n\t
GameView.prototype.playZoom = function (type, duration) {
\n\t
var _this = this;
\n\t
if (duration === void 0) { duration = 700; }
\n\t
this.background.playZoom(type, duration);
\n\t
var count = this.stage.height / props.blockHitHeight;
\n\t
return new Promise(function (resolve) {
\n\t
_this.frontContainer.anchorY = -props.blockHitHeight * (_this.index + count * 1.3) + props.baseOffset;
\n\t
var scale = type === 'in' ? 1 : Math.min((_this.stage.height / props.blockHitHeight / (_this.index + count)), props.maxScale);
\n\t
console.log(scale);
\n\t
engine.Tween.get(_this.frontContainer, null, null, true)
\n\t
.to({ scaleX: scale, scaleY: scale }, duration, engine.Ease.cubicInOut)
\n\t
.call(resolve);
\n\t
});
\n\t
};
\n\t
GameView.prototype.playShake = function () {
\n\t
var _this = this;
\n\t
var _a = this.frontContainer, x = _a.x, y = _a.y;
\n\t
return new Promise(function (resolve) {
\n\t
var shakeOffset = 7;
\n\t
var duration = 30;
\n\t
engine.Tween.get(_this.frontContainer, null, null, true)
\n\t
.to({ x: x, y: y - shakeOffset }, duration)
\n\t
.to({ x: x, y: y + shakeOffset }, duration)
\n\t
.to({ x: x + shakeOffset, y: y }, duration)
\n\t
.to({ x: x - shakeOffset, y: y }, duration)
\n\t
.to({ x: x, y: y }, duration
)
\n\t
.call(resolve);
\n\t
});
\n\t
};
\n\t
return GameView;
\n\t
}(engine.Container));
\n\t
//# sourceMappingURL=GameView.js.map
\n\n\t
var JumpHigh = (function (_super) {
\n\t
tslib.__extends(JumpHigh, _super);
\n\t
function JumpHigh() {
\n\t
var _this = _super.call(this) || this;
\n\t
engine.globalEvent.addEventListener('jump-high-reset', _this.reset, _this);
\n\t
engine.globalEvent.addEventListener('jump-high-start', _this.start, _this);
\n\t
engine.globalEvent.addEventListener('jump-high-pause', _this.pause, _this);
\n\t
engine.globalEvent.addEventListener('jump-high-resume', _this.resume, _this);
\n\t
engine.globalEvent.addEventListener('jump-high-revive', _this.revive, _this);
\n\t
_this.addEventListener(engine.MouseEvent.MOUSE_DOWN, _this.onTap, _this);
\n\t
var gameView = _this._gameView = new GameView();
\n\t
_this.addChild(gameView);
\n\t
return _this;
\n\t
}
\n\t
JumpHigh.prototype.reset = function () {
\n\t
this._gameView.reset();
\n\t
};
\n\t
JumpHigh.prototype.start = function (event) {
\n\t
{
\n\t
injectProps(event.data);
\n\t
}
\n\t
this._status = 1;
\n\t
this._gameView.start();
\n\t
};
\n\t
JumpHigh.prototype.pause = function () {
\n\t
this._gameView.pause();
\n\t
};
\n\t
JumpHigh.prototype.resume = function () {
\n\t
this._gameView.resume();
\n\t
};
\n\t
JumpHigh.prototype.revive = function () {
\n\t
this._gameView.revive();
\n\t
};
\n\t
JumpHigh.prototype.onTap = function (event) {
\n\t
this._gameView.jump();
\n\t
};
\n\t
return JumpHigh;
\n\t
}(engine.Container));
\n\t
//# sourceMappingURL=JumpHigh.js.map
\n\n\t
function index (props) {
\n\t
prepareProps();
\n\t
injectProps(props);
\n\t
var instance = new JumpHigh();
\n\t
return instance;
\n\t
}
\n\t
//# sourceMappingURL=index.js.map
\n\n\t
return index;
\n\n
})));
\n
"
"code"
:
"(function (global, factory) {
\n\t
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :
\n\t
typeof define === 'function' && define.amd ? define(['tslib'], factory) :
\n\t
(global = global || self, global['jump-high-3'] = factory(global.tslib));
\n
}(this, (function (tslib) { 'use strict';
\n\n\t
var props = {};
\n\t
function prepareProps() {
\n\t
var metaProps = getProps();
\n\t
engine.injectProp(props, metaProps);
\n\t
}
\n\t
function injectProps(p) {
\n\t
engine.injectProp(props, p);
\n\t
}
\n\t
//# sourceMappingURL=props.js.map
\n\n\t
function getTexture(uuid) {
\n\t
return engine.Texture.from(getAssetByUUID(uuid).uuid);
\n\t
}
\n\t
function getTextureByName(name) {
\n\t
return getTexture(engine.getAssetByName(name).uuid);
\n\t
}
\n\t
function getBlockAsset(
) {
\n\t
return engine.getAssetByName(props.blockAssets[0]);
\n\t
}
\n\t
function createSvga(name, anchorName) {
\n\t
var inst = new svga.Svga();
\n\t
inst.source = 'asset://' + engine.getAssetByName(name).uuid;
\n\t
var anchor = props[(anchorName)];
\n\t
if (anchor) {
\n\t
inst.x = -anchor.x;
\n\t
inst.y = -anchor.y;
\n\t
inst.anchorX = anchor.x;
\n\t
inst.anchorY = anchor.y;
\n\t
}
\n\t
return inst;
\n\t
}
\n\t
function playSound(name) {
\n\t
engine.playSound(engine.getAssetByName(name).uuid, { keep: true });
\n\t
}
\n\t
//# sourceMappingURL=utils.js.map
\n\n\t
var Background = (function (_super) {
\n\t
tslib.__extends(Background, _super);
\n\t
function Background() {
\n\t
return _super.call(this) || this;
\n\t
}
\n\t
Background.prototype.setup = function () {
\n\t
var _a = this.stage, width = _a.width, height = _a.height;
\n\t
var bg = this._bg = new engine.Image(getTextureByName('背景图'));
\n\t
this.addChild(bg);
\n\t
};
\n\t
Background.prototype.playZoom = function (type, duration) {
\n\t
var _this = this;
\n\t
if (duration === void 0) { duration = 700; }
\n\t
return new Promise(function (resolve) {
\n\t
var scale = type === 'in' ? 1 : _this._minScale;
\n\t
engine.Tween.get(_this._bg, null, null, true)
\n\t
.to({ scaleX: scale, scaleY: scale }, duration, engine.Ease.cubicInOut)
\n\t
.call(resolve);
\n\t
});
\n\t
};
\n\t
return Background;
\n\t
}(engine.Container));
\n\t
//# sourceMappingURL=Background.js.map
\n\n\t
var Base = (function (_super) {
\n\t
tslib.__extends(Base, _super);
\n\t
function Base() {
\n\t
return _super.call(this, getTextureByName('底座')) || this;
\n\t
}
\n\t
Base.prototype.setup = function () {
\n\t
this.x = -(this.width) / 2;
\n\t
};
\n\t
Base.prototype.reset = function () {
\n\t
this.y = -props.baseOffset;
\n\t
};
\n\t
return Base;
\n\t
}(engine.Image));
\n\t
//# sourceMappingURL=Base.js.map
\n\n\t
var Block = (function (_super) {
\n\t
tslib.__extends(Block, _super);
\n\t
function Block() {
\n\t
var _this = _super.call(this) || this;
\n\t
var body = _this.body = new svga.Svga();
\n\t
body.x = -props.blockWidth / 2;
\n\t
body.y = -props.blockHitHeight - props.blockPaddingTop;
\n\t
_this.addChild(body);
\n\t
return _this;
\n\t
}
\n\t
Block.prototype.reset = function (_a) {
\n\t
var type = _a.type;
\n\t
this.dir = Math.random() > 0.5 ? 1 : -1;
\n\t
this.type = type;
\n\t
var asset = getBlockAsset();
\n\t
this.body.source = 'asset://' + asset.uuid;
\n\t
this.scaleX = this.dir;
\n\t
this.body.gotoAndStop(1);
\n\t
this.body.visible = true;
\n\t
};
\n\t
Block.prototype.playEnter = function (index, animation) {
\n\t
var _this = this;
\n\t
this.visible = true;
\n\t
this.x = this.dir * this.stage.width;
\n\t
var _a = props.blockDurationRange, min = _a[0], max = _a[1];
\n\t
var duration = Math.max(max - index * props.blockDurationStep, min);
\n\t
duration = duration + max * Math.random() * props.blockDurationRandom * (Math.random() > 0.5 ? 1 : -1);
\n\t
return new Promise(function (resolve) {
\n\t
if (animation) {
\n\t
engine.Tween.get(_this, null, null, true)
\n\t
.to({ x: 0, }, duration)
\n\t
.call(resolve);
\n\t
}
\n\t
else {
\n\t
_this.x = 0;
\n\t
setTimeout(function () {
\n\t
}, 200);
\n\t
resolve();
\n\t
}
\n\t
});
\n\t
};
\n\t
Block.prototype.playLeave = function () {
\n\t
this.visible = false;
\n\t
};
\n\t
Block.prototype.playEffect = function () {
\n\t
var body = this.body;
\n\t
body.play(true, false);
\n\t
body.once(engine.Event.END_FRAME, function () {
\n\t
body.gotoAndStop(1);
\n\t
}, this);
\n\t
};
\n\t
Block.prototype.stop = function () {
\n\t
engine.Tween.removeTweens(this);
\n\t
};
\n\t
return Block;
\n\t
}(engine.Container));
\n\t
//# sourceMappingURL=Block.js.map
\n\n\t
var GoldBag = (function (_super) {
\n\t
tslib.__extends(GoldBag, _super);
\n\t
function GoldBag() {
\n\t
var _this = _super.call(this) || this;
\n\t
_this.setup();
\n\t
return _this;
\n\t
}
\n\t
GoldBag.prototype.setup = function () {
\n\t
var avatar = this.avatar = new engine.Sprite(getTextureByName('钱袋-静态'));
\n\t
avatar.x = -props.goldPackAvatarAnchor.x;
\n\t
avatar.y = -props.goldPackAvatarAnchor.y;
\n\t
this.addChild(avatar);
\n\t
var svga = this.svga = createSvga('钱袋', 'goldPackAnchor');
\n\t
svga.visible = false;
\n\t
this.addChild(svga);
\n\t
};
\n\t
GoldBag.prototype.reset = function (data) {
\n\t
this.y = data.y;
\n\t
this.avatar.visible = true;
\n\t
this.svga.visible = false;
\n\t
this.svga.gotoAndStop(1);
\n\t
this.remain = data.remain;
\n\t
};
\n\t
GoldBag.prototype.playOpen = function () {
\n\t
var _this = this;
\n\t
this.avatar.visible = false;
\n\t
this.svga.visible = true;
\n\t
return new Promise(function (resolve) {
\n\t
_this.svga.play(true, false);
\n\t
_this.svga.once(engine.Event.END_FRAME, function () {
\n\t
this.svga.visible = false;
\n\t
resolve();
\n\t
}, _this);
\n\t
});
\n\t
};
\n\t
return GoldBag;
\n\t
}(engine.Container));
\n\t
//# sourceMappingURL=GoldBag.js.map
\n\n\t
var GuideLayer = (function (_super) {
\n\t
tslib.__extends(GuideLayer, _super);
\n\t
function GuideLayer() {
\n\t
var _this = _super.call(this) || this;
\n\t
_this.setup();
\n\t
return _this;
\n\t
}
\n\t
GuideLayer.prototype.setup = function () {
\n\t
};
\n\t
GuideLayer.prototype.show = function (id, options) {
\n\t
var _this = this;
\n\t
return new Promise(function (resolve) {
\n\t
_this.visible = true;
\n\t
if (!_this.guideMask) {
\n\t
var _a = _this.stage, width = _a.width, height = _a.height;
\n\t
var guideMask = _this.guideMask = new engine.Container();
\n\t
var guideHole = new engine.Image(getTextureByName('引导遮罩'));
\n\t
guideHole.x = (width - guideHole.width) / 2;
\n\t
guideHole.y = options.y;
\n\t
guideMask.addChild(guideHole);
\n\t
_this.createRect(guideMask, 0, 0, width, guideHole.y);
\n\t
_this.createRect(guideMask, 0, guideHole.y, guideHole.x, guideHole.height);
\n\t
_this.createRect(guideMask, guideHole.x + guideHole.width, guideHole.y, width - guideHole.x - guideHole.width, guideHole.height);
\n\t
_this.createRect(guideMask, 0, guideHole.y + guideHole.height, width, height - guideHole.y - guideHole.height);
\n\t
var label = _this.label = new engine.Label();
\n\t
label.fillColor = 'white';
\n\t
label.size = 25;
\n\t
label.text = props.guideText;
\n\t
label.x = (width - label.width) / 2;
\n\t
label.y = guideHole.y + guideHole.height + 50;
\n\t
guideMask.addChild(label);
\n\t
_this.addChild(guideMask);
\n\t
}
\n\t
_this.once(engine.MouseEvent.CLICK, function () {
\n\t
this.visible = false;
\n\t
resolve();
\n\t
}, _this);
\n\t
});
\n\t
};
\n\t
GuideLayer.prototype.createRect = function (container, x, y, width, height) {
\n\t
var rect = new engine.Rect();
\n\t
rect.x = x;
\n\t
rect.y = y;
\n\t
rect.width = width;
\n\t
rect.height = height;
\n\t
rect.fillColor = 'black';
\n\t
rect.alpha = 0.7;
\n\t
container.addChild(rect);
\n\t
};
\n\t
return GuideLayer;
\n\t
}(engine.Container));
\n\t
//# sourceMappingURL=GuideLayer.js.map
\n\n\t
var svgaAssets = {
\n\t
aniReady: { name: '准备立正', dir: 1 },
\n\t
aniReady2: { name: '准备立正', dir: 1 },
\n\t
aniJump: { name: '跳上升', dir: 1 },
\n\t
aniFall: { name: '跳下落', dir: 1 },
\n\t
aniLandNormal: { name: '普通着地', dir: 1 },
\n\t
aniLandSide: { name: '边缘着地', dir: -1 },
\n\t
aniHit: { name: '被撞开', dir: -1 },
\n\t
aniParachute: { name: '降落pic', dir: -1, type: 'pic' },
\n\t
aniLandPerfect: { name: '完美着地_笑', dir: 1 },
\n\t
};
\n\t
var Player = (function (_super) {
\n\t
tslib.__extends(Player, _super);
\n\t
function Player() {
\n\t
var _this = _super.call(this) || this;
\n\t
_this.g = props.gravity;
\n\t
_this.addEventListener(engine.Event.ENTER_FRAME, _this.onEnterFrame, _this);
\n\t
return _this;
\n\t
}
\n\t
Player.prototype.switchAni = function (name, dir, play, loop) {
\n\t
var _this = this;
\n\t
if (dir === void 0) { dir = 1; }
\n\t
if (play === void 0) { play = true; }
\n\t
if (loop === void 0) { loop = false; }
\n\t
return new Promise(function (resolve) {
\n\t
_this.scaleX = dir;
\n\t
if (_this._aniName !== name) {
\n\t
_this._aniName = name;
\n\t
var oldAni = _this.removeChild(_this.getChildByName('body'));
\n\t
if (oldAni) {
\n\t
oldAni.stop();
\n\t
}
\n\t
var ani = _this._currentAni = _this['ani' + name];
\n\t
_this.addChild(ani);
\n\t
ani.y = -300;
\n\t
if (play) {
\n\t
ani.play && ani.play(false, loop);
\n\t
if (loop) {
\n\t
resolve();
\n\t
}
\n\t
else {
\n\t
ani.once(engine.Event.END_FRAME, resolve);
\n\t
}
\n\t
}
\n\t
else {
\n\t
resolve();
\n\t
}
\n\t
}
\n\t
});
\n\t
};
\n\t
Player.prototype.setup = function () {
\n\t
this.prefectEffect = createSvga('完美着地特效', 'playerLandPrefectAnchor');
\n\t
this.landEffect = createSvga('着地特效', 'playerLandEffectAnchor');
\n\t
for (var key in svgaAssets) {
\n\t
var body = void 0;
\n\t
var _a = svgaAssets[key], name = _a.name, dir = _a.dir, type = _a.type;
\n\t
if (type == 'pic') {
\n\t
body = this[key] = new engine.Image(getTextureByName('降落pic'));
\n\t
var anchor = { x: 75, y: 122 };
\n\t
body.x = -anchor.x;
\n\t
body.y = -anchor.y;
\n\t
body.anchorX = anchor.x;
\n\t
body.anchorY = anchor.y;
\n\t
}
\n\t
else {
\n\t
body = this[key] = createSvga(name, key.replace('ani', 'player') + 'Anchor');
\n\t
}
\n\t
body.name = 'body';
\n\t
body.scaleX = dir;
\n\t
}
\n\t
};
\n\t
Player.prototype.reset = function (revive) {
\n\t
this.x = 0;
\n\t
this.rotation = 0;
\n\t
this.scaleX = this.scaleY = 1;
\n\t
this._prefectLandCounting = 0;
\n\t
engine.Tween.removeTweens(this);
\n\t
if (revive) {
\n\t
this.switchAni('Jump', 1, false);
\n\t
}
\n\t
};
\n\t
Player.prototype.playReady = function () {
\n\t
var _this = this;
\n\t
return new Promise(function (resolve) {
\n\t
_this.switchAni('Ready', 1);
\n\t
_this._currentAni.once(engine.Event.END_FRAME, function () {
\n\t
this.switchAni('Ready2', 1, true, true);
\n\t
resolve();
\n\t
}, _this);
\n\t
});
\n\t
};
\n\t
Player.prototype.onEnterFrame = function (event) {
\n\t
if (!this.playing) {
\n\t
return;
\n\t
}
\n\t
this.vy += this.g;
\n\t
this.y += this.vy;
\n\t
if (this.vy > 0 && this._aniName !== 'Fall') {
\n\t
this.dispatchEvent('jump-on-top');
\n\t
this.switchAni('Fall');
\n\t
}
\n\t
if (this.y > this.baseY) {
\n\t
this.y = this.baseY;
\n\t
this.playing = false;
\n\t
this.jumpPromise && this.jumpPromise({
\n\t
aboveBlock: this.aboveBlock,
\n\t
});
\n\t
this.jumpPromise = null;
\n\t
}
\n\t
};
\n\t
Player.prototype.changeBaseY = function (v) {
\n\t
if (this.baseY == v) {
\n\t
return;
\n\t
}
\n\t
this.aboveBlock = true;
\n\t
this.baseY = v;
\n\t
};
\n\t
Player.prototype.jump = function () {
\n\t
var _this = this;
\n\t
playSound('跳起音效');
\n\t
this.switchAni('Jump', 1, false);
\n\t
this._currentAni.play(false, false);
\n\t
this.aboveBlock = false;
\n\t
this.playing = true;
\n\t
this.baseY = this.y;
\n\t
this.vy = -props.jumpSpeed;
\n\t
return new Promise(function (resolve) {
\n\t
_this.jumpPromise = resolve;
\n\t
});
\n\t
};
\n\t
Player.prototype.playLand = function (type, dir) {
\n\t
return tslib.__awaiter(this, void 0, void 0, function () {
\n\t
var _a, prefectEffect_1, landEffect_1;
\n\t
return tslib.__generator(this, function (_b) {
\n\t
switch (_b.label) {
\n\t
case 0:
\n\t
_a = type;
\n\t
switch (_a) {
\n\t
case 0: return [3, 1];
\n\t
case 1: return [3, 4];
\n\t
case 2: return [3, 4];
\n\t
case 3: return [3, 5];
\n\t
}
\n\t
return [3, 6];
\n\t
case 1:
\n\t
this._prefectLandCounting++;
\n\t
playSound('完美落地音效' + Math.min(4, this._prefectLandCounting));
\n\t
prefectEffect_1 = this.prefectEffect;
\n\t
this.addChildAt(prefectEffect_1, 0);
\n\t
prefectEffect_1.gotoAndPlay(1);
\n\t
prefectEffect_1.once(engine.Event.END_FRAME, function () {
\n\t
this.removeChild(prefectEffect_1);
\n\t
}, this);
\n\t
landEffect_1 = this.landEffect;
\n\t
this.addChildAt(landEffect_1, 0);
\n\t
landEffect_1.gotoAndPlay(1);
\n\t
landEffect_1.once(engine.Event.END_FRAME, function () {
\n\t
this.removeChild(landEffect_1);
\n\t
}, this);
\n\t
return [4, this.switchAni('LandPerfect')];
\n\t
case 2:
\n\t
_b.sent();
\n\t
return [4, this.switchAni('Ready2', 1, true, true)];
\n\t
case 3:
\n\t
_b.sent();
\n\t
return [3, 6];
\n\t
case 4:
\n\t
this._prefectLandCounting = 0;
\n\t
playSound('普通落地音效');
\n\t
this.switchAni('Ready2', 1, true, true);
\n\t
return [3, 6];
\n\t
case 5:
\n\t
this._prefectLandCounting = 0;
\n\t
playSound('边缘落地音效');
\n\t
this.switchAni('LandSide', dir);
\n\t
return [3, 6];
\n\t
case 6: return [2];
\n\t
}
\n\t
});
\n\t
});
\n\t
};
\n\t
Player.prototype.hitAway = function (dir) {
\n\t
return tslib.__awaiter(this, void 0, void 0, function () {
\n\t
var _this = this;
\n\t
return tslib.__generator(this, function (_a) {
\n\t
switch (_a.label) {
\n\t
case 0:
\n\t
this.jumpPromise && this.jumpPromise();
\n\t
this.jumpPromise = null;
\n\t
playSound('被撞开音效');
\n\t
this.switchAni('Hit', dir);
\n\t
this.vy = 0;
\n\t
return [4, new Promise(function (resolve) {
\n\t
engine.Tween.get(_this)
\n\t
.to({
\n\t
x: -dir * props.hitAwayDistance.x,
\n\t
}, props.hitAwayDuration, engine.Ease.quartOut);
\n\t
engine.Tween.get(_this)
\n\t
.to({
\n\t
y: _this.y + props.hitAwayDistance.y,
\n\t
}, props.hitAwayDuration, engine.Ease.cubicOut)
\n\t
.call(resolve);
\n\t
})];
\n\t
case 1:
\n\t
_a.sent();
\n\t
return [2];
\n\t
}
\n\t
});
\n\t
});
\n\t
};
\n\t
Player.prototype.parachute = function (dir) {
\n\t
var _this = this;
\n\t
this.switchAni('Parachute', dir);
\n\t
return new Promise(function (resolve) {
\n\t
engine.Tween.get(_this)
\n\t
.call(function () {
\n\t
playSound('降落伞下落音效');
\n\t
})
\n\t
.to({ y: _this.y + props.parachuteDistance }, props.parachuteDuration)
\n\t
.set({ anchorOffsetY: 0 })
\n\t
.call(resolve);
\n\t
});
\n\t
};
\n\t
return Player;
\n\t
}(engine.Container));
\n\n\t
var ObjectPool = engine.ObjectPool;
\n\t
var PoolName = 'gold-bag';
\n\t
ObjectPool.registerPool(PoolName, function () {
\n\t
return new GoldBag();
\n\t
}, function (item, data) {
\n\t
item.reset(data);
\n\t
});
\n\t
var GameView = (function (_super) {
\n\t
tslib.__extends(GameView, _super);
\n\t
function GameView() {
\n\t
var _this = _super.call(this) || this;
\n\t
_this.index = -1;
\n\t
_this.goldBags = [];
\n\t
_this.baseOffset = -props.baseOffset + props.playerOffset;
\n\t
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
\n\t
return _this;
\n\t
}
\n\t
GameView.prototype.setup = function () {
\n\t
if (this._hasSetup) {
\n\t
return;
\n\t
}
\n\t
this._hasSetup = true;
\n\t
var _a = this.stage, width = _a.width, height = _a.height;
\n\t
var background = this.background = new Background();
\n\t
background.y = height - 1624;
\n\t
this.addChild(background);
\n\t
background.setup();
\n\t
var frontContainer = this.frontContainer = new engine.Container();
\n\t
frontContainer.x = width / 2;
\n\t
this.addChild(frontContainer);
\n\t
var guideLayer = this.guideLayer = new GuideLayer();
\n\t
this.addChild(guideLayer);
\n\t
var blockContainer = this.blockContainer = new engine.Container();
\n\t
frontContainer.addChild(blockContainer);
\n\t
var base = this.base = new Base();
\n\t
frontContainer.addChild(base);
\n\t
base.setup();
\n\t
var player = this.player = new Player();
\n\t
frontContainer.addChildAt(player, 0);
\n\t
player.setup();
\n\t
player.addEventListener('jump-on-top', this.onPlayerJumpOnTop, this);
\n\t
var scoreAddTipsContainer = this.scoreAddTipsContainer = new engine.Container();
\n\t
scoreAddTipsContainer.width = 750;
\n\t
scoreAddTipsContainer.anchorX = scoreAddTipsContainer.width / 2;
\n\t
scoreAddTipsContainer.anchorY = scoreAddTipsContainer.height / 2;
\n\t
var scoreAddTips = this.scoreAddTips = new engine.Label();
\n\t
scoreAddTips.width = 750;
\n\t
scoreAddTips.fillColor = props.scoreAddFontColor;
\n\t
scoreAddTips.textAlign = engine.TEXT_ALIGN.CENTER;
\n\t
scoreAddTips.size = props.scoreAddFontSize;
\n\t
scoreAddTips.alpha = 0;
\n\t
scoreAddTips.text =
\"
+0
\"
;
\n\t
scoreAddTips.x = this.player.x - scoreAddTips.width / 2;
\n\t
scoreAddTipsContainer.addChild(scoreAddTips);
\n\t
frontContainer.addChildAt(player, 0);
\n\t
frontContainer.addChild(scoreAddTipsContainer);
\n\t
ObjectPool.recycleObject(PoolName, ObjectPool.getObject(PoolName, {
\n\t
y: 0,
\n\t
remain: 0,
\n\t
}));
\n\t
this.hitEffect = createSvga('被撞烟雾', 'hitEffectAnchor');
\n\t
this.pos = 0;
\n\t
this.background.setup();
\n\t
this.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);
\n\t
this.reset();
\n\t
};
\n\t
GameView.prototype.setScoreText = function (score) {
\n\t
return tslib.__awaiter(this, void 0, void 0, function () {
\n\t
var _this = this;
\n\t
return tslib.__generator(this, function (_a) {
\n\t
return [2, new Promise(function (resolve) {
\n\t
_this.scoreAddTips.text = score;
\n\t
_this.scoreAddTips.y = 0;
\n\t
_this.scoreAddTips.alpha = 1;
\n\t
engine.Tween.get(_this.scoreAddTips, null, null, true)
\n\t
.to({ y: -100, alpha: 0 }, 500, engine.Ease.cubicInOut)
\n\t
.call(resolve);
\n\t
})];
\n\t
});
\n\t
});
\n\t
};
\n\t
GameView.prototype.reset = function (revive) {
\n\t
if (revive === void 0) { revive = false; }
\n\t
return tslib.__awaiter(this, void 0, void 0, function () {
\n\t
var blockContainer, i, li, block, i, i, li, goldBag;
\n\t
return tslib.__generator(this, function (_a) {
\n\t
switch (_a.label) {
\n\t
case 0:
\n\t
this.base.reset();
\n\t
this.index = -1;
\n\t
this._score = 0;
\n\t
if (revive) ;
\n\t
else {
\n\t
this.pos = 0;
\n\t
blockContainer = this.blockContainer;
\n\t
for (i = 0, li = blockContainer.children.length; i < li; i++) {
\n\t
block = blockContainer.getChildAt(i);
\n\t
block.playLeave();
\n\t
}
\n\t
}
\n\t
for (i = 0; i < props.initBlockCount; i++) {
\n\t
this.addBlock(false);
\n\t
}
\n\t
for (i = 0, li = this.goldBags.length; i < li; i++) {
\n\t
goldBag = this.goldBags[i];
\n\t
this.frontContainer.removeChild(goldBag);
\n\t
ObjectPool.recycleObject(PoolName, goldBag);
\n\t
}
\n\t
this.goldBags.splice(0);
\n\t
this.playZoom('in');
\n\t
return [4, this.resetPlayer(revive)];
\n\t
case 1:
\n\t
_a.sent();
\n\t
return [2];
\n\t
}
\n\t
});
\n\t
});
\n\t
};
\n\t
GameView.prototype.resetPlayer = function (revive) {
\n\t
if (revive === void 0) { revive = false; }
\n\t
return tslib.__awaiter(this, void 0, void 0, function () {
\n\t
return tslib.__generator(this, function (_a) {
\n\t
this.player.reset(revive);
\n\t
this.player.y = this.baseOffset - (this.index + 1) * props.blockHitHeight + props.blockBaseOffset;
\n\t
return [2];
\n\t
});
\n\t
});
\n\t
};
\n\t
GameView.prototype.start = function (revive) {
\n\t
if (revive === void 0) { revive = false; }
\n\t
return tslib.__awaiter(this, void 0, void 0, function () {
\n\t
var guideFlagKey, guideFlag;
\n\t
var _this = this;
\n\t
return tslib.__generator(this, function (_a) {
\n\t
switch (_a.label) {
\n\t
case 0:
\n\t
this.scoreAddTipsContainer.y = this.player.y + props.scoreAddTipsOffset;
\n\t
if (!!revive) return [3, 2];
\n\t
return [4, this.player.playReady()];
\n\t
case 1:
\n\t
_a.sent();
\n\t
_a.label = 2;
\n\t
case 2:
\n\t
console.log(
\"
开始
\"
);
\n\t
guideFlagKey = 'jump-high-guide_' + props.guideFlagKey;
\n\t
guideFlag = localStorage.getItem(guideFlagKey);
\n\t
if (!!guideFlag) return [3, 4];
\n\t
localStorage.setItem(guideFlagKey, '1');
\n\t
return [4, this.guideLayer.show('', { y: this.stage.height + this.player.y - 280 })];
\n\t
case 3:
\n\t
_a.sent();
\n\t
_a.label = 4;
\n\t
case 4:
\n\t
this.lastLandType = 0;
\n\t
this._remainToShowGoldBag = props.goldBagScoreMultiple - props.goldBagScoreSubtraction;
\n\t
this._touchEnabled = true;
\n\t
setTimeout(function () {
\n\t
_this.addBlock();
\n\t
}, 100);
\n\t
engine.globalEvent.dispatchEvent('jump-high-game-start');
\n\t
return [2];
\n\t
}
\n\t
});
\n\t
});
\n\t
};
\n\t
GameView.prototype.pause = function () {
\n\t
if (this.currentBlock) {
\n\t
engine.Tween.pauseTweens(this.currentBlock);
\n\t
}
\n\t
engine.Tween.pauseTweens(this.player);
\n\t
};
\n\t
GameView.prototype.resume = function () {
\n\t
if (this.currentBlock) {
\n\t
engine.Tween.resumeTweens(this.currentBlock);
\n\t
}
\n\t
engine.Tween.resumeTweens(this.player);
\n\t
};
\n\t
GameView.prototype.revive = function () {
\n\t
return tslib.__awaiter(this, void 0, void 0, function () {
\n\t
return tslib.__generator(this, function (_a) {
\n\t
switch (_a.label) {
\n\t
case 0:
\n\t
this.blockContainer.getChildAt(this.index).visible = false;
\n\t
this.index--;
\n\t
return [4, this.resetPlayer(true)];
\n\t
case 1:
\n\t
_a.sent();
\n\t
return [4, this.playZoom('in')];
\n\t
case 2:
\n\t
_a.sent();
\n\t
this.start(true);
\n\t
return [2];
\n\t
}
\n\t
});
\n\t
});
\n\t
};
\n\t
GameView.prototype.addBlock = function (animation) {
\n\t
var _this = this;
\n\t
if (animation === void 0) { animation = true; }
\n\t
this.index++;
\n\t
var blockContainer = this.blockContainer;
\n\t
var block;
\n\t
if (blockContainer.children.length > this.index) {
\n\t
block = blockContainer.getChildAt(this.index);
\n\t
block.visible = true;
\n\t
}
\n\t
else {
\n\t
block = new Block();
\n\t
blockContainer.addChildAt(block, 0);
\n\t
}
\n\t
blockContainer.addChildAt(block, 0);
\n\t
block.reset({
\n\t
type: Math.floor(Math.random() * props.blockAssets.length),
\n\t
});
\n\t
console.log('addblock', this.index);
\n\t
block.y = this.baseOffset - (this.index * props.blockHitHeight) + props.blockBaseOffset;
\n\t
this.blockComplete = false;
\n\t
block.playEnter(this.index, animation).then(function (data) {
\n\t
_this.blockComplete = true;
\n\t
});
\n\t
if (animation) {
\n\t
this.needHitTest = true;
\n\t
}
\n\t
this.currentBlock = block;
\n\t
};
\n\t
GameView.prototype.addGoldBag = function () {
\n\t
var goldBag = ObjectPool.getObject(PoolName, {
\n\t
y: this.baseOffset - (this.blockCount + props.goldBagDistance + props.goldBagJumpSubtraction) * props.blockHitHeight,
\n\t
remain: props.goldBagDistance,
\n\t
});
\n\t
this.frontContainer.addChild(goldBag);
\n\t
this.goldBags.push(goldBag);
\n\t
};
\n\t
GameView.prototype.playOpenGoldBag = function () {
\n\t
return tslib.__awaiter(this, void 0, void 0, function () {
\n\t
var i, li, goldBag;
\n\t
return tslib.__generator(this, function (_a) {
\n\t
switch (_a.label) {
\n\t
case 0:
\n\t
i = 0, li = this.goldBags.length;
\n\t
_a.label = 1;
\n\t
case 1:
\n\t
if (!(i < li)) return [3, 4];
\n\t
goldBag = this.goldBags[i];
\n\t
goldBag.remain--;
\n\t
if (!(goldBag.remain <= 0)) return [3, 3];
\n\t
this.goldBags.splice(i, 1);
\n\t
i--;
\n\t
li--;
\n\t
this.nextToUpdateScore = true;
\n\t
return [4, goldBag.playOpen()];
\n\t
case 2:
\n\t
_a.sent();
\n\t
this.frontContainer.removeChild(goldBag);
\n\t
ObjectPool.recycleObject(PoolName, goldBag);
\n\t
_a.label = 3;
\n\t
case 3:
\n\t
i++;
\n\t
return [3, 1];
\n\t
case 4: return [2];
\n\t
}
\n\t
});
\n\t
});
\n\t
};
\n\t
GameView.prototype.onPlayerJumpOnTop = function () {
\n\t
if (this.nextToUpdateScore) {
\n\t
this.nextToUpdateScore = false;
\n\t
this.scoreChange(4);
\n\t
playSound('撞击钱袋音效');
\n\t
}
\n\t
};
\n\t
Object.defineProperty(GameView.prototype,
\"
blockCount
\"
, {
\n\t
get: function () {
\n\t
return this.index - props.initBlockCount + 1;
\n\t
},
\n\t
enumerable: false,
\n\t
configurable: true
\n\t
});
\n\t
Object.defineProperty(GameView.prototype,
\"
pos
\"
, {
\n\t
get: function () {
\n\t
return this._pos;
\n\t
},
\n\t
set: function (v) {
\n\t
this._pos = v;
\n\t
this.updatePos();
\n\t
},
\n\t
enumerable: false,
\n\t
configurable: true
\n\t
});
\n\t
GameView.prototype.updatePos = function () {
\n\t
this.frontContainer.y = this.stage.height + this._pos;
\n\t
};
\n\t
GameView.prototype.onEnterFrame = function (event) {
\n\t
if (this.needHitTest) {
\n\t
if (this.currentBlock) {
\n\t
var _a = this.currentBlock, bx = _a.x, by = _a.y, dir = _a.dir;
\n\t
var _b = this.player, px = _b.x, py = _b.y;
\n\t
var blockHitWidth = props.blockHitWidth, blockHitHeight = props.blockHitHeight, playerWidth = props.playerWidth;
\n\t
var hitOn = false;
\n\t
if (Math.abs(px - bx) < (blockHitWidth + playerWidth) / 2) {
\n\t
this.player.changeBaseY(by - blockHitHeight);
\n\t
if (py > by - blockHitHeight) {
\n\t
hitOn = true;
\n\t
}
\n\t
}
\n\t
if (hitOn) {
\n\t
this.onHitOn(dir);
\n\t
}
\n\t
}
\n\t
}
\n\t
};
\n\t
GameView.prototype.onHitOn = function (dir) {
\n\t
return tslib.__awaiter(this, void 0, void 0, function () {
\n\t
return tslib.__generator(this, function (_a) {
\n\t
switch (_a.label) {
\n\t
case 0:
\n\t
this._touchEnabled = false;
\n\t
this.needHitTest = false;
\n\t
clearInterval(this.timer);
\n\t
return [4, this.player.hitAway(dir)];
\n\t
case 1:
\n\t
_a.sent();
\n\t
this.frontContainer.addChild(this.player);
\n\t
return [4, this.player.parachute(dir)];
\n\t
case 2:
\n\t
_a.sent();
\n\t
console.log('jump-high-game-end');
\n\t
engine.globalEvent.dispatchEvent('jump-high-game-end');
\n\t
return [2];
\n\t
}
\n\t
});
\n\t
});
\n\t
};
\n\t
GameView.prototype.jump = function () {
\n\t
return tslib.__awaiter(this, void 0, void 0, function () {
\n\t
var result, pos, type, lastLandType;
\n\t
var _this = this;
\n\t
return tslib.__generator(this, function (_a) {
\n\t
switch (_a.label) {
\n\t
case 0:
\n\t
if (!this._touchEnabled) {
\n\t
return [2];
\n\t
}
\n\t
this._touchEnabled = false;
\n\t
this.playOpenGoldBag();
\n\t
return [4, this.player.jump()];
\n\t
case 1:
\n\t
result = _a.sent();
\n\t
if (!result) return [3, 4];
\n\t
if (!result.aboveBlock) return [3, 3];
\n\t
pos = Math.abs(this.currentBlock.x);
\n\t
type = 0;
\n\t
if (pos > 0) {
\n\t
type = pos > 0 && pos < props.scoreThreshold ? 2 : 3;
\n\t
}
\n\t
lastLandType = this.lastLandType;
\n\t
this.lastLandType = type;
\n\t
if (type === 0) {
\n\t
if (lastLandType !== type) {
\n\t
type = 1;
\n\t
}
\n\t
}
\n\t
this.currentBlock.playEffect();
\n\t
this.player.playLand(type, this.currentBlock.dir);
\n\t
this.currentBlock.stop();
\n\t
this.scoreChange(type);
\n\t
return [4, new Promise(function (resolve) {
\n\t
engine.Tween.get(_this, null, null, true)
\n\t
.to({ pos: props.blockHitHeight * _this.index }, 300, engine.Ease.cubicOut)
\n\t
.call(resolve);
\n\t
})];
\n\t
case 2:
\n\t
_a.sent();
\n\t
this.addBlock();
\n\t
_a.label = 3;
\n\t
case 3:
\n\t
this._touchEnabled = true;
\n\t
_a.label = 4;
\n\t
case 4: return [2];
\n\t
}
\n\t
});
\n\t
});
\n\t
};
\n\t
GameView.prototype.scoreChange = function (type) {
\n\t
var scoreAdd = props.scoreWeights[type];
\n\t
this._score += scoreAdd;
\n\t
this._remainToShowGoldBag -= scoreAdd;
\n\t
var score = this._score;
\n\t
engine.globalEvent.dispatchEvent('jump-high-score', {
\n\t
type: type,
\n\t
score: score,
\n\t
scoreAdd: scoreAdd,
\n\t
});
\n\t
this.scoreAddTipsContainer.y = this.player.y + props.scoreAddTipsOffset;
\n\t
this.setScoreText(
\"
+
\"
+ scoreAdd);
\n\t
console.log(score, this._remainToShowGoldBag);
\n\t
if (this._remainToShowGoldBag <= 0) {
\n\t
this._remainToShowGoldBag += props.goldBagScoreMultiple;
\n\t
this.addGoldBag();
\n\t
console.log('addGoldBag');
\n\t
}
\n\t
};
\n\t
GameView.prototype.playHitEffect = function (dir) {
\n\t
var hitEffect = this.hitEffect;
\n\t
hitEffect.scaleX = dir;
\n\t
hitEffect.y = this.player.y - props.hitEffectAnchor.y;
\n\t
hitEffect.play(true, false);
\n\t
hitEffect.once(engine.Event.END_FRAME, function () {
\n\t
this.frontContainer.removeChild(hitEffect);
\n\t
}, this);
\n\t
this.frontContainer.addChild(hitEffect);
\n\t
};
\n\t
GameView.prototype.playZoom = function (type, duration) {
\n\t
var _this = this;
\n\t
if (duration === void 0) { duration = 700; }
\n\t
this.background.playZoom(type, duration);
\n\t
var count = this.stage.height / props.blockHitHeight;
\n\t
return new Promise(function (resolve) {
\n\t
_this.frontContainer.anchorY = -props.blockHitHeight * (_this.index + count * 1.3) + props.baseOffset;
\n\t
var scale = type === 'in' ? 1 : Math.min((_this.stage.height / props.blockHitHeight / (_this.index + count)), props.maxScale);
\n\t
console.log(scale);
\n\t
engine.Tween.get(_this.frontContainer, null, null, true)
\n\t
.to({ scaleX: scale, scaleY: scale }, duration, engine.Ease.cubicInOut
)
\n\t
.call(resolve);
\n\t
});
\n\t
};
\n\t
return GameView;
\n\t
}(engine.Container));
\n\t
//# sourceMappingURL=GameView.js.map
\n\n\t
var JumpHigh = (function (_super) {
\n\t
tslib.__extends(JumpHigh, _super);
\n\t
function JumpHigh() {
\n\t
var _this = _super.call(this) || this;
\n\t
engine.globalEvent.addEventListener('jump-high-reset', _this.reset, _this);
\n\t
engine.globalEvent.addEventListener('jump-high-start', _this.start, _this);
\n\t
engine.globalEvent.addEventListener('jump-high-pause', _this.pause, _this);
\n\t
engine.globalEvent.addEventListener('jump-high-resume', _this.resume, _this);
\n\t
engine.globalEvent.addEventListener('jump-high-revive', _this.revive, _this);
\n\t
_this.addEventListener(engine.MouseEvent.MOUSE_DOWN, _this.onTap, _this);
\n\t
var gameView = _this._gameView = new GameView();
\n\t
_this.addChild(gameView);
\n\t
return _this;
\n\t
}
\n\t
JumpHigh.prototype.reset = function () {
\n\t
this._gameView.reset();
\n\t
};
\n\t
JumpHigh.prototype.start = function (event) {
\n\t
{
\n\t
injectProps(event.data);
\n\t
}
\n\t
this._status = 1;
\n\t
this._gameView.start();
\n\t
};
\n\t
JumpHigh.prototype.pause = function () {
\n\t
this._gameView.pause();
\n\t
};
\n\t
JumpHigh.prototype.resume = function () {
\n\t
this._gameView.resume();
\n\t
};
\n\t
JumpHigh.prototype.revive = function () {
\n\t
this._gameView.revive();
\n\t
};
\n\t
JumpHigh.prototype.onTap = function (event) {
\n\t
this._gameView.jump();
\n\t
};
\n\t
return JumpHigh;
\n\t
}(engine.Container));
\n\t
//# sourceMappingURL=JumpHigh.js.map
\n\n\t
function index (props) {
\n\t
prepareProps();
\n\t
injectProps(props);
\n\t
var instance = new JumpHigh();
\n\t
return instance;
\n\t
}
\n\t
//# sourceMappingURL=index.js.map
\n\n\t
return index;
\n\n
})));
\n
"
}
}
src/custom/jump-high-3/debug/load-assets.js
View file @
86efa534
...
@@ -5,15 +5,9 @@
...
@@ -5,15 +5,9 @@
const
assets
=
[
const
assets
=
[
{
{
"name"
:
"方块素材0"
,
"name"
:
"方块素材0"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/
4c6fba8e09e6fa6015e911870c295ff3e11bde72
.svga"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/
f4a8043e67c73dcb65d5c1f2e09aa302ef977373
.svga"
,
"uuid"
:
"c3e908ad-a895-4463-98a9-c78c19ba5e6b"
,
"uuid"
:
"c3e908ad-a895-4463-98a9-c78c19ba5e6b"
,
"ext"
:
".svga"
"ext"
:
".svga"
},
{
"name"
:
"方块素材0_hit"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/4c6fba8e09e6fa6015e911870c295ff3e11bde72.svga"
,
"uuid"
:
"79cd10e7-67c4-4cb1-9e56-598100162a7c"
,
"ext"
:
".svga"
}
}
];
];
...
...
src/custom/jump-high-3/debug/main.js
View file @
86efa534
...
@@ -20,12 +20,8 @@
...
@@ -20,12 +20,8 @@
function
getTextureByName
(
name
)
{
function
getTextureByName
(
name
)
{
return
getTexture
(
engine
.
getAssetByName
(
name
).
uuid
);
return
getTexture
(
engine
.
getAssetByName
(
name
).
uuid
);
}
}
function
getBlockAsset
(
type
)
{
function
getBlockAsset
()
{
return
engine
.
getAssetByName
(
props
.
blockAssets
[
type
]);
return
engine
.
getAssetByName
(
props
.
blockAssets
[
0
]);
}
function
getBlockHitAsset
(
type
)
{
console
.
log
(
"props.blockHitAssets"
,
props
.
blockHitAssets
);
return
engine
.
getAssetByName
(
props
.
blockHitAssets
[
type
]);
}
}
function
createSvga
(
name
,
anchorName
)
{
function
createSvga
(
name
,
anchorName
)
{
var
inst
=
new
svga
.
Svga
();
var
inst
=
new
svga
.
Svga
();
...
@@ -52,12 +48,7 @@
...
@@ -52,12 +48,7 @@
Background
.
prototype
.
setup
=
function
()
{
Background
.
prototype
.
setup
=
function
()
{
var
_a
=
this
.
stage
,
width
=
_a
.
width
,
height
=
_a
.
height
;
var
_a
=
this
.
stage
,
width
=
_a
.
width
,
height
=
_a
.
height
;
var
bg
=
this
.
_bg
=
new
engine
.
Image
(
getTextureByName
(
'背景图'
));
var
bg
=
this
.
_bg
=
new
engine
.
Image
(
getTextureByName
(
'背景图'
));
bg
.
anchorX
=
bg
.
width
/
2
;
bg
.
anchorY
=
bg
.
height
/
2
;
bg
.
x
=
-
(
bg
.
width
-
width
)
/
2
;
bg
.
y
=
-
(
bg
.
height
-
height
)
/
2
;
this
.
addChild
(
bg
);
this
.
addChild
(
bg
);
this
.
_minScale
=
width
/
bg
.
width
;
};
};
Background
.
prototype
.
playZoom
=
function
(
type
,
duration
)
{
Background
.
prototype
.
playZoom
=
function
(
type
,
duration
)
{
var
_this
=
this
;
var
_this
=
this
;
...
@@ -96,35 +87,17 @@
...
@@ -96,35 +87,17 @@
body
.
x
=
-
props
.
blockWidth
/
2
;
body
.
x
=
-
props
.
blockWidth
/
2
;
body
.
y
=
-
props
.
blockHitHeight
-
props
.
blockPaddingTop
;
body
.
y
=
-
props
.
blockHitHeight
-
props
.
blockPaddingTop
;
_this
.
addChild
(
body
);
_this
.
addChild
(
body
);
var
bodyHit
=
_this
.
bodyHit
=
new
svga
.
Svga
();
bodyHit
.
x
=
-
props
.
blockWidth
/
2
;
bodyHit
.
y
=
-
props
.
blockHitHeight
-
props
.
blockPaddingTop
+
props
.
blockHitOffsetY
;
_this
.
addChild
(
bodyHit
);
console
.
log
(
"props.blockProfectOffset"
,
props
.
blockProfectOffset
);
var
bodyProfect
=
_this
.
bodyProfect
=
new
svga
.
Svga
();
bodyProfect
.
x
=
-
props
.
blockWidth
/
2
+
props
.
blockProfectOffset
.
x
;
bodyProfect
.
y
=
-
props
.
blockHitHeight
-
props
.
blockPaddingTop
+
props
.
blockProfectOffset
.
y
;
_this
.
addChild
(
bodyProfect
);
return
_this
;
return
_this
;
}
}
Block
.
prototype
.
reset
=
function
(
_a
)
{
Block
.
prototype
.
reset
=
function
(
_a
)
{
var
type
=
_a
.
type
;
var
type
=
_a
.
type
;
this
.
dir
=
Math
.
random
()
>
0.5
?
1
:
-
1
;
this
.
dir
=
Math
.
random
()
>
0.5
?
1
:
-
1
;
if
(
this
.
type
!=
type
)
{
this
.
type
=
type
;
this
.
type
=
type
;
var
asset
=
getBlockAsset
(
type
);
var
asset
=
getBlockAsset
(
);
this
.
body
.
source
=
'asset://'
+
asset
.
uuid
;
this
.
body
.
source
=
'asset://'
+
asset
.
uuid
;
var
assetHit
=
getBlockHitAsset
(
type
);
console
.
log
(
"assetHit"
,
assetHit
);
this
.
bodyHit
.
source
=
'asset://'
+
assetHit
.
uuid
;
}
this
.
bodyProfect
.
source
=
'asset://'
+
engine
.
getAssetByName
(
"完美方块素材"
).
uuid
;
this
.
scaleX
=
this
.
dir
;
this
.
scaleX
=
this
.
dir
;
this
.
body
.
gotoAndStop
(
1
);
this
.
body
.
gotoAndStop
(
1
);
this
.
bodyHit
.
gotoAndStop
(
1
);
this
.
bodyProfect
.
gotoAndStop
(
1
);
this
.
body
.
visible
=
true
;
this
.
body
.
visible
=
true
;
this
.
bodyHit
.
visible
=
false
;
};
};
Block
.
prototype
.
playEnter
=
function
(
index
,
animation
)
{
Block
.
prototype
.
playEnter
=
function
(
index
,
animation
)
{
var
_this
=
this
;
var
_this
=
this
;
...
@@ -142,7 +115,6 @@
...
@@ -142,7 +115,6 @@
else
{
else
{
_this
.
x
=
0
;
_this
.
x
=
0
;
setTimeout
(
function
()
{
setTimeout
(
function
()
{
console
.
log
(
_this
.
body
);
},
200
);
},
200
);
resolve
();
resolve
();
}
}
...
@@ -158,24 +130,6 @@
...
@@ -158,24 +130,6 @@
body
.
gotoAndStop
(
1
);
body
.
gotoAndStop
(
1
);
},
this
);
},
this
);
};
};
Block
.
prototype
.
playHit
=
function
()
{
var
bodyHit
=
this
.
bodyHit
;
bodyHit
.
play
(
true
,
false
);
this
.
body
.
visible
=
false
;
this
.
bodyHit
.
visible
=
true
;
bodyHit
.
once
(
engine
.
Event
.
END_FRAME
,
function
()
{
this
.
body
.
visible
=
true
;
this
.
bodyHit
.
visible
=
false
;
bodyHit
.
gotoAndStop
(
1
);
},
this
);
};
Block
.
prototype
.
playProFect
=
function
()
{
var
bodyProfect
=
this
.
bodyProfect
;
bodyProfect
.
play
(
true
,
false
);
bodyProfect
.
once
(
engine
.
Event
.
END_FRAME
,
function
()
{
bodyProfect
.
gotoAndStop
(
1
);
},
this
);
};
Block
.
prototype
.
stop
=
function
()
{
Block
.
prototype
.
stop
=
function
()
{
engine
.
Tween
.
removeTweens
(
this
);
engine
.
Tween
.
removeTweens
(
this
);
};
};
...
@@ -283,7 +237,7 @@
...
@@ -283,7 +237,7 @@
aniLandNormal
:
{
name
:
'普通着地'
,
dir
:
1
},
aniLandNormal
:
{
name
:
'普通着地'
,
dir
:
1
},
aniLandSide
:
{
name
:
'边缘着地'
,
dir
:
-
1
},
aniLandSide
:
{
name
:
'边缘着地'
,
dir
:
-
1
},
aniHit
:
{
name
:
'被撞开'
,
dir
:
-
1
},
aniHit
:
{
name
:
'被撞开'
,
dir
:
-
1
},
aniParachute
:
{
name
:
'降落
'
,
dir
:
-
1
},
aniParachute
:
{
name
:
'降落
pic'
,
dir
:
-
1
,
type
:
'pic'
},
aniLandPerfect
:
{
name
:
'完美着地_笑'
,
dir
:
1
},
aniLandPerfect
:
{
name
:
'完美着地_笑'
,
dir
:
1
},
};
};
var
Player
=
(
function
(
_super
)
{
var
Player
=
(
function
(
_super
)
{
...
@@ -309,8 +263,9 @@
...
@@ -309,8 +263,9 @@
}
}
var
ani
=
_this
.
_currentAni
=
_this
[
'ani'
+
name
];
var
ani
=
_this
.
_currentAni
=
_this
[
'ani'
+
name
];
_this
.
addChild
(
ani
);
_this
.
addChild
(
ani
);
ani
.
y
=
-
300
;
if
(
play
)
{
if
(
play
)
{
ani
.
play
(
false
,
loop
);
ani
.
play
&&
ani
.
play
(
false
,
loop
);
if
(
loop
)
{
if
(
loop
)
{
resolve
();
resolve
();
}
}
...
@@ -328,8 +283,19 @@
...
@@ -328,8 +283,19 @@
this
.
prefectEffect
=
createSvga
(
'完美着地特效'
,
'playerLandPrefectAnchor'
);
this
.
prefectEffect
=
createSvga
(
'完美着地特效'
,
'playerLandPrefectAnchor'
);
this
.
landEffect
=
createSvga
(
'着地特效'
,
'playerLandEffectAnchor'
);
this
.
landEffect
=
createSvga
(
'着地特效'
,
'playerLandEffectAnchor'
);
for
(
var
key
in
svgaAssets
)
{
for
(
var
key
in
svgaAssets
)
{
var
_a
=
svgaAssets
[
key
],
name
=
_a
.
name
,
dir
=
_a
.
dir
;
var
body
=
void
0
;
var
body
=
this
[
key
]
=
createSvga
(
name
,
key
.
replace
(
'ani'
,
'player'
)
+
'Anchor'
);
var
_a
=
svgaAssets
[
key
],
name
=
_a
.
name
,
dir
=
_a
.
dir
,
type
=
_a
.
type
;
if
(
type
==
'pic'
)
{
body
=
this
[
key
]
=
new
engine
.
Image
(
getTextureByName
(
'降落pic'
));
var
anchor
=
{
x
:
75
,
y
:
122
};
body
.
x
=
-
anchor
.
x
;
body
.
y
=
-
anchor
.
y
;
body
.
anchorX
=
anchor
.
x
;
body
.
anchorY
=
anchor
.
y
;
}
else
{
body
=
this
[
key
]
=
createSvga
(
name
,
key
.
replace
(
'ani'
,
'player'
)
+
'Anchor'
);
}
body
.
name
=
'body'
;
body
.
name
=
'body'
;
body
.
scaleX
=
dir
;
body
.
scaleX
=
dir
;
}
}
...
@@ -513,6 +479,7 @@
...
@@ -513,6 +479,7 @@
this
.
_hasSetup
=
true
;
this
.
_hasSetup
=
true
;
var
_a
=
this
.
stage
,
width
=
_a
.
width
,
height
=
_a
.
height
;
var
_a
=
this
.
stage
,
width
=
_a
.
width
,
height
=
_a
.
height
;
var
background
=
this
.
background
=
new
Background
();
var
background
=
this
.
background
=
new
Background
();
background
.
y
=
height
-
1624
;
this
.
addChild
(
background
);
this
.
addChild
(
background
);
background
.
setup
();
background
.
setup
();
var
frontContainer
=
this
.
frontContainer
=
new
engine
.
Container
();
var
frontContainer
=
this
.
frontContainer
=
new
engine
.
Container
();
...
@@ -520,13 +487,13 @@
...
@@ -520,13 +487,13 @@
this
.
addChild
(
frontContainer
);
this
.
addChild
(
frontContainer
);
var
guideLayer
=
this
.
guideLayer
=
new
GuideLayer
();
var
guideLayer
=
this
.
guideLayer
=
new
GuideLayer
();
this
.
addChild
(
guideLayer
);
this
.
addChild
(
guideLayer
);
var
blockContainer
=
this
.
blockContainer
=
new
engine
.
Container
();
frontContainer
.
addChild
(
blockContainer
);
var
base
=
this
.
base
=
new
Base
();
var
base
=
this
.
base
=
new
Base
();
frontContainer
.
addChild
(
base
);
frontContainer
.
addChild
(
base
);
base
.
setup
();
base
.
setup
();
var
blockContainer
=
this
.
blockContainer
=
new
engine
.
Container
();
frontContainer
.
addChild
(
blockContainer
);
var
player
=
this
.
player
=
new
Player
();
var
player
=
this
.
player
=
new
Player
();
frontContainer
.
addChild
(
player
);
frontContainer
.
addChild
At
(
player
,
0
);
player
.
setup
();
player
.
setup
();
player
.
addEventListener
(
'jump-on-top'
,
this
.
onPlayerJumpOnTop
,
this
);
player
.
addEventListener
(
'jump-on-top'
,
this
.
onPlayerJumpOnTop
,
this
);
var
scoreAddTipsContainer
=
this
.
scoreAddTipsContainer
=
new
engine
.
Container
();
var
scoreAddTipsContainer
=
this
.
scoreAddTipsContainer
=
new
engine
.
Container
();
...
@@ -542,7 +509,7 @@
...
@@ -542,7 +509,7 @@
scoreAddTips
.
text
=
"+0"
;
scoreAddTips
.
text
=
"+0"
;
scoreAddTips
.
x
=
this
.
player
.
x
-
scoreAddTips
.
width
/
2
;
scoreAddTips
.
x
=
this
.
player
.
x
-
scoreAddTips
.
width
/
2
;
scoreAddTipsContainer
.
addChild
(
scoreAddTips
);
scoreAddTipsContainer
.
addChild
(
scoreAddTips
);
frontContainer
.
addChild
(
player
);
frontContainer
.
addChild
At
(
player
,
0
);
frontContainer
.
addChild
(
scoreAddTipsContainer
);
frontContainer
.
addChild
(
scoreAddTipsContainer
);
ObjectPool
.
recycleObject
(
PoolName
,
ObjectPool
.
getObject
(
PoolName
,
{
ObjectPool
.
recycleObject
(
PoolName
,
ObjectPool
.
getObject
(
PoolName
,
{
y
:
0
,
y
:
0
,
...
@@ -702,7 +669,8 @@
...
@@ -702,7 +669,8 @@
block
.
reset
({
block
.
reset
({
type
:
Math
.
floor
(
Math
.
random
()
*
props
.
blockAssets
.
length
),
type
:
Math
.
floor
(
Math
.
random
()
*
props
.
blockAssets
.
length
),
});
});
block
.
y
=
this
.
baseOffset
-
this
.
index
*
props
.
blockHitHeight
+
props
.
blockBaseOffset
;
console
.
log
(
'addblock'
,
this
.
index
);
block
.
y
=
this
.
baseOffset
-
(
this
.
index
*
props
.
blockHitHeight
)
+
props
.
blockBaseOffset
;
this
.
blockComplete
=
false
;
this
.
blockComplete
=
false
;
block
.
playEnter
(
this
.
index
,
animation
).
then
(
function
(
data
)
{
block
.
playEnter
(
this
.
index
,
animation
).
then
(
function
(
data
)
{
_this
.
blockComplete
=
true
;
_this
.
blockComplete
=
true
;
...
@@ -806,10 +774,10 @@
...
@@ -806,10 +774,10 @@
this
.
_touchEnabled
=
false
;
this
.
_touchEnabled
=
false
;
this
.
needHitTest
=
false
;
this
.
needHitTest
=
false
;
clearInterval
(
this
.
timer
);
clearInterval
(
this
.
timer
);
this
.
currentBlock
.
playHit
();
return
[
4
,
this
.
player
.
hitAway
(
dir
)];
return
[
4
,
this
.
player
.
hitAway
(
dir
)];
case
1
:
case
1
:
_a
.
sent
();
_a
.
sent
();
this
.
frontContainer
.
addChild
(
this
.
player
);
return
[
4
,
this
.
player
.
parachute
(
dir
)];
return
[
4
,
this
.
player
.
parachute
(
dir
)];
case
2
:
case
2
:
_a
.
sent
();
_a
.
sent
();
...
@@ -835,8 +803,8 @@
...
@@ -835,8 +803,8 @@
return
[
4
,
this
.
player
.
jump
()];
return
[
4
,
this
.
player
.
jump
()];
case
1
:
case
1
:
result
=
_a
.
sent
();
result
=
_a
.
sent
();
if
(
!
result
)
return
[
3
,
5
];
if
(
!
result
)
return
[
3
,
4
];
if
(
!
result
.
aboveBlock
)
return
[
3
,
4
];
if
(
!
result
.
aboveBlock
)
return
[
3
,
3
];
pos
=
Math
.
abs
(
this
.
currentBlock
.
x
);
pos
=
Math
.
abs
(
this
.
currentBlock
.
x
);
type
=
0
;
type
=
0
;
if
(
pos
>
0
)
{
if
(
pos
>
0
)
{
...
@@ -849,31 +817,23 @@
...
@@ -849,31 +817,23 @@
type
=
1
;
type
=
1
;
}
}
}
}
if
(
type
<
3
)
{
this
.
currentBlock
.
playEffect
();
this
.
currentBlock
.
playEffect
();
}
if
(
type
===
0
)
{
this
.
currentBlock
.
playProFect
();
}
this
.
player
.
playLand
(
type
,
this
.
currentBlock
.
dir
);
this
.
player
.
playLand
(
type
,
this
.
currentBlock
.
dir
);
this
.
currentBlock
.
stop
();
this
.
currentBlock
.
stop
();
this
.
scoreChange
(
type
);
this
.
scoreChange
(
type
);
return
[
4
,
this
.
playShake
()];
case
2
:
_a
.
sent
();
return
[
4
,
new
Promise
(
function
(
resolve
)
{
return
[
4
,
new
Promise
(
function
(
resolve
)
{
engine
.
Tween
.
get
(
_this
,
null
,
null
,
true
)
engine
.
Tween
.
get
(
_this
,
null
,
null
,
true
)
.
to
({
pos
:
props
.
blockHitHeight
*
_this
.
index
},
300
,
engine
.
Ease
.
cubicOut
)
.
to
({
pos
:
props
.
blockHitHeight
*
_this
.
index
},
300
,
engine
.
Ease
.
cubicOut
)
.
call
(
resolve
);
.
call
(
resolve
);
})];
})];
case
3
:
case
2
:
_a
.
sent
();
_a
.
sent
();
this
.
addBlock
();
this
.
addBlock
();
_a
.
label
=
4
;
_a
.
label
=
3
;
case
4
:
case
3
:
this
.
_touchEnabled
=
true
;
this
.
_touchEnabled
=
true
;
_a
.
label
=
5
;
_a
.
label
=
4
;
case
5
:
return
[
2
];
case
4
:
return
[
2
];
}
}
});
});
});
});
...
@@ -921,21 +881,6 @@
...
@@ -921,21 +881,6 @@
.
call
(
resolve
);
.
call
(
resolve
);
});
});
};
};
GameView
.
prototype
.
playShake
=
function
()
{
var
_this
=
this
;
var
_a
=
this
.
frontContainer
,
x
=
_a
.
x
,
y
=
_a
.
y
;
return
new
Promise
(
function
(
resolve
)
{
var
shakeOffset
=
7
;
var
duration
=
30
;
engine
.
Tween
.
get
(
_this
.
frontContainer
,
null
,
null
,
true
)
.
to
({
x
:
x
,
y
:
y
-
shakeOffset
},
duration
)
.
to
({
x
:
x
,
y
:
y
+
shakeOffset
},
duration
)
.
to
({
x
:
x
+
shakeOffset
,
y
:
y
},
duration
)
.
to
({
x
:
x
-
shakeOffset
,
y
:
y
},
duration
)
.
to
({
x
:
x
,
y
:
y
},
duration
)
.
call
(
resolve
);
});
};
return
GameView
;
return
GameView
;
}(
engine
.
Container
));
}(
engine
.
Container
));
//# sourceMappingURL=GameView.js.map
//# sourceMappingURL=GameView.js.map
...
...
src/custom/jump-high-3/debug/main.js.map
View file @
86efa534
This source diff could not be displayed because it is too large. You can
view the blob
instead.
src/custom/jump-high-3/meta.json
View file @
86efa534
...
@@ -47,25 +47,15 @@
...
@@ -47,25 +47,15 @@
"type"
:
"array<string>"
,
"type"
:
"array<string>"
,
"default"
:
"方块素材0"
"default"
:
"方块素材0"
},
},
"blockHitAssets"
:
{
"alias"
:
"方块素材组撞击状态"
,
"type"
:
"array<string>"
,
"default"
:
"方块素材0_hit"
},
"blockHitOffsetY"
:
{
"blockHitOffsetY"
:
{
"alias"
:
"方块素材组撞击状态Y轴锚点"
,
"alias"
:
"方块素材组撞击状态Y轴锚点"
,
"type"
:
"number"
,
"type"
:
"number"
,
"default"
:
75
"default"
:
75
},
},
"blockProfectOffset"
:
{
"alias"
:
"方块素材组完美状态锚点"
,
"type"
:
"vector2"
,
"default"
:
"-100,35"
},
"blockBaseOffset"
:
{
"blockBaseOffset"
:
{
"alias"
:
"初始方块偏移"
,
"alias"
:
"初始方块偏移"
,
"type"
:
"number"
,
"type"
:
"number"
,
"default"
:
-
4
0
"default"
:
-
2
0
},
},
"blockShadowOffset"
:
{
"blockShadowOffset"
:
{
"alias"
:
"初始方块阴影偏移"
,
"alias"
:
"初始方块阴影偏移"
,
...
@@ -110,7 +100,7 @@
...
@@ -110,7 +100,7 @@
"blockHitHeight"
:
{
"blockHitHeight"
:
{
"alias"
:
"方块碰撞高度"
,
"alias"
:
"方块碰撞高度"
,
"type"
:
"number"
,
"type"
:
"number"
,
"default"
:
1
6
0
"default"
:
1
2
0
},
},
"blockPaddingTop"
:
{
"blockPaddingTop"
:
{
"alias"
:
"方块上边距"
,
"alias"
:
"方块上边距"
,
...
@@ -205,42 +195,42 @@
...
@@ -205,42 +195,42 @@
"playerReadyAnchor"
:
{
"playerReadyAnchor"
:
{
"alias"
:
"角色准备锚点"
,
"alias"
:
"角色准备锚点"
,
"type"
:
"vector2"
,
"type"
:
"vector2"
,
"default"
:
"
150,210
"
"default"
:
"
75,122
"
},
},
"playerReady2Anchor"
:
{
"playerReady2Anchor"
:
{
"alias"
:
"角色准备2锚点"
,
"alias"
:
"角色准备2锚点"
,
"type"
:
"vector2"
,
"type"
:
"vector2"
,
"default"
:
"
150,210
"
"default"
:
"
75,122
"
},
},
"playerJumpAnchor"
:
{
"playerJumpAnchor"
:
{
"alias"
:
"角色跳起锚点"
,
"alias"
:
"角色跳起锚点"
,
"type"
:
"vector2"
,
"type"
:
"vector2"
,
"default"
:
"
150,210
"
"default"
:
"
75,122
"
},
},
"playerFallAnchor"
:
{
"playerFallAnchor"
:
{
"alias"
:
"角色下落锚点"
,
"alias"
:
"角色下落锚点"
,
"type"
:
"vector2"
,
"type"
:
"vector2"
,
"default"
:
"
150,210
"
"default"
:
"
75,122
"
},
},
"playerHitAnchor"
:
{
"playerHitAnchor"
:
{
"alias"
:
"角色撞开锚点"
,
"alias"
:
"角色撞开锚点"
,
"type"
:
"vector2"
,
"type"
:
"vector2"
,
"default"
:
"
150,210
"
"default"
:
"
75,122
"
},
},
"playerParachuteAnchor"
:
{
"playerParachuteAnchor"
:
{
"alias"
:
"角色降落锚点"
,
"alias"
:
"角色降落锚点"
,
"type"
:
"vector2"
,
"type"
:
"vector2"
,
"default"
:
"1
50,210
"
"default"
:
"1
26,212
"
},
},
"playerLandNormalAnchor"
:
{
"playerLandNormalAnchor"
:
{
"alias"
:
"角色正常落地锚点"
,
"alias"
:
"角色正常落地锚点"
,
"type"
:
"vector2"
,
"type"
:
"vector2"
,
"default"
:
"
150,210
"
"default"
:
"
75,122
"
},
},
"playerLandPerfectAnchor"
:
{
"playerLandPerfectAnchor"
:
{
"alias"
:
"角色完美落地锚点"
,
"alias"
:
"角色完美落地锚点"
,
"type"
:
"vector2"
,
"type"
:
"vector2"
,
"default"
:
"
150,210
"
"default"
:
"
75,122
"
},
},
"playerLandEffectAnchor"
:
{
"playerLandEffectAnchor"
:
{
"alias"
:
"角色落地特效锚点"
,
"alias"
:
"角色落地特效锚点"
,
...
@@ -250,7 +240,7 @@
...
@@ -250,7 +240,7 @@
"playerLandSideAnchor"
:
{
"playerLandSideAnchor"
:
{
"alias"
:
"角色边缘落地锚点"
,
"alias"
:
"角色边缘落地锚点"
,
"type"
:
"vector2"
,
"type"
:
"vector2"
,
"default"
:
"
150,210
"
"default"
:
"
75,122
"
},
},
"playerLandPrefectAnchor"
:
{
"playerLandPrefectAnchor"
:
{
"alias"
:
"角色完美落地锚点"
,
"alias"
:
"角色完美落地锚点"
,
...
@@ -275,12 +265,6 @@
...
@@ -275,12 +265,6 @@
},
},
"assets"
:
[
"assets"
:
[
{
"name"
:
"完美方块素材"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/e2150383e8391a2972bc43fd888e4c1250e1933a.svga"
,
"uuid"
:
"7499df87-4155-406b-8c2b-fea972719f39"
,
"ext"
:
".svga"
},
{
{
"name"
:
"背景图"
,
"name"
:
"背景图"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/c90e6bc6718e4cc83d30bf2ce8b9f80a909adbee.jpg"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/c90e6bc6718e4cc83d30bf2ce8b9f80a909adbee.jpg"
,
...
@@ -363,9 +347,15 @@
...
@@ -363,9 +347,15 @@
{
{
"name"
:
"降落"
,
"name"
:
"降落"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/0c33a8285661684f24062af815a38befdbf36a06.svga"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/0c33a8285661684f24062af815a38befdbf36a06.svga"
,
"uuid"
:
"
82b514a9-69c4-425c-a77d-f34efeef1997
"
,
"uuid"
:
"
f234sf
"
,
"ext"
:
".svga"
"ext"
:
".svga"
},
},
{
"name"
:
"降落pic"
,
"url"
:
"////yun.duiba.com.cn/aurora/assets/e42a48c9b4a47dc180523bdeecd6b7305e088e27.png"
,
"uuid"
:
"9sf881289"
,
"ext"
:
".png"
},
{
{
"name"
:
"钱袋-静态"
,
"name"
:
"钱袋-静态"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/c5d04d5caf2dc812baeebdd34ea1abb17d183f44.png"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/c5d04d5caf2dc812baeebdd34ea1abb17d183f44.png"
,
...
...
src/custom/jump-high-3/src/game/Background.ts
View file @
86efa534
/**
/**
* Created by rockyl on 2020-01-21.
* Created by rockyl on 2020-01-21.
*/
*/
import
{
getTextureByName
}
from
"./utils"
;
import
{
getTextureByName
}
from
"./utils"
;
export
class
Background
extends
engine
.
Container
{
export
class
Background
extends
engine
.
Container
{
private
_bg
:
engine
.
Image
;
private
_bg
:
engine
.
Image
;
...
@@ -13,21 +13,21 @@ export class Background extends engine.Container {
...
@@ -13,21 +13,21 @@ export class Background extends engine.Container {
}
}
setup
()
{
setup
()
{
const
{
width
,
height
}
=
this
.
stage
;
const
{
width
,
height
}
=
this
.
stage
;
let
bg
=
this
.
_bg
=
new
engine
.
Image
(
getTextureByName
(
'背景图'
));
let
bg
=
this
.
_bg
=
new
engine
.
Image
(
getTextureByName
(
'背景图'
));
bg
.
anchorX
=
bg
.
width
/
2
;
//
bg.anchorX = bg.width / 2;
bg
.
anchorY
=
bg
.
height
/
2
;
//
bg.anchorY = bg.height / 2;
bg
.
x
=
-
(
bg
.
width
-
width
)
/
2
;
//
bg.x = -(bg.width - width) / 2;
bg
.
y
=
-
(
bg
.
height
-
height
)
/
2
;
//
bg.y = -(bg.height - height) / 2;
this
.
addChild
(
bg
);
this
.
addChild
(
bg
);
this
.
_minScale
=
width
/
bg
.
width
;
//
this._minScale = width / bg.width;
}
}
playZoom
(
type
:
'in'
|
'out'
,
duration
=
700
)
{
playZoom
(
type
:
'in'
|
'out'
,
duration
=
700
)
{
return
new
Promise
(
resolve
=>
{
return
new
Promise
(
resolve
=>
{
let
scale
=
type
===
'in'
?
1
:
this
.
_minScale
;
let
scale
=
type
===
'in'
?
1
:
this
.
_minScale
;
engine
.
Tween
.
get
(
this
.
_bg
,
null
,
null
,
true
)
engine
.
Tween
.
get
(
this
.
_bg
,
null
,
null
,
true
)
.
to
({
scaleX
:
scale
,
scaleY
:
scale
},
duration
,
engine
.
Ease
.
cubicInOut
)
.
to
({
scaleX
:
scale
,
scaleY
:
scale
},
duration
,
engine
.
Ease
.
cubicInOut
)
.
call
(
resolve
);
.
call
(
resolve
);
})
})
}
}
...
...
src/custom/jump-high-3/src/game/Block.ts
View file @
86efa534
...
@@ -3,65 +3,38 @@
...
@@ -3,65 +3,38 @@
* 障碍块
* 障碍块
*/
*/
import
{
getBlockAsset
,
getBlockHitAsset
,
getTextureByName
}
from
"./utils"
;
import
{
getBlockAsset
,
getTextureByName
}
from
"./utils"
;
import
{
props
}
from
"../props"
;
import
{
props
}
from
"../props"
;
export
default
class
Block
extends
engine
.
Container
{
export
default
class
Block
extends
engine
.
Container
{
private
body
:
svga
.
Svga
;
private
body
:
svga
.
Svga
;
private
bodyHit
:
svga
.
Svga
;
private
bodyProfect
:
svga
.
Svga
;
type
;
type
;
dir
;
dir
;
constructor
()
{
constructor
()
{
super
();
super
();
let
body
=
this
.
body
=
new
svga
.
Svga
();
let
body
=
this
.
body
=
new
svga
.
Svga
();
body
.
x
=
-
props
.
blockWidth
/
2
;
body
.
x
=
-
props
.
blockWidth
/
2
;
body
.
y
=
-
props
.
blockHitHeight
-
props
.
blockPaddingTop
;
body
.
y
=
-
props
.
blockHitHeight
-
props
.
blockPaddingTop
;
this
.
addChild
(
body
);
this
.
addChild
(
body
);
let
bodyHit
=
this
.
bodyHit
=
new
svga
.
Svga
();
bodyHit
.
x
=
-
props
.
blockWidth
/
2
;
bodyHit
.
y
=
-
props
.
blockHitHeight
-
props
.
blockPaddingTop
+
props
.
blockHitOffsetY
;
this
.
addChild
(
bodyHit
);
console
.
log
(
"props.blockProfectOffset"
,
props
.
blockProfectOffset
)
let
bodyProfect
=
this
.
bodyProfect
=
new
svga
.
Svga
();
bodyProfect
.
x
=
-
props
.
blockWidth
/
2
+
props
.
blockProfectOffset
.
x
;
bodyProfect
.
y
=
-
props
.
blockHitHeight
-
props
.
blockPaddingTop
+
props
.
blockProfectOffset
.
y
;
this
.
addChild
(
bodyProfect
);
}
}
reset
({
type
,
})
{
reset
({
type
,
})
{
this
.
dir
=
Math
.
random
()
>
0.5
?
1
:
-
1
;
this
.
dir
=
Math
.
random
()
>
0.5
?
1
:
-
1
;
if
(
this
.
type
!=
type
)
{
this
.
type
=
type
;
this
.
type
=
type
;
let
asset
=
getBlockAsset
(
type
);
let
asset
=
getBlockAsset
(
);
this
.
body
.
source
=
'asset://'
+
asset
.
uuid
;
this
.
body
.
source
=
'asset://'
+
asset
.
uuid
;
let
assetHit
=
getBlockHitAsset
(
type
);
console
.
log
(
"assetHit"
,
assetHit
)
this
.
bodyHit
.
source
=
'asset://'
+
assetHit
.
uuid
;
}
this
.
bodyProfect
.
source
=
'asset://'
+
engine
.
getAssetByName
(
"完美方块素材"
).
uuid
;
this
.
scaleX
=
this
.
dir
;
this
.
scaleX
=
this
.
dir
;
this
.
body
.
gotoAndStop
(
1
);
this
.
body
.
gotoAndStop
(
1
);
this
.
bodyHit
.
gotoAndStop
(
1
);
this
.
bodyProfect
.
gotoAndStop
(
1
);
this
.
body
.
visible
=
true
;
this
.
bodyHit
.
visible
=
false
;
this
.
body
.
visible
=
true
;
}
}
playEnter
(
index
,
animation
)
{
playEnter
(
index
,
animation
)
{
...
@@ -73,12 +46,12 @@ export default class Block extends engine.Container {
...
@@ -73,12 +46,12 @@ export default class Block extends engine.Container {
return
new
Promise
(
resolve
=>
{
return
new
Promise
(
resolve
=>
{
if
(
animation
)
{
if
(
animation
)
{
engine
.
Tween
.
get
(
this
,
null
,
null
,
true
)
engine
.
Tween
.
get
(
this
,
null
,
null
,
true
)
.
to
({
x
:
0
,
},
duration
)
.
to
({
x
:
0
,
},
duration
)
.
call
(
resolve
);
.
call
(
resolve
);
}
else
{
}
else
{
this
.
x
=
0
;
this
.
x
=
0
;
setTimeout
(()
=>
{
setTimeout
(()
=>
{
console
.
log
(
this
.
body
);
//
console.log(this.body);
},
200
);
},
200
);
resolve
();
resolve
();
}
}
...
@@ -97,25 +70,6 @@ export default class Block extends engine.Container {
...
@@ -97,25 +70,6 @@ export default class Block extends engine.Container {
},
this
);
},
this
);
}
}
playHit
()
{
let
bodyHit
=
this
.
bodyHit
;
bodyHit
.
play
(
true
,
false
);
this
.
body
.
visible
=
false
;
this
.
bodyHit
.
visible
=
true
;
bodyHit
.
once
(
engine
.
Event
.
END_FRAME
,
function
()
{
this
.
body
.
visible
=
true
;
this
.
bodyHit
.
visible
=
false
;
bodyHit
.
gotoAndStop
(
1
);
},
this
);
}
playProFect
()
{
let
bodyProfect
=
this
.
bodyProfect
;
bodyProfect
.
play
(
true
,
false
);
bodyProfect
.
once
(
engine
.
Event
.
END_FRAME
,
function
()
{
bodyProfect
.
gotoAndStop
(
1
);
},
this
);
}
stop
()
{
stop
()
{
engine
.
Tween
.
removeTweens
(
this
);
engine
.
Tween
.
removeTweens
(
this
);
...
...
src/custom/jump-high-3/src/game/GameView.ts
View file @
86efa534
...
@@ -64,6 +64,7 @@ export default class GameView extends engine.Container {
...
@@ -64,6 +64,7 @@ export default class GameView extends engine.Container {
const
{
width
,
height
}
=
this
.
stage
;
const
{
width
,
height
}
=
this
.
stage
;
const
background
=
this
.
background
=
new
Background
();
const
background
=
this
.
background
=
new
Background
();
background
.
y
=
height
-
1624
;
this
.
addChild
(
background
);
this
.
addChild
(
background
);
background
.
setup
();
background
.
setup
();
...
@@ -74,22 +75,19 @@ export default class GameView extends engine.Container {
...
@@ -74,22 +75,19 @@ export default class GameView extends engine.Container {
const
guideLayer
=
this
.
guideLayer
=
new
GuideLayer
();
const
guideLayer
=
this
.
guideLayer
=
new
GuideLayer
();
this
.
addChild
(
guideLayer
);
this
.
addChild
(
guideLayer
);
const
base
=
this
.
base
=
new
Base
();
frontContainer
.
addChild
(
base
);
base
.
setup
();
const
blockContainer
=
this
.
blockContainer
=
new
engine
.
Container
();
const
blockContainer
=
this
.
blockContainer
=
new
engine
.
Container
();
frontContainer
.
addChild
(
blockContainer
);
frontContainer
.
addChild
(
blockContainer
);
const
base
=
this
.
base
=
new
Base
();
frontContainer
.
addChild
(
base
);
base
.
setup
();
const
player
=
this
.
player
=
new
Player
();
const
player
=
this
.
player
=
new
Player
();
frontContainer
.
addChild
(
player
);
frontContainer
.
addChildAt
(
player
,
0
);
player
.
setup
();
player
.
setup
();
player
.
addEventListener
(
'jump-on-top'
,
this
.
onPlayerJumpOnTop
,
this
);
player
.
addEventListener
(
'jump-on-top'
,
this
.
onPlayerJumpOnTop
,
this
);
let
scoreAddTipsContainer
=
this
.
scoreAddTipsContainer
=
new
engine
.
Container
();
let
scoreAddTipsContainer
=
this
.
scoreAddTipsContainer
=
new
engine
.
Container
();
scoreAddTipsContainer
.
width
=
750
;
scoreAddTipsContainer
.
width
=
750
;
scoreAddTipsContainer
.
anchorX
=
scoreAddTipsContainer
.
width
/
2
;
scoreAddTipsContainer
.
anchorX
=
scoreAddTipsContainer
.
width
/
2
;
...
@@ -106,9 +104,7 @@ export default class GameView extends engine.Container {
...
@@ -106,9 +104,7 @@ export default class GameView extends engine.Container {
scoreAddTips
.
x
=
this
.
player
.
x
-
scoreAddTips
.
width
/
2
;
scoreAddTips
.
x
=
this
.
player
.
x
-
scoreAddTips
.
width
/
2
;
scoreAddTipsContainer
.
addChild
(
scoreAddTips
);
scoreAddTipsContainer
.
addChild
(
scoreAddTips
);
frontContainer
.
addChildAt
(
player
,
0
);
frontContainer
.
addChild
(
player
);
frontContainer
.
addChild
(
scoreAddTipsContainer
);
frontContainer
.
addChild
(
scoreAddTipsContainer
);
...
@@ -230,8 +226,6 @@ export default class GameView extends engine.Container {
...
@@ -230,8 +226,6 @@ export default class GameView extends engine.Container {
addBlock
(
animation
=
true
)
{
addBlock
(
animation
=
true
)
{
this
.
index
++
;
this
.
index
++
;
const
blockContainer
=
this
.
blockContainer
;
const
blockContainer
=
this
.
blockContainer
;
let
block
:
Block
;
let
block
:
Block
;
...
@@ -247,7 +241,8 @@ export default class GameView extends engine.Container {
...
@@ -247,7 +241,8 @@ export default class GameView extends engine.Container {
block
.
reset
({
block
.
reset
({
type
:
Math
.
floor
(
Math
.
random
()
*
props
.
blockAssets
.
length
),
type
:
Math
.
floor
(
Math
.
random
()
*
props
.
blockAssets
.
length
),
});
});
block
.
y
=
this
.
baseOffset
-
this
.
index
*
props
.
blockHitHeight
+
props
.
blockBaseOffset
;
console
.
log
(
'addblock'
,
this
.
index
)
block
.
y
=
this
.
baseOffset
-
(
this
.
index
*
props
.
blockHitHeight
)
+
props
.
blockBaseOffset
;
this
.
blockComplete
=
false
;
this
.
blockComplete
=
false
;
block
.
playEnter
(
this
.
index
,
animation
).
then
(
block
.
playEnter
(
this
.
index
,
animation
).
then
(
...
@@ -349,11 +344,10 @@ export default class GameView extends engine.Container {
...
@@ -349,11 +344,10 @@ export default class GameView extends engine.Container {
this
.
needHitTest
=
false
;
this
.
needHitTest
=
false
;
clearInterval
(
this
.
timer
);
clearInterval
(
this
.
timer
);
this
.
currentBlock
.
playHit
();
// this.currentBlock.stop();
// this.playHitEffect(dir);
await
this
.
player
.
hitAway
(
dir
);
await
this
.
player
.
hitAway
(
dir
);
// this.playZoom('out');
this
.
frontContainer
.
addChild
(
this
.
player
);
await
this
.
player
.
parachute
(
dir
);
await
this
.
player
.
parachute
(
dir
);
console
.
log
(
'jump-high-game-end'
)
console
.
log
(
'jump-high-game-end'
)
...
@@ -382,12 +376,10 @@ export default class GameView extends engine.Container {
...
@@ -382,12 +376,10 @@ export default class GameView extends engine.Container {
}
}
}
}
if
(
type
<
3
)
{
if
(
type
<
3
)
{
this
.
currentBlock
.
playEffect
();
//
this.currentBlock.playEffect();
}
}
this
.
currentBlock
.
playEffect
();
if
(
type
===
0
){
this
.
currentBlock
.
playProFect
();
}
if
(
type
!=
3
){
if
(
type
!=
3
){
}
}
...
@@ -395,7 +387,6 @@ export default class GameView extends engine.Container {
...
@@ -395,7 +387,6 @@ export default class GameView extends engine.Container {
this
.
player
.
playLand
(
type
,
this
.
currentBlock
.
dir
);
this
.
player
.
playLand
(
type
,
this
.
currentBlock
.
dir
);
this
.
currentBlock
.
stop
();
this
.
currentBlock
.
stop
();
this
.
scoreChange
(
type
);
this
.
scoreChange
(
type
);
await
this
.
playShake
();
await
new
Promise
(
resolve
=>
{
await
new
Promise
(
resolve
=>
{
engine
.
Tween
.
get
(
this
,
null
,
null
,
true
)
engine
.
Tween
.
get
(
this
,
null
,
null
,
true
)
.
to
({
pos
:
props
.
blockHitHeight
*
this
.
index
},
300
,
engine
.
Ease
.
cubicOut
)
.
to
({
pos
:
props
.
blockHitHeight
*
this
.
index
},
300
,
engine
.
Ease
.
cubicOut
)
...
@@ -454,19 +445,4 @@ export default class GameView extends engine.Container {
...
@@ -454,19 +445,4 @@ export default class GameView extends engine.Container {
.
call
(
resolve
);
.
call
(
resolve
);
})
})
}
}
playShake
(){
const
{
x
,
y
}
=
this
.
frontContainer
;
return
new
Promise
(
resolve
=>
{
const
shakeOffset
=
7
;
const
duration
=
30
;
engine
.
Tween
.
get
(
this
.
frontContainer
,
null
,
null
,
true
)
.
to
({
x
:
x
,
y
:
y
-
shakeOffset
},
duration
)
.
to
({
x
:
x
,
y
:
y
+
shakeOffset
},
duration
)
.
to
({
x
:
x
+
shakeOffset
,
y
:
y
},
duration
)
.
to
({
x
:
x
-
shakeOffset
,
y
:
y
},
duration
)
.
to
({
x
:
x
,
y
:
y
},
duration
)
.
call
(
resolve
)
})
}
}
}
src/custom/jump-high-3/src/game/Player.ts
View file @
86efa534
...
@@ -2,19 +2,20 @@
...
@@ -2,19 +2,20 @@
* Created by rockyl on 2018/8/17.
* Created by rockyl on 2018/8/17.
*/
*/
import
{
props
}
from
"../props"
;
import
{
props
}
from
"../props"
;
import
{
createSvga
,
playSound
,
getTextureByName
}
from
"./utils"
;
import
{
createSvga
,
playSound
,
getTextureByName
}
from
"./utils"
;
const
svgaAssets
=
{
const
svgaAssets
=
{
aniReady
:
{
name
:
'准备立正'
,
dir
:
1
},
aniReady
:
{
name
:
'准备立正'
,
dir
:
1
},
aniReady2
:
{
name
:
'准备立正'
,
dir
:
1
},
aniReady2
:
{
name
:
'准备立正'
,
dir
:
1
},
aniJump
:
{
name
:
'跳上升'
,
dir
:
1
},
aniJump
:
{
name
:
'跳上升'
,
dir
:
1
},
aniFall
:
{
name
:
'跳下落'
,
dir
:
1
},
aniFall
:
{
name
:
'跳下落'
,
dir
:
1
},
aniLandNormal
:
{
name
:
'普通着地'
,
dir
:
1
},
aniLandNormal
:
{
name
:
'普通着地'
,
dir
:
1
},
aniLandSide
:
{
name
:
'边缘着地'
,
dir
:
-
1
},
aniLandSide
:
{
name
:
'边缘着地'
,
dir
:
-
1
},
aniHit
:
{
name
:
'被撞开'
,
dir
:
-
1
},
aniHit
:
{
name
:
'被撞开'
,
dir
:
-
1
},
aniParachute
:
{
name
:
'降落'
,
dir
:
-
1
},
// aniParachute: {name: '降落', dir: -1},
aniLandPerfect
:
{
name
:
'完美着地_笑'
,
dir
:
1
},
aniParachute
:
{
name
:
'降落pic'
,
dir
:
-
1
,
type
:
'pic'
},
aniLandPerfect
:
{
name
:
'完美着地_笑'
,
dir
:
1
},
};
};
export
default
class
Player
extends
engine
.
Container
{
export
default
class
Player
extends
engine
.
Container
{
...
@@ -58,9 +59,10 @@ export default class Player extends engine.Container {
...
@@ -58,9 +59,10 @@ export default class Player extends engine.Container {
}
}
let
ani
:
svga
.
Svga
=
this
.
_currentAni
=
this
[
'ani'
+
name
];
let
ani
:
svga
.
Svga
=
this
.
_currentAni
=
this
[
'ani'
+
name
];
this
.
addChild
(
ani
);
this
.
addChild
(
ani
);
ani
.
y
=
-
300
;
if
(
play
)
{
if
(
play
)
{
ani
.
play
(
false
,
loop
);
ani
.
play
&&
ani
.
play
(
false
,
loop
);
if
(
loop
)
{
if
(
loop
)
{
resolve
();
resolve
();
}
else
{
}
else
{
...
@@ -79,8 +81,18 @@ export default class Player extends engine.Container {
...
@@ -79,8 +81,18 @@ export default class Player extends engine.Container {
this
.
landEffect
=
createSvga
(
'着地特效'
,
'playerLandEffectAnchor'
);
this
.
landEffect
=
createSvga
(
'着地特效'
,
'playerLandEffectAnchor'
);
for
(
let
key
in
svgaAssets
)
{
for
(
let
key
in
svgaAssets
)
{
let
{
name
,
dir
}
=
svgaAssets
[
key
];
let
body
let
body
=
this
[
key
]
=
createSvga
(
name
,
key
.
replace
(
'ani'
,
'player'
)
+
'Anchor'
);
let
{
name
,
dir
,
type
}
=
svgaAssets
[
key
];
if
(
type
==
'pic'
)
{
body
=
this
[
key
]
=
new
engine
.
Image
(
getTextureByName
(
'降落pic'
));
let
anchor
=
{
x
:
75
,
y
:
122
};
body
.
x
=
-
anchor
.
x
;
body
.
y
=
-
anchor
.
y
;
body
.
anchorX
=
anchor
.
x
;
body
.
anchorY
=
anchor
.
y
;
}
else
{
body
=
this
[
key
]
=
createSvga
(
name
,
key
.
replace
(
'ani'
,
'player'
)
+
'Anchor'
);
}
body
.
name
=
'body'
;
body
.
name
=
'body'
;
body
.
scaleX
=
dir
;
body
.
scaleX
=
dir
;
...
@@ -94,7 +106,7 @@ export default class Player extends engine.Container {
...
@@ -94,7 +106,7 @@ export default class Player extends engine.Container {
this
.
_prefectLandCounting
=
0
;
this
.
_prefectLandCounting
=
0
;
engine
.
Tween
.
removeTweens
(
this
);
engine
.
Tween
.
removeTweens
(
this
);
if
(
revive
)
{
if
(
revive
)
{
this
.
switchAni
(
'Jump'
,
1
,
false
);
this
.
switchAni
(
'Jump'
,
1
,
false
);
}
}
}
}
...
@@ -103,7 +115,7 @@ export default class Player extends engine.Container {
...
@@ -103,7 +115,7 @@ export default class Player extends engine.Container {
return
new
Promise
(
resolve
=>
{
return
new
Promise
(
resolve
=>
{
this
.
switchAni
(
'Ready'
,
1
);
this
.
switchAni
(
'Ready'
,
1
);
this
.
_currentAni
.
once
(
engine
.
Event
.
END_FRAME
,
function
()
{
this
.
_currentAni
.
once
(
engine
.
Event
.
END_FRAME
,
function
()
{
this
.
switchAni
(
'Ready2'
,
1
,
true
,
true
);
this
.
switchAni
(
'Ready2'
,
1
,
true
,
true
);
resolve
();
resolve
();
},
this
);
},
this
);
})
})
...
@@ -179,13 +191,13 @@ export default class Player extends engine.Container {
...
@@ -179,13 +191,13 @@ export default class Player extends engine.Container {
this
.
removeChild
(
landEffect
);
this
.
removeChild
(
landEffect
);
},
this
);
},
this
);
await
this
.
switchAni
(
'LandPerfect'
);
await
this
.
switchAni
(
'LandPerfect'
);
await
this
.
switchAni
(
'Ready2'
,
1
,
true
,
true
);
await
this
.
switchAni
(
'Ready2'
,
1
,
true
,
true
);
break
;
break
;
case
1
:
case
1
:
case
2
:
case
2
:
this
.
_prefectLandCounting
=
0
;
this
.
_prefectLandCounting
=
0
;
playSound
(
'普通落地音效'
);
playSound
(
'普通落地音效'
);
this
.
switchAni
(
'Ready2'
,
1
,
true
,
true
);
this
.
switchAni
(
'Ready2'
,
1
,
true
,
true
);
break
;
break
;
case
3
:
case
3
:
this
.
_prefectLandCounting
=
0
;
this
.
_prefectLandCounting
=
0
;
...
@@ -226,8 +238,8 @@ export default class Player extends engine.Container {
...
@@ -226,8 +238,8 @@ export default class Player extends engine.Container {
playSound
(
'降落伞下落音效'
);
playSound
(
'降落伞下落音效'
);
})
})
// .wait(300)
// .wait(300)
.
to
({
y
:
this
.
y
+
props
.
parachuteDistance
},
props
.
parachuteDuration
)
.
to
({
y
:
this
.
y
+
props
.
parachuteDistance
},
props
.
parachuteDuration
)
.
set
({
anchorOffsetY
:
0
})
.
set
({
anchorOffsetY
:
0
})
.
call
(
resolve
)
.
call
(
resolve
)
});
});
}
}
...
...
src/custom/jump-high-3/src/game/utils.ts
View file @
86efa534
...
@@ -11,14 +11,10 @@ export function getTextureByName(name) {
...
@@ -11,14 +11,10 @@ export function getTextureByName(name) {
return
getTexture
(
engine
.
getAssetByName
(
name
).
uuid
);
return
getTexture
(
engine
.
getAssetByName
(
name
).
uuid
);
}
}
export
function
getBlockAsset
(
type
)
{
export
function
getBlockAsset
()
{
return
engine
.
getAssetByName
(
props
.
blockAssets
[
type
]);
return
engine
.
getAssetByName
(
props
.
blockAssets
[
0
]);
}
}
export
function
getBlockHitAsset
(
type
)
{
console
.
log
(
"props.blockHitAssets"
,
props
.
blockHitAssets
)
return
engine
.
getAssetByName
(
props
.
blockHitAssets
[
type
]);
}
export
function
createSvga
(
name
,
anchorName
)
{
export
function
createSvga
(
name
,
anchorName
)
{
let
inst
=
new
svga
.
Svga
();
let
inst
=
new
svga
.
Svga
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment