mirror of
https://github.com/SFML/SFML.git
synced 2024-12-11 12:39:15 +08:00
64aebf0b9f
Moved files related to the documentation into /doc git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1384 4e206d99-4929-0410-ac5d-dfc041789085
72 lines
3.7 KiB
HTML
72 lines
3.7 KiB
HTML
<h2>Welcome</h2>
|
|
<p>
|
|
Welcome to the official SFML.Net documentation. Here you will find a detailed
|
|
description of all the SFML.Net classes. <br/>
|
|
If you are looking for tutorials, help or whatever, you can visit the official website
|
|
at <a href="http://www.sfml-dev.org/">www.sfml-dev.org</a>.
|
|
</p>
|
|
|
|
<h2>Short example</h2>
|
|
<p>
|
|
Here is a short example in C#, to show you how simple it is to use SFML.Net :
|
|
</p>
|
|
|
|
<pre style="background-color:#F0F0F0">
|
|
<span style="color:blue">using</span> System;
|
|
<span style="color:blue">using</span> SFML.Audio;
|
|
<span style="color:blue">using</span> SFML.Window;
|
|
<span style="color:blue">using</span> SFML.Graphics;
|
|
|
|
<span style="color:blue">namespace</span> Example
|
|
{
|
|
<span style="color:blue">class</span> <span style="color:#2B91AF">Program</span>
|
|
{
|
|
<span style="color:blue">static void</span> OnClose(<span style="color:blue">object</span> sender, <span style="color:#2B91AF">EventArgs</span> e)
|
|
{
|
|
<span style="color:#008000">// Close the window when OnClose event is received</span>
|
|
<span style="color:#2B91AF">RenderWindow</span> window = (<span style="color:#2B91AF">RenderWindow</span>)sender;
|
|
window.Close();
|
|
}
|
|
|
|
<span style="color:blue">static void</span> Main(<span style="color:blue">string</span>[] args)
|
|
{
|
|
<span style="color:#008000">// Create the main window</span>
|
|
<span style="color:#2B91AF">RenderWindow</span> window = <span style="color:blue">new</span> <span style="color:#2B91AF">RenderWindow</span>(<span style="color:blue">new</span> <span style="color:#2B91AF">VideoMode</span>(800, 600), <span style="color:#A31515">"SFML window"</span>);
|
|
window.Closed += <span style="color:blue">new</span> <span style="color:#2B91AF">EventHandler</span>(OnClose);
|
|
|
|
<span style="color:#008000">// Load a sprite to display</span>
|
|
<span style="color:#2B91AF">Image</span> image = <span style="color:blue">new</span> <span style="color:#2B91AF">Image</span>(<span style="color:#A31515">"cute_image.jpg"</span>);
|
|
<span style="color:#2B91AF">Sprite</span> sprite = <span style="color:blue">new</span> <span style="color:#2B91AF">Sprite</span>(image);
|
|
|
|
<span style="color:#008000">// Create a graphical string to display</span>
|
|
<span style="color:#2B91AF">Font</span> font = <span style="color:blue">new</span> <span style="color:#2B91AF">Font</span>(<span style="color:#A31515">"arial.ttf"</span>);
|
|
<span style="color:#2B91AF">Text</span> text = <span style="color:blue">new</span> <span style="color:#2B91AF">Text</span>(<span style="color:#A31515">"Hello SFML.Net"</span>, font);
|
|
|
|
<span style="color:#008000">// Load a music to play</span>
|
|
<span style="color:#2B91AF">Music</span> music = <span style="color:blue">new</span> Music(<span style="color:#A31515">"nice_music.ogg"</span>);
|
|
music.Play();
|
|
|
|
<span style="color:#008000">// Start the game loop</span>
|
|
<span style="color:blue">while</span> (window.IsOpened())
|
|
{
|
|
<span style="color:#008000">// Process events</span>
|
|
window.DispatchEvents();
|
|
|
|
<span style="color:#008000">// Clear screen</span>
|
|
window.Clear();
|
|
|
|
<span style="color:#008000">// Draw the sprite</span>
|
|
window.Draw(sprite);
|
|
|
|
<span style="color:#008000">// Draw the string</span>
|
|
window.Draw(text);
|
|
|
|
<span style="color:#008000">// Update the window</span>
|
|
window.Display();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</pre>
|
|
|