0
我有一個簡單的遊戲,我有一個動畫圖像在屏幕上飛行,你點擊得分點。大約5秒後,圖像將飛離屏幕。我只是想通過任何必要的手段將它包含在div中。jquery設置一個邊界,所以動畫不會離開屏幕
$(document).ready(function() {
$('#cursor').animate({
top: '500px'
, left: '500px'
});
$('img').click(function() {
var randomNumber = Math.random();
console.log(randomNumber);
$('#output').html(function (i, val) {
return val * 1 + 10
});
$(this).animate({
top: '+=' + ((Math.random() * 500) - 400) + 'px'
, left: '+=' + ((Math.random() * 500) - 400) + 'px'
})
})
function explode() {
alert("TIME UP!");
}
setTimeout(explode, 10000);
});
這個解決方案只是一個CSS修復或需要在jQuery中完成嗎?
非常感謝你,要試一試。 –