我做了一个老虎机游戏,有3个按钮,播放,停止,刷新..播放按钮开始旋转,停止按钮停止旋转所选图像,我只需要添加一个刷新按钮来刷新游戏,像它一样重新启动窗口刚刚打开。
<div id="buttons">
<div id="play" class="butn butn--stripe">spin</div>
<div id="setStopAt" class="butn butn--stripe">stop</div>
<div id="refresh" class="butn butn--stripe">refresh</div>
</div>
按钮的html声明
Game.prototype.restart = function() {
this.lastUpdate = new Date();
this.speed1 = this.speed2 = this.speed3 = SLOT_SPEED
// function locates id from items
function _find(items, id) {
for (var i = 0; i < items.length; i++) {
if (items[i].id == id)
return i;
}
}
// Clear stop locations
this.stopped1 = false;
this.stopped2 = false;
this.stopped3 = false;
// randomize reel locations
this.offset1 = -parseInt(Math.random(ITEM_COUNT)) * SLOT_HEIGHT;
this.offset2 = -parseInt(Math.random(ITEM_COUNT)) * SLOT_HEIGHT;
this.offset3 = -parseInt(Math.random(ITEM_COUNT)) * SLOT_HEIGHT;
$('#results').hide();
game.increaseSpeed();
this.state = 2;
}