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
eccf6925
Commit
eccf6925
authored
Dec 03, 2020
by
wildfirecode13
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
1399ae5c
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
1023 additions
and
82 deletions
+1023
-82
.DS_Store
dist/.DS_Store
+0
-0
jump-high-3.json
dist/customs/jump-high-3.json
+2
-2
main.js
src/custom/jump-high-3/debug/main.js
+1013
-1
main.js.map
src/custom/jump-high-3/debug/main.js.map
+1
-1
meta.json
src/custom/jump-high-3/meta.json
+1
-1
GameView.ts
src/custom/jump-high-3/src/game/GameView.ts
+6
-18
JumpTips.ts
src/custom/jump-high-3/src/game/JumpTips.ts
+0
-59
No files found.
dist/.DS_Store
View file @
eccf6925
No preview for this file type
dist/customs/jump-high-3.json
View file @
eccf6925
...
...
@@ -135,7 +135,7 @@
"baseOffset"
:
{
"alias"
:
"底座偏移"
,
"type"
:
"number"
,
"default"
:
500
"default"
:
262
},
"playerOffset"
:
{
"alias"
:
"角色偏移"
,
...
...
@@ -493,5 +493,5 @@
}
},
"id"
:
"jump-high-3"
,
"code"
:
"
\"
use strict
\"
;var tslib=require(
\"
tslib
\"
),props={};function prepareProps(){var e=getProps();engine.injectProp(props,e)}function injectProps(e){engine.injectProp(props,e)}function getTexture(e){return engine.Texture.from(getAssetByUUID(e).uuid)}function getTextureByName(e){return getTexture(engine.getAssetByName(e).uuid)}function getBlockAsset(e){return engine.getAssetByName(props.blockAssets[e])}function getBlockHitAsset(e){return console.log(
\"
props.blockHitAssets
\"
,props.blockHitAssets),engine.getAssetByName(props.blockHitAssets[e])}function createSvga(e,t){var i=new svga.Svga;i.source=
\"
asset://
\"
+engine.getAssetByName(e).uuid;var n=props[t];return n&&(i.x=-n.x,i.y=-n.y,i.anchorX=n.x,i.anchorY=n.y),i}function playSound(e){engine.playSound(engine.getAssetByName(e).uuid,{keep:!0})}var Block=function(o){function e(){var e=o.call(this)||this,t=e.body=new svga.Svga;t.x=-props.blockWidth/2,t.y=-props.blockHitHeight-props.blockPaddingTop,e.addChild(t);var i=e.bodyHit=new svga.Svga;i.x=-props.blockWidth/2,i.y=-props.blockHitHeight-props.blockPaddingTop+props.blockHitOffsetY,e.addChild(i),console.log(
\"
props.blockProfectOffset
\"
,props.blockProfectOffset);var n=e.bodyProfect=new svga.Svga;return n.x=-props.blockWidth/2+props.blockProfectOffset.x,n.y=-props.blockHitHeight-props.blockPaddingTop+props.blockProfectOffset.y,e.addChild(n),e}return tslib.__extends(e,o),e.prototype.reset=function(e){var t,i,n=e.type;this.dir=.5<Math.random()?1:-1,this.type!=n&&(t=getBlockAsset(this.type=n),this.body.source=
\"
asset://
\"
+t.uuid,i=getBlockHitAsset(n),console.log(
\"
assetHit
\"
,i),this.bodyHit.source=
\"
asset://
\"
+i.uuid),this.bodyProfect.source=
\"
asset://
\"
+engine.getAssetByName(
\"
完美方块素材
\"
).uuid,this.scaleX=this.dir,this.body.gotoAndStop(1),this.bodyHit.gotoAndStop(1),this.bodyProfect.gotoAndStop(1),this.body.visible=!0,this.bodyHit.visible=!1},e.prototype.playEnter=function(e,t){var i=this;this.visible=!0,this.x=this.dir*this.stage.width;var n=props.blockDurationRange,o=n[0],s=n[1],r=Math.max(s-e*props.blockDurationStep,o);return r+=s*Math.random()*props.blockDurationRandom*(.5<Math.random()?1:-1),new Promise(function(e){t?engine.Tween.get(i,null,null,!0).to({x:0},r).call(e):(i.x=0,setTimeout(function(){console.log(i.body)},200),e())})},e.prototype.playLeave=function(){this.visible=!1},e.prototype.playEffect=function(){var e=this.body;e.play(!0,!1),e.once(engine.Event.END_FRAME,function(){e.gotoAndStop(1)},this)},e.prototype.playHit=function(){var e=this.bodyHit;e.play(!0,!1),this.body.visible=!1,this.bodyHit.visible=!0,e.once(engine.Event.END_FRAME,function(){this.body.visible=!0,this.bodyHit.visible=!1,e.gotoAndStop(1)},this)},e.prototype.playProFect=function(){var e=this.bodyProfect;e.play(!0,!1),e.once(engine.Event.END_FRAME,function(){e.gotoAndStop(1)},this)},e.prototype.stop=function(){engine.Tween.removeTweens(this)},e}(engine.Container),Background=function(e){function t(){return e.call(this)||this}return tslib.__extends(t,e),t.prototype.setup=function(){var e=this.stage,t=e.width,i=e.height,n=this._bg=new engine.Image(getTextureByName(
\"
背景图
\"
));n.anchorX=n.width/2,n.anchorY=n.height/2,n.x=-(n.width-t)/2,n.y=-(n.height-i)/2,this.addChild(n),this._minScale=t/n.width},t.prototype.playZoom=function(i,n){var o=this;return void 0===n&&(n=700),new Promise(function(e){var t=
\"
in
\"
===i?1:o._minScale;engine.Tween.get(o._bg,null,null,!0).to({scaleX:t,scaleY:t},n,engine.Ease.cubicInOut).call(e)})},t}(engine.Container),svgaAssets={aniReady:{name:
\"
准备立正
\"
,dir:1},aniReady2:{name:
\"
准备立正
\"
,dir:1},aniJump:{name:
\"
跳上升
\"
,dir:1},aniFall:{name:
\"
跳下落
\"
,dir:1},aniLandNormal:{name:
\"
普通着地
\"
,dir:1},aniLandSide:{name:
\"
边缘着地
\"
,dir:-1},aniHit:{name:
\"
被撞开
\"
,dir:-1},aniParachute:{name:
\"
降落
\"
,dir:-1},aniLandPerfect:{name:
\"
完美着地_笑
\"
,dir:1}},Player=function(t){function e(){var e=t.call(this)||this;return e.g=props.gravity,e.addEventListener(engine.Event.ENTER_FRAME,e.onEnterFrame,e),e}return tslib.__extends(e,t),e.prototype.switchAni=function(n,o,s,r){var a=this;return void 0===o&&(o=1),void 0===s&&(s=!0),void 0===r&&(r=!1),new Promise(function(e){var t,i;a.scaleX=o,a._aniName!==n&&(a._aniName=n,(t=a.removeChild(a.getChildByName(
\"
body
\"
)))&&t.stop(),i=a._currentAni=a[
\"
ani
\"
+n],a.addChild(i),s?(i.play(!1,r),r?e():i.once(engine.Event.END_FRAME,e)):e())})},e.prototype.setup=function(){for(var e in this.prefectEffect=createSvga(
\"
完美着地特效
\"
,
\"
playerLandPrefectAnchor
\"
),this.landEffect=createSvga(
\"
着地特效
\"
,
\"
playerLandEffectAnchor
\"
),svgaAssets){var t=svgaAssets[e],i=t.name,n=t.dir,o=this[e]=createSvga(i,e.replace(
\"
ani
\"
,
\"
player
\"
)+
\"
Anchor
\"
);o.name=
\"
body
\"
,o.scaleX=n}},e.prototype.reset=function(e){this.x=0,this.rotation=0,this.scaleX=this.scaleY=1,this._prefectLandCounting=0,engine.Tween.removeTweens(this),e&&this.switchAni(
\"
Jump
\"
,1,!1)},e.prototype.playReady=function(){var t=this;return new Promise(function(e){t.switchAni(
\"
Ready
\"
,1),t._currentAni.once(engine.Event.END_FRAME,function(){this.switchAni(
\"
Ready2
\"
,1,!0,!0),e()},t)})},e.prototype.onEnterFrame=function(e){this.playing&&(this.vy+=this.g,this.y+=this.vy,0<this.vy&&
\"
Fall
\"
!==this._aniName&&(this.dispatchEvent(
\"
jump-on-top
\"
),this.switchAni(
\"
Fall
\"
)),this.y>this.baseY&&(this.y=this.baseY,this.playing=!1,this.jumpPromise&&this.jumpPromise({aboveBlock:this.aboveBlock}),this.jumpPromise=null))},e.prototype.changeBaseY=function(e){this.baseY!=e&&(this.aboveBlock=!0,this.baseY=e)},e.prototype.jump=function(){var t=this;return playSound(
\"
跳起音效
\"
),this.switchAni(
\"
Jump
\"
,1,!1),this._currentAni.play(!1,!1),this.aboveBlock=!1,this.playing=!0,this.baseY=this.y,this.vy=-props.jumpSpeed,new Promise(function(e){t.jumpPromise=e})},e.prototype.playLand=function(n,o){return tslib.__awaiter(this,void 0,void 0,function(){var t,i;return tslib.__generator(this,function(e){switch(e.label){case 0:switch(n){case 0:return[3,1];case 1:case 2:return[3,4];case 3:return[3,5]}return[3,6];case 1:return this._prefectLandCounting++,playSound(
\"
完美落地音效
\"
+Math.min(4,this._prefectLandCounting)),t=this.prefectEffect,this.addChildAt(t,0),t.gotoAndPlay(1),t.once(engine.Event.END_FRAME,function(){this.removeChild(t)},this),i=this.landEffect,this.addChildAt(i,0),i.gotoAndPlay(1),i.once(engine.Event.END_FRAME,function(){this.removeChild(i)},this),[4,this.switchAni(
\"
LandPerfect
\"
)];case 2:return e.sent(),[4,this.switchAni(
\"
Ready2
\"
,1,!0,!0)];case 3:return e.sent(),[3,6];case 4:return this._prefectLandCounting=0,playSound(
\"
普通落地音效
\"
),this.switchAni(
\"
Ready2
\"
,1,!0,!0),[3,6];case 5:return this._prefectLandCounting=0,playSound(
\"
边缘落地音效
\"
),this.switchAni(
\"
LandSide
\"
,o),[3,6];case 6:return[2]}})})},e.prototype.hitAway=function(i){return tslib.__awaiter(this,void 0,void 0,function(){var t=this;return tslib.__generator(this,function(e){switch(e.label){case 0:return this.jumpPromise&&this.jumpPromise(),this.jumpPromise=null,playSound(
\"
被撞开音效
\"
),this.switchAni(
\"
Hit
\"
,i),this.vy=0,[4,new Promise(function(e){engine.Tween.get(t).to({x:-i*props.hitAwayDistance.x},props.hitAwayDuration,engine.Ease.quartOut),engine.Tween.get(t).to({y:t.y+props.hitAwayDistance.y},props.hitAwayDuration,engine.Ease.cubicOut).call(e)})];case 1:return e.sent(),[2]}})})},e.prototype.parachute=function(e){var t=this;return this.switchAni(
\"
Parachute
\"
,e),new Promise(function(e){engine.Tween.get(t).call(function(){playSound(
\"
降落伞下落音效
\"
)}).to({y:t.y+props.parachuteDistance},props.parachuteDuration).set({anchorOffsetY:0}).call(e)})},e}(engine.Container),Base=function(e){function t(){return e.call(this,getTextureByName(
\"
底座
\"
))||this}return tslib.__extends(t,e),t.prototype.setup=function(){this.x=-this.width/2},t.prototype.reset=function(){this.y=-props.baseOffset},t}(engine.Image),GuideLayer=function(t){function e(){var e=t.call(this)||this;return e.setup(),e}return tslib.__extends(e,t),e.prototype.setup=function(){},e.prototype.show=function(e,a){var h=this;return new Promise(function(e){var t,i,n,o,s,r;h.visible=!0,h.guideMask||(i=(t=h.stage).width,n=t.height,o=h.guideMask=new engine.Container,(s=new engine.Image(getTextureByName(
\"
引导遮罩
\"
))).x=(i-s.width)/2,s.y=a.y,o.addChild(s),h.createRect(o,0,0,i,s.y),h.createRect(o,0,s.y,s.x,s.height),h.createRect(o,s.x+s.width,s.y,i-s.x-s.width,s.height),h.createRect(o,0,s.y+s.height,i,n-s.y-s.height),(r=h.label=new engine.Label).fillColor=
\"
white
\"
,r.size=25,r.text=props.guideText,r.x=(i-r.width)/2,r.y=s.y+s.height+50,o.addChild(r),h.addChild(o)),h.once(engine.MouseEvent.CLICK,function(){this.visible=!1,e()},h)})},e.prototype.createRect=function(e,t,i,n,o){var s=new engine.Rect;s.x=t,s.y=i,s.width=n,s.height=o,s.fillColor=
\"
black
\"
,s.alpha=.7,e.addChild(s)},e}(engine.Container),GoldBag=function(t){function e(){var e=t.call(this)||this;return e.setup(),e}return tslib.__extends(e,t),e.prototype.setup=function(){var e=this.avatar=new engine.Sprite(getTextureByName(
\"
钱袋-静态
\"
));e.x=-props.goldPackAvatarAnchor.x,e.y=-props.goldPackAvatarAnchor.y,this.addChild(e);var t=this.svga=createSvga(
\"
钱袋
\"
,
\"
goldPackAnchor
\"
);t.visible=!1,this.addChild(t)},e.prototype.reset=function(e){this.y=e.y,this.avatar.visible=!0,this.svga.visible=!1,this.svga.gotoAndStop(1),this.remain=e.remain},e.prototype.playOpen=function(){var t=this;return this.avatar.visible=!1,this.svga.visible=!0,new Promise(function(e){t.svga.play(!0,!1),t.svga.once(engine.Event.END_FRAME,function(){this.svga.visible=!1,e()},t)})},e}(engine.Container),JumpTips=function(e){function t(){return e.call(this)||this}return tslib.__extends(t,e),t.prototype.setup=function(){this.width=124,this.height=93;var e=this._bg=new engine.Image(getTextureByName(
\"
跳跃提示背景
\"
));e.width=this.width,e.height=this.height,e.anchorX=e.width/2,e.anchorY=e.height/2,this.addChild(e);var t=this._jumpTipsLabel=new engine.Label;t.width=this.width,t.height=this.height,t.anchorX=t.width/2,t.anchorY=t.height/2,t.fillColor=
\"
#fc4454
\"
,t.textAlign=engine.TEXT_ALIGN.CENTER,t.verticalAlign=engine.VERTICAL_ALIGN.MIDDLE,t.size=24,t.rotation=-26,t.text=
\"
+00
\"
,t.x=0,t.y=0,this.addChild(t),this.alpha=0},t.prototype.show=function(){var t=this;return new Promise(function(e){t._jumpTipsLabel.text=props.jumpTips[parseInt(Math.random()*props.jumpTips.length+
\"\"
)],t.alpha=1,engine.Tween.get(t,null,null,!0).wait(800).to({alpha:0},200,engine.Ease.cubicInOut).call(e)})},t}(engine.Container),ObjectPool=engine.ObjectPool,PoolName=
\"
gold-bag
\"
;ObjectPool.registerPool(PoolName,function(){return new GoldBag},function(e,t){e.reset(t)});var GameView=function(t){function e(){var e=t.call(this)||this;return e.index=-1,e.goldBags=[],e.baseOffset=-props.baseOffset+props.playerOffset,e.once(engine.Event.ADDED_TO_STAGE,e.setup,e),e}return tslib.__extends(e,t),e.prototype.setup=function(){var e,t,i,n,o,s,r,a,h,p,l,c,u;this._hasSetup||(this._hasSetup=!0,t=(e=this.stage).width,e.height,i=this.background=new Background,this.addChild(i),i.setup(),(n=this.frontContainer=new engine.Container).x=t/2,this.addChild(n),o=this.guideLayer=new GuideLayer,this.addChild(o),s=this.base=new Base,n.addChild(s),s.setup(),(r=this._blockShadow=new engine.Image(getTextureByName(
\"
方块阴影
\"
))).anchorX=r.width/2,r.anchorY=r.height/2,r.x=-(r.width-s.width)/2,r.y=props.blockShadowOffset,s.addChild(r),a=this.blockContainer=new engine.Container,n.addChild(a),h=this.player=new Player,n.addChild(h),h.setup(),h.addEventListener(
\"
jump-on-top
\"
,this.onPlayerJumpOnTop,this),(p=this._playerShadow=new engine.Image(getTextureByName(
\"
玩家阴影
\"
))).anchorX=p.width/2,p.anchorY=p.height/2,p.x=this.player.x-p.width/2,(l=this.scoreAddTipsContainer=new engine.Container).width=750,l.anchorX=l.width/2,l.anchorY=l.height/2,(c=this.scoreAddTips=new engine.Label).width=750,c.fillColor=props.scoreAddFontColor,c.textAlign=engine.TEXT_ALIGN.CENTER,c.size=props.scoreAddFontSize,c.alpha=0,c.text=
\"
+0
\"
,c.x=this.player.x-c.width/2,l.addChild(c),(u=this.jumpTips=new JumpTips).setup(),u.x=props.jumpTipsOffset.x,n.addChild(p),n.addChild(h),n.addChild(l),n.addChild(u),ObjectPool.recycleObject(PoolName,ObjectPool.getObject(PoolName,{y:0,remain:0})),this.hitEffect=createSvga(
\"
被撞烟雾
\"
,
\"
hitEffectAnchor
\"
),this.pos=0,this.background.setup(),this.addEventListener(engine.Event.ENTER_FRAME,this.onEnterFrame,this),this.reset())},e.prototype.setScoreText=function(i){return tslib.__awaiter(this,void 0,void 0,function(){var t=this;return tslib.__generator(this,function(e){return[2,new Promise(function(e){t.scoreAddTips.text=i,t.scoreAddTips.y=0,t.scoreAddTips.alpha=1,engine.Tween.get(t.scoreAddTips,null,null,!0).to({y:-100,alpha:0},500,engine.Ease.cubicInOut).call(e)})]})})},e.prototype.reset=function(s){return void 0===s&&(s=!1),tslib.__awaiter(this,void 0,void 0,function(){var t,i,n,o;return tslib.__generator(this,function(e){switch(e.label){case 0:if(this.base.reset(),this.index=-1,this._score=0,!s)for(this.pos=0,t=this.blockContainer,i=0,n=t.children.length;i<n;i++)t.getChildAt(i).playLeave();for(i=0;i<props.initBlockCount;i++)this.addBlock(!1);for(i=0,n=this.goldBags.length;i<n;i++)o=this.goldBags[i],this.frontContainer.removeChild(o),ObjectPool.recycleObject(PoolName,o);return this.goldBags.splice(0),this.playZoom(
\"
in
\"
),[4,this.resetPlayer(s)];case 1:return e.sent(),[2]}})})},e.prototype.resetPlayer=function(t){return void 0===t&&(t=!1),tslib.__awaiter(this,void 0,void 0,function(){return tslib.__generator(this,function(e){return this.player.reset(t),this.player.y=this.baseOffset-(this.index+1)*props.blockHitHeight+props.blockBaseOffset,[2]})})},e.prototype.start=function(n){return void 0===n&&(n=!1),tslib.__awaiter(this,void 0,void 0,function(){var t,i=this;return tslib.__generator(this,function(e){switch(e.label){case 0:return this._playerShadow.y=this.player.y+props.playerShadowOffset,this.scoreAddTipsContainer.y=this.player.y+props.scoreAddTipsOffset,this.jumpTips.y=this.player.y+props.jumpTipsOffset.y,n?[3,2]:[4,this.player.playReady()];case 1:e.sent(),e.label=2;case 2:return(console.log(
\"
开始
\"
),t=
\"
jump-high-guide_
\"
+props.guideFlagKey,localStorage.getItem(t))?[3,4]:(localStorage.setItem(t,
\"
1
\"
),[4,this.guideLayer.show(
\"\"
,{y:this.stage.height+this.player.y-280})]);case 3:e.sent(),e.label=4;case 4:return this.lastLandType=0,this._remainToShowGoldBag=props.goldBagScoreMultiple-props.goldBagScoreSubtraction,this._touchEnabled=!0,setTimeout(function(){i.addBlock()},100),engine.globalEvent.dispatchEvent(
\"
jump-high-game-start
\"
),[2]}})})},e.prototype.pause=function(){this.currentBlock&&engine.Tween.pauseTweens(this.currentBlock),engine.Tween.pauseTweens(this.player)},e.prototype.resume=function(){this.currentBlock&&engine.Tween.resumeTweens(this.currentBlock),engine.Tween.resumeTweens(this.player)},e.prototype.revive=function(){return tslib.__awaiter(this,void 0,void 0,function(){return tslib.__generator(this,function(e){switch(e.label){case 0:return this.blockContainer.getChildAt(this.index).visible=!1,this.index--,[4,this.resetPlayer(!0)];case 1:return e.sent(),[4,this.playZoom(
\"
in
\"
)];case 2:return e.sent(),this.start(!0),[2]}})})},e.prototype.addBlock=function(e){var t=this;void 0===e&&(e=!0),this.index++;var i,n=this.blockContainer;n.children.length>this.index?(i=n.getChildAt(this.index)).visible=!0:(i=new Block,n.addChildAt(i,0)),n.addChildAt(i,0),i.reset({type:Math.floor(Math.random()*props.blockAssets.length)}),i.y=this.baseOffset-this.index*props.blockHitHeight+props.blockBaseOffset,this.blockComplete=!1,i.playEnter(this.index,e).then(function(e){t.blockComplete=!0}),e&&(this.needHitTest=!0),this.currentBlock=i},e.prototype.addGoldBag=function(){var e=ObjectPool.getObject(PoolName,{y:this.baseOffset-(this.blockCount+props.goldBagDistance+props.goldBagJumpSubtraction)*props.blockHitHeight,remain:props.goldBagDistance});this.frontContainer.addChild(e),this.goldBags.push(e)},e.prototype.playOpenGoldBag=function(){return tslib.__awaiter(this,void 0,void 0,function(){var t,i,n;return tslib.__generator(this,function(e){switch(e.label){case 0:t=0,i=this.goldBags.length,e.label=1;case 1:return t<i?((n=this.goldBags[t]).remain--,n.remain<=0?(this.goldBags.splice(t,1),t--,i--,this.nextToUpdateScore=!0,[4,n.playOpen()]):[3,3]):[3,4];case 2:e.sent(),this.frontContainer.removeChild(n),ObjectPool.recycleObject(PoolName,n),e.label=3;case 3:return t++,[3,1];case 4:return[2]}})})},e.prototype.onPlayerJumpOnTop=function(){this.nextToUpdateScore&&(this.nextToUpdateScore=!1,this.scoreChange(4),playSound(
\"
撞击钱袋音效
\"
))},Object.defineProperty(e.prototype,
\"
blockCount
\"
,{get:function(){return this.index-props.initBlockCount+1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,
\"
pos
\"
,{get:function(){return this._pos},set:function(e){this._pos=e,this.updatePos()},enumerable:!1,configurable:!0}),e.prototype.updatePos=function(){this.frontContainer.y=this.stage.height+this._pos},e.prototype.onEnterFrame=function(e){var t,i,n,o,s,r,a,h,p,l,c;this.needHitTest&&this.currentBlock&&(i=(t=this.currentBlock).x,n=t.y,o=t.dir,r=(s=this.player).x,a=s.y,h=props.blockHitWidth,p=props.blockHitHeight,l=props.playerWidth,c=!1,Math.abs(r-i)<(h+l)/2&&(this.player.changeBaseY(n-p),n-p<a&&(c=!0)),c&&this.onHitOn(o))},e.prototype.onHitOn=function(t){return tslib.__awaiter(this,void 0,void 0,function(){return tslib.__generator(this,function(e){switch(e.label){case 0:return this._touchEnabled=!1,this.needHitTest=!1,clearInterval(this.timer),this.currentBlock.playHit(),this._playerShadow.visible=!1,[4,this.player.hitAway(t)];case 1:return e.sent(),[4,this.player.parachute(t)];case 2:return e.sent(),console.log(
\"
jump-high-game-end
\"
),engine.globalEvent.dispatchEvent(
\"
jump-high-game-end
\"
),[2]}})})},e.prototype.jump=function(){return tslib.__awaiter(this,void 0,void 0,function(){var t,i,n,o,s=this;return tslib.__generator(this,function(e){switch(e.label){case 0:return this._touchEnabled?(this._playerShadow.visible=!1,this._touchEnabled=!1,this.playOpenGoldBag(),[4,this.player.jump()]):[2];case 1:return(t=e.sent())?t.aboveBlock?(i=Math.abs(this.currentBlock.x),(n=0)<i&&(n=0<i&&i<props.scoreThreshold?2:3),o=this.lastLandType,0===(this.lastLandType=n)&&o!==n&&(n=1),n<3&&this.currentBlock.playEffect(),0===n&&this.currentBlock.playProFect(),3!=n&&(this._playerShadow.visible=!0),this._playerShadow.y=this.player.y+props.playerShadowOffset,this.player.playLand(n,this.currentBlock.dir),this.currentBlock.stop(),this.scoreChange(n),[4,this.playShake()]):[3,4]:[3,5];case 2:return e.sent(),[4,new Promise(function(e){engine.Tween.get(s,null,null,!0).to({pos:props.blockHitHeight*s.index},300,engine.Ease.cubicOut).call(e)})];case 3:e.sent(),this.addBlock(),e.label=4;case 4:this._touchEnabled=!0,e.label=5;case 5:return[2]}})})},e.prototype.scoreChange=function(e){var t=props.scoreWeights[e];this._score+=t,this._remainToShowGoldBag-=t;var i=this._score;engine.globalEvent.dispatchEvent(
\"
jump-high-score
\"
,{type:e,score:i,scoreAdd:t}),this.scoreAddTipsContainer.y=this.player.y+props.scoreAddTipsOffset,this.setScoreText(
\"
+
\"
+t),this.jumpTips.y=this.player.y+props.jumpTipsOffset.y,this.jumpTips.show(),console.log(i,this._remainToShowGoldBag),this._remainToShowGoldBag<=0&&(this._remainToShowGoldBag+=props.goldBagScoreMultiple,this.addGoldBag(),console.log(
\"
addGoldBag
\"
))},e.prototype.playHitEffect=function(e){var t=this.hitEffect;t.scaleX=e,t.y=this.player.y-props.hitEffectAnchor.y,t.play(!0,!1),t.once(engine.Event.END_FRAME,function(){this.frontContainer.removeChild(t)},this),this.frontContainer.addChild(t)},e.prototype.playZoom=function(i,n){var o=this;void 0===n&&(n=700),this.background.playZoom(i,n);var s=this.stage.height/props.blockHitHeight;return new Promise(function(e){o.frontContainer.anchorY=-props.blockHitHeight*(o.index+1.3*s)+props.baseOffset;var t=
\"
in
\"
===i?1:Math.min(o.stage.height/props.blockHitHeight/(o.index+s),props.maxScale);console.log(t),engine.Tween.get(o.frontContainer,null,null,!0).to({scaleX:t,scaleY:t},n,engine.Ease.cubicInOut).call(e)})},e.prototype.playShake=function(){var t=this,e=this.frontContainer,i=e.x,n=e.y;return new Promise(function(e){engine.Tween.get(t.frontContainer,null,null,!0).to({x:i,y:n-7},30).to({x:i,y:n+7},30).to({x:i+7,y:n},30).to({x:i-7,y:n},30).to({x:i,y:n},30).call(e)})},e}(engine.Container),JumpHigh=function(i){function e(){var e=i.call(this)||this;engine.globalEvent.addEventListener(
\"
jump-high-reset
\"
,e.reset,e),engine.globalEvent.addEventListener(
\"
jump-high-start
\"
,e.start,e),engine.globalEvent.addEventListener(
\"
jump-high-pause
\"
,e.pause,e),engine.globalEvent.addEventListener(
\"
jump-high-resume
\"
,e.resume,e),engine.globalEvent.addEventListener(
\"
jump-high-revive
\"
,e.revive,e),e.addEventListener(engine.MouseEvent.MOUSE_DOWN,e.onTap,e);var t=e._gameView=new GameView;return e.addChild(t),e}return tslib.__extends(e,i),e.prototype.reset=function(){this._gameView.reset()},e.prototype.start=function(e){injectProps(e.data),this._status=1,this._gameView.start()},e.prototype.pause=function(){this._gameView.pause()},e.prototype.resume=function(){this._gameView.resume()},e.prototype.revive=function(){this._gameView.revive()},e.prototype.onTap=function(e){this._gameView.jump()},e}(engine.Container);function index(e){return prepareProps(),injectProps(e),new JumpHigh}module.exports=index
;
\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(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\t
//# sourceMappingURL=Player.js.map
\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 blockShadow = this._blockShadow = new engine.Image(getTextureByName('方块阴影'));
\n\t
blockShadow.anchorX = blockShadow.width / 2;
\n\t
blockShadow.anchorY = blockShadow.height / 2;
\n\t
blockShadow.x = -(blockShadow.width - base.width) / 2;
\n\t
blockShadow.y = props.blockShadowOffset;
\n\t
base.addChild(blockShadow);
\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 playerShadow = this._playerShadow = new engine.Image(getTextureByName('玩家阴影'));
\n\t
playerShadow.anchorX = playerShadow.width / 2;
\n\t
playerShadow.anchorY = playerShadow.height / 2;
\n\t
playerShadow.x = this.player.x - playerShadow.width / 2;
\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(playerShadow);
\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._playerShadow.y = this.player.y + props.playerShadowOffset;
\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
this._playerShadow.visible = false;
\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._playerShadow.visible = false;
\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
if (type != 3) {
\n\t
this._playerShadow.visible = true;
\n\t
}
\n\t
this._playerShadow.y = this.player.y + props.playerShadowOffset;
\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\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/main.js
View file @
eccf6925
"use strict"
;
var
tslib
=
require
(
"tslib"
),
props
=
{};
function
prepareProps
(){
var
e
=
getProps
();
engine
.
injectProp
(
props
,
e
)}
function
injectProps
(
e
){
engine
.
injectProp
(
props
,
e
)}
function
getTexture
(
e
){
return
engine
.
Texture
.
from
(
getAssetByUUID
(
e
).
uuid
)}
function
getTextureByName
(
e
){
return
getTexture
(
engine
.
getAssetByName
(
e
).
uuid
)}
function
getBlockAsset
(
e
){
return
engine
.
getAssetByName
(
props
.
blockAssets
[
e
])}
function
getBlockHitAsset
(
e
){
return
console
.
log
(
"props.blockHitAssets"
,
props
.
blockHitAssets
),
engine
.
getAssetByName
(
props
.
blockHitAssets
[
e
])}
function
createSvga
(
e
,
t
){
var
i
=
new
svga
.
Svga
;
i
.
source
=
"asset://"
+
engine
.
getAssetByName
(
e
).
uuid
;
var
n
=
props
[
t
];
return
n
&&
(
i
.
x
=-
n
.
x
,
i
.
y
=-
n
.
y
,
i
.
anchorX
=
n
.
x
,
i
.
anchorY
=
n
.
y
),
i
}
function
playSound
(
e
){
engine
.
playSound
(
engine
.
getAssetByName
(
e
).
uuid
,{
keep
:
!
0
})}
var
Block
=
function
(
o
){
function
e
(){
var
e
=
o
.
call
(
this
)
||
this
,
t
=
e
.
body
=
new
svga
.
Svga
;
t
.
x
=-
props
.
blockWidth
/
2
,
t
.
y
=-
props
.
blockHitHeight
-
props
.
blockPaddingTop
,
e
.
addChild
(
t
);
var
i
=
e
.
bodyHit
=
new
svga
.
Svga
;
i
.
x
=-
props
.
blockWidth
/
2
,
i
.
y
=-
props
.
blockHitHeight
-
props
.
blockPaddingTop
+
props
.
blockHitOffsetY
,
e
.
addChild
(
i
),
console
.
log
(
"props.blockProfectOffset"
,
props
.
blockProfectOffset
);
var
n
=
e
.
bodyProfect
=
new
svga
.
Svga
;
return
n
.
x
=-
props
.
blockWidth
/
2
+
props
.
blockProfectOffset
.
x
,
n
.
y
=-
props
.
blockHitHeight
-
props
.
blockPaddingTop
+
props
.
blockProfectOffset
.
y
,
e
.
addChild
(
n
),
e
}
return
tslib
.
__extends
(
e
,
o
),
e
.
prototype
.
reset
=
function
(
e
){
var
t
,
i
,
n
=
e
.
type
;
this
.
dir
=
.
5
<
Math
.
random
()?
1
:
-
1
,
this
.
type
!=
n
&&
(
t
=
getBlockAsset
(
this
.
type
=
n
),
this
.
body
.
source
=
"asset://"
+
t
.
uuid
,
i
=
getBlockHitAsset
(
n
),
console
.
log
(
"assetHit"
,
i
),
this
.
bodyHit
.
source
=
"asset://"
+
i
.
uuid
),
this
.
bodyProfect
.
source
=
"asset://"
+
engine
.
getAssetByName
(
"完美方块素材"
).
uuid
,
this
.
scaleX
=
this
.
dir
,
this
.
body
.
gotoAndStop
(
1
),
this
.
bodyHit
.
gotoAndStop
(
1
),
this
.
bodyProfect
.
gotoAndStop
(
1
),
this
.
body
.
visible
=!
0
,
this
.
bodyHit
.
visible
=!
1
},
e
.
prototype
.
playEnter
=
function
(
e
,
t
){
var
i
=
this
;
this
.
visible
=!
0
,
this
.
x
=
this
.
dir
*
this
.
stage
.
width
;
var
n
=
props
.
blockDurationRange
,
o
=
n
[
0
],
s
=
n
[
1
],
r
=
Math
.
max
(
s
-
e
*
props
.
blockDurationStep
,
o
);
return
r
+=
s
*
Math
.
random
()
*
props
.
blockDurationRandom
*
(.
5
<
Math
.
random
()?
1
:
-
1
),
new
Promise
(
function
(
e
){
t
?
engine
.
Tween
.
get
(
i
,
null
,
null
,
!
0
).
to
({
x
:
0
},
r
).
call
(
e
):(
i
.
x
=
0
,
setTimeout
(
function
(){
console
.
log
(
i
.
body
)},
200
),
e
())})},
e
.
prototype
.
playLeave
=
function
(){
this
.
visible
=!
1
},
e
.
prototype
.
playEffect
=
function
(){
var
e
=
this
.
body
;
e
.
play
(
!
0
,
!
1
),
e
.
once
(
engine
.
Event
.
END_FRAME
,
function
(){
e
.
gotoAndStop
(
1
)},
this
)},
e
.
prototype
.
playHit
=
function
(){
var
e
=
this
.
bodyHit
;
e
.
play
(
!
0
,
!
1
),
this
.
body
.
visible
=!
1
,
this
.
bodyHit
.
visible
=!
0
,
e
.
once
(
engine
.
Event
.
END_FRAME
,
function
(){
this
.
body
.
visible
=!
0
,
this
.
bodyHit
.
visible
=!
1
,
e
.
gotoAndStop
(
1
)},
this
)},
e
.
prototype
.
playProFect
=
function
(){
var
e
=
this
.
bodyProfect
;
e
.
play
(
!
0
,
!
1
),
e
.
once
(
engine
.
Event
.
END_FRAME
,
function
(){
e
.
gotoAndStop
(
1
)},
this
)},
e
.
prototype
.
stop
=
function
(){
engine
.
Tween
.
removeTweens
(
this
)},
e
}(
engine
.
Container
),
Background
=
function
(
e
){
function
t
(){
return
e
.
call
(
this
)
||
this
}
return
tslib
.
__extends
(
t
,
e
),
t
.
prototype
.
setup
=
function
(){
var
e
=
this
.
stage
,
t
=
e
.
width
,
i
=
e
.
height
,
n
=
this
.
_bg
=
new
engine
.
Image
(
getTextureByName
(
"背景图"
));
n
.
anchorX
=
n
.
width
/
2
,
n
.
anchorY
=
n
.
height
/
2
,
n
.
x
=-
(
n
.
width
-
t
)
/
2
,
n
.
y
=-
(
n
.
height
-
i
)
/
2
,
this
.
addChild
(
n
),
this
.
_minScale
=
t
/
n
.
width
},
t
.
prototype
.
playZoom
=
function
(
i
,
n
){
var
o
=
this
;
return
void
0
===
n
&&
(
n
=
700
),
new
Promise
(
function
(
e
){
var
t
=
"in"
===
i
?
1
:
o
.
_minScale
;
engine
.
Tween
.
get
(
o
.
_bg
,
null
,
null
,
!
0
).
to
({
scaleX
:
t
,
scaleY
:
t
},
n
,
engine
.
Ease
.
cubicInOut
).
call
(
e
)})},
t
}(
engine
.
Container
),
svgaAssets
=
{
aniReady
:{
name
:
"准备立正"
,
dir
:
1
},
aniReady2
:{
name
:
"准备立正"
,
dir
:
1
},
aniJump
:{
name
:
"跳上升"
,
dir
:
1
},
aniFall
:{
name
:
"跳下落"
,
dir
:
1
},
aniLandNormal
:{
name
:
"普通着地"
,
dir
:
1
},
aniLandSide
:{
name
:
"边缘着地"
,
dir
:
-
1
},
aniHit
:{
name
:
"被撞开"
,
dir
:
-
1
},
aniParachute
:{
name
:
"降落"
,
dir
:
-
1
},
aniLandPerfect
:{
name
:
"完美着地_笑"
,
dir
:
1
}},
Player
=
function
(
t
){
function
e
(){
var
e
=
t
.
call
(
this
)
||
this
;
return
e
.
g
=
props
.
gravity
,
e
.
addEventListener
(
engine
.
Event
.
ENTER_FRAME
,
e
.
onEnterFrame
,
e
),
e
}
return
tslib
.
__extends
(
e
,
t
),
e
.
prototype
.
switchAni
=
function
(
n
,
o
,
s
,
r
){
var
a
=
this
;
return
void
0
===
o
&&
(
o
=
1
),
void
0
===
s
&&
(
s
=!
0
),
void
0
===
r
&&
(
r
=!
1
),
new
Promise
(
function
(
e
){
var
t
,
i
;
a
.
scaleX
=
o
,
a
.
_aniName
!==
n
&&
(
a
.
_aniName
=
n
,(
t
=
a
.
removeChild
(
a
.
getChildByName
(
"body"
)))
&&
t
.
stop
(),
i
=
a
.
_currentAni
=
a
[
"ani"
+
n
],
a
.
addChild
(
i
),
s
?(
i
.
play
(
!
1
,
r
),
r
?
e
():
i
.
once
(
engine
.
Event
.
END_FRAME
,
e
)):
e
())})},
e
.
prototype
.
setup
=
function
(){
for
(
var
e
in
this
.
prefectEffect
=
createSvga
(
"完美着地特效"
,
"playerLandPrefectAnchor"
),
this
.
landEffect
=
createSvga
(
"着地特效"
,
"playerLandEffectAnchor"
),
svgaAssets
){
var
t
=
svgaAssets
[
e
],
i
=
t
.
name
,
n
=
t
.
dir
,
o
=
this
[
e
]
=
createSvga
(
i
,
e
.
replace
(
"ani"
,
"player"
)
+
"Anchor"
);
o
.
name
=
"body"
,
o
.
scaleX
=
n
}},
e
.
prototype
.
reset
=
function
(
e
){
this
.
x
=
0
,
this
.
rotation
=
0
,
this
.
scaleX
=
this
.
scaleY
=
1
,
this
.
_prefectLandCounting
=
0
,
engine
.
Tween
.
removeTweens
(
this
),
e
&&
this
.
switchAni
(
"Jump"
,
1
,
!
1
)},
e
.
prototype
.
playReady
=
function
(){
var
t
=
this
;
return
new
Promise
(
function
(
e
){
t
.
switchAni
(
"Ready"
,
1
),
t
.
_currentAni
.
once
(
engine
.
Event
.
END_FRAME
,
function
(){
this
.
switchAni
(
"Ready2"
,
1
,
!
0
,
!
0
),
e
()},
t
)})},
e
.
prototype
.
onEnterFrame
=
function
(
e
){
this
.
playing
&&
(
this
.
vy
+=
this
.
g
,
this
.
y
+=
this
.
vy
,
0
<
this
.
vy
&&
"Fall"
!==
this
.
_aniName
&&
(
this
.
dispatchEvent
(
"jump-on-top"
),
this
.
switchAni
(
"Fall"
)),
this
.
y
>
this
.
baseY
&&
(
this
.
y
=
this
.
baseY
,
this
.
playing
=!
1
,
this
.
jumpPromise
&&
this
.
jumpPromise
({
aboveBlock
:
this
.
aboveBlock
}),
this
.
jumpPromise
=
null
))},
e
.
prototype
.
changeBaseY
=
function
(
e
){
this
.
baseY
!=
e
&&
(
this
.
aboveBlock
=!
0
,
this
.
baseY
=
e
)},
e
.
prototype
.
jump
=
function
(){
var
t
=
this
;
return
playSound
(
"跳起音效"
),
this
.
switchAni
(
"Jump"
,
1
,
!
1
),
this
.
_currentAni
.
play
(
!
1
,
!
1
),
this
.
aboveBlock
=!
1
,
this
.
playing
=!
0
,
this
.
baseY
=
this
.
y
,
this
.
vy
=-
props
.
jumpSpeed
,
new
Promise
(
function
(
e
){
t
.
jumpPromise
=
e
})},
e
.
prototype
.
playLand
=
function
(
n
,
o
){
return
tslib
.
__awaiter
(
this
,
void
0
,
void
0
,
function
(){
var
t
,
i
;
return
tslib
.
__generator
(
this
,
function
(
e
){
switch
(
e
.
label
){
case
0
:
switch
(
n
){
case
0
:
return
[
3
,
1
];
case
1
:
case
2
:
return
[
3
,
4
];
case
3
:
return
[
3
,
5
]}
return
[
3
,
6
];
case
1
:
return
this
.
_prefectLandCounting
++
,
playSound
(
"完美落地音效"
+
Math
.
min
(
4
,
this
.
_prefectLandCounting
)),
t
=
this
.
prefectEffect
,
this
.
addChildAt
(
t
,
0
),
t
.
gotoAndPlay
(
1
),
t
.
once
(
engine
.
Event
.
END_FRAME
,
function
(){
this
.
removeChild
(
t
)},
this
),
i
=
this
.
landEffect
,
this
.
addChildAt
(
i
,
0
),
i
.
gotoAndPlay
(
1
),
i
.
once
(
engine
.
Event
.
END_FRAME
,
function
(){
this
.
removeChild
(
i
)},
this
),[
4
,
this
.
switchAni
(
"LandPerfect"
)];
case
2
:
return
e
.
sent
(),[
4
,
this
.
switchAni
(
"Ready2"
,
1
,
!
0
,
!
0
)];
case
3
:
return
e
.
sent
(),[
3
,
6
];
case
4
:
return
this
.
_prefectLandCounting
=
0
,
playSound
(
"普通落地音效"
),
this
.
switchAni
(
"Ready2"
,
1
,
!
0
,
!
0
),[
3
,
6
];
case
5
:
return
this
.
_prefectLandCounting
=
0
,
playSound
(
"边缘落地音效"
),
this
.
switchAni
(
"LandSide"
,
o
),[
3
,
6
];
case
6
:
return
[
2
]}})})},
e
.
prototype
.
hitAway
=
function
(
i
){
return
tslib
.
__awaiter
(
this
,
void
0
,
void
0
,
function
(){
var
t
=
this
;
return
tslib
.
__generator
(
this
,
function
(
e
){
switch
(
e
.
label
){
case
0
:
return
this
.
jumpPromise
&&
this
.
jumpPromise
(),
this
.
jumpPromise
=
null
,
playSound
(
"被撞开音效"
),
this
.
switchAni
(
"Hit"
,
i
),
this
.
vy
=
0
,[
4
,
new
Promise
(
function
(
e
){
engine
.
Tween
.
get
(
t
).
to
({
x
:
-
i
*
props
.
hitAwayDistance
.
x
},
props
.
hitAwayDuration
,
engine
.
Ease
.
quartOut
),
engine
.
Tween
.
get
(
t
).
to
({
y
:
t
.
y
+
props
.
hitAwayDistance
.
y
},
props
.
hitAwayDuration
,
engine
.
Ease
.
cubicOut
).
call
(
e
)})];
case
1
:
return
e
.
sent
(),[
2
]}})})},
e
.
prototype
.
parachute
=
function
(
e
){
var
t
=
this
;
return
this
.
switchAni
(
"Parachute"
,
e
),
new
Promise
(
function
(
e
){
engine
.
Tween
.
get
(
t
).
call
(
function
(){
playSound
(
"降落伞下落音效"
)}).
to
({
y
:
t
.
y
+
props
.
parachuteDistance
},
props
.
parachuteDuration
).
set
({
anchorOffsetY
:
0
}).
call
(
e
)})},
e
}(
engine
.
Container
),
Base
=
function
(
e
){
function
t
(){
return
e
.
call
(
this
,
getTextureByName
(
"底座"
))
||
this
}
return
tslib
.
__extends
(
t
,
e
),
t
.
prototype
.
setup
=
function
(){
this
.
x
=-
this
.
width
/
2
},
t
.
prototype
.
reset
=
function
(){
this
.
y
=-
props
.
baseOffset
},
t
}(
engine
.
Image
),
GuideLayer
=
function
(
t
){
function
e
(){
var
e
=
t
.
call
(
this
)
||
this
;
return
e
.
setup
(),
e
}
return
tslib
.
__extends
(
e
,
t
),
e
.
prototype
.
setup
=
function
(){},
e
.
prototype
.
show
=
function
(
e
,
a
){
var
h
=
this
;
return
new
Promise
(
function
(
e
){
var
t
,
i
,
n
,
o
,
s
,
r
;
h
.
visible
=!
0
,
h
.
guideMask
||
(
i
=
(
t
=
h
.
stage
).
width
,
n
=
t
.
height
,
o
=
h
.
guideMask
=
new
engine
.
Container
,(
s
=
new
engine
.
Image
(
getTextureByName
(
"引导遮罩"
))).
x
=
(
i
-
s
.
width
)
/
2
,
s
.
y
=
a
.
y
,
o
.
addChild
(
s
),
h
.
createRect
(
o
,
0
,
0
,
i
,
s
.
y
),
h
.
createRect
(
o
,
0
,
s
.
y
,
s
.
x
,
s
.
height
),
h
.
createRect
(
o
,
s
.
x
+
s
.
width
,
s
.
y
,
i
-
s
.
x
-
s
.
width
,
s
.
height
),
h
.
createRect
(
o
,
0
,
s
.
y
+
s
.
height
,
i
,
n
-
s
.
y
-
s
.
height
),(
r
=
h
.
label
=
new
engine
.
Label
).
fillColor
=
"white"
,
r
.
size
=
25
,
r
.
text
=
props
.
guideText
,
r
.
x
=
(
i
-
r
.
width
)
/
2
,
r
.
y
=
s
.
y
+
s
.
height
+
50
,
o
.
addChild
(
r
),
h
.
addChild
(
o
)),
h
.
once
(
engine
.
MouseEvent
.
CLICK
,
function
(){
this
.
visible
=!
1
,
e
()},
h
)})},
e
.
prototype
.
createRect
=
function
(
e
,
t
,
i
,
n
,
o
){
var
s
=
new
engine
.
Rect
;
s
.
x
=
t
,
s
.
y
=
i
,
s
.
width
=
n
,
s
.
height
=
o
,
s
.
fillColor
=
"black"
,
s
.
alpha
=
.
7
,
e
.
addChild
(
s
)},
e
}(
engine
.
Container
),
GoldBag
=
function
(
t
){
function
e
(){
var
e
=
t
.
call
(
this
)
||
this
;
return
e
.
setup
(),
e
}
return
tslib
.
__extends
(
e
,
t
),
e
.
prototype
.
setup
=
function
(){
var
e
=
this
.
avatar
=
new
engine
.
Sprite
(
getTextureByName
(
"钱袋-静态"
));
e
.
x
=-
props
.
goldPackAvatarAnchor
.
x
,
e
.
y
=-
props
.
goldPackAvatarAnchor
.
y
,
this
.
addChild
(
e
);
var
t
=
this
.
svga
=
createSvga
(
"钱袋"
,
"goldPackAnchor"
);
t
.
visible
=!
1
,
this
.
addChild
(
t
)},
e
.
prototype
.
reset
=
function
(
e
){
this
.
y
=
e
.
y
,
this
.
avatar
.
visible
=!
0
,
this
.
svga
.
visible
=!
1
,
this
.
svga
.
gotoAndStop
(
1
),
this
.
remain
=
e
.
remain
},
e
.
prototype
.
playOpen
=
function
(){
var
t
=
this
;
return
this
.
avatar
.
visible
=!
1
,
this
.
svga
.
visible
=!
0
,
new
Promise
(
function
(
e
){
t
.
svga
.
play
(
!
0
,
!
1
),
t
.
svga
.
once
(
engine
.
Event
.
END_FRAME
,
function
(){
this
.
svga
.
visible
=!
1
,
e
()},
t
)})},
e
}(
engine
.
Container
),
JumpTips
=
function
(
e
){
function
t
(){
return
e
.
call
(
this
)
||
this
}
return
tslib
.
__extends
(
t
,
e
),
t
.
prototype
.
setup
=
function
(){
this
.
width
=
124
,
this
.
height
=
93
;
var
e
=
this
.
_bg
=
new
engine
.
Image
(
getTextureByName
(
"跳跃提示背景"
));
e
.
width
=
this
.
width
,
e
.
height
=
this
.
height
,
e
.
anchorX
=
e
.
width
/
2
,
e
.
anchorY
=
e
.
height
/
2
,
this
.
addChild
(
e
);
var
t
=
this
.
_jumpTipsLabel
=
new
engine
.
Label
;
t
.
width
=
this
.
width
,
t
.
height
=
this
.
height
,
t
.
anchorX
=
t
.
width
/
2
,
t
.
anchorY
=
t
.
height
/
2
,
t
.
fillColor
=
"#fc4454"
,
t
.
textAlign
=
engine
.
TEXT_ALIGN
.
CENTER
,
t
.
verticalAlign
=
engine
.
VERTICAL_ALIGN
.
MIDDLE
,
t
.
size
=
24
,
t
.
rotation
=-
26
,
t
.
text
=
"+00"
,
t
.
x
=
0
,
t
.
y
=
0
,
this
.
addChild
(
t
),
this
.
alpha
=
0
},
t
.
prototype
.
show
=
function
(){
var
t
=
this
;
return
new
Promise
(
function
(
e
){
t
.
_jumpTipsLabel
.
text
=
props
.
jumpTips
[
parseInt
(
Math
.
random
()
*
props
.
jumpTips
.
length
+
""
)],
t
.
alpha
=
1
,
engine
.
Tween
.
get
(
t
,
null
,
null
,
!
0
).
wait
(
800
).
to
({
alpha
:
0
},
200
,
engine
.
Ease
.
cubicInOut
).
call
(
e
)})},
t
}(
engine
.
Container
),
ObjectPool
=
engine
.
ObjectPool
,
PoolName
=
"gold-bag"
;
ObjectPool
.
registerPool
(
PoolName
,
function
(){
return
new
GoldBag
},
function
(
e
,
t
){
e
.
reset
(
t
)});
var
GameView
=
function
(
t
){
function
e
(){
var
e
=
t
.
call
(
this
)
||
this
;
return
e
.
index
=-
1
,
e
.
goldBags
=
[],
e
.
baseOffset
=-
props
.
baseOffset
+
props
.
playerOffset
,
e
.
once
(
engine
.
Event
.
ADDED_TO_STAGE
,
e
.
setup
,
e
),
e
}
return
tslib
.
__extends
(
e
,
t
),
e
.
prototype
.
setup
=
function
(){
var
e
,
t
,
i
,
n
,
o
,
s
,
r
,
a
,
h
,
p
,
l
,
c
,
u
;
this
.
_hasSetup
||
(
this
.
_hasSetup
=!
0
,
t
=
(
e
=
this
.
stage
).
width
,
e
.
height
,
i
=
this
.
background
=
new
Background
,
this
.
addChild
(
i
),
i
.
setup
(),(
n
=
this
.
frontContainer
=
new
engine
.
Container
).
x
=
t
/
2
,
this
.
addChild
(
n
),
o
=
this
.
guideLayer
=
new
GuideLayer
,
this
.
addChild
(
o
),
s
=
this
.
base
=
new
Base
,
n
.
addChild
(
s
),
s
.
setup
(),(
r
=
this
.
_blockShadow
=
new
engine
.
Image
(
getTextureByName
(
"方块阴影"
))).
anchorX
=
r
.
width
/
2
,
r
.
anchorY
=
r
.
height
/
2
,
r
.
x
=-
(
r
.
width
-
s
.
width
)
/
2
,
r
.
y
=
props
.
blockShadowOffset
,
s
.
addChild
(
r
),
a
=
this
.
blockContainer
=
new
engine
.
Container
,
n
.
addChild
(
a
),
h
=
this
.
player
=
new
Player
,
n
.
addChild
(
h
),
h
.
setup
(),
h
.
addEventListener
(
"jump-on-top"
,
this
.
onPlayerJumpOnTop
,
this
),(
p
=
this
.
_playerShadow
=
new
engine
.
Image
(
getTextureByName
(
"玩家阴影"
))).
anchorX
=
p
.
width
/
2
,
p
.
anchorY
=
p
.
height
/
2
,
p
.
x
=
this
.
player
.
x
-
p
.
width
/
2
,(
l
=
this
.
scoreAddTipsContainer
=
new
engine
.
Container
).
width
=
750
,
l
.
anchorX
=
l
.
width
/
2
,
l
.
anchorY
=
l
.
height
/
2
,(
c
=
this
.
scoreAddTips
=
new
engine
.
Label
).
width
=
750
,
c
.
fillColor
=
props
.
scoreAddFontColor
,
c
.
textAlign
=
engine
.
TEXT_ALIGN
.
CENTER
,
c
.
size
=
props
.
scoreAddFontSize
,
c
.
alpha
=
0
,
c
.
text
=
"+0"
,
c
.
x
=
this
.
player
.
x
-
c
.
width
/
2
,
l
.
addChild
(
c
),(
u
=
this
.
jumpTips
=
new
JumpTips
).
setup
(),
u
.
x
=
props
.
jumpTipsOffset
.
x
,
n
.
addChild
(
p
),
n
.
addChild
(
h
),
n
.
addChild
(
l
),
n
.
addChild
(
u
),
ObjectPool
.
recycleObject
(
PoolName
,
ObjectPool
.
getObject
(
PoolName
,{
y
:
0
,
remain
:
0
})),
this
.
hitEffect
=
createSvga
(
"被撞烟雾"
,
"hitEffectAnchor"
),
this
.
pos
=
0
,
this
.
background
.
setup
(),
this
.
addEventListener
(
engine
.
Event
.
ENTER_FRAME
,
this
.
onEnterFrame
,
this
),
this
.
reset
())},
e
.
prototype
.
setScoreText
=
function
(
i
){
return
tslib
.
__awaiter
(
this
,
void
0
,
void
0
,
function
(){
var
t
=
this
;
return
tslib
.
__generator
(
this
,
function
(
e
){
return
[
2
,
new
Promise
(
function
(
e
){
t
.
scoreAddTips
.
text
=
i
,
t
.
scoreAddTips
.
y
=
0
,
t
.
scoreAddTips
.
alpha
=
1
,
engine
.
Tween
.
get
(
t
.
scoreAddTips
,
null
,
null
,
!
0
).
to
({
y
:
-
100
,
alpha
:
0
},
500
,
engine
.
Ease
.
cubicInOut
).
call
(
e
)})]})})},
e
.
prototype
.
reset
=
function
(
s
){
return
void
0
===
s
&&
(
s
=!
1
),
tslib
.
__awaiter
(
this
,
void
0
,
void
0
,
function
(){
var
t
,
i
,
n
,
o
;
return
tslib
.
__generator
(
this
,
function
(
e
){
switch
(
e
.
label
){
case
0
:
if
(
this
.
base
.
reset
(),
this
.
index
=-
1
,
this
.
_score
=
0
,
!
s
)
for
(
this
.
pos
=
0
,
t
=
this
.
blockContainer
,
i
=
0
,
n
=
t
.
children
.
length
;
i
<
n
;
i
++
)
t
.
getChildAt
(
i
).
playLeave
();
for
(
i
=
0
;
i
<
props
.
initBlockCount
;
i
++
)
this
.
addBlock
(
!
1
);
for
(
i
=
0
,
n
=
this
.
goldBags
.
length
;
i
<
n
;
i
++
)
o
=
this
.
goldBags
[
i
],
this
.
frontContainer
.
removeChild
(
o
),
ObjectPool
.
recycleObject
(
PoolName
,
o
);
return
this
.
goldBags
.
splice
(
0
),
this
.
playZoom
(
"in"
),[
4
,
this
.
resetPlayer
(
s
)];
case
1
:
return
e
.
sent
(),[
2
]}})})},
e
.
prototype
.
resetPlayer
=
function
(
t
){
return
void
0
===
t
&&
(
t
=!
1
),
tslib
.
__awaiter
(
this
,
void
0
,
void
0
,
function
(){
return
tslib
.
__generator
(
this
,
function
(
e
){
return
this
.
player
.
reset
(
t
),
this
.
player
.
y
=
this
.
baseOffset
-
(
this
.
index
+
1
)
*
props
.
blockHitHeight
+
props
.
blockBaseOffset
,[
2
]})})},
e
.
prototype
.
start
=
function
(
n
){
return
void
0
===
n
&&
(
n
=!
1
),
tslib
.
__awaiter
(
this
,
void
0
,
void
0
,
function
(){
var
t
,
i
=
this
;
return
tslib
.
__generator
(
this
,
function
(
e
){
switch
(
e
.
label
){
case
0
:
return
this
.
_playerShadow
.
y
=
this
.
player
.
y
+
props
.
playerShadowOffset
,
this
.
scoreAddTipsContainer
.
y
=
this
.
player
.
y
+
props
.
scoreAddTipsOffset
,
this
.
jumpTips
.
y
=
this
.
player
.
y
+
props
.
jumpTipsOffset
.
y
,
n
?[
3
,
2
]:[
4
,
this
.
player
.
playReady
()];
case
1
:
e
.
sent
(),
e
.
label
=
2
;
case
2
:
return
(
console
.
log
(
"开始"
),
t
=
"jump-high-guide_"
+
props
.
guideFlagKey
,
localStorage
.
getItem
(
t
))?[
3
,
4
]:(
localStorage
.
setItem
(
t
,
"1"
),[
4
,
this
.
guideLayer
.
show
(
""
,{
y
:
this
.
stage
.
height
+
this
.
player
.
y
-
280
})]);
case
3
:
e
.
sent
(),
e
.
label
=
4
;
case
4
:
return
this
.
lastLandType
=
0
,
this
.
_remainToShowGoldBag
=
props
.
goldBagScoreMultiple
-
props
.
goldBagScoreSubtraction
,
this
.
_touchEnabled
=!
0
,
setTimeout
(
function
(){
i
.
addBlock
()},
100
),
engine
.
globalEvent
.
dispatchEvent
(
"jump-high-game-start"
),[
2
]}})})},
e
.
prototype
.
pause
=
function
(){
this
.
currentBlock
&&
engine
.
Tween
.
pauseTweens
(
this
.
currentBlock
),
engine
.
Tween
.
pauseTweens
(
this
.
player
)},
e
.
prototype
.
resume
=
function
(){
this
.
currentBlock
&&
engine
.
Tween
.
resumeTweens
(
this
.
currentBlock
),
engine
.
Tween
.
resumeTweens
(
this
.
player
)},
e
.
prototype
.
revive
=
function
(){
return
tslib
.
__awaiter
(
this
,
void
0
,
void
0
,
function
(){
return
tslib
.
__generator
(
this
,
function
(
e
){
switch
(
e
.
label
){
case
0
:
return
this
.
blockContainer
.
getChildAt
(
this
.
index
).
visible
=!
1
,
this
.
index
--
,[
4
,
this
.
resetPlayer
(
!
0
)];
case
1
:
return
e
.
sent
(),[
4
,
this
.
playZoom
(
"in"
)];
case
2
:
return
e
.
sent
(),
this
.
start
(
!
0
),[
2
]}})})},
e
.
prototype
.
addBlock
=
function
(
e
){
var
t
=
this
;
void
0
===
e
&&
(
e
=!
0
),
this
.
index
++
;
var
i
,
n
=
this
.
blockContainer
;
n
.
children
.
length
>
this
.
index
?(
i
=
n
.
getChildAt
(
this
.
index
)).
visible
=!
0
:(
i
=
new
Block
,
n
.
addChildAt
(
i
,
0
)),
n
.
addChildAt
(
i
,
0
),
i
.
reset
({
type
:
Math
.
floor
(
Math
.
random
()
*
props
.
blockAssets
.
length
)}),
i
.
y
=
this
.
baseOffset
-
this
.
index
*
props
.
blockHitHeight
+
props
.
blockBaseOffset
,
this
.
blockComplete
=!
1
,
i
.
playEnter
(
this
.
index
,
e
).
then
(
function
(
e
){
t
.
blockComplete
=!
0
}),
e
&&
(
this
.
needHitTest
=!
0
),
this
.
currentBlock
=
i
},
e
.
prototype
.
addGoldBag
=
function
(){
var
e
=
ObjectPool
.
getObject
(
PoolName
,{
y
:
this
.
baseOffset
-
(
this
.
blockCount
+
props
.
goldBagDistance
+
props
.
goldBagJumpSubtraction
)
*
props
.
blockHitHeight
,
remain
:
props
.
goldBagDistance
});
this
.
frontContainer
.
addChild
(
e
),
this
.
goldBags
.
push
(
e
)},
e
.
prototype
.
playOpenGoldBag
=
function
(){
return
tslib
.
__awaiter
(
this
,
void
0
,
void
0
,
function
(){
var
t
,
i
,
n
;
return
tslib
.
__generator
(
this
,
function
(
e
){
switch
(
e
.
label
){
case
0
:
t
=
0
,
i
=
this
.
goldBags
.
length
,
e
.
label
=
1
;
case
1
:
return
t
<
i
?((
n
=
this
.
goldBags
[
t
]).
remain
--
,
n
.
remain
<=
0
?(
this
.
goldBags
.
splice
(
t
,
1
),
t
--
,
i
--
,
this
.
nextToUpdateScore
=!
0
,[
4
,
n
.
playOpen
()]):[
3
,
3
]):[
3
,
4
];
case
2
:
e
.
sent
(),
this
.
frontContainer
.
removeChild
(
n
),
ObjectPool
.
recycleObject
(
PoolName
,
n
),
e
.
label
=
3
;
case
3
:
return
t
++
,[
3
,
1
];
case
4
:
return
[
2
]}})})},
e
.
prototype
.
onPlayerJumpOnTop
=
function
(){
this
.
nextToUpdateScore
&&
(
this
.
nextToUpdateScore
=!
1
,
this
.
scoreChange
(
4
),
playSound
(
"撞击钱袋音效"
))},
Object
.
defineProperty
(
e
.
prototype
,
"blockCount"
,{
get
:
function
(){
return
this
.
index
-
props
.
initBlockCount
+
1
},
enumerable
:
!
1
,
configurable
:
!
0
}),
Object
.
defineProperty
(
e
.
prototype
,
"pos"
,{
get
:
function
(){
return
this
.
_pos
},
set
:
function
(
e
){
this
.
_pos
=
e
,
this
.
updatePos
()},
enumerable
:
!
1
,
configurable
:
!
0
}),
e
.
prototype
.
updatePos
=
function
(){
this
.
frontContainer
.
y
=
this
.
stage
.
height
+
this
.
_pos
},
e
.
prototype
.
onEnterFrame
=
function
(
e
){
var
t
,
i
,
n
,
o
,
s
,
r
,
a
,
h
,
p
,
l
,
c
;
this
.
needHitTest
&&
this
.
currentBlock
&&
(
i
=
(
t
=
this
.
currentBlock
).
x
,
n
=
t
.
y
,
o
=
t
.
dir
,
r
=
(
s
=
this
.
player
).
x
,
a
=
s
.
y
,
h
=
props
.
blockHitWidth
,
p
=
props
.
blockHitHeight
,
l
=
props
.
playerWidth
,
c
=!
1
,
Math
.
abs
(
r
-
i
)
<
(
h
+
l
)
/
2
&&
(
this
.
player
.
changeBaseY
(
n
-
p
),
n
-
p
<
a
&&
(
c
=!
0
)),
c
&&
this
.
onHitOn
(
o
))},
e
.
prototype
.
onHitOn
=
function
(
t
){
return
tslib
.
__awaiter
(
this
,
void
0
,
void
0
,
function
(){
return
tslib
.
__generator
(
this
,
function
(
e
){
switch
(
e
.
label
){
case
0
:
return
this
.
_touchEnabled
=!
1
,
this
.
needHitTest
=!
1
,
clearInterval
(
this
.
timer
),
this
.
currentBlock
.
playHit
(),
this
.
_playerShadow
.
visible
=!
1
,[
4
,
this
.
player
.
hitAway
(
t
)];
case
1
:
return
e
.
sent
(),[
4
,
this
.
player
.
parachute
(
t
)];
case
2
:
return
e
.
sent
(),
console
.
log
(
"jump-high-game-end"
),
engine
.
globalEvent
.
dispatchEvent
(
"jump-high-game-end"
),[
2
]}})})},
e
.
prototype
.
jump
=
function
(){
return
tslib
.
__awaiter
(
this
,
void
0
,
void
0
,
function
(){
var
t
,
i
,
n
,
o
,
s
=
this
;
return
tslib
.
__generator
(
this
,
function
(
e
){
switch
(
e
.
label
){
case
0
:
return
this
.
_touchEnabled
?(
this
.
_playerShadow
.
visible
=!
1
,
this
.
_touchEnabled
=!
1
,
this
.
playOpenGoldBag
(),[
4
,
this
.
player
.
jump
()]):[
2
];
case
1
:
return
(
t
=
e
.
sent
())?
t
.
aboveBlock
?(
i
=
Math
.
abs
(
this
.
currentBlock
.
x
),(
n
=
0
)
<
i
&&
(
n
=
0
<
i
&&
i
<
props
.
scoreThreshold
?
2
:
3
),
o
=
this
.
lastLandType
,
0
===
(
this
.
lastLandType
=
n
)
&&
o
!==
n
&&
(
n
=
1
),
n
<
3
&&
this
.
currentBlock
.
playEffect
(),
0
===
n
&&
this
.
currentBlock
.
playProFect
(),
3
!=
n
&&
(
this
.
_playerShadow
.
visible
=!
0
),
this
.
_playerShadow
.
y
=
this
.
player
.
y
+
props
.
playerShadowOffset
,
this
.
player
.
playLand
(
n
,
this
.
currentBlock
.
dir
),
this
.
currentBlock
.
stop
(),
this
.
scoreChange
(
n
),[
4
,
this
.
playShake
()]):[
3
,
4
]:[
3
,
5
];
case
2
:
return
e
.
sent
(),[
4
,
new
Promise
(
function
(
e
){
engine
.
Tween
.
get
(
s
,
null
,
null
,
!
0
).
to
({
pos
:
props
.
blockHitHeight
*
s
.
index
},
300
,
engine
.
Ease
.
cubicOut
).
call
(
e
)})];
case
3
:
e
.
sent
(),
this
.
addBlock
(),
e
.
label
=
4
;
case
4
:
this
.
_touchEnabled
=!
0
,
e
.
label
=
5
;
case
5
:
return
[
2
]}})})},
e
.
prototype
.
scoreChange
=
function
(
e
){
var
t
=
props
.
scoreWeights
[
e
];
this
.
_score
+=
t
,
this
.
_remainToShowGoldBag
-=
t
;
var
i
=
this
.
_score
;
engine
.
globalEvent
.
dispatchEvent
(
"jump-high-score"
,{
type
:
e
,
score
:
i
,
scoreAdd
:
t
}),
this
.
scoreAddTipsContainer
.
y
=
this
.
player
.
y
+
props
.
scoreAddTipsOffset
,
this
.
setScoreText
(
"+"
+
t
),
this
.
jumpTips
.
y
=
this
.
player
.
y
+
props
.
jumpTipsOffset
.
y
,
this
.
jumpTips
.
show
(),
console
.
log
(
i
,
this
.
_remainToShowGoldBag
),
this
.
_remainToShowGoldBag
<=
0
&&
(
this
.
_remainToShowGoldBag
+=
props
.
goldBagScoreMultiple
,
this
.
addGoldBag
(),
console
.
log
(
"addGoldBag"
))},
e
.
prototype
.
playHitEffect
=
function
(
e
){
var
t
=
this
.
hitEffect
;
t
.
scaleX
=
e
,
t
.
y
=
this
.
player
.
y
-
props
.
hitEffectAnchor
.
y
,
t
.
play
(
!
0
,
!
1
),
t
.
once
(
engine
.
Event
.
END_FRAME
,
function
(){
this
.
frontContainer
.
removeChild
(
t
)},
this
),
this
.
frontContainer
.
addChild
(
t
)},
e
.
prototype
.
playZoom
=
function
(
i
,
n
){
var
o
=
this
;
void
0
===
n
&&
(
n
=
700
),
this
.
background
.
playZoom
(
i
,
n
);
var
s
=
this
.
stage
.
height
/
props
.
blockHitHeight
;
return
new
Promise
(
function
(
e
){
o
.
frontContainer
.
anchorY
=-
props
.
blockHitHeight
*
(
o
.
index
+
1.3
*
s
)
+
props
.
baseOffset
;
var
t
=
"in"
===
i
?
1
:
Math
.
min
(
o
.
stage
.
height
/
props
.
blockHitHeight
/
(
o
.
index
+
s
),
props
.
maxScale
);
console
.
log
(
t
),
engine
.
Tween
.
get
(
o
.
frontContainer
,
null
,
null
,
!
0
).
to
({
scaleX
:
t
,
scaleY
:
t
},
n
,
engine
.
Ease
.
cubicInOut
).
call
(
e
)})},
e
.
prototype
.
playShake
=
function
(){
var
t
=
this
,
e
=
this
.
frontContainer
,
i
=
e
.
x
,
n
=
e
.
y
;
return
new
Promise
(
function
(
e
){
engine
.
Tween
.
get
(
t
.
frontContainer
,
null
,
null
,
!
0
).
to
({
x
:
i
,
y
:
n
-
7
},
30
).
to
({
x
:
i
,
y
:
n
+
7
},
30
).
to
({
x
:
i
+
7
,
y
:
n
},
30
).
to
({
x
:
i
-
7
,
y
:
n
},
30
).
to
({
x
:
i
,
y
:
n
},
30
).
call
(
e
)})},
e
}(
engine
.
Container
),
JumpHigh
=
function
(
i
){
function
e
(){
var
e
=
i
.
call
(
this
)
||
this
;
engine
.
globalEvent
.
addEventListener
(
"jump-high-reset"
,
e
.
reset
,
e
),
engine
.
globalEvent
.
addEventListener
(
"jump-high-start"
,
e
.
start
,
e
),
engine
.
globalEvent
.
addEventListener
(
"jump-high-pause"
,
e
.
pause
,
e
),
engine
.
globalEvent
.
addEventListener
(
"jump-high-resume"
,
e
.
resume
,
e
),
engine
.
globalEvent
.
addEventListener
(
"jump-high-revive"
,
e
.
revive
,
e
),
e
.
addEventListener
(
engine
.
MouseEvent
.
MOUSE_DOWN
,
e
.
onTap
,
e
);
var
t
=
e
.
_gameView
=
new
GameView
;
return
e
.
addChild
(
t
),
e
}
return
tslib
.
__extends
(
e
,
i
),
e
.
prototype
.
reset
=
function
(){
this
.
_gameView
.
reset
()},
e
.
prototype
.
start
=
function
(
e
){
injectProps
(
e
.
data
),
this
.
_status
=
1
,
this
.
_gameView
.
start
()},
e
.
prototype
.
pause
=
function
(){
this
.
_gameView
.
pause
()},
e
.
prototype
.
resume
=
function
(){
this
.
_gameView
.
resume
()},
e
.
prototype
.
revive
=
function
(){
this
.
_gameView
.
revive
()},
e
.
prototype
.
onTap
=
function
(
e
){
this
.
_gameView
.
jump
()},
e
}(
engine
.
Container
);
function
index
(
e
){
return
prepareProps
(),
injectProps
(
e
),
new
JumpHigh
}
module
.
exports
=
index
;
(
function
(
global
,
factory
)
{
typeof
exports
===
'object'
&&
typeof
module
!==
'undefined'
?
module
.
exports
=
factory
(
require
(
'tslib'
))
:
typeof
define
===
'function'
&&
define
.
amd
?
define
([
'tslib'
],
factory
)
:
(
global
=
global
||
self
,
global
[
'jump-high-3'
]
=
factory
(
global
.
tslib
));
}(
this
,
(
function
(
tslib
)
{
'use strict'
;
var
props
=
{};
function
prepareProps
()
{
var
metaProps
=
getProps
();
engine
.
injectProp
(
props
,
metaProps
);
}
function
injectProps
(
p
)
{
engine
.
injectProp
(
props
,
p
);
}
//# sourceMappingURL=props.js.map
function
getTexture
(
uuid
)
{
return
engine
.
Texture
.
from
(
getAssetByUUID
(
uuid
).
uuid
);
}
function
getTextureByName
(
name
)
{
return
getTexture
(
engine
.
getAssetByName
(
name
).
uuid
);
}
function
getBlockAsset
(
type
)
{
return
engine
.
getAssetByName
(
props
.
blockAssets
[
type
]);
}
function
getBlockHitAsset
(
type
)
{
console
.
log
(
"props.blockHitAssets"
,
props
.
blockHitAssets
);
return
engine
.
getAssetByName
(
props
.
blockHitAssets
[
type
]);
}
function
createSvga
(
name
,
anchorName
)
{
var
inst
=
new
svga
.
Svga
();
inst
.
source
=
'asset://'
+
engine
.
getAssetByName
(
name
).
uuid
;
var
anchor
=
props
[(
anchorName
)];
if
(
anchor
)
{
inst
.
x
=
-
anchor
.
x
;
inst
.
y
=
-
anchor
.
y
;
inst
.
anchorX
=
anchor
.
x
;
inst
.
anchorY
=
anchor
.
y
;
}
return
inst
;
}
function
playSound
(
name
)
{
engine
.
playSound
(
engine
.
getAssetByName
(
name
).
uuid
,
{
keep
:
true
});
}
//# sourceMappingURL=utils.js.map
var
Background
=
(
function
(
_super
)
{
tslib
.
__extends
(
Background
,
_super
);
function
Background
()
{
return
_super
.
call
(
this
)
||
this
;
}
Background
.
prototype
.
setup
=
function
()
{
var
_a
=
this
.
stage
,
width
=
_a
.
width
,
height
=
_a
.
height
;
var
bg
=
this
.
_bg
=
new
engine
.
Image
(
getTextureByName
(
'背景图'
));
bg
.
anchorX
=
bg
.
width
/
2
;
bg
.
anchorY
=
bg
.
height
/
2
;
bg
.
x
=
-
(
bg
.
width
-
width
)
/
2
;
bg
.
y
=
-
(
bg
.
height
-
height
)
/
2
;
this
.
addChild
(
bg
);
this
.
_minScale
=
width
/
bg
.
width
;
};
Background
.
prototype
.
playZoom
=
function
(
type
,
duration
)
{
var
_this
=
this
;
if
(
duration
===
void
0
)
{
duration
=
700
;
}
return
new
Promise
(
function
(
resolve
)
{
var
scale
=
type
===
'in'
?
1
:
_this
.
_minScale
;
engine
.
Tween
.
get
(
_this
.
_bg
,
null
,
null
,
true
)
.
to
({
scaleX
:
scale
,
scaleY
:
scale
},
duration
,
engine
.
Ease
.
cubicInOut
)
.
call
(
resolve
);
});
};
return
Background
;
}(
engine
.
Container
));
//# sourceMappingURL=Background.js.map
var
Base
=
(
function
(
_super
)
{
tslib
.
__extends
(
Base
,
_super
);
function
Base
()
{
return
_super
.
call
(
this
,
getTextureByName
(
'底座'
))
||
this
;
}
Base
.
prototype
.
setup
=
function
()
{
this
.
x
=
-
(
this
.
width
)
/
2
;
};
Base
.
prototype
.
reset
=
function
()
{
this
.
y
=
-
props
.
baseOffset
;
};
return
Base
;
}(
engine
.
Image
));
//# sourceMappingURL=Base.js.map
var
Block
=
(
function
(
_super
)
{
tslib
.
__extends
(
Block
,
_super
);
function
Block
()
{
var
_this
=
_super
.
call
(
this
)
||
this
;
var
body
=
_this
.
body
=
new
svga
.
Svga
();
body
.
x
=
-
props
.
blockWidth
/
2
;
body
.
y
=
-
props
.
blockHitHeight
-
props
.
blockPaddingTop
;
_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
;
}
Block
.
prototype
.
reset
=
function
(
_a
)
{
var
type
=
_a
.
type
;
this
.
dir
=
Math
.
random
()
>
0.5
?
1
:
-
1
;
if
(
this
.
type
!=
type
)
{
this
.
type
=
type
;
var
asset
=
getBlockAsset
(
type
);
this
.
body
.
source
=
'asset://'
+
asset
.
uuid
;
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
.
body
.
gotoAndStop
(
1
);
this
.
bodyHit
.
gotoAndStop
(
1
);
this
.
bodyProfect
.
gotoAndStop
(
1
);
this
.
body
.
visible
=
true
;
this
.
bodyHit
.
visible
=
false
;
};
Block
.
prototype
.
playEnter
=
function
(
index
,
animation
)
{
var
_this
=
this
;
this
.
visible
=
true
;
this
.
x
=
this
.
dir
*
this
.
stage
.
width
;
var
_a
=
props
.
blockDurationRange
,
min
=
_a
[
0
],
max
=
_a
[
1
];
var
duration
=
Math
.
max
(
max
-
index
*
props
.
blockDurationStep
,
min
);
duration
=
duration
+
max
*
Math
.
random
()
*
props
.
blockDurationRandom
*
(
Math
.
random
()
>
0.5
?
1
:
-
1
);
return
new
Promise
(
function
(
resolve
)
{
if
(
animation
)
{
engine
.
Tween
.
get
(
_this
,
null
,
null
,
true
)
.
to
({
x
:
0
,
},
duration
)
.
call
(
resolve
);
}
else
{
_this
.
x
=
0
;
setTimeout
(
function
()
{
console
.
log
(
_this
.
body
);
},
200
);
resolve
();
}
});
};
Block
.
prototype
.
playLeave
=
function
()
{
this
.
visible
=
false
;
};
Block
.
prototype
.
playEffect
=
function
()
{
var
body
=
this
.
body
;
body
.
play
(
true
,
false
);
body
.
once
(
engine
.
Event
.
END_FRAME
,
function
()
{
body
.
gotoAndStop
(
1
);
},
this
);
};
Block
.
prototype
.
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
()
{
engine
.
Tween
.
removeTweens
(
this
);
};
return
Block
;
}(
engine
.
Container
));
//# sourceMappingURL=Block.js.map
var
GoldBag
=
(
function
(
_super
)
{
tslib
.
__extends
(
GoldBag
,
_super
);
function
GoldBag
()
{
var
_this
=
_super
.
call
(
this
)
||
this
;
_this
.
setup
();
return
_this
;
}
GoldBag
.
prototype
.
setup
=
function
()
{
var
avatar
=
this
.
avatar
=
new
engine
.
Sprite
(
getTextureByName
(
'钱袋-静态'
));
avatar
.
x
=
-
props
.
goldPackAvatarAnchor
.
x
;
avatar
.
y
=
-
props
.
goldPackAvatarAnchor
.
y
;
this
.
addChild
(
avatar
);
var
svga
=
this
.
svga
=
createSvga
(
'钱袋'
,
'goldPackAnchor'
);
svga
.
visible
=
false
;
this
.
addChild
(
svga
);
};
GoldBag
.
prototype
.
reset
=
function
(
data
)
{
this
.
y
=
data
.
y
;
this
.
avatar
.
visible
=
true
;
this
.
svga
.
visible
=
false
;
this
.
svga
.
gotoAndStop
(
1
);
this
.
remain
=
data
.
remain
;
};
GoldBag
.
prototype
.
playOpen
=
function
()
{
var
_this
=
this
;
this
.
avatar
.
visible
=
false
;
this
.
svga
.
visible
=
true
;
return
new
Promise
(
function
(
resolve
)
{
_this
.
svga
.
play
(
true
,
false
);
_this
.
svga
.
once
(
engine
.
Event
.
END_FRAME
,
function
()
{
this
.
svga
.
visible
=
false
;
resolve
();
},
_this
);
});
};
return
GoldBag
;
}(
engine
.
Container
));
//# sourceMappingURL=GoldBag.js.map
var
GuideLayer
=
(
function
(
_super
)
{
tslib
.
__extends
(
GuideLayer
,
_super
);
function
GuideLayer
()
{
var
_this
=
_super
.
call
(
this
)
||
this
;
_this
.
setup
();
return
_this
;
}
GuideLayer
.
prototype
.
setup
=
function
()
{
};
GuideLayer
.
prototype
.
show
=
function
(
id
,
options
)
{
var
_this
=
this
;
return
new
Promise
(
function
(
resolve
)
{
_this
.
visible
=
true
;
if
(
!
_this
.
guideMask
)
{
var
_a
=
_this
.
stage
,
width
=
_a
.
width
,
height
=
_a
.
height
;
var
guideMask
=
_this
.
guideMask
=
new
engine
.
Container
();
var
guideHole
=
new
engine
.
Image
(
getTextureByName
(
'引导遮罩'
));
guideHole
.
x
=
(
width
-
guideHole
.
width
)
/
2
;
guideHole
.
y
=
options
.
y
;
guideMask
.
addChild
(
guideHole
);
_this
.
createRect
(
guideMask
,
0
,
0
,
width
,
guideHole
.
y
);
_this
.
createRect
(
guideMask
,
0
,
guideHole
.
y
,
guideHole
.
x
,
guideHole
.
height
);
_this
.
createRect
(
guideMask
,
guideHole
.
x
+
guideHole
.
width
,
guideHole
.
y
,
width
-
guideHole
.
x
-
guideHole
.
width
,
guideHole
.
height
);
_this
.
createRect
(
guideMask
,
0
,
guideHole
.
y
+
guideHole
.
height
,
width
,
height
-
guideHole
.
y
-
guideHole
.
height
);
var
label
=
_this
.
label
=
new
engine
.
Label
();
label
.
fillColor
=
'white'
;
label
.
size
=
25
;
label
.
text
=
props
.
guideText
;
label
.
x
=
(
width
-
label
.
width
)
/
2
;
label
.
y
=
guideHole
.
y
+
guideHole
.
height
+
50
;
guideMask
.
addChild
(
label
);
_this
.
addChild
(
guideMask
);
}
_this
.
once
(
engine
.
MouseEvent
.
CLICK
,
function
()
{
this
.
visible
=
false
;
resolve
();
},
_this
);
});
};
GuideLayer
.
prototype
.
createRect
=
function
(
container
,
x
,
y
,
width
,
height
)
{
var
rect
=
new
engine
.
Rect
();
rect
.
x
=
x
;
rect
.
y
=
y
;
rect
.
width
=
width
;
rect
.
height
=
height
;
rect
.
fillColor
=
'black'
;
rect
.
alpha
=
0.7
;
container
.
addChild
(
rect
);
};
return
GuideLayer
;
}(
engine
.
Container
));
//# sourceMappingURL=GuideLayer.js.map
var
svgaAssets
=
{
aniReady
:
{
name
:
'准备立正'
,
dir
:
1
},
aniReady2
:
{
name
:
'准备立正'
,
dir
:
1
},
aniJump
:
{
name
:
'跳上升'
,
dir
:
1
},
aniFall
:
{
name
:
'跳下落'
,
dir
:
1
},
aniLandNormal
:
{
name
:
'普通着地'
,
dir
:
1
},
aniLandSide
:
{
name
:
'边缘着地'
,
dir
:
-
1
},
aniHit
:
{
name
:
'被撞开'
,
dir
:
-
1
},
aniParachute
:
{
name
:
'降落'
,
dir
:
-
1
},
aniLandPerfect
:
{
name
:
'完美着地_笑'
,
dir
:
1
},
};
var
Player
=
(
function
(
_super
)
{
tslib
.
__extends
(
Player
,
_super
);
function
Player
()
{
var
_this
=
_super
.
call
(
this
)
||
this
;
_this
.
g
=
props
.
gravity
;
_this
.
addEventListener
(
engine
.
Event
.
ENTER_FRAME
,
_this
.
onEnterFrame
,
_this
);
return
_this
;
}
Player
.
prototype
.
switchAni
=
function
(
name
,
dir
,
play
,
loop
)
{
var
_this
=
this
;
if
(
dir
===
void
0
)
{
dir
=
1
;
}
if
(
play
===
void
0
)
{
play
=
true
;
}
if
(
loop
===
void
0
)
{
loop
=
false
;
}
return
new
Promise
(
function
(
resolve
)
{
_this
.
scaleX
=
dir
;
if
(
_this
.
_aniName
!==
name
)
{
_this
.
_aniName
=
name
;
var
oldAni
=
_this
.
removeChild
(
_this
.
getChildByName
(
'body'
));
if
(
oldAni
)
{
oldAni
.
stop
();
}
var
ani
=
_this
.
_currentAni
=
_this
[
'ani'
+
name
];
_this
.
addChild
(
ani
);
if
(
play
)
{
ani
.
play
(
false
,
loop
);
if
(
loop
)
{
resolve
();
}
else
{
ani
.
once
(
engine
.
Event
.
END_FRAME
,
resolve
);
}
}
else
{
resolve
();
}
}
});
};
Player
.
prototype
.
setup
=
function
()
{
this
.
prefectEffect
=
createSvga
(
'完美着地特效'
,
'playerLandPrefectAnchor'
);
this
.
landEffect
=
createSvga
(
'着地特效'
,
'playerLandEffectAnchor'
);
for
(
var
key
in
svgaAssets
)
{
var
_a
=
svgaAssets
[
key
],
name
=
_a
.
name
,
dir
=
_a
.
dir
;
var
body
=
this
[
key
]
=
createSvga
(
name
,
key
.
replace
(
'ani'
,
'player'
)
+
'Anchor'
);
body
.
name
=
'body'
;
body
.
scaleX
=
dir
;
}
};
Player
.
prototype
.
reset
=
function
(
revive
)
{
this
.
x
=
0
;
this
.
rotation
=
0
;
this
.
scaleX
=
this
.
scaleY
=
1
;
this
.
_prefectLandCounting
=
0
;
engine
.
Tween
.
removeTweens
(
this
);
if
(
revive
)
{
this
.
switchAni
(
'Jump'
,
1
,
false
);
}
};
Player
.
prototype
.
playReady
=
function
()
{
var
_this
=
this
;
return
new
Promise
(
function
(
resolve
)
{
_this
.
switchAni
(
'Ready'
,
1
);
_this
.
_currentAni
.
once
(
engine
.
Event
.
END_FRAME
,
function
()
{
this
.
switchAni
(
'Ready2'
,
1
,
true
,
true
);
resolve
();
},
_this
);
});
};
Player
.
prototype
.
onEnterFrame
=
function
(
event
)
{
if
(
!
this
.
playing
)
{
return
;
}
this
.
vy
+=
this
.
g
;
this
.
y
+=
this
.
vy
;
if
(
this
.
vy
>
0
&&
this
.
_aniName
!==
'Fall'
)
{
this
.
dispatchEvent
(
'jump-on-top'
);
this
.
switchAni
(
'Fall'
);
}
if
(
this
.
y
>
this
.
baseY
)
{
this
.
y
=
this
.
baseY
;
this
.
playing
=
false
;
this
.
jumpPromise
&&
this
.
jumpPromise
({
aboveBlock
:
this
.
aboveBlock
,
});
this
.
jumpPromise
=
null
;
}
};
Player
.
prototype
.
changeBaseY
=
function
(
v
)
{
if
(
this
.
baseY
==
v
)
{
return
;
}
this
.
aboveBlock
=
true
;
this
.
baseY
=
v
;
};
Player
.
prototype
.
jump
=
function
()
{
var
_this
=
this
;
playSound
(
'跳起音效'
);
this
.
switchAni
(
'Jump'
,
1
,
false
);
this
.
_currentAni
.
play
(
false
,
false
);
this
.
aboveBlock
=
false
;
this
.
playing
=
true
;
this
.
baseY
=
this
.
y
;
this
.
vy
=
-
props
.
jumpSpeed
;
return
new
Promise
(
function
(
resolve
)
{
_this
.
jumpPromise
=
resolve
;
});
};
Player
.
prototype
.
playLand
=
function
(
type
,
dir
)
{
return
tslib
.
__awaiter
(
this
,
void
0
,
void
0
,
function
()
{
var
_a
,
prefectEffect_1
,
landEffect_1
;
return
tslib
.
__generator
(
this
,
function
(
_b
)
{
switch
(
_b
.
label
)
{
case
0
:
_a
=
type
;
switch
(
_a
)
{
case
0
:
return
[
3
,
1
];
case
1
:
return
[
3
,
4
];
case
2
:
return
[
3
,
4
];
case
3
:
return
[
3
,
5
];
}
return
[
3
,
6
];
case
1
:
this
.
_prefectLandCounting
++
;
playSound
(
'完美落地音效'
+
Math
.
min
(
4
,
this
.
_prefectLandCounting
));
prefectEffect_1
=
this
.
prefectEffect
;
this
.
addChildAt
(
prefectEffect_1
,
0
);
prefectEffect_1
.
gotoAndPlay
(
1
);
prefectEffect_1
.
once
(
engine
.
Event
.
END_FRAME
,
function
()
{
this
.
removeChild
(
prefectEffect_1
);
},
this
);
landEffect_1
=
this
.
landEffect
;
this
.
addChildAt
(
landEffect_1
,
0
);
landEffect_1
.
gotoAndPlay
(
1
);
landEffect_1
.
once
(
engine
.
Event
.
END_FRAME
,
function
()
{
this
.
removeChild
(
landEffect_1
);
},
this
);
return
[
4
,
this
.
switchAni
(
'LandPerfect'
)];
case
2
:
_b
.
sent
();
return
[
4
,
this
.
switchAni
(
'Ready2'
,
1
,
true
,
true
)];
case
3
:
_b
.
sent
();
return
[
3
,
6
];
case
4
:
this
.
_prefectLandCounting
=
0
;
playSound
(
'普通落地音效'
);
this
.
switchAni
(
'Ready2'
,
1
,
true
,
true
);
return
[
3
,
6
];
case
5
:
this
.
_prefectLandCounting
=
0
;
playSound
(
'边缘落地音效'
);
this
.
switchAni
(
'LandSide'
,
dir
);
return
[
3
,
6
];
case
6
:
return
[
2
];
}
});
});
};
Player
.
prototype
.
hitAway
=
function
(
dir
)
{
return
tslib
.
__awaiter
(
this
,
void
0
,
void
0
,
function
()
{
var
_this
=
this
;
return
tslib
.
__generator
(
this
,
function
(
_a
)
{
switch
(
_a
.
label
)
{
case
0
:
this
.
jumpPromise
&&
this
.
jumpPromise
();
this
.
jumpPromise
=
null
;
playSound
(
'被撞开音效'
);
this
.
switchAni
(
'Hit'
,
dir
);
this
.
vy
=
0
;
return
[
4
,
new
Promise
(
function
(
resolve
)
{
engine
.
Tween
.
get
(
_this
)
.
to
({
x
:
-
dir
*
props
.
hitAwayDistance
.
x
,
},
props
.
hitAwayDuration
,
engine
.
Ease
.
quartOut
);
engine
.
Tween
.
get
(
_this
)
.
to
({
y
:
_this
.
y
+
props
.
hitAwayDistance
.
y
,
},
props
.
hitAwayDuration
,
engine
.
Ease
.
cubicOut
)
.
call
(
resolve
);
})];
case
1
:
_a
.
sent
();
return
[
2
];
}
});
});
};
Player
.
prototype
.
parachute
=
function
(
dir
)
{
var
_this
=
this
;
this
.
switchAni
(
'Parachute'
,
dir
);
return
new
Promise
(
function
(
resolve
)
{
engine
.
Tween
.
get
(
_this
)
.
call
(
function
()
{
playSound
(
'降落伞下落音效'
);
})
.
to
({
y
:
_this
.
y
+
props
.
parachuteDistance
},
props
.
parachuteDuration
)
.
set
({
anchorOffsetY
:
0
})
.
call
(
resolve
);
});
};
return
Player
;
}(
engine
.
Container
));
//# sourceMappingURL=Player.js.map
var
ObjectPool
=
engine
.
ObjectPool
;
var
PoolName
=
'gold-bag'
;
ObjectPool
.
registerPool
(
PoolName
,
function
()
{
return
new
GoldBag
();
},
function
(
item
,
data
)
{
item
.
reset
(
data
);
});
var
GameView
=
(
function
(
_super
)
{
tslib
.
__extends
(
GameView
,
_super
);
function
GameView
()
{
var
_this
=
_super
.
call
(
this
)
||
this
;
_this
.
index
=
-
1
;
_this
.
goldBags
=
[];
_this
.
baseOffset
=
-
props
.
baseOffset
+
props
.
playerOffset
;
_this
.
once
(
engine
.
Event
.
ADDED_TO_STAGE
,
_this
.
setup
,
_this
);
return
_this
;
}
GameView
.
prototype
.
setup
=
function
()
{
if
(
this
.
_hasSetup
)
{
return
;
}
this
.
_hasSetup
=
true
;
var
_a
=
this
.
stage
,
width
=
_a
.
width
,
height
=
_a
.
height
;
var
background
=
this
.
background
=
new
Background
();
this
.
addChild
(
background
);
background
.
setup
();
var
frontContainer
=
this
.
frontContainer
=
new
engine
.
Container
();
frontContainer
.
x
=
width
/
2
;
this
.
addChild
(
frontContainer
);
var
guideLayer
=
this
.
guideLayer
=
new
GuideLayer
();
this
.
addChild
(
guideLayer
);
var
base
=
this
.
base
=
new
Base
();
frontContainer
.
addChild
(
base
);
base
.
setup
();
var
blockShadow
=
this
.
_blockShadow
=
new
engine
.
Image
(
getTextureByName
(
'方块阴影'
));
blockShadow
.
anchorX
=
blockShadow
.
width
/
2
;
blockShadow
.
anchorY
=
blockShadow
.
height
/
2
;
blockShadow
.
x
=
-
(
blockShadow
.
width
-
base
.
width
)
/
2
;
blockShadow
.
y
=
props
.
blockShadowOffset
;
base
.
addChild
(
blockShadow
);
var
blockContainer
=
this
.
blockContainer
=
new
engine
.
Container
();
frontContainer
.
addChild
(
blockContainer
);
var
player
=
this
.
player
=
new
Player
();
frontContainer
.
addChild
(
player
);
player
.
setup
();
player
.
addEventListener
(
'jump-on-top'
,
this
.
onPlayerJumpOnTop
,
this
);
var
playerShadow
=
this
.
_playerShadow
=
new
engine
.
Image
(
getTextureByName
(
'玩家阴影'
));
playerShadow
.
anchorX
=
playerShadow
.
width
/
2
;
playerShadow
.
anchorY
=
playerShadow
.
height
/
2
;
playerShadow
.
x
=
this
.
player
.
x
-
playerShadow
.
width
/
2
;
var
scoreAddTipsContainer
=
this
.
scoreAddTipsContainer
=
new
engine
.
Container
();
scoreAddTipsContainer
.
width
=
750
;
scoreAddTipsContainer
.
anchorX
=
scoreAddTipsContainer
.
width
/
2
;
scoreAddTipsContainer
.
anchorY
=
scoreAddTipsContainer
.
height
/
2
;
var
scoreAddTips
=
this
.
scoreAddTips
=
new
engine
.
Label
();
scoreAddTips
.
width
=
750
;
scoreAddTips
.
fillColor
=
props
.
scoreAddFontColor
;
scoreAddTips
.
textAlign
=
engine
.
TEXT_ALIGN
.
CENTER
;
scoreAddTips
.
size
=
props
.
scoreAddFontSize
;
scoreAddTips
.
alpha
=
0
;
scoreAddTips
.
text
=
"+0"
;
scoreAddTips
.
x
=
this
.
player
.
x
-
scoreAddTips
.
width
/
2
;
scoreAddTipsContainer
.
addChild
(
scoreAddTips
);
frontContainer
.
addChild
(
playerShadow
);
frontContainer
.
addChild
(
player
);
frontContainer
.
addChild
(
scoreAddTipsContainer
);
ObjectPool
.
recycleObject
(
PoolName
,
ObjectPool
.
getObject
(
PoolName
,
{
y
:
0
,
remain
:
0
,
}));
this
.
hitEffect
=
createSvga
(
'被撞烟雾'
,
'hitEffectAnchor'
);
this
.
pos
=
0
;
this
.
background
.
setup
();
this
.
addEventListener
(
engine
.
Event
.
ENTER_FRAME
,
this
.
onEnterFrame
,
this
);
this
.
reset
();
};
GameView
.
prototype
.
setScoreText
=
function
(
score
)
{
return
tslib
.
__awaiter
(
this
,
void
0
,
void
0
,
function
()
{
var
_this
=
this
;
return
tslib
.
__generator
(
this
,
function
(
_a
)
{
return
[
2
,
new
Promise
(
function
(
resolve
)
{
_this
.
scoreAddTips
.
text
=
score
;
_this
.
scoreAddTips
.
y
=
0
;
_this
.
scoreAddTips
.
alpha
=
1
;
engine
.
Tween
.
get
(
_this
.
scoreAddTips
,
null
,
null
,
true
)
.
to
({
y
:
-
100
,
alpha
:
0
},
500
,
engine
.
Ease
.
cubicInOut
)
.
call
(
resolve
);
})];
});
});
};
GameView
.
prototype
.
reset
=
function
(
revive
)
{
if
(
revive
===
void
0
)
{
revive
=
false
;
}
return
tslib
.
__awaiter
(
this
,
void
0
,
void
0
,
function
()
{
var
blockContainer
,
i
,
li
,
block
,
i
,
i
,
li
,
goldBag
;
return
tslib
.
__generator
(
this
,
function
(
_a
)
{
switch
(
_a
.
label
)
{
case
0
:
this
.
base
.
reset
();
this
.
index
=
-
1
;
this
.
_score
=
0
;
if
(
revive
)
;
else
{
this
.
pos
=
0
;
blockContainer
=
this
.
blockContainer
;
for
(
i
=
0
,
li
=
blockContainer
.
children
.
length
;
i
<
li
;
i
++
)
{
block
=
blockContainer
.
getChildAt
(
i
);
block
.
playLeave
();
}
}
for
(
i
=
0
;
i
<
props
.
initBlockCount
;
i
++
)
{
this
.
addBlock
(
false
);
}
for
(
i
=
0
,
li
=
this
.
goldBags
.
length
;
i
<
li
;
i
++
)
{
goldBag
=
this
.
goldBags
[
i
];
this
.
frontContainer
.
removeChild
(
goldBag
);
ObjectPool
.
recycleObject
(
PoolName
,
goldBag
);
}
this
.
goldBags
.
splice
(
0
);
this
.
playZoom
(
'in'
);
return
[
4
,
this
.
resetPlayer
(
revive
)];
case
1
:
_a
.
sent
();
return
[
2
];
}
});
});
};
GameView
.
prototype
.
resetPlayer
=
function
(
revive
)
{
if
(
revive
===
void
0
)
{
revive
=
false
;
}
return
tslib
.
__awaiter
(
this
,
void
0
,
void
0
,
function
()
{
return
tslib
.
__generator
(
this
,
function
(
_a
)
{
this
.
player
.
reset
(
revive
);
this
.
player
.
y
=
this
.
baseOffset
-
(
this
.
index
+
1
)
*
props
.
blockHitHeight
+
props
.
blockBaseOffset
;
return
[
2
];
});
});
};
GameView
.
prototype
.
start
=
function
(
revive
)
{
if
(
revive
===
void
0
)
{
revive
=
false
;
}
return
tslib
.
__awaiter
(
this
,
void
0
,
void
0
,
function
()
{
var
guideFlagKey
,
guideFlag
;
var
_this
=
this
;
return
tslib
.
__generator
(
this
,
function
(
_a
)
{
switch
(
_a
.
label
)
{
case
0
:
this
.
_playerShadow
.
y
=
this
.
player
.
y
+
props
.
playerShadowOffset
;
this
.
scoreAddTipsContainer
.
y
=
this
.
player
.
y
+
props
.
scoreAddTipsOffset
;
if
(
!!
revive
)
return
[
3
,
2
];
return
[
4
,
this
.
player
.
playReady
()];
case
1
:
_a
.
sent
();
_a
.
label
=
2
;
case
2
:
console
.
log
(
"开始"
);
guideFlagKey
=
'jump-high-guide_'
+
props
.
guideFlagKey
;
guideFlag
=
localStorage
.
getItem
(
guideFlagKey
);
if
(
!!
guideFlag
)
return
[
3
,
4
];
localStorage
.
setItem
(
guideFlagKey
,
'1'
);
return
[
4
,
this
.
guideLayer
.
show
(
''
,
{
y
:
this
.
stage
.
height
+
this
.
player
.
y
-
280
})];
case
3
:
_a
.
sent
();
_a
.
label
=
4
;
case
4
:
this
.
lastLandType
=
0
;
this
.
_remainToShowGoldBag
=
props
.
goldBagScoreMultiple
-
props
.
goldBagScoreSubtraction
;
this
.
_touchEnabled
=
true
;
setTimeout
(
function
()
{
_this
.
addBlock
();
},
100
);
engine
.
globalEvent
.
dispatchEvent
(
'jump-high-game-start'
);
return
[
2
];
}
});
});
};
GameView
.
prototype
.
pause
=
function
()
{
if
(
this
.
currentBlock
)
{
engine
.
Tween
.
pauseTweens
(
this
.
currentBlock
);
}
engine
.
Tween
.
pauseTweens
(
this
.
player
);
};
GameView
.
prototype
.
resume
=
function
()
{
if
(
this
.
currentBlock
)
{
engine
.
Tween
.
resumeTweens
(
this
.
currentBlock
);
}
engine
.
Tween
.
resumeTweens
(
this
.
player
);
};
GameView
.
prototype
.
revive
=
function
()
{
return
tslib
.
__awaiter
(
this
,
void
0
,
void
0
,
function
()
{
return
tslib
.
__generator
(
this
,
function
(
_a
)
{
switch
(
_a
.
label
)
{
case
0
:
this
.
blockContainer
.
getChildAt
(
this
.
index
).
visible
=
false
;
this
.
index
--
;
return
[
4
,
this
.
resetPlayer
(
true
)];
case
1
:
_a
.
sent
();
return
[
4
,
this
.
playZoom
(
'in'
)];
case
2
:
_a
.
sent
();
this
.
start
(
true
);
return
[
2
];
}
});
});
};
GameView
.
prototype
.
addBlock
=
function
(
animation
)
{
var
_this
=
this
;
if
(
animation
===
void
0
)
{
animation
=
true
;
}
this
.
index
++
;
var
blockContainer
=
this
.
blockContainer
;
var
block
;
if
(
blockContainer
.
children
.
length
>
this
.
index
)
{
block
=
blockContainer
.
getChildAt
(
this
.
index
);
block
.
visible
=
true
;
}
else
{
block
=
new
Block
();
blockContainer
.
addChildAt
(
block
,
0
);
}
blockContainer
.
addChildAt
(
block
,
0
);
block
.
reset
({
type
:
Math
.
floor
(
Math
.
random
()
*
props
.
blockAssets
.
length
),
});
block
.
y
=
this
.
baseOffset
-
this
.
index
*
props
.
blockHitHeight
+
props
.
blockBaseOffset
;
this
.
blockComplete
=
false
;
block
.
playEnter
(
this
.
index
,
animation
).
then
(
function
(
data
)
{
_this
.
blockComplete
=
true
;
});
if
(
animation
)
{
this
.
needHitTest
=
true
;
}
this
.
currentBlock
=
block
;
};
GameView
.
prototype
.
addGoldBag
=
function
()
{
var
goldBag
=
ObjectPool
.
getObject
(
PoolName
,
{
y
:
this
.
baseOffset
-
(
this
.
blockCount
+
props
.
goldBagDistance
+
props
.
goldBagJumpSubtraction
)
*
props
.
blockHitHeight
,
remain
:
props
.
goldBagDistance
,
});
this
.
frontContainer
.
addChild
(
goldBag
);
this
.
goldBags
.
push
(
goldBag
);
};
GameView
.
prototype
.
playOpenGoldBag
=
function
()
{
return
tslib
.
__awaiter
(
this
,
void
0
,
void
0
,
function
()
{
var
i
,
li
,
goldBag
;
return
tslib
.
__generator
(
this
,
function
(
_a
)
{
switch
(
_a
.
label
)
{
case
0
:
i
=
0
,
li
=
this
.
goldBags
.
length
;
_a
.
label
=
1
;
case
1
:
if
(
!
(
i
<
li
))
return
[
3
,
4
];
goldBag
=
this
.
goldBags
[
i
];
goldBag
.
remain
--
;
if
(
!
(
goldBag
.
remain
<=
0
))
return
[
3
,
3
];
this
.
goldBags
.
splice
(
i
,
1
);
i
--
;
li
--
;
this
.
nextToUpdateScore
=
true
;
return
[
4
,
goldBag
.
playOpen
()];
case
2
:
_a
.
sent
();
this
.
frontContainer
.
removeChild
(
goldBag
);
ObjectPool
.
recycleObject
(
PoolName
,
goldBag
);
_a
.
label
=
3
;
case
3
:
i
++
;
return
[
3
,
1
];
case
4
:
return
[
2
];
}
});
});
};
GameView
.
prototype
.
onPlayerJumpOnTop
=
function
()
{
if
(
this
.
nextToUpdateScore
)
{
this
.
nextToUpdateScore
=
false
;
this
.
scoreChange
(
4
);
playSound
(
'撞击钱袋音效'
);
}
};
Object
.
defineProperty
(
GameView
.
prototype
,
"blockCount"
,
{
get
:
function
()
{
return
this
.
index
-
props
.
initBlockCount
+
1
;
},
enumerable
:
false
,
configurable
:
true
});
Object
.
defineProperty
(
GameView
.
prototype
,
"pos"
,
{
get
:
function
()
{
return
this
.
_pos
;
},
set
:
function
(
v
)
{
this
.
_pos
=
v
;
this
.
updatePos
();
},
enumerable
:
false
,
configurable
:
true
});
GameView
.
prototype
.
updatePos
=
function
()
{
this
.
frontContainer
.
y
=
this
.
stage
.
height
+
this
.
_pos
;
};
GameView
.
prototype
.
onEnterFrame
=
function
(
event
)
{
if
(
this
.
needHitTest
)
{
if
(
this
.
currentBlock
)
{
var
_a
=
this
.
currentBlock
,
bx
=
_a
.
x
,
by
=
_a
.
y
,
dir
=
_a
.
dir
;
var
_b
=
this
.
player
,
px
=
_b
.
x
,
py
=
_b
.
y
;
var
blockHitWidth
=
props
.
blockHitWidth
,
blockHitHeight
=
props
.
blockHitHeight
,
playerWidth
=
props
.
playerWidth
;
var
hitOn
=
false
;
if
(
Math
.
abs
(
px
-
bx
)
<
(
blockHitWidth
+
playerWidth
)
/
2
)
{
this
.
player
.
changeBaseY
(
by
-
blockHitHeight
);
if
(
py
>
by
-
blockHitHeight
)
{
hitOn
=
true
;
}
}
if
(
hitOn
)
{
this
.
onHitOn
(
dir
);
}
}
}
};
GameView
.
prototype
.
onHitOn
=
function
(
dir
)
{
return
tslib
.
__awaiter
(
this
,
void
0
,
void
0
,
function
()
{
return
tslib
.
__generator
(
this
,
function
(
_a
)
{
switch
(
_a
.
label
)
{
case
0
:
this
.
_touchEnabled
=
false
;
this
.
needHitTest
=
false
;
clearInterval
(
this
.
timer
);
this
.
currentBlock
.
playHit
();
this
.
_playerShadow
.
visible
=
false
;
return
[
4
,
this
.
player
.
hitAway
(
dir
)];
case
1
:
_a
.
sent
();
return
[
4
,
this
.
player
.
parachute
(
dir
)];
case
2
:
_a
.
sent
();
console
.
log
(
'jump-high-game-end'
);
engine
.
globalEvent
.
dispatchEvent
(
'jump-high-game-end'
);
return
[
2
];
}
});
});
};
GameView
.
prototype
.
jump
=
function
()
{
return
tslib
.
__awaiter
(
this
,
void
0
,
void
0
,
function
()
{
var
result
,
pos
,
type
,
lastLandType
;
var
_this
=
this
;
return
tslib
.
__generator
(
this
,
function
(
_a
)
{
switch
(
_a
.
label
)
{
case
0
:
if
(
!
this
.
_touchEnabled
)
{
return
[
2
];
}
this
.
_playerShadow
.
visible
=
false
;
this
.
_touchEnabled
=
false
;
this
.
playOpenGoldBag
();
return
[
4
,
this
.
player
.
jump
()];
case
1
:
result
=
_a
.
sent
();
if
(
!
result
)
return
[
3
,
5
];
if
(
!
result
.
aboveBlock
)
return
[
3
,
4
];
pos
=
Math
.
abs
(
this
.
currentBlock
.
x
);
type
=
0
;
if
(
pos
>
0
)
{
type
=
pos
>
0
&&
pos
<
props
.
scoreThreshold
?
2
:
3
;
}
lastLandType
=
this
.
lastLandType
;
this
.
lastLandType
=
type
;
if
(
type
===
0
)
{
if
(
lastLandType
!==
type
)
{
type
=
1
;
}
}
if
(
type
<
3
)
{
this
.
currentBlock
.
playEffect
();
}
if
(
type
===
0
)
{
this
.
currentBlock
.
playProFect
();
}
if
(
type
!=
3
)
{
this
.
_playerShadow
.
visible
=
true
;
}
this
.
_playerShadow
.
y
=
this
.
player
.
y
+
props
.
playerShadowOffset
;
this
.
player
.
playLand
(
type
,
this
.
currentBlock
.
dir
);
this
.
currentBlock
.
stop
();
this
.
scoreChange
(
type
);
return
[
4
,
this
.
playShake
()];
case
2
:
_a
.
sent
();
return
[
4
,
new
Promise
(
function
(
resolve
)
{
engine
.
Tween
.
get
(
_this
,
null
,
null
,
true
)
.
to
({
pos
:
props
.
blockHitHeight
*
_this
.
index
},
300
,
engine
.
Ease
.
cubicOut
)
.
call
(
resolve
);
})];
case
3
:
_a
.
sent
();
this
.
addBlock
();
_a
.
label
=
4
;
case
4
:
this
.
_touchEnabled
=
true
;
_a
.
label
=
5
;
case
5
:
return
[
2
];
}
});
});
};
GameView
.
prototype
.
scoreChange
=
function
(
type
)
{
var
scoreAdd
=
props
.
scoreWeights
[
type
];
this
.
_score
+=
scoreAdd
;
this
.
_remainToShowGoldBag
-=
scoreAdd
;
var
score
=
this
.
_score
;
engine
.
globalEvent
.
dispatchEvent
(
'jump-high-score'
,
{
type
:
type
,
score
:
score
,
scoreAdd
:
scoreAdd
,
});
this
.
scoreAddTipsContainer
.
y
=
this
.
player
.
y
+
props
.
scoreAddTipsOffset
;
this
.
setScoreText
(
"+"
+
scoreAdd
);
console
.
log
(
score
,
this
.
_remainToShowGoldBag
);
if
(
this
.
_remainToShowGoldBag
<=
0
)
{
this
.
_remainToShowGoldBag
+=
props
.
goldBagScoreMultiple
;
this
.
addGoldBag
();
console
.
log
(
'addGoldBag'
);
}
};
GameView
.
prototype
.
playHitEffect
=
function
(
dir
)
{
var
hitEffect
=
this
.
hitEffect
;
hitEffect
.
scaleX
=
dir
;
hitEffect
.
y
=
this
.
player
.
y
-
props
.
hitEffectAnchor
.
y
;
hitEffect
.
play
(
true
,
false
);
hitEffect
.
once
(
engine
.
Event
.
END_FRAME
,
function
()
{
this
.
frontContainer
.
removeChild
(
hitEffect
);
},
this
);
this
.
frontContainer
.
addChild
(
hitEffect
);
};
GameView
.
prototype
.
playZoom
=
function
(
type
,
duration
)
{
var
_this
=
this
;
if
(
duration
===
void
0
)
{
duration
=
700
;
}
this
.
background
.
playZoom
(
type
,
duration
);
var
count
=
this
.
stage
.
height
/
props
.
blockHitHeight
;
return
new
Promise
(
function
(
resolve
)
{
_this
.
frontContainer
.
anchorY
=
-
props
.
blockHitHeight
*
(
_this
.
index
+
count
*
1.3
)
+
props
.
baseOffset
;
var
scale
=
type
===
'in'
?
1
:
Math
.
min
((
_this
.
stage
.
height
/
props
.
blockHitHeight
/
(
_this
.
index
+
count
)),
props
.
maxScale
);
console
.
log
(
scale
);
engine
.
Tween
.
get
(
_this
.
frontContainer
,
null
,
null
,
true
)
.
to
({
scaleX
:
scale
,
scaleY
:
scale
},
duration
,
engine
.
Ease
.
cubicInOut
)
.
call
(
resolve
);
});
};
GameView
.
prototype
.
playShake
=
function
()
{
var
_this
=
this
;
var
_a
=
this
.
frontContainer
,
x
=
_a
.
x
,
y
=
_a
.
y
;
return
new
Promise
(
function
(
resolve
)
{
var
shakeOffset
=
7
;
var
duration
=
30
;
engine
.
Tween
.
get
(
_this
.
frontContainer
,
null
,
null
,
true
)
.
to
({
x
:
x
,
y
:
y
-
shakeOffset
},
duration
)
.
to
({
x
:
x
,
y
:
y
+
shakeOffset
},
duration
)
.
to
({
x
:
x
+
shakeOffset
,
y
:
y
},
duration
)
.
to
({
x
:
x
-
shakeOffset
,
y
:
y
},
duration
)
.
to
({
x
:
x
,
y
:
y
},
duration
)
.
call
(
resolve
);
});
};
return
GameView
;
}(
engine
.
Container
));
var
JumpHigh
=
(
function
(
_super
)
{
tslib
.
__extends
(
JumpHigh
,
_super
);
function
JumpHigh
()
{
var
_this
=
_super
.
call
(
this
)
||
this
;
engine
.
globalEvent
.
addEventListener
(
'jump-high-reset'
,
_this
.
reset
,
_this
);
engine
.
globalEvent
.
addEventListener
(
'jump-high-start'
,
_this
.
start
,
_this
);
engine
.
globalEvent
.
addEventListener
(
'jump-high-pause'
,
_this
.
pause
,
_this
);
engine
.
globalEvent
.
addEventListener
(
'jump-high-resume'
,
_this
.
resume
,
_this
);
engine
.
globalEvent
.
addEventListener
(
'jump-high-revive'
,
_this
.
revive
,
_this
);
_this
.
addEventListener
(
engine
.
MouseEvent
.
MOUSE_DOWN
,
_this
.
onTap
,
_this
);
var
gameView
=
_this
.
_gameView
=
new
GameView
();
_this
.
addChild
(
gameView
);
return
_this
;
}
JumpHigh
.
prototype
.
reset
=
function
()
{
this
.
_gameView
.
reset
();
};
JumpHigh
.
prototype
.
start
=
function
(
event
)
{
{
injectProps
(
event
.
data
);
}
this
.
_status
=
1
;
this
.
_gameView
.
start
();
};
JumpHigh
.
prototype
.
pause
=
function
()
{
this
.
_gameView
.
pause
();
};
JumpHigh
.
prototype
.
resume
=
function
()
{
this
.
_gameView
.
resume
();
};
JumpHigh
.
prototype
.
revive
=
function
()
{
this
.
_gameView
.
revive
();
};
JumpHigh
.
prototype
.
onTap
=
function
(
event
)
{
this
.
_gameView
.
jump
();
};
return
JumpHigh
;
}(
engine
.
Container
));
//# sourceMappingURL=JumpHigh.js.map
function
index
(
props
)
{
prepareProps
();
injectProps
(
props
);
var
instance
=
new
JumpHigh
();
return
instance
;
}
//# sourceMappingURL=index.js.map
return
index
;
})));
//# sourceMappingURL=main.js.map
\ No newline at end of file
src/custom/jump-high-3/debug/main.js.map
View file @
eccf6925
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 @
eccf6925
...
...
@@ -135,7 +135,7 @@
"baseOffset"
:
{
"alias"
:
"底座偏移"
,
"type"
:
"number"
,
"default"
:
500
"default"
:
262
},
"playerOffset"
:
{
"alias"
:
"角色偏移"
,
...
...
src/custom/jump-high-3/src/game/GameView.ts
View file @
eccf6925
/**
* Created by rockyl on 2018/8/16.
*/
import
{
props
}
from
"../props"
;
import
{
Background
}
from
"./Background"
;
import
{
Base
}
from
"./Base"
;
import
Block
from
"./Block"
;
import
{
Background
}
from
"./Background"
;
import
{
GoldBag
}
from
"./GoldBag"
;
import
{
GuideLayer
}
from
"./GuideLayer"
;
import
Player
from
"./Player"
;
import
{
props
}
from
"../props"
;
import
{
createSvga
,
getTextureByName
,
playSound
}
from
"./utils"
;
import
{
Base
}
from
"./Base"
;
import
{
GuideLayer
}
from
"./GuideLayer"
;
import
{
GoldBag
}
from
"./GoldBag"
;
import
{
createSvga
,
getTextureByName
,
playSound
}
from
"./utils"
;
import
ObjectPool
=
engine
.
ObjectPool
;
import
{
JumpTips
}
from
"./JumpTips"
;
const
PoolName
:
string
=
'gold-bag'
;
...
...
@@ -37,7 +36,6 @@ export default class GameView extends engine.Container {
baseOffset
:
number
;
scoreAddTipsContainer
;
jumpTips
timer
;
...
...
@@ -124,11 +122,6 @@ export default class GameView extends engine.Container {
scoreAddTips
.
text
=
"+0"
;
scoreAddTips
.
x
=
this
.
player
.
x
-
scoreAddTips
.
width
/
2
;
scoreAddTipsContainer
.
addChild
(
scoreAddTips
);
let
jumpTips
=
this
.
jumpTips
=
new
JumpTips
()
jumpTips
.
setup
()
jumpTips
.
x
=
props
.
jumpTipsOffset
.
x
frontContainer
.
addChild
(
playerShadow
);
...
...
@@ -136,7 +129,6 @@ export default class GameView extends engine.Container {
frontContainer
.
addChild
(
scoreAddTipsContainer
);
frontContainer
.
addChild
(
jumpTips
);
ObjectPool
.
recycleObject
(
PoolName
,
ObjectPool
.
getObject
(
PoolName
,
{
y
:
0
,
...
...
@@ -209,7 +201,6 @@ export default class GameView extends engine.Container {
this
.
_playerShadow
.
y
=
this
.
player
.
y
+
props
.
playerShadowOffset
;
this
.
scoreAddTipsContainer
.
y
=
this
.
player
.
y
+
props
.
scoreAddTipsOffset
;
this
.
jumpTips
.
y
=
this
.
player
.
y
+
props
.
jumpTipsOffset
.
y
;
//this.setScoreText("+100")
if
(
!
revive
)
{
await
this
.
player
.
playReady
();
...
...
@@ -456,9 +447,6 @@ export default class GameView extends engine.Container {
this
.
scoreAddTipsContainer
.
y
=
this
.
player
.
y
+
props
.
scoreAddTipsOffset
;
this
.
setScoreText
(
`+
${
scoreAdd
}
`
)
this
.
jumpTips
.
y
=
this
.
player
.
y
+
props
.
jumpTipsOffset
.
y
;
this
.
jumpTips
.
show
()
console
.
log
(
score
,
this
.
_remainToShowGoldBag
);
if
(
this
.
_remainToShowGoldBag
<=
0
)
{
...
...
src/custom/jump-high-3/src/game/JumpTips.ts
deleted
100644 → 0
View file @
1399ae5c
/**
* Created by rockyl on 2020-01-21.
*/
import
{
getTextureByName
}
from
"./utils"
;
import
{
props
}
from
"../props"
;
export
class
JumpTips
extends
engine
.
Container
{
private
_bg
:
engine
.
Image
;
private
_jumpTipsLabel
:
engine
.
Label
;
private
_minScale
:
number
;
constructor
()
{
super
();
}
setup
()
{
// const {width, height} = this.stage;
this
.
width
=
124
;
this
.
height
=
93
;
let
bg
=
this
.
_bg
=
new
engine
.
Image
(
getTextureByName
(
'跳跃提示背景'
));
bg
.
width
=
this
.
width
;
bg
.
height
=
this
.
height
;
bg
.
anchorX
=
bg
.
width
/
2
;
bg
.
anchorY
=
bg
.
height
/
2
;
this
.
addChild
(
bg
);
//this._minScale = width / bg.width;
let
jumpTipsLabel
=
this
.
_jumpTipsLabel
=
new
engine
.
Label
();
jumpTipsLabel
.
width
=
this
.
width
;
jumpTipsLabel
.
height
=
this
.
height
;
jumpTipsLabel
.
anchorX
=
jumpTipsLabel
.
width
/
2
;
jumpTipsLabel
.
anchorY
=
jumpTipsLabel
.
height
/
2
;
jumpTipsLabel
.
fillColor
=
"#fc4454"
;
jumpTipsLabel
.
textAlign
=
engine
.
TEXT_ALIGN
.
CENTER
;
jumpTipsLabel
.
verticalAlign
=
engine
.
VERTICAL_ALIGN
.
MIDDLE
;
jumpTipsLabel
.
size
=
24
;
jumpTipsLabel
.
rotation
=-
26
;
jumpTipsLabel
.
text
=
"+00"
;
jumpTipsLabel
.
x
=
0
;
jumpTipsLabel
.
y
=
0
;
this
.
addChild
(
jumpTipsLabel
);
this
.
alpha
=
0
;
}
show
()
{
return
new
Promise
(
resolve
=>
{
this
.
_jumpTipsLabel
.
text
=
props
.
jumpTips
[
parseInt
((
Math
.
random
()
*
props
.
jumpTips
.
length
)
+
""
)]
this
.
alpha
=
1
;
engine
.
Tween
.
get
(
this
,
null
,
null
,
true
)
.
wait
(
800
)
.
to
({
alpha
:
0
},
200
,
engine
.
Ease
.
cubicInOut
)
.
call
(
resolve
);
})
}
}
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