抛洒金币的效果主要是由jQuery的animate动画效果完成,也就是改变金币的运动轨迹,定时去执行,直到洒落到地面。
0、请不要问“在不在”之类的问题,有问题直接问!1、学生或暂时没有工作的童鞋,整站资源免费下载!2、¥9.9充值终身VIP会员,加我微信,826096331 拉你进VIP群学习!3、程序员加油,技术改变世界。在线 充值
口袋和金币
<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);
});
}
});
友情提示:垃圾评论一律封号 加我微信:826096331拉你进VIP群学习群