lufy's legend

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 19945|回复: 0
打印 上一主题 下一主题

《html5 canvas游戏开发实战》勘误汇总

[复制链接]

0

主题

0

好友

6

积分

士兵

Rank: 1

楼主
发表于 2016-5-5 10:22:47 |显示全部楼层
本帖最后由 遥远的眼眸 于 2016-5-5 10:27 编辑

大家好,我是一个新手。刚看到书中第17页。在
var proto=this.constructor.prototype;
if(!proto[prop]){
这两行均会报错。。怎么回事啊?
另外, proto[prop]["super"]=PeopleClass.prototype;这一行是什么意思啊?
function PeopleClass(){
                this.type="人";
        };
        PeopleClass.prototype={
                getType:function(){
                        alert("这是一个人");
                }
        };
        function StudentClass(name,sex){
                PeopleClass.apply(this,arguments);
                var prop;
                for(prop in PeopleClass.prototype){
                        var proto=this.constructor.prototype;
                        if(!proto[prop]){
                                proto[prop]=PeopleClass.prototype[prop];
                        }
                        proto[prop]["super"]=PeopleClass.prototype;
                }
                this.name=name;
                this.sex=sex;
        };
        var stu=new StudentClass("lufy","男");
        alert(stu.type);
        stu.getType();
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

防止垃圾广告,请填写任意字符

Archiver|lufy's legend

GMT+8, 2024-5-3 17:29 , Processed in 0.045206 second(s), 19 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部