lufy's legend

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
楼主: lufy
打印 上一主题 下一主题

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

[复制链接]

37

主题

8

好友

9309

积分

诸侯王

Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15

跳转到指定楼层
楼主
发表于 2013-5-18 09:08:51 |只看该作者 |倒序浏览
这个帖子是勘误信息的汇总。
希望大家将所发现的书中的错误通过论坛或者邮件反馈给我。
不回答与技术和引擎不相关的问题
回复

使用道具 举报

37

主题

8

好友

9309

积分

诸侯王

Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15

沙发
发表于 2013-5-18 09:09:10 |只看该作者

勘误列表

1.
代码清单1-7中
  1. cxt.fillStyle="#FF0000";
  2. cxt.fillRect(0,0,150,75);
复制代码
两个cxt改为ctx。

2.
第13页
1.6.1小节中最下面部分的代码
  1. function MyClass(name,age){
  2.         this.name = name;
  3.         this.age = age;
  4.         this.toString() = function(){
  5.                 alert(this.name + “:” + this.age);
  6.         };
  7. };
复制代码
改为
  1. function MyClass(name,age){
  2.         this.name = name;
  3.         this.age = age;
  4.         this.toString = function(){
  5.                 alert(this.name + “:” + this.age);
  6.         };
  7. };
复制代码
3.
第14页
经过测试,可以发现,我们已经成功地给MyClass增加了toString方法。另外,也可以用以下方式来添加方法,代码如下所示:】下面的代码
  1. cls1.toString() = function(){
  2.         alert(this.name + “:” + this.age);
  3. };
复制代码
改为
  1. cls1.toString = function(){
  2.         alert(this.name + “:” + this.age);
  3. };
复制代码
4.
比如,下面的代码会出错:】下面的代码
  1. cls1.toString() = function(){
  2.         alert(this.name + “:” + this.age);
  3. };
复制代码
改为
  1. cls1.toString = function(){
  2.         alert(this.name + “:” + this.age);
  3. };
复制代码
5.
第34页
代码清单2-17中最后一个注释【//设定文字大小为100px】改为【//设定文字大小为70px】

6.

不回答与技术和引擎不相关的问题
回复

使用道具 举报

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();
回复

使用道具 举报

37

主题

8

好友

9309

积分

诸侯王

Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15

地板
发表于 2016-5-5 11:45:38 |只看该作者
遥远的眼眸 发表于 2016-5-5 10:22
大家好,我是一个新手。刚看到书中第17页。在
var proto=this.constructor.prototype;
if(!proto){

http://lufylegend.com/demo/test/128.html
这个是demo,自己测试一下,如果没出错就检查一下自己有没有写错了
如果出错,麻烦说明一下浏览器以及浏览器版本
不回答与技术和引擎不相关的问题
回复

使用道具 举报

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

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

Archiver|lufy's legend

GMT+8, 2024-4-20 16:27 , Processed in 0.048773 second(s), 24 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部