给十八岁的自己,canvas投篮小游戏_javascript技巧_脚本之家

本文实例为大家分享了H5
canvas投篮小游戏实现代码,供大家参考,具体内容如下

希望十八岁的你最爱的人是自己

     loading......    var backLayer,cLayer,enemy,gameOver=false,all=0,aim=0,bitmap,checkpoint=1; var point={x:100,y:250}; var imgList={}; var imgData=new Array( {name:'face',path:'../JQueryTest/images/L8.png'} ); function main(){ LLoadManage.load; LGlobal.box2d=new LBox2d(); backLayer=new LSprite(); addChild; //建立一组墙壁 //backLayer.graphics.drawRect(1,"#cc3300",[0,0,800,10],true,"#cc3300"); backLayer.graphics.drawRect(1,"#cc3300",[790,0,10,400],true,"#cc3300"); backLayer.graphics.drawRect(1,"#cc3300",[0,0,10,400],true,"#cc3300"); backLayer.graphics.drawRect(1,"#cc3300",[0,390,800,10],true,"#cc3300"); backLayer.graphics.drawRect(1,"#cc3300",[450,187,50,3],true,"#cc3300");//1 backLayer.graphics.drawRect(1,"#cc3300",[500,170,3,20],true,"#cc3300");//2 backLayer.graphics.drawRect(1,"#cc3300",[447,187,3,210],true,"#cc3300");//3 backLayer.graphics.drawRect(1,"#cc3300",[538,87,3,103],true,"#cc3300");//4 框半径35 backLayer.graphics.drawRect(1,"#cc3300",[541,137,70,3],true,"#cc3300");//5 backLayer.graphics.drawRect(1,"#cc3300",[611,137,3,263],true,"#cc3300");//6 cLayer=new LSprite(); backLayer.addChild; //通过顶点坐标数组,加入上下左右四面墙 var shapeArray=[ //[[0,0],[800,0],[800,10],[0,10]], [[790,0],[800,0],[800,400],[790,400]], [[0,0],[10,0],[10,400],[0,400]], [[0,390],[800,390],[800,400],[0,400]], [[450,187],[500,187],[500,190],[450,190]], [[500,170],[503,170],[503,190],[500,190]], [[447,187],[450,187],[450,397],[447,397]], [[538,87],[541,87],[541,190],[538,190]], [[541,137],[611,137],[611,140],[541,140]], [[611,137],[614,137],[614,400],[611,400]] ]; cLayer.addBodyVertices(shapeArray,0,0,0,0.5,0.4,0.5); //加入圆 用来添加点击事件来出现小球 circle=new LSprite(); backLayer.addChild; circle.graphics.drawArc(1,"#336699",[point.x,point.y,40,0,2*Math.PI,true,"#336699"]); //添加游戏说明栏 shuoming=new LTextField(); shuoming.x=20; shuoming.y=10; shuoming.text='点击左侧圆圈进行投篮,鼠标和圆心的距离控制投篮力度'; backLayer.addChild; //添加得分栏和命中率栏 defen=new LTextField(); defen.x=200; defen.y=100; defen.text='得分:0'; backLayer.addChild; mingzhong=new LTextField(); mingzhong.x=280; mingzhong.y=100; mingzhong.text='命中率:0%'; backLayer.addChild; //关卡显示 guanqia=new LTextField(); guanqia.x=120; guanqia.y=100; guanqia.text='关卡:'+checkpoint; backLayer.addChild; //加入鼠标事件 点击鼠标增加小球 backLayer.addEventListener(LMouseEvent.MOUSE_DOWN,createBox); //键盘事件 //LEvent.addEventListener(window,LKeyboardEvent.KEY_DOWN,down); } function createBox{ if*+*>40*40)return; var box01=new LSprite(); box01.name='mybox'; box01.x=e.selfX; box01.y=e.selfY; backLayer.addChild; box01.graphics.drawArc(1,"orange",[16,16,16,0,360*Math.PI/180],true,"orange"); box01.addBodyCircle; var angle=Math.atan2(e.offsetY-point.y,e.offsetX-point.x); var force=(Math.sqrt*+*/20)*330; var vec=new LGlobal.box2d.b2Vec2,force*Math.sin; box01.box2dBody.ApplyForce(vec,box01.box2dBody.GetWorldCenter{ if(box01.x<610&&box01.x>450&&box01.y<400&&box01.y>180){ checkpoint++; aim++; all++; defen.text='得分:'+aim; mingzhong.text='命中率:'+Math.floor+'%'; if{//第二关 rail=new LSprite(); backLayer.addChild; rail.graphics.drawRect(1,"#cc3300",[220,135,10,255],true,"#cc3300"); raill=new LSprite(); backLayer.addChild; raill.addBodyVertices([[[220,135],[230,135],[230,390],[220,390]]],0,0,0,0.5,0.4,0.5); }else if{//第三关 backLayer.removeChild; backLayer.removeChild; rail=new LSprite(); backLayer.addChild; rail.graphics.drawRect(1,"#cc3300",[220,35,10,355],true,"#cc3300"); raill=new LSprite(); backLayer.addChild; raill.addBodyVertices([[[220,35],[230,35],[230,390],[220,390]]],0,0,0,0.5,0.4,0.5); }else if{//第四关 backLayer.removeChild; backLayer.removeChild; rail=new LSprite(); backLayer.addChild; rail.graphics.drawRect(1,"#cc3300",[10,180,200,10],true,"#cc3300"); raill=new LSprite(); backLayer.addChild; raill.addBodyVertices([[[10,180],[220,180],[220,190],[10,190]]],0,0,0,0.5,0.4,0.5); }else if{//通关 checkpoint=4; alert; } guanqia.text='关卡:'+checkpoint; }else{ all++; mingzhong.text='命中率:'+Math.floor+'%'; } } setTimeout; } //键盘按下 移动枪口 function down{ if{//left point.x-=10; }else if{//right point.x+=10; }else if{//up point.y-=10; }else if{//down point.y+=10; } backLayer.removeChild; circle=new LSprite(); backLayer.addChild; circle.graphics.drawArc(1,"#336699",[point.x,point.y,40,0,2*Math.PI,true,"#336699"]); }  

希望十八岁的你每天都能吃到可口的食物

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

给十八岁的自己,canvas投篮小游戏_javascript技巧_脚本之家。希望十八岁的你每天都能穿上心爱的衣裳

希望十八岁的你可以在每个街口听见好听的歌

希望十八岁的你可以在每个阴天都能看场电影

希望十八岁的你还喜欢着那个作家的文字

希望十八岁的你会一样乐器还能有一道拿手菜

希望十八岁的你能好好照顾自己不要生病

希望十八岁的你不再有丢三落四的坏毛病

希望十八岁的你喜欢鲜艳的颜色

希望十八岁的你不用去揣测对面人的心思

希望十八岁的你不出挑也别被人群淹没

希望十八岁的你不经历恋爱的消遣和磨难

希望十八岁的你不要变得太成熟也别太幼稚

希望十八岁的你洒脱明朗没有灰暗的第二面

希望十八岁的你眼睛里只透着笑意和阳光

希望十八岁的你依然念旧但不恋旧

希望十八岁的你不掉进世俗的黑洞

希望十八岁的你不伤害别人对得起自己

希望十八岁的你坦坦荡荡与所有的恶人无关

希望十八岁的你看得清现实也做得起梦

希望十八岁的你不用忍受误解和苛责

希望十八岁的你身边没有任何人离开

希望十八岁之后的你可以和之前不一样

希望十八岁的你能够不留遗憾安安稳稳

希望十八岁的你永远庆幸你是你

希望在十九岁的你来到之前我们好好相处

发表评论

电子邮件地址不会被公开。 必填项已用*标注