lufy's legend
标题:
《html5 canvas游戏开发实战》勘误汇总
[打印本页]
作者:
lufy
时间:
2013-5-18 09:08
标题:
《html5 canvas游戏开发实战》勘误汇总
这个帖子是勘误信息的汇总。
希望大家将所发现的书中的错误通过论坛或者邮件反馈给我。
作者:
lufy
时间:
2013-5-18 09:09
标题:
勘误列表
1.
代码清单1-7中
cxt.fillStyle="#FF0000";
cxt.fillRect(0,0,150,75);
复制代码
两个cxt改为ctx。
2.
第13页
1.6.1小节中最下面部分的代码
function MyClass(name,age){
this.name = name;
this.age = age;
this.toString() = function(){
alert(this.name + “:” + this.age);
};
};
复制代码
改为
function MyClass(name,age){
this.name = name;
this.age = age;
this.toString = function(){
alert(this.name + “:” + this.age);
};
};
复制代码
3.
第14页
【
经过测试,可以发现,我们已经成功地给
MyClass
增加了
toString
方法。另外,也可以用以下方式来添加方法,代码如下所示:
】下面的代码
cls1.toString() = function(){
alert(this.name + “:” + this.age);
};
复制代码
改为
cls1.toString = function(){
alert(this.name + “:” + this.age);
};
复制代码
4.
【
比如,下面的代码会出错:
】下面的代码
cls1.toString() = function(){
alert(this.name + “:” + this.age);
};
复制代码
改为
cls1.toString = function(){
alert(this.name + “:” + this.age);
};
复制代码
5.
第34页
代码清单2-17中最后一个注释【//设定文字大小为100px】改为【//设定文字大小为70px】
6.
作者:
遥远的眼眸
时间:
2016-5-5 10:22
本帖最后由 遥远的眼眸 于 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();
作者:
lufy
时间:
2016-5-5 11:45
遥远的眼眸 发表于 2016-5-5 10:22
大家好,我是一个新手。刚看到书中第17页。在
var proto=this.constructor.prototype;
if(!proto){
http://lufylegend.com/demo/test/128.html
这个是demo,自己测试一下,如果没出错就检查一下自己有没有写错了
如果出错,麻烦说明一下浏览器以及浏览器版本
欢迎光临 lufy's legend (http://lufylegend.com/forum/)
Powered by Discuz! X2.5