handjs触屏控制飞机发射子弹小游戏效果代码
代码语言:html
所属分类:游戏
代码描述:handjs触屏控制飞机发射子弹小游戏效果代码,触摸屏幕左侧的任何位置。 在您触摸屏幕的确切位置,它将显示一个简单但非常有效的键盘。 移动手指将更新虚拟触摸板,并将移动一个简单的太空飞船。 触摸屏幕右侧将显示一些红色圆圈,这些圆圈将生成一些从子弹飞出的子弹。
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!doctype html>
<html lang=en>
<head>
<meta charset=utf-8>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/hand.js"></script>
<style>
* {
-webkit-touch-callout: none;
/* prevent callout to copy image, etc when tap to hold */
-webkit-text-size-adjust: none;
/* prevent webkit from resizing text to fit */
/* make transparent link selection, adjust last value opacity 0 to 1.0 */
-webkit-tap-highlight-color: rgba(0,0,0,0);
-webkit-user-select: none;
/* prevent copy paste, to allow, change 'none' to 'text' */
-webkit-tap-highlight-color: rgba(0,0,0,0);
touch-action: none;
}
body {
background-color: #000000;
margin: 0px;
}
canvas {
background-color: #111133;
display: block;
position: absolute;
}
.container {
width: auto;
text-align: center;
background-color: #ff0000;
}
</style>
</head>
<body>
<div class="container">
<canvas id="canvasSurfaceGame"></canvas>
</div>
<script>
var Collection = function () {
this.count = 0;
this.collection = {};
this.add = function (key, item) {
if (this.collection[key] != undefined)
return undefined;
this.collection[key] = item;
return ++this.count
}
this.remove = function (key) {
if (this.collection[key] == undefined)
return undefined;
delete this.collection[key]
return --this.count
}
this.item = function (key) {
return this.collection[key];
}
this.forEach = function (block) {
for (key in this.collection) {
if (this.collection.hasOwnProperty(key)) {
block(this.collection[key]);
}
}
}
}
var Vector2 = function (x,y) {
this.x= x || 0;
this.y = y || 0;
};
Vector2.prototype = {
reset: function ( x, y ) {
this.x = x;
this.y = y;
return this;
},
toString : function (decPlaces) {
decPlaces = decPlaces || 3;
var scalar = Math.pow(10,decPlaces);
return "[" + Math.round (this.x * scalar) / scalar + ", " + Math.ro.........完整代码请登录后点击上方下载按钮下载查看
网友评论0