How to loop in a time interval of an animation in JQuery?

1

I have a Guitar Hero style animation and I would like to repeat the animation of the green note falling in a defined interval of time, however I am not able to ...

link

    
asked by anonymous 30.05.2014 / 23:25

1 answer

3

You need to create copies / clones of notes to be able to drop them again. What is happening now is that at the end of the animation the $('.nota_verde_cair') is removed and can not be reused ...

Here's a suggestion: link

function newgame() {
    $("#comecar").hide();
    $("div.teclas").css("margin-right", "393px");
    $("div.teclas").css("float", "right");
    $("div.bgplay").css("opacity", "1.0");
    hover();


    setInterval(verde, 7000); // para repetir a animaçao

    function verde() {
        inicio;
        acertos = 0;
        var notaVerde = $('.nota_verde_cair').clone(); // criar um clone
        $('div.bgplay').append(notaVerde);             // inserí-lo no documento

        function testarAcerto(e) {
            if (e.which == 51 && Math.round(valorAtual) > 0) {
                notaVerde.remove(); // usar o clone em vez do original
                acertos++;
                $(document).bind("keyup");
            }
        }

        notaVerde.fadeTo(500, 1);   // usar o clone em vez do original
        // etc, usando sempre o clone
    
30.05.2014 / 23:43