0
因此,我正在创建一个小游戏(以前从未这样做过),但它引起了我的注意并让我好奇,所以在这里。需要关于如何正确设计游戏的层次结构的建议我创建
我想设计游戏内物体的层次结构。
一些关于我到目前为止的对象。
/* this is the basic object - every object in game will have that */
var fnObject = function (node){
this.nNode = node || '';
this.id = '';
this.sType = 'pc'/*pc,npc,physics,obstacle*/;
this.oPosition = {
marginTop : 0,
marginLeft : 0
};
/*
* and more properties.
* */
}
/* not all objects will have those */
var fnPhysics = function(){
this.iFriction = '';
this.iAcceleration = '';
this.iGravity = '';
this.iWind = '';
this.iIncline = '';
this.iSpeed = 1;
this.iMoveDistant = 5;
/*
* and more properties.
* */
}
/* Only objects that can move will have those */
var fnControls = function(){
this.fnGetMvDist = function(){
//..
}
this.fnDoMove = function(){
//..
};
this.fnMoveRight = function(){
//..
}
}
/* not all objects will have those */
var fnStats = function(){
this.hp = 100;
this.manaLeft = 100;
this.livesLeft = 5;
/*
* and more properties.
* */
}
我怎样才能构建出良好的层次结构。我的意思是有些物体不会有所有这些和一些将。
感谢
好吧,我想学习继承,而这样做,但是这个心不是我所期待的感谢。 –