我正在学习基于javascript的PHASER HTML5游戏开发框架,在此期间我遇到了这段我无法理解的代码
var BunnyDefender = {};
BunnyDefender.Boot = function(game) {};
BunnyDefender.Boot.prototype = {
preload: function()
{
//-----to load objects and units before we begin our game
this.load.image('preloadbar', 'images/loader_bar.png');
this.load.image('titleimage', 'images/TitleImage.png');
},
create: function()
{
this.input.addPointer();
this.stage.backgroundColor = '#171642';
this.state.start('Preloader'); // launches preloader from Boot.js
}
};
从我学到的关于 javascript 原型的知识中,为了向对象或构造函数添加任何方法,我们使用以下语法/示例:
function employee(name,jobtitle,born)
{
this.name=name;
this.jobtitle=jobtitle;
this.born=born;
}
var fred=new employee("Fred Flintstone","Caveman",1970);
employee.prototype.salary=null;
fred.salary=20000;
请帮忙 !!!