特效描述:html5 手机游戏。html5双击页面 测试双击的时间间隔,测试你的手指灵活度。
代码结构
1. 引入JS
2. HTML代码
请点击右上角
点击【分享到朋友圈】
测测好友的反应能力吧!
var helptime=0;
function help(){
}
var mebtnopenurl = 'http://mp.weixin.qq.com/s?__biz=MjM5MDIzNzA3OQ==&mid=212363137&idx=1&sn=30a38c9e63cf9475bc55a6673b3ac397#rd';
var myscore=0;
window.shareData = {
"imgUrl": "http://mmbiz.qpic.cn/mmbiz/kG4NuD28mGictKFRXfZ0g7uqcLXTc8ObCL4X4wIDCiboe8U1LDNmd6RFs957EznDEbeHu04uTnIuBGzCRMgOOn0w/640",
"timeLineLink": "http://game.weixine.net/fksz/index.html",
"tTitle": "疯狂手指-根本停不下来,玩过之后我的手指已经不是我的了!",
"tContent": "在10秒内疯狂的点按钮,想赢?不容易。"
};
function goHome(){
window.location="http://game.weixine.net/fksz/index.html";
}
function dp_share(score){
if(score>0){
document.title = "10秒我能点"+score+"下!你行?你试试"
}
else{
document.title = "疯狂手指-根本停不下来,玩过之后我的手指已经不是我的了!"
}
document.getElementById("share").style.display="";
window.shareData.tTitle = document.title;
}
function dp_Ranking(){
window.location="http://game.weixine.net/fksz/index.html";
}
function showAd(){
}
function hideAd(){
}
document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
WeixinJSBridge.on('menu:share:appmessage', function(argv) {
WeixinJSBridge.invoke('sendAppMessage', {
"img_url": window.shareData.imgUrl,
"link": window.shareData.timeLineLink,
"desc": window.shareData.tContent,
"title": window.shareData.tTitle
}, onShareComplete);
});
WeixinJSBridge.on('menu:share:timeline', function(argv) {
WeixinJSBridge.invoke('shareTimeline', {
"img_url": window.shareData.imgUrl,
"img_width": "640",
"img_height": "640",
"link": window.shareData.timeLineLink,
"desc": window.shareData.tContent,
"title": window.shareData.tTitle
}, onShareComplete);
});
}, false);
function dp_submitScore(score){
dp_share(score);
/*
if(score<40){
if (confirm("")){
myCRdata.score = score;
myCRdata.scoreName = score+"步";
dp_share(score);
}
}
*/
}
function onShareComplete(res) {
document.location.href = mebtnopenurl;
}
var initial = 1000;
var count = initial;
var counter; //10 will run it every 100th of a second
var state = 0;
var total = 0;
if (localStorage.max) {
$('#best').html( '最好成绩:' + localStorage.max + ' 次');
}
function timer() {
if (count <= 0) {
clearInterval(counter);
state = 0;
$('#result_panel').show();
if ( !localStorage.max || parseInt(localStorage.max) < total) {
localStorage.max = total;
$('#best').html( '最好成绩:' + localStorage.max + ' 次');
}
localStorage.max = parseInt(localStorage.max) > total ? localStorage.max: total;
return;
}
count--;
displayCount(count);
}
function displayCount(count) {
var res = count / 100;
document.getElementById("timer").innerHTML = res.toPrecision(count.toString().length) + " 秒";
}
$(document).on('touchmove', function(e) {
e.preventDefault();
})
$('#button').on('touchstart', function () {
if (!state) {
state = 1;
counter = setInterval(timer, 10);
}
this.classList.add('active');
});
$('#button').on('touchend', function () {
if (state) {
total++;
$('#result').html(total + ' 次');
}
this.classList.remove('active');
});
// $('#stop').on('click', function () {
// clearInterval(counter);
// });
function reset() {
count = initial;
total = 0;
state = 0;
$('#result').html(total + ' 次');
$('#timer').html(10 + ' 秒');
}
$('#reset').on('touchend', function () {
reset();
$('#result_panel').hide();
});
$('#doShare').on('touchend', function () {
dp_share(total);
$('#result_panel').hide();
reset();
});
displayCount(initial);