2

私が完成させようとしているアニメーションは、下から出てきて、クリックすると爆発してテキストを表示するバブルに似ているはずです。

現在の効果は、次のコードによって作成されます。

jQuery('.bubble1').on('click', function () {
 jQuery(this).stop(true,true).hide('explode', { pieces: 75 } , 1000, function() {
  jQuery('.corpo-del-testo').show();
 });
});

効果を実証するために jsFiddle も作成しました

より良いバースト効果が欲しいのですが、解決策が見つかりません。誰かが同様の問題を抱えているか、より「現実的」な爆発のようなバブルを実現する方法を知っていますか? バーストのように。

前もって感謝します。

4

2 に答える 2

10

これは、私が作成した別のバブル ポップ エフェクトです。

http://jsfiddle.net/EkZBg

<div id="content">
  <div id="bubble"></div>
  <div id="dummy_debris" class="debris" />
</div>

<script>

$(function(){
  // Document is ready
  $("#bubble").on("click", function(e) {
    pop(e.pageX, e.pageY, 13);
  });
});

function r2d(x) {
    return x / (Math.PI / 180);
  }

  function d2r(x) {
    return x * (Math.PI / 180);
  }

  // Specify particle_count as 10 + Math.random()*10 to make things interesting!
  function pop(start_x, start_y, particle_count) {
    arr = [];
    angle = 0;
    particles = [];
    offset_x = $("#dummy_debris").width() / 2;
    offset_y = $("#dummy_debris").height() / 2;

    for (i = 0; i < particle_count; i++) {
      rad = d2r(angle);
      x = Math.cos(rad)*(80+Math.random()*20);
      y = Math.sin(rad)*(80+Math.random()*20);
      arr.push([start_x + x, start_y + y]);
      // You could use an IMG tag here instead to make the particles sprites
      z = $('<div class="debris" />');
      z.css({
        "left": start_x - offset_x,
        "top": start_y - offset_x
      }).appendTo($("#content"));
      particles.push(z);
      angle += 360/particle_count;
    }

    $.each(particles, function(i, v){
      $(v).show();
      $(v).animate({
        top: arr[i][1], 
        left: arr[i][0],
        width: 4, 
        height: 4, 
        opacity: 0
      }, 600, function(){
        $(v).remove()
      });
    });
  }
</script>

<style>
/* Add browser prefixes as-needed. See CSS3please.com */
.debris {
 display: none;   
 position: absolute;
 width: 28px;
 height: 28px;
 background-color: #ff00ff;
 opacity: 1.0;
 overflow: hidden;
 border-radius: 8px;
}

#bubble {
  position:absolute;
  background-color: #ff0000;
  left:150px;
  top:150px;
  width:32px;
  height:32px;
  border-radius: 8px;
  z-index: 9;
}
</style>
于 2013-04-05T20:57:55.640 に答える