本文整理汇总了C#中SFML.Graphics.RenderWindow.SetVisible方法的典型用法代码示例。如果您正苦于以下问题:C# RenderWindow.SetVisible方法的具体用法?C# RenderWindow.SetVisible怎么用?C# RenderWindow.SetVisible使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SFML.Graphics.RenderWindow
的用法示例。
在下文中一共展示了RenderWindow.SetVisible方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
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();
}
}
示例2: Main
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;
}
}
示例3: InitializeWindow
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;
}
示例4: Game
Game()
{
Window = new RenderWindow(new VideoMode(1024u, 768u), "Living Space");
Window.SetVisible(true);
Window.SetVerticalSyncEnabled(true);
Window.SetFramerateLimit(30);
Window.Closed += OnWindowClosed;
}
示例5: StartSFMLProgram
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();
}
}
示例6: StartSFMLProgram
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();
}
}
示例7: InitializeWindow
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(); } };
}
示例8: Game
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();
}
示例9: StartSFMLProgram
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();
}
}
示例10: StartGame
//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();
}
}
示例11: Main
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();
}
}
示例12: Start
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();
}
}
示例13: OnRenderWindowChanged
/// <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);
}
示例14: RecreateRenderWindow
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);
}
示例15: Main
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;
}
}
//.........这里部分代码省略.........