Home php教程 php手册 微信公共账号营销工具 刮刮乐的开发

微信公共账号营销工具 刮刮乐的开发

May 25, 2016 pm 04:46 PM

因为公司要做一个项目活动在微信中要有这一样款游戏活动了,但自己不会写于是网上找到了一个作者写的方案下面我整理了一下可以用同时也分享给大家。

本来是不想写这篇博文的,但又怕网友被坑,我还是写一下。

下载 jquery扩展wScratchPad.js, 原站的页面打不开,我这里提供一个下载地址 http://www.phprm.com

然后(冷静),一些没节操的博主,直接转别人的文章,验证的过程都省了,应该坑了不是小白。我这里修正一下

在这个扩展里面,怎么才能过去用户的刮开的面积

$("#wScratchPad3").wScratchPad({
cursor:'',  //设置鼠标的样式
color:'gray' ,  //设置覆盖物的颜色,跟image2功能相斥
width:"300",
height:"100",
image: "" //顶部的图片
// 更多配置相关的选项请看源码
scratchUp : function (e, percent) {
    if (percent > 60) {
        alert("sss");
    }
}
});
Copy after login

从上面的代码,看的出来,这个跟网上所谓的教程不一样,这里获取刮开的范围用到函数不是

scratchMove()

而是

scratchUp()

为嘛?看源码

scratchFunc: function(e, $this, event)
{
    e.pageX = Math.floor(e.pageX - $this.canvas_offset.left);
    e.pageY = Math.floor(e.pageY - $this.canvas_offset.top);
    $this['scratch' + event](e, $this);
    if(this.settings.realtimePercent || event == "Up") {
        if($this.settings['scratch' + event]) $this.settings['scratch' + event].apply($this, [e, $this.scratchPercentage($this)]);
    }
}
Copy after login

这里这个获取函数绑定的UP 而不是move

注意这里的wScratchPad是1.4.4最新版。


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)