- - - - - - - - - -質問1: - - - - - - - - - - - -
私はSceneクラスを持っていて、...まあ...「シーン」と呼ばれるシーンの配列を作りたいです:
class Scene
{
public:
int id;
string title;
Image backgroundImage;
Scene( int id, string title, Image backgroundImage );
};
ゲーム ヘッダーの Game クラス内でシーン配列を宣言します。
Scene scenes[ 2 ];
次に、game.cpp ループ デ ループ内のシーンでポンピングを開始します。
scenes[ 0 ] = Scene();
新しいシーンを宣言せずに上記を実行できるのはなぜですか? 例えば:
scenes[ 0 ] = new Scene();
クラス Scene を public として宣言していないためでしょうか。それは静的または何かとして作成されますか?私は混乱しているスクービー!
- - - - - - - - - - 質問2 - - - - - - - - - - - -
シーンのプロパティをコンストラクターに渡すより良い方法はありますか...たとえば、javascript では次のようにします。
var Scene = function( properties )
{
this.id = properties.id;
this.string = properties.string;
this.backgroundImage = properties.backgroundImage;
}
var scenes = [
new Scene( {
id:0,
string:"a scene",
Image: new Image( ... )
} ),
new Scene( {
id:1,
string:"a scene 1",
Image: new Image( ... )
} ),
]
これは自己文書化になります..私のドリフトブラを捕まえますか?
- - - - - - ノート - - - - - - :
Scene[ 0 ] = Scene() と言うだけでオブジェクトの新しいインスタンスが宣言されることを知らなかったので、それを new として宣言する必要があると思いますか?