public SetVisible ( bool visible ) : void | ||
visible | bool | True to show the window, false to hide it |
Результат | void |
public static void Main(string[] args) { window = new RenderWindow(new VideoMode(800, 600), "SFML window"); window.SetVisible(true); window.SetVerticalSyncEnabled(true); window.Closed += OnClosed; window.MouseMoved += OnMouse; window.MouseLeft += Window_MouseLeft; window.Resized += Window_Resized; List<Button> buttons = new List<Button>(); for (int i = 0; i < 10; i++) { buttons.Add(new Button(new Vector2f(i*200, 100), new Vector2f(75, 20))); } while (window.IsOpen) { window.DispatchEvents(); window.Clear(new Color(50, 50, 50)); GUIManager.GuiManager.Update(Mouse.GetPosition(window).X, Mouse.GetPosition(window).Y); foreach (var item in buttons) { window.Draw(item); } window.Display(); } }
public static void Main(string[] args) { var win = new RenderWindow(new VideoMode(800, 600), "Some Crappy Zombie Thing"); win.Closed += (sender, e) => win.Close (); var curtime = DateTime.Now; double dt = 0; double frametime; win.SetVisible (true); EntityManager.Add (new RectangleTestEntity(true)); EntityManager.Add (new DebugInfo()); EntityManager.Add (new TileEntity("data/graphics/test_tileset.xml", 0, 1)); EntityManager.Add (new TileEntity("data/graphics/test_tileset.xml", "45down", new Vector2f(35, 40), 1)); Entity ent = new Entity(); ent.OnDraw += (sender, e) => e.Surface.Draw (new Text("Loooooonnnnggg Teeeexxxttt") {Position = new Vector2f(700, 500)}); EntityManager.Add (ent); EntityManager.InitializeWindow (win); while(win.IsOpen ()) { win.DispatchEvents(); EntityManager.Draw (win); win.Display (); frametime = (DateTime.Now-curtime).TotalMilliseconds; dt += frametime; while (dt >= EntityManager.TimeStep) { //Console.WriteLine (dt.ToString ()); EntityManager.Update (dt, frametime); dt -= EntityManager.TimeStep; } curtime = DateTime.Now; } }
private static void InitializeWindow() { Window = new RenderWindow(new VideoMode(1600, 900, 32), "Planet Simulation", Styles.Default); //window.SetVerticalSyncEnabled(true); Window.SetActive(false); Window.SetVisible(true); Window.Closed += WindowClosedEvent; }
Game() { Window = new RenderWindow(new VideoMode(1024u, 768u), "Living Space"); Window.SetVisible(true); Window.SetVerticalSyncEnabled(true); Window.SetFramerateLimit(30); Window.Closed += OnWindowClosed; }
public void StartSFMLProgram() { _window = new RenderWindow(new VideoMode(800, 600), "SFML window"); _window.SetVisible(true); _window.Closed += new EventHandler(OnClosed); while (_window.IsOpen) { _window.DispatchEvents(); _window.Clear(Color.Red); _window.Display(); } }
public void StartSFMLProgram() { _window = new RenderWindow(new VideoMode(800, 600), "SFML window"); _window.SetVisible(true); _window.Closed += new EventHandler(OnClosed); tests = new Tests(_window); Stopwatch watch = new Stopwatch(); watch.Start(); Stopwatch pauseWatch = new Stopwatch(); pauseWatch.Start(); while (_window.IsOpen()) { _window.DispatchEvents(); _window.Clear(); if (watch.ElapsedMilliseconds > 500) { if (SFML.Window.Keyboard.IsKeyPressed(Keyboard.Key.Left) && currentTest > 0) { --currentTest; watch.Reset(); watch.Start(); tests.TestCounter = 1; tests.Paused = false; } else if (SFML.Window.Keyboard.IsKeyPressed(Keyboard.Key.Right) && currentTest < 6) { ++currentTest; watch.Reset(); watch.Start(); tests.TestCounter = 1; tests.Paused = false; } } if (pauseWatch.ElapsedMilliseconds > 250) { if (SFML.Window.Keyboard.IsKeyPressed(Keyboard.Key.Space)) { tests.Paused = !tests.Paused; pauseWatch.Reset(); pauseWatch.Start(); } } RunCurrentTest(); _window.Display(); } }
private static void InitializeWindow() { //Construct window = new RenderWindow(new VideoMode(1920, 1080), "Orbs", IsFullscreen ? Styles.Fullscreen : Styles.Default); //Set parameters window.SetVisible(true); window.SetMouseCursorVisible(false); window.SetVerticalSyncEnabled(IsVSyncEnabled); //Bind events window.Closed += (sender, i) => window.Close(); window.KeyPressed += (sender, i) => stateManager.CurrentState?.HandleKeyPressed(i); window.KeyPressed += (sender, i) => { if (i.Code == Keyboard.Key.F11) { window.Close(); IsFullscreen = !IsFullscreen; InitializeWindow(); } }; }
public Game() { var sim = new GenePool(100); mainWindow = new RenderWindow(new VideoMode(800, 475), "FightingMachines"); mainWindow.SetVisible(true); // Set up events mainWindow.Closed += MainWindowOnClosed; mainWindow.KeyPressed += MainWindowOnKeyPressed; mainWindow.KeyReleased += MainWindowOnKeyReleased; font = new Font("data/fonts/DejaVuSansMono.ttf"); currentField = new Field(); Loop(); }
public void StartSFMLProgram() { timer = new Stopwatch(); _window = new RenderWindow(new VideoMode(800, 600), "SFML window"); _window.SetVisible(true); _window.Closed += new EventHandler(OnClosed); Texture tex = new Texture("resources\\Sprites\\Sharpedo.png"); Sprite spr = new Sprite(tex); Text fps = new Text("Fps is", new Font("resources\\gstbinrm.ttf")); fps.DisplayedString = "Fps is this"; fps.Position = new Vector2f(40f, 20f); timer.Start(); int count = 0; while (_window.IsOpen()) { if (timer.ElapsedMilliseconds > 0) { } count++; if (count > 1000) { double time = (double)count / ((double)timer.ElapsedMilliseconds / 1000d); count = 0; timer.Restart(); fps.DisplayedString = string.Format("Fps is this: {0}", time); } _window.DispatchEvents(); _window.Clear(Color.Red); _window.Draw(spr); _window.Draw(fps); _window.Display(); } }
//Open Window public void StartGame() { this.XWindowSize = 400; this.YWindowSize = 300; this.WindowOffset = 15; _window = new RenderWindow(new VideoMode(XWindowSize, YWindowSize), "Pixel Blaster"); _window.SetVisible(true); _window.Closed += new EventHandler(OnClosed); _window.KeyPressed += new EventHandler<SFML.Window.KeyEventArgs>(OnKeyPress); circle = new CircleShape(); circle.Radius = 25f; circle.FillColor = Color.Green; Vector2f vect = new Vector2f(); vect.X = (float)XWindowSize / 2 - circle.Radius; vect.Y = 4 * (float)YWindowSize / 5; circle.Position = vect; float circleSpeed = 4.0f; sprite = new Sprite(); sprite.Color = Color.Red; sprite.Scale = vect; while (_window.IsOpen ) { _window.DispatchEvents(); _window.Clear(); handleMovement(circleSpeed); _window.Draw(circle); _window.Draw(sprite); _window.Display(); } }
static void Main(string[] args) { Log.GlobalLevel = Log.Level.Debug; RenderWindow app = new RenderWindow(new VideoMode(800, 600), "HP!", Styles.Default, new ContextSettings(0, 0, 4)); app.SetFramerateLimit(60); app.Closed += delegate { app.Close(); }; app.SetVisible(true); app.SetActive(true); L.I("Assuming assets in \"assets\""); Assets assets = new Assets("assets"); LoadAnimations(assets); Level level1 = assets.Level("level1.json"); Game game = new Game(assets, level1); var view = new View(); int lastFrameTime = Environment.TickCount; while (app.IsOpen) { app.DispatchEvents(); float aspect = (float)app.Size.X / app.Size.Y; float targetWidth = 20, targetHeight = targetWidth / aspect; view.Reset(new FloatRect(0, 0, targetWidth, targetHeight)); app.SetView(view); int ticks = Environment.TickCount; float delta = (ticks - lastFrameTime) / 1000F; lastFrameTime = ticks; game.Update(delta); game.Render(app); app.Display(); } }
public void Start() { AssetManager.LoadSprites(); _board = new Pieces.Piece[8, 8]; for (int x = 0; x < 8; x++ ) { for (int y = 0; y < 8; y++) { _board[x, y] = null; } } // Create window instance. _window = new RenderWindow(new VideoMode(520, 520), "Chess", Styles.Default); _window.SetVisible(true); _window.Closed += OnClosed; _window.MouseButtonPressed += OnMousePressed; LoadTable(); UpdateTitle(); // Main loop. while (_window.IsOpen()) { _window.DispatchEvents(); _window.Clear(Color.Black); for (int x = 0; x < 8; x++) { for (int y = 0; y < 8; y++) { RectangleShape shape = new RectangleShape(); shape.Size = new Vector2f(65, 65); shape.Position = new Vector2f(x*65, y*65); Color col = ((x+y)%2) == 0 ? new Color(255, 206, 158) : new Color(209, 139, 71); shape.FillColor = col; _window.Draw(shape); } } for (int x = 0; x < 8; x++) { for (int y = 0; y < 8; y++) { var piece = _board[x, y]; if (piece != null) { _window.Draw(piece.Sprite); } } } if (SecondClick) { RectangleShape shape = new RectangleShape(); shape.Size = new Vector2f(65, 65); shape.Position = _selectedPiece.Sprite.Position; Color col = Color.Cyan; shape.OutlineColor = col; shape.OutlineThickness = 4; shape.FillColor = new Color(255, 255, 255, 0); _window.Draw(shape); } _window.Display(); } }
/// <summary> /// Handles the <see cref="IGameContainer.RenderWindowChanged"/> event. /// </summary> /// <param name="oldValue">The old value.</param> /// <param name="newValue">The new value.</param> protected virtual void OnRenderWindowChanged(RenderWindow oldValue, RenderWindow newValue) { if (newValue == null) return; newValue.SetMouseCursorVisible(ShowMouseCursor); newValue.SetVerticalSyncEnabled(UseVerticalSync); newValue.SetActive(); newValue.SetVisible(true); }
void RecreateRenderWindow(IntPtr handle) { if (_rw != null) { if (!_rw.IsDisposed) _rw.Dispose(); _rw = null; } _rw = new RenderWindow(handle); _rw.SetVerticalSyncEnabled(false); _rw.SetVisible(true); OnRenderWindowCreated(_rw); }
static void Main(string[] args) { Texture textureBack = new Texture(File.ReadAllBytes(@"assets/back.png")); textureBack.Smooth = true; Sprite spriteBack = new Sprite(textureBack, new IntRect(0, 0, 800, 500)); Texture textureLock = new Texture(File.ReadAllBytes(@"assets/lock.png")); textureLock.Smooth = true; Sprite spriteLock = new Sprite(textureLock, new IntRect(0, 0, 80, 80)); spriteLock.Position = new Vector2f(76, 68); icons = new List<Sprite>(); for (int index = 0; index < 15; index++) { int col = index % 5; int row = (index - col) / 5; Texture textureIcon = new Texture(File.ReadAllBytes(String.Format(@"assets/buttons/{0:00}.png", index + 1))); textureIcon.Smooth = true; Sprite spriteIcon = new Sprite(textureIcon, new IntRect(0, 0, 72, 72)); spriteIcon.Position = new Vector2f(80 + col * 72 + col * 70, 72 + row * 72 + row * 70); icons.Add(spriteIcon); } ContextSettings context = new ContextSettings(); context.DepthBits = 32; RenderWindow window = new RenderWindow(new VideoMode(800, 500), String.Empty, Styles.Default, context); window.SetActive(); window.SetVisible(true); window.SetKeyRepeatEnabled(true); window.SetMouseCursorVisible(true); window.SetVerticalSyncEnabled(false); window.Closed += new EventHandler( delegate(object sender, EventArgs e) { window.Close(); window.Dispose(); } ); window.GainedFocus += new EventHandler( delegate(object sender, EventArgs e) { } ); window.LostFocus += new EventHandler( delegate(object sender, EventArgs e) { } ); window.KeyPressed += new EventHandler<KeyEventArgs>( delegate(object sender, KeyEventArgs e) { if (e.Code == Keyboard.Key.Escape) { /* sound.Stop(); sound.Dispose(); buffer.Dispose(); */ window.Close(); window.Dispose(); } if (e.Code == Keyboard.Key.Right) { if (col < 4) { col += 1; } } if (e.Code == Keyboard.Key.Left) { if (col > 0) { col -= 1; } } if (e.Code == Keyboard.Key.Up) { if (row > 0) { row -= 1; } } if (e.Code == Keyboard.Key.Down) { if (row < 2) { row += 1; } } spriteLock.Position = new Vector2f(80 + col * 72 + col * 70 - 4, 72 + row * 72 + row * 70 - 4); } ); window.KeyReleased += new EventHandler<KeyEventArgs>( delegate(object sender, KeyEventArgs e) { } ); window.TouchBegan += new EventHandler<TouchEventArgs>( delegate(object sender, TouchEventArgs e) { } ); window.TouchEnded += new EventHandler<TouchEventArgs>( delegate(object sender, TouchEventArgs e) { } ); window.TouchMoved += new EventHandler<TouchEventArgs>( delegate(object sender, TouchEventArgs e) { } ); window.JoystickConnected += new EventHandler<JoystickConnectEventArgs>( delegate(object sender, JoystickConnectEventArgs e) { } ); window.JoystickDisconnected += new EventHandler<JoystickConnectEventArgs>( delegate(object sender, JoystickConnectEventArgs e) { } ); window.JoystickButtonPressed += new EventHandler<JoystickButtonEventArgs>( delegate(object sender, JoystickButtonEventArgs e) { //File.AppendAllText(@"joystick.log", Convert.ToString(e.Button) + ":JoystickButtonPressed\n"); // A 0 // B 1 // X 2 // Y 3 // BACK 6 // START 7 } ); window.JoystickButtonReleased += new EventHandler<JoystickButtonEventArgs>( delegate(object sender, JoystickButtonEventArgs e) { //File.AppendAllText(@"joystick.log", Convert.ToString(e.Button) + ":JoystickButtonReleased\n"); } ); window.JoystickMoved += new EventHandler<JoystickMoveEventArgs>( delegate(object sender, JoystickMoveEventArgs e) { //File.AppendAllText(@"joystick.log", Convert.ToString(e.Axis) + ":" + Convert.ToString(e.JoystickId) + ":" + Convert.ToString(e.Position) + "\n"); // RIGHT PovX +100 // LEFT PovX -100 if (e.Axis == Joystick.Axis.PovX) { if (e.Position.Equals(+100.0f)) { // RIGHT if (col < 4) { col += 1; } } if (e.Position.Equals(-100.0f)) { // LEFT if (col > 0) { col -= 1; } } } // UP PovY +100 // DOWN PovY -100 if (e.Axis == Joystick.Axis.PovY) { if (e.Position.Equals(+100.0f)) { // UP if (row > 0) { row -= 1; } } if (e.Position.Equals(-100.0f)) { // DOWN if (row < 2) { row += 1; } } } spriteLock.Position = new Vector2f(80 + col * 72 + col * 70 - 4, 72 + row * 72 + row * 70 - 4); } ); while (window.IsOpen) { window.DispatchEvents(); window.Clear(); window.Draw(spriteBack); foreach (Sprite icon in icons) { window.Draw(icon); } window.Draw(spriteLock); window.Display(); } }
private void LoadWindow() { // Determine settings var vmode = new VideoMode( (uint)Settings.ReadInt("Video", "ResX", 1024), (uint)Settings.ReadInt("Video", "ResY", 600), 24); bool fscreen = Settings.ReadInt("Video", "Fullscreen", 0) == 1; bool vsync = Settings.ReadInt("Video", "VSync", 1) == 1; // Setup the new window window = new RenderWindow(vmode, "FTL: Overdrive", fscreen ? Styles.Fullscreen : Styles.Close, new ContextSettings(24, 8, 8)); window.SetVisible(true); window.SetVerticalSyncEnabled(vsync); window.MouseMoved += new EventHandler<MouseMoveEventArgs>(window_MouseMoved); window.Closed += new EventHandler(window_Closed); window.MouseButtonPressed += new EventHandler<MouseButtonEventArgs>(window_MouseButtonPressed); window.MouseButtonReleased += new EventHandler<MouseButtonEventArgs>(window_MouseButtonReleased); window.KeyPressed += new EventHandler<KeyEventArgs>(window_KeyPressed); window.KeyReleased += new EventHandler<KeyEventArgs>(window_KeyReleased); window.TextEntered += new EventHandler<TextEventArgs>(window_TextEntered); // Init UI Canvas = new UI.Canvas(); var screenrect = Util.ScreenRect(window.Size.X, window.Size.Y, 1.77778f); Canvas.X = screenrect.Left; Canvas.Y = screenrect.Top; Canvas.Width = screenrect.Width; Canvas.Height = screenrect.Height; // Load icon using (var bmp = new System.Drawing.Bitmap(Resource("img/exe_icon.bmp"))) { byte[] data = new byte[bmp.Width * bmp.Height * 4]; int i = 0; for (int y = 0; y < bmp.Height; y++) for (int x = 0; x < bmp.Width; x++) { var c = bmp.GetPixel(x, y); data[i++] = c.R; data[i++] = c.G; data[i++] = c.B; data[i++] = c.A; } window.SetIcon((uint)bmp.Width, (uint)bmp.Height, data); } }
void RecreateWindow() { if (window != null) { window.Close(); window.Dispose(); } window = new RenderWindow(VideoMode.DesktopMode, "N'oubliez pas les paroles", windowStyle); window.SetActive(); window.SetVisible(true); window.Closed += new EventHandler(OnClose); window.KeyPressed += new EventHandler<KeyEventArgs>(OnKeyPressed); guiStyle = GuiStyle.LoadFromFile("configihm.xml"); activeComponent.Initialize(); activeComponent.LoadContent(); }