質問に回答するたびにランダムに生成される上記の合計に従って、ユーザーが正しい数字をクリックする必要があるモグラたたきスタイルのゲームを作成しています。私が抱えている問題は、ユーザーが必要な回答が実際に表示されるまでに長時間待たなければならない場合があり、何かが表示されるまでに約 10 秒かかる場合があることです。div をより頻繁に表示するにはアニメーションが必要ですが、これを実現する方法がわかりません。
number div のアニメーション属性は次のとおりです。
function randomFromTo(from, to) {
return Math.floor(Math.random() * (to - from + 1) + from);
}
function scramble() {
var children = $('#container').children();
var randomId = randomFromTo(1, children.length);
moveRandom("char" + randomId);
}
var currentMoving = [];
function moveRandom(id) {
// If this one's already animating, skip it
if ($.inArray(id, currentMoving) !== -1) {
return;
}
// Mark this one as animating
currentMoving.push(id);
var cPos = $('#container').offset();
var cHeight = $('#container').height();
var cWidth = $('#container').width();
var bWidth = $('#' + id).width();
var bHeight = $('#' + id).css('top', '395px').fadeIn(100).animate({
'top': '-55px'
}, AnimationSpeed).fadeOut(100);
maxWidth = cPos.left + cWidth - bWidth;
minWidth = cPos.left;
newWidth = randomFromTo(minWidth, maxWidth);
$('#' + id).css({
left: newWidth
}).fadeIn(1000, function () {
setTimeout(function () {
$('#' + id).fadeOut(1000);
// Mark this as no longer animating
var ix = $.inArray(id, currentMoving);
if (ix !== -1) {
currentMoving.splice(ix, 1);
}
window.cont++;
}, 1000);
});
}
現在の数字で長い待ち時間を過ごすのではなく、一度に設定された数の回答が常に画面に表示されるようにする方法を誰かに教えてもらえますか?