1
DotNet / SFML Events w/C#.NET
« on: January 27, 2013, 09:22:58 pm »
I'm trying to figure out how to register events in SFML.NET, and I'm clueless. I'm looking for tutorials, but a no go.
This is my code so far:
Is this how you register events? Or am I mistaken.
This is my code so far:
using System;
using SFML.Audio;
using SFML.Window;
using SFML.Graphics;
namespace Example
{
class Program
{
static void OnClose(object sender, EventArgs e)
{
// Close the window when OnClose event is received
RenderWindow window = (RenderWindow)sender;
window.Close();
}
static void Main(string[] args)
{
// Create the main window
System.Threading.Thread.Sleep(1000/50);
RenderWindow window = new RenderWindow(new VideoMode(1024, 768), "Game");
window.Closed += new EventHandler(OnClose);
// Load a sprite to display
Texture texture = new Texture("Graphics/mainCharStand.PNG");
Sprite sprite = new Sprite(texture);
// Start the game loop
while (window.IsOpen())
{
// Process events
window.DispatchEvents();
// Clear screen
window.Clear();
// Draw the sprite
window.Draw(sprite);
// Update the window
window.Display();
}
}
}
}
using SFML.Audio;
using SFML.Window;
using SFML.Graphics;
namespace Example
{
class Program
{
static void OnClose(object sender, EventArgs e)
{
// Close the window when OnClose event is received
RenderWindow window = (RenderWindow)sender;
window.Close();
}
static void Main(string[] args)
{
// Create the main window
System.Threading.Thread.Sleep(1000/50);
RenderWindow window = new RenderWindow(new VideoMode(1024, 768), "Game");
window.Closed += new EventHandler(OnClose);
// Load a sprite to display
Texture texture = new Texture("Graphics/mainCharStand.PNG");
Sprite sprite = new Sprite(texture);
// Start the game loop
while (window.IsOpen())
{
// Process events
window.DispatchEvents();
// Clear screen
window.Clear();
// Draw the sprite
window.Draw(sprite);
// Update the window
window.Display();
}
}
}
}
Is this how you register events? Or am I mistaken.