3

重なっているドロップ可能オブジェクトのアイソメ グリッドにドロップされているドラッグ可能オブジェクトがあります。ドロップ可能なものは灰色のタイル、img タグで、最初に添付された画像のように見えます。ドラッグ可能なオブジェクトがその上にある場合、それらは青色で強調表示されるように設定されています。

ドロップ可能なソースコードは次のとおりです。

        $(".sprite").droppable({
            drop: function(event,ui) {
                object_id = ui.draggable.attr("id").replace("sprite_","");
                set_action('move_object',$(this).attr("id"));
                set_target(object_id);
                ui.draggable.removeClass("holding");
            },
            over: function(event, ui) {
                $(this).attr("src",$(this).attr("src").replace('.png','-hover-blue.png'));
            },
            out: function(event, ui) {
                $(this).attr("src",$(this).attr("src").replace('-hover-blue.png','.png'));
            },
            tolerance: 'pointer'
        });

基本的には、a) 一度に 1 つのタイルを強調表示し、b) 強調表示されたタイルをオブジェクトがドロップされたものにしたいと考えています。

私はあらゆる種類の寛容を試みましたが、役に立ちませんでした。

画像:

i.imgur.com/dGx9X.png

i.imgur.com/vb1d9.png

4

1 に答える 1

2

ドラブブルがドロップ可能に移動するときは、他のすべてのドロップ可能を非アクティブにして、現在のドロップ可能をアクティブにする必要があります。次に、ドロップ効果をアクティブなドロップ可能にするのは簡単です。

オーバー関数で

$(".sprite").not($(this)).removeClass("over")
   .each(function(){
     $(this).attr("src",$(this).attr("src").replace('-hover-blue.png','.png'));
   });
$(this).addClass("over");

次に、ドロップで $(this) を $(".over") に置き換えます

于 2010-11-05T18:04:14.820 に答える