欢迎来到程序小院
打怪物
玩法:30秒内看到怪物点击鼠标左键敲打怪物,看看你能打掉多少个怪物,快去打怪物吧^^。
开始游戏https://www.ormcc.com/play/gameStart/215
html
<canvas width="800" height="600"></canvas>
css
canvas {
display: block;
touch-action: none;
user-select: none;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
width: 733px;
height: 550px;
}
js
function countobj(){
this.text;
this.create = function(){
var style = { font: "bold 28px Arial", fill: "#ffffff",boundsAlignH: "left"};
var x = 0;
var y =30;
var str = '打中'+score+'个怪物';
this.text = game.add.text(x,y,str,style);
this.text.setTextBounds(30, 0, 800, 600);
}
this.update = function(){
var str = '打中'+score+'个怪物';
this.text.setText(str);
}
this.create();
}
function overobj(){
this.s;
this.child;
this.g;
var me = this;
this.create = function(){
this.g = game.add.graphics(0,0);
this.g.beginFill(0x000000);
this.g.drawRect(0,0,800,600);
this.s = game.add.sprite(0,0,this.g.generateTexture());
this.g.kill();
this.s.alpha = 0;
this.child = game.add.sprite(0,0,"over");
this.child.anchor.set(0.5);
this.child.x = w/2;
this.child.y = h/2;
this.s.inputEnabled = true;
this.s.events.onInputDown.add(function(){
me.gameInit();
});
this.child.events.onInputDown.add(function(){
me.gameInit();
})
}
this.update = function(){
}
this.gameInit = function(){
time = 30;
score = 0;
me.s.kill();
me.child.kill();
}
this.create();
}
需要源码请关注添加好友哦^ ^
转载:欢迎来到本站,转载请注明文章出处
https://ormcc.com/