12 |
- var e=Object.defineProperty,t=(t,s,a)=>(((t,s,a)=>{s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a})(t,"symbol"!=typeof s?s+"":s,a),a);import{g as s,r as a,l as o,s as i,o as l,c as n,w as m,h as g,b as c,m as d,d as u,p as f,q as r,f as h,j as p,k as b}from"./index-22fb332c.js";import{H as w,_ as x}from"./Hilo.70feeeab.js";import{P as _,_ as y}from"./Page.692802d8.js";const v={Mixes:w.EventMixin,fire:w.EventMixin.fire,on:w.EventMixin.on,off:w.EventMixin.off,queue:null,bg:null,man:null,bom:null,ground:null,ready:null,over:null,numberGlyphs:null,birdAtlas:null,holdback:null,load:function(){let e="https://ssl.ycxxkj.com/demo_list/game_test1/dist/build/h5";var t=[{id:"bg",src:e+"/static/images/map.jpg"},{id:"man",src:e+"/static/images/man.png"},{id:"bom",src:e+"/static/images/bom.png"}];console.log("#debug#🚀 ~ file: Asset.ts:24 ~ resources:",t),this.queue=new w.LoadQueue,this.queue.add(t),this.queue.on("complete",this.onComplete.bind(this)),this.queue.start()},onComplete:function(e){console.log("#debug#🚀 ~ file: Asset.ts:33 ~ Asset onComplete: Asset"),this.bg=this.queue.get("bg").content,this.man=new w.TextureAtlas({image:this.queue.get("man").content,width:204,height:375,frames:{frameWidth:204,frameHeight:375,numFrames:13},sprites:{man:{from:0,to:12}}}),this.bom=new w.TextureAtlas({image:this.queue.get("bom").content,width:137,height:135.31,frames:{frameWidth:137,frameHeight:135.31,numFrames:16},sprites:{bom:{from:0,to:12}}}),this.queue.off("complete"),this.fire("complete")}};let L;console.log("#debug#🚀 ~ file: game.ts:2 ~ Hilo:",w),console.log("#debug#🚀 ~ file: game.ts:4 ~ Asset:",v);let G=200,T=1e3;class C{constructor(e,s=375,a=667){t(this,"stage"),t(this,"asset"),t(this,"bg"),t(this,"width"),t(this,"height"),t(this,"scale",.5),t(this,"man"),t(this,"bom"),this.stage=L=new w.Stage({renderType:"canvas",container:e,width:s,height:a,scaleX:this.scale,scaleY:this.scale}),this.width=s,this.height=a,v.on("complete",(()=>{v.off("complete"),this.init()})),v.load();var o=new w.Ticker(60);o.addTick(L),o.addTick(w.Tween),o.start()}init(){let e=v.bg;new w.Bitmap({id:"bg",image:e,rect:[0,0,1381,1043],x:0,y:0,scaleX:this.width/1381,scaleY:this.height/1043}).addTo(L),this.initMan()}initMan(){console.log("#debug#🚀 ~ file: game.ts:65 ~ Game ~ initMan ~ Asset.getman:",v.man),v.man.getSprite("man"),this.man=new w.Sprite({frames:v.man.getSprite("man"),x:600,y:500,scaleX:.5,scaleY:.5,interval:5,timeBased:!1,loop:!0,paused:!0,onUpdate:function(){}}).addTo(L),console.log("#debug#🚀 ~ file: game.ts:78 ~ Game ~ initMan ~ this.man:",this.man),this.bom=new w.Sprite({frames:v.bom.getSprite("bom"),x:400,y:400,scaleX:1,scaleY:1,interval:8,timeBased:!1,loop:!0,paused:!1,onUpdate:function(){}}).addTo(L),console.log("#debug#🚀 ~ file: game.ts:90 ~ Game ~ initMan ~ bom:",this.bom)}goLeft(){console.log("#debug#🚀 ~ file: game.ts:81 ~ Game ~ goLeft ~ goLeft:"),console.log("#debug#🚀 ~ file: game.ts:84 ~ Game ~ goLeft ~ this.man:before",this.man,{x:this.man.x-100});let e=this.man;e.paused=!1,w.Tween.to(e,{x:e.x-G},{duration:T,onComplete:function(){e.paused=!0,console.log("complete")}}),console.log("#debug#🚀 ~ file: game.ts:84 ~ Game ~ goLeft ~ this.man:after",this.man)}goRight(){console.log("#debug#🚀 ~ file: game.ts:81 ~ Game ~ goLeft ~ goLeft:"),console.log("#debug#🚀 ~ file: game.ts:84 ~ Game ~ goLeft ~ this.man:before",this.man,{x:this.man.x-100});let e=this.man;e.paused=!1,w.Tween.to(e,{x:e.x+G},{duration:T,onComplete:function(){e.paused=!0,console.log("complete")}}),console.log("#debug#🚀 ~ file: game.ts:84 ~ Game ~ goLeft ~ this.man:after",this.man)}goUp(){console.log("#debug#🚀 ~ file: game.ts:81 ~ Game ~ goLeft ~ goLeft:"),console.log("#debug#🚀 ~ file: game.ts:84 ~ Game ~ goLeft ~ this.man:before",this.man,{x:this.man.x-100});let e=this.man;e.paused=!1,w.Tween.to(e,{y:e.y-G},{duration:T,onComplete:function(){e.paused=!0,console.log("complete")}}),console.log("#debug#🚀 ~ file: game.ts:84 ~ Game ~ goLeft ~ this.man:after",this.man)}goDown(){console.log("#debug#🚀 ~ file: game.ts:81 ~ Game ~ goLeft ~ goLeft:"),console.log("#debug#🚀 ~ file: game.ts:84 ~ Game ~ goLeft ~ this.man:before",this.man,{x:this.man.x-100});let e=this.man;e.paused=!1,w.Tween.to(e,{y:e.y+G},{duration:T,onComplete:function(){e.paused=!0,console.log("complete")}}),console.log("#debug#🚀 ~ file: game.ts:84 ~ Game ~ goLeft ~ this.man:after",this.man)}startBom(){console.log("#debug#🚀 ~ file: game.ts:102 ~ Game ~ startBom ~ startBom:"),this.bom.x=parseInt((651*Math.random()).toString())+50,this.bom.y=parseInt((451*Math.random()).toString())+50,this.bom.paused=!1,this.bom.alpha=1}stopBom(){console.log("#debug#🚀 ~ file: game.ts:107 ~ Game ~ stopBom ~ stopBom:"),this.bom.paused=!0,this.bom.alpha=0}}const k=y(s({__name:"index",setup(e){let t;a("Hello");const s=()=>{t.goLeft()},w=()=>{t.startBom()},y=()=>{t.goUp()},v=()=>{t.goRight()},L=()=>{t.goDown()},G=()=>{t.stopBom()};return o((async()=>{i({title:"动画演示"}),await _.Yc.delay(100),(()=>{let e=document.getElementById("game-container"),s=f();console.log("#debug#🚀 ~ file: index.vue:22 ~ init ~ sysinfo:",s);let a=4*r(s.screenWidth),o=2*r(566/750*a);e.style.height=o/2+"px",e.style.width=a/2+"px",t=new C(e,a,o)})()})),(e,t)=>{const a=h,o=p(b("u-button"),x);return l(),n(a,{class:"page"},{default:m((()=>[g(a,{class:"canvas_box pos_r"},{default:m((()=>[c(' <view class="tc p20 titlebar">canvas演示</view> '),c(' <canvas id="canvasId" class="canvas" /> '),d("div",{id:"game-container",class:"bg_ff"})])),_:1}),g(a,null,{default:m((()=>[g(a,{class:"tl mt20 text_color_tips pl20"},{default:m((()=>[u("为方便演示动画,提供功能按钮看效果")])),_:1}),g(a,{class:"dis_flex_align_between_center p20"},{default:m((()=>[g(a,{class:"left dis_flex"},{default:m((()=>[g(o,{type:"primary",onClick:w,class:"w100"},{default:m((()=>[u("开炮")])),_:1}),g(o,{type:"primary",onClick:G,class:"ml30 w100"},{default:m((()=>[u("停炮")])),_:1})])),_:1}),g(a,{class:"w300 tc"},{default:m((()=>[g(o,{class:"w100",type:"primary",onClick:y},{default:m((()=>[u("向上")])),_:1}),g(a,{class:"dis_flex_align_between_center mt20 mb20"},{default:m((()=>[g(o,{type:"primary",class:"w100",onClick:s},{default:m((()=>[u("向左")])),_:1}),g(o,{type:"primary",class:"w100",onClick:v},{default:m((()=>[u("向右")])),_:1})])),_:1}),g(o,{type:"primary",class:"w100",onClick:L},{default:m((()=>[u("向下")])),_:1})])),_:1})])),_:1})])),_:1})])),_:1})}}}),[["__scopeId","data-v-d7fb647b"]]);export{k as default};
|