最新赞助活动温馨提示:自愿赞助服务器费用,学生和没有工作的整站资源免费下载!
头像

jQuery抛洒金币效果

来源:http://www.erdangjiade.com/ 沐浴春风 2015-11-28 05:29浏览(1813)

抛洒金币的效果主要是由jQuery的animate动画效果完成,也就是改变金币的运动轨迹,定时去执行,直到洒落到地面。

0、请不要问“在不在”之类的问题,有问题直接问!1、学生或暂时没有工作的童鞋,整站资源免费下载!2、¥9.9充值终身VIP会员,加我微信,826096331 拉你进VIP群学习!3、程序员加油,技术改变世界。在线 充值

jQuery抛洒金币效果
分类:其它特效 > 抽奖 难易:初级
查看演示

加我微信,拉你进VIP群学习:

下载资源 下载积分: 30 积分

口袋和金币

<div class="kodai">
    <img src="images/kd2.png" class="full" />
    <img src="images/kd1.png" class="empty" />
</div>

点击口袋,抛洒金币效果

$('.item1 div.kodai').on('click', function() {

    if (clicked === false) {
        $('.full').css({
            'display': 'none'
        });
        $('.empty').css({
            'display': 'block'
        });
        clicked = true;

        $('.item1 .clipped-box').css({
            'display': 'block'
        });
        // Apply to each clipped-box div.
        $('.clipped-box img').each(function() {
            var v = rand(120, 90),
                    angle = rand(80, 89),
                    theta = (angle * Math.PI) / 180,
                    g = -9.8;

            // $(this) as self
            var self = $(this);
            var t = 0,
                    z, r, nx, ny,
                    totalt = 10;
            var negate = [1, -1, 0],
                    direction = negate[Math.floor(Math.random() * negate.length)];

            var randDeg = rand(-5, 10),
                    randScale = rand(0.9, 1.1),
                    randDeg2 = rand(30, 5);

            // And apply those
            $(this).css({
                'transform': 'scale(' + randScale + ') skew(' + randDeg + 'deg) rotateZ(' + randDeg2 + 'deg)'
            });

            // Set an interval
            z = setInterval(function() {
                var ux = (Math.cos(theta) * v) * direction;
                var uy = (Math.sin(theta) * v) - ((-g) * t);
                nx = (ux * t);
                ny = (uy * t) + (0.25 * (g) * Math.pow(t, 2));
                if (ny < -40) {
                    ny = -40;
                }
                //$("#html").html("g:" + g + "bottom:" + ny + "left:" + nx + "direction:" + direction);
                $(self).css({
                    'bottom': (ny) + 'px',
                    'left': (nx) + 'px'
                });
                // Increase the time by 0.10
                t = t + 0.10;

                //跳出循环
                if (t > totalt) {
                    clicked = false;
                    first = true;
                    clearInterval(z);
                }
            }, 20);
        });
    }
});
标签: 抽奖金币
声明:本文为原创文章,如需转载,请注明来源erdangjiade.com并保留原文链接:https://www.erdangjiade.com/js/577.html
评论0
头像

友情提示:垃圾评论一律封号 加我微信:826096331拉你进VIP群学习群

1 2