Class: TonScene
ゲームのシーン(場面)遷移を管理します。
Interfaces
interface IScene
シーンクラスが実装すべきインターフェースです。
void Initialize(): 初期化処理void Terminate(): 終了処理void Update(GameTime gameTime): 更新処理void Draw(): 描画処理
Scene Template
class TonSceneTemplate
新しいシーンを作成するためのテンプレートクラスです(TonSceneTemplate.cs)。
このファイルをコピー&リネームし、クラス名を変更するだけですぐに新しいシーンとして利用できます。
Initialize(): リソース読み込みなどを記述する場所Terminate(): リソース破棄などを記述する場所Update(): ゲームロジックを記述する場所Draw(): 描画処理を記述する場所
Methods
void Change(IScene nextScene, float durationOut = 0.0f, float durationIn = -1.0f,
Color fadeColor = default)
指定したシーンへ遷移します。フェードアウト→フェードインのアニメーションを伴います。
nextScene: 次のシーンのインスタンスdurationOut: フェードアウト(暗転)にかかる時間(秒)durationIn: フェードイン(明転)にかかる時間(秒)。(省略時または負の値でdurationOutと同じ)fadeColor: フェードの色(デフォルトは黒)
Sample Code
// Implementation of a Scene
public class TitleScene : IScene
{
public void Initialize() { /* Load Resources */ }
public void Update(GameTime gameTime)
{
// Transition to GameScene when 'A' is pressed
if (Ton.Input.IsJustPressed("A"))
{
// Change scene over 1.0 seconds, fading through Black
Ton.Scene.Change(new GameScene(), 1.0f, Color.Black);
}
}
public void Draw() { /* Draw Title */ }
public void Terminate() { /* Cleanup */ }
}
// In Game1.Initialize()
// Set initial scene
Ton.Scene.Change(new TitleScene(), 0f); // Instant change