zoukankan      html  css  js  c++  java
  • 组件的写成

    8.20更新

    quark.base.js结构很清晰,主要是一个main.js

    (function(){
        window.onload = function(){
            game.init();
        };
    
        var game = {}
    
        game.init = function(){}

      //还有很多game.someFunc = function(){...} })();

    在其他js,中比如掉下来的水果fruit.js,接篮子boy.js,里面的结构是:

    (function(){
    
    var Boy = game.Boy = function(props){}
    
    Q.inherit(Boy, Q.DisplayObjectContainer);
    //inherit的可能是其他的一些东西,Q.MovieClip
    
    Boy.prototype.init = function(){}
    //用到了prototype呢!!!!
    
    
    })();

    框架就是这个,但是具体的东西,还要再研究一下,怎么可以整体搭建起来,好赞!

    关键还是quark.base啊,写个框架才是王道!

    --------------------------------------------------------------------------------------------------------------------------------------

    上一次问球,说jquery是一种方式,用函数prototype什么的,是另外一种还给看了他很早之前写的。

     其实这个就是块级作用域嘛,带个参数啥的也不吓人,为了防止变量全局污染啥的--20140714

    看人家老的,两种我分不太清楚:

    似乎fancybox满足我的要求?感觉还不错的样子!!!!!!,但是这里面的参数是干什么的?

    (function (window, document, $, undefined) {
        //todo
    }(window, document, jQuery));

    还有这样写的,为啥呢?有啥区别?

    WebcamToy.Audio = (function (c) {
    }(WebcamToy));

    哈根达斯camera

    WebcamToy.Camera = (function () {
    })()

    lottery.js

    window.homeNav = {
        open:function(){
            //开始动画
            console.log("open");
        };
        close:function(){
            //结束动画
    
        };
    }

    定时器 ↓

    var WebcamToy = {};
    WebcamToy.RuntimeTimer=function(){
        var _this=this,endtime=180,current=0,timer;
    
        this.update=function(){
            current=0;
        }
    
        this.destroy=function(){
            clearInterval(timer);
            window.location.reload();
        }
    
        this.start=function(){
            timer=setInterval(function(){
                current++;
                if(current>=endtime){
                    _this.destroy();
                }
            },1000);
        }
    
        var _init=function(){
    
            this.start();
        }
    
        _init.apply(this,arguments);
    }

    //调用 20140917更新 拼图采用这种方式写模块
    window.RuntimeTimer=new WebcamToy.RuntimeTimer(); //直接调用了_init
    window.RuntimeTimer.update(); //单独调用里面的某个函数
  • 相关阅读:
    「ZJOI2019」&「十二省联考 2019」题解索引
    jmeter测试20个QPS下的响应时间-设置QPS限制
    Postman的基础使用
    Selenium如何定位动态id的元素?
    python+selenium:iframe框架中多种定位
    关于正则表达式
    项目关键路径
    paycharm导入webdriver包报错:module 'selenium.webdriver' has no attribute 'Firefox'
    随着firefox的迭代更新:FireBug不能用了?使用火狐Try Xpath插件替代Firebug和Firepath
    Python——连接操作数据库
  • 原文地址:https://www.cnblogs.com/della/p/3811398.html
Copyright © 2011-2022 走看看