1

アニメーションの実行後にコードをリンクにたどらせようとしています。

アイデアは、「Gnoll」がボタンを押すと、リンクに移動するというものです。

これはこれまでの私のコードです:

内部にリンクがありません。

(また、ボタンの色は「ヒット」アニメーションの途中で変わるはずです。これまでのところ、私はそれで失敗しています)

$(document).ready(function(){


    $('.Homebutton').click(function(){

        $('.animateme').html('<img src="Construct2/Images/Gnoll_Running.gif" />');         
        $('.animateme').animate({
            left: '+=150',
        }, 800, function() {
            $('.animateme').html('<img src="Construct2/Images/Gnoll_Hit.gif" />');
        });
        $('.animateme').animate({
            left: '+=0',
        }, 500);

        $('.animateme').animate({
            left: '+=0',
        }, 500, function() {
            $('.animateme') .html('<img src="Construct2/Images/Gnoll_Resting_smaller.gif" />');
            });

    });

    $('#AddOnbutton').click(function(){
        $('.animateme').html('<img src="Construct2/Images/Gnoll_Running.gif" />');         
        $('.animateme').animate({
            left: '+=250',
        }, 1000, function() {
            $('.animateme').html('<img src="Construct2/Images/Gnoll_Hit.gif" />')

        });
        $('.animateme').animate({
            left: '+=0',
        }, 1000, function() {
            $('.animateme') .html('<img src="Construct2/Images/Gnoll_Resting_smaller.gif" />');
            $("#AddOnbutton").html('<img src="Construct2/Images/redbutton.png" />');
            });


    });

});

ご覧のとおり、コードは非常に基本的です。リンクは、最後のリンクから約 0.5 秒後にトリガーされます。

$('.animateme') .html('<img src="Construct2/Images/Gnoll_Resting_smaller.gif" />');
4

1 に答える 1

0

私はちょっと自分自身を見つけました:) まだ完璧ではありませんが、大丈夫です.

$('a.home').click(function(){
    var newLocation = $(this).attr('href');
        $('.animateme').html('<img src="Construct2/Images/Gnoll_Running.gif" />');         
        $('.animateme').animate({
            left: '+=150',
        }, 800, function() {
            $('.animateme').html('<img src="Construct2/Images/Gnoll_Hit.gif" />');
        });
        $('.animateme').animate({
            left: '+=0',
        }, 500);

        $('.animateme').animate({
            left: '+=0',
        }, 500, function() {
            $('.animateme') .html('<img src="Construct2/Images/Gnoll_Resting_smaller.gif" />');

            document.location = newLocation;
            });
            return false;     
    });
于 2012-07-09T14:29:47.137 に答える