/// <summary> /// Load graphics content for the game. /// </summary> public override void Activate(bool instancePreserved) { if (!instancePreserved) { //LOAD MAZE maze = new Maze(GraphicsDevice); //ASSIGN some texture from content enemy_energy = (Texture2D)Maze.Content[CONFIG_SPRITE_BOTTOM + "enemy_live_full"]; enemy_livePoints = (Texture2D)Maze.Content[CONFIG_SPRITE_BOTTOM + "enemy_live_empty"]; player_energy = (Texture2D)Maze.Content[CONFIG_SPRITE_BOTTOM + "player_live_full"]; player_livePoints = (Texture2D)Maze.Content[CONFIG_SPRITE_BOTTOM + "player_live_empty"]; //Load texture touch control texControl = (Texture2D)Maze.Content["backgrounds/touchcontrol_arrow"]; texControlButton = (Texture2D)Maze.Content["backgrounds/touchcontrol_button"]; fontPrinceOfPersia_bigger = (FontFile)Maze.Content[CONFIG_FONTS + "princeofpersia_bigger"]; fontTexturePrinceOfPersia_bigger = (Texture2D)Maze.Content[CONFIG_FONTS + "princeofpersia_bigger_0"]; fontPrinceOfPersia_small = (FontFile)Maze.Content[CONFIG_FONTS + "princeofpersia_small"]; fontTexturePrinceOfPersia_small = (Texture2D)Maze.Content[CONFIG_FONTS + "princeofpersia_small_0"]; //NOW START FROM 1'LEVEL maze.player = new Player(this.GraphicsDevice, maze.CurrentLevel.StartRoom()); maze.player.MyRoom.StartNewLife(); // once the load has finished, we use ResetElapsedTime to tell the game's // timing mechanism that we have just finished a very long frame, and that // it should not try to catch up. ScreenManager.Game.ResetElapsedTime(); } }
public static FontFile Load(String filename) { #if ANDROID FontFile file; XmlSerializer deserializer = new XmlSerializer(typeof(FontFile)); using (Stream stream = Game.Activity.Assets.Open(filename)) { //TextReader tr = new StreamReader(stream); file = (FontFile)deserializer.Deserialize(stream); } return(file); using (var stream = TitleContainer.OpenStream(filename)) { System.Runtime.Serialization.Formatters.Binary.BinaryFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); file = (FontFile)formatter.Deserialize(stream); } return(file); #else XmlSerializer deserializer = new XmlSerializer(typeof(FontFile)); TextReader textReader = new StreamReader(filename); FontFile file = (FontFile)deserializer.Deserialize(textReader); textReader.Close(); return(file); #endif }
private void DrawShadowedString(FontFile font, string value, Vector2 position, Color color) { FontRenderer fontRender = new FontRenderer(fontPrinceOfPersia_small, fontTexturePrinceOfPersia_small); fontRender.DrawString(spriteBatch, position, value); //fontRender.DrawString(font, value, position + new Vector2(1.0f, 1.0f), Color.Black); //spriteBatch.DrawString(font, value, position, color); }
public FontRenderer(FontFile fontFile, Texture2D fontTexture) { _fontFile = fontFile; _texture = fontTexture; _characterMap = new Dictionary <char, FontChar>(); foreach (var fontCharacter in _fontFile.Chars) { char c = (char)fontCharacter.ID; _characterMap.Add(c, fontCharacter); } }
/// <summary> /// Load your graphics content. /// </summary> protected override void LoadContent() { // Load content belonging to the screen manager. //content = Game.Content; spriteBatch = new SpriteBatch(GraphicsDevice); //AMF how can load content?? //font = content.Load<SpriteFont>("fonts/PoP"); string fontFilePath = Path.Combine(content.RootDirectory, "fonts/princeofpersia_bigger.fnt"); fontFile = FontLoader.Load(fontFilePath); fontTexture = content.Load <Texture2D>("fonts/princeofpersia_bigger_0"); //blankTexture = content.Load<Texture2D>("backgrounds/main_background"); // Tell each of the screens to load their content. foreach (GameScreen screen in screens) { screen.Activate(false); } }