记录立邦商城母亲节浇花js效果

本文介绍了一个交互式浇花游戏,玩家通过点击按钮开始游戏,使用水壶倒水来浇灌虚拟花朵。游戏设有奖励机制,包括激活水壶倒水状态、触发花开效果以及提供优惠券奖励。同时,展示了如何通过JavaScript实现游戏的互动性和奖励逻辑。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

$(document).ready(function(){
    window.active = false;
    $(".mothersday_button").click(function(){//开始浇花
        active = true;                 
        $(".mothersday_button").hide();
        $(".mothersday_flower").removeClass("cursor_change").addClass("cursor");  //水壶初始状态
        return false;
    });


    $(".mothersday_flower").mousedown(function(){    //水壶倒水状态         
        if( !active ) return;
        $(this).removeClass("cursor").addClass("cursor_change"); 
        });


    $(".mothersday_flower").mouseup(function(){//水壶回到初始状态        
        if( !active ) return;        
        setTimeout(function(){
             $(".mothersday_flower").removeClass("cursor_change").addClass("cursor");              
         }, 100); 
        var test = setTimeout(function(){
            showtime(); //4秒后,花开
        },1500); 
    });


    $(".get_coupon img").click(function(){  //弹框
        $(".get_coupon").remove();         
    });;


    window.showtime = function(){
        $(".success").fadeIn();
         setTimeout(function(){
             $(".success").remove();
         }, 800);
        $(".mothersday_flower").unbind("mousedown").unbind("mouseup");
        $(".mothersday_flower").removeClass("cursor").removeClass("cursor_change");
         $(".mothersday_flower").css('background','url(./images/index/kv/mothersday_flower_change.png)');
        setTimeout(function(){
              $(".get_coupon").fadeIn();
         }, 1500);        
    }
});
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值