Jypeli  5
The simple game programming library
XnaSerialization.cs
Siirry tämän tiedoston dokumentaatioon.
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.IO;
6 
7 namespace Jypeli
8 {
9  public partial class FileManager
10  {
11  public LoadState BeginLoadContent( string assetName )
12  {
13  if ( Game.Instance == null )
14  throw new InvalidOperationException( "Content can not be loaded here, because the game has not been initialized." );
15 
16  StorageFile contentFile = Game.Instance.Content.Load<StorageFile>( assetName );
17  return new LoadState( contentFile, assetName );
18  }
19 
20  public T LoadContent<T>( T obj, string assetName )
21  {
22  if ( Game.Instance == null )
23  throw new InvalidOperationException( "Content can not be loaded here, because the game has not been initialized." );
24 
25  byte[] contentData = Game.Instance.Content.Load<byte[]>( assetName );
26  MemoryStream contentStream = new MemoryStream( contentData );
27  StorageFile contentFile = new StorageFile( assetName, contentStream );
28 
29  LoadState state = BeginLoad( contentFile, assetName );
30  T result = state.Load<T>( obj, "default" );
31  state.EndLoad();
32  return result;
33  }
34  }
35 }
object Load(object obj, Type type, string name)
Definition: LoadState.cs:80
T LoadContent< T >(T obj, string assetName)
LoadState BeginLoadContent(string assetName)
LoadState BeginLoad(string fileName)
static Game Instance
Definition: Game.cs:149
Peliluokka reaaliaikaisille peleille.
Definition: DebugScreen.cs:10
void EndLoad()
Definition: LoadState.cs:33