現在、私のゲームは次のように動作します:
public class TheGame: Microsoft.Xna.Framework.Game
{
public static Level CurrentLevel;
private Level level1, level2, level3;
protected override void LoadContent()
{
level1 = new Level(//param);
level2 = new Level(//param);
level3 = new Level(//param);
}
protected override void Update(GameTime gameTime)
{
If(something)
LoadLevel(level1);
currentLevel.Update(gameTime);
//
}
LoadLevel(Level theLevel)
{
currentLevel = theLevel;
}
}
問題は、Update()を使用してcurrentLevelを変更すると、Level1も変更されることです。
For example :
Level1 has a crate with position (100,200).
if currentLevel.Update() modifies the crate's position (120,200),
that modifies the crate's position in CurrentLevel AND the crate's position in Level1.
したがって、Level1をリロードすると、レベルは元のlevel1とは異なります。
スタティックのせいですか?レベル1のクローンを作成する必要があるためですか?他に何かありますか?:s読み取り用のThx。