zoukankan      html  css  js  c++  java
  • 一段代码,给游戏添加统一的封面和旋屏提示

    (function(){

    function isMobile(){

    return navigator.userAgent.match(/android|iphone|ipod|blackberry|meego|symbianos|windowsphone/i);

    }

    var coverNode = document.createElement("div");

    coverNode.style.cssText = "position:absolute;z-index:1000000;left:0;top:0;background:#39445a url(../../cover/cover.jpg) no-repeat center center;"+window.innerWidth+"px;height:"+Math.max(window.innerHeight,window.document.documentElement.offsetHeight)+"px";

    coverNode.className = "common_cover";

    document.body.appendChild(coverNode);

    setTimeout(function(){coverNode.parentNode.removeChild(coverNode)},(COVER_SHOW_TIME || 3000));


    if(!isMobile()) return;

    document.addEventListener("touchmove",function(e){e.preventDefault();},false);

    var noticeNode = document.createElement("div");

    noticeNode.className = "common_notice";

    noticeNode.style.cssText = "position:absolute;z-index:999999;left:0;top:0;background:#39445a url(../../cover/rotate_tip.jpg) no-repeat center center;";

    document.body.appendChild(noticeNode);


    function checkCover(){

    window.scroll(0,0);

    var horizontal;

    if(window.orientation == 0 || window.orientation == 180){

    horizontal = false;

    }else if (window.orientation == -90 || window.orientation == 90){

    horizontal = true;

    }

    if(horizontal == (HORIZONTAL || false)){

    noticeNode.style.display = "none";

    }else{

    setTimeout(function(){

    noticeNode.style.width = window.innerWidth+"px";

    noticeNode.style.height = window.innerHeight+"px";

    noticeNode.style.display = "block";

    },(navigator.userAgent.match(/iphone|ipod|ios/i) ? 0 : 600));

    }

    }

    window.addEventListener("orientationchange",checkCover);

    window.addEventListener("load",checkCover);

    window.addEventListener("scroll",function(){coverNode.style.height=window.innerHeight+"px";coverNode.style.width=window.innerWidth+"px";noticeNode.style.height=window.innerHeight+"px"});

    })();


  • 相关阅读:
    shell 使用Seq算出1-100的奇数之和
    Shell脚本判断是否是闰年
    shell脚本之使用bc工具实现数值转换(浮点转二进制)
    shell脚本之函数的参数
    shell脚本之while
    大数据JAVA基础第十六天
    大数据JAVA基础第十五天
    大数据JAVA基础第十四天
    大数据JAVA基础第十三天
    大数据JAVA基础第十二天
  • 原文地址:https://www.cnblogs.com/cly84920/p/4426461.html
Copyright © 2011-2022 走看看