public TileMapRenderer(GameScreen parentScreen, GameMap gameMap) { ParentScreen = parentScreen; _gameMap = gameMap; // Load up our texture if we need to _tilesetTexture = TextureLoader.GetTexture(@"Levels\castle.png", parentScreen.ScreenManager.GraphicsDevice); }
/// <summary> /// Removes a screen from the screen manager. You should normally /// use GameScreen.ExitScreen instead of calling this directly, so /// the screen can gradually transition off rather than just being /// instantly removed. /// </summary> public void RemoveScreen(GameScreen screen) { // If we have a graphics device, tell the screen to unload content. if (isInitialized) { screen.UnloadContent(); } screens.Remove(screen); screensToUpdate.Remove(screen); // if there is a screen still in the manager, update TouchPanel // to respond to gestures that screen is interested in. if (screens.Count > 0) { TouchPanel.EnabledGestures = screens[screens.Count - 1].EnabledGestures; } }
/// <summary> /// Adds a new screen to the screen manager. /// </summary> public void AddScreen(GameScreen screen, PlayerIndex? controllingPlayer) { screen.ControllingPlayer = controllingPlayer; screen.ScreenManager = this; screen.IsExiting = false; screen.UiManager = _ui; if (!_done) { var executionPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName); var width = GraphicsDevice.PresentationParameters.BackBufferWidth; var height = GraphicsDevice.PresentationParameters.BackBufferHeight; screen.UiManager.Initialize(GraphicsDevice, width, height, executionPath); _ui.webView.ConsoleMessage += WebViewOnConsoleMessage; //JSObject jsConsole = UiManager.webView.CreateGlobalJavascriptObject("console"); //jsConsole.Bind("log", false, JSConsoleLog); //jsConsole.Bind("dir", false, JSConsoleLog); if (Window != null) { InputSystem.Initialize(Window); InputSystem.CharEntered += CharEnteredHandler; InputSystem.KeyUp += KeyUpHandler; InputSystem.FullKeyHandler += FullKeyHandler; InputSystem.MouseMove += MouseMoveHandler; InputSystem.MouseDown += MouseDownHandler; InputSystem.MouseUp += MouseUpHandler; } _done = true; } // If we have a graphics device, tell the screen to load content. if (isInitialized) { screen.Initialize(); screen.LoadContent(); } screens.Add(screen); // update the TouchPanel to respond to gestures this screen is interested in TouchPanel.EnabledGestures = screen.EnabledGestures; }