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.
* */
}
我怎樣才能構建出良好的層次結構。我的意思是有些物體不會有所有這些和一些將。
感謝
好吧,我想學習繼承,而這樣做,但是這個心不是我所期待的感謝。 –