tags:

views:

63

answers:

2

I just downloaded SFML.NET and added a reference to the library DLLs included with it, but it seems the Text class is not there. In the example on the site, it is clear that a Text object being used... so the example won't compile. See for yourself...

alt text

There's only Font, no Text! Anyone knows what I could be doing wrong?

A: 

You probably want to use the String2D class (the String class in the documentation) to actually draw text. The variable of this class in the tutorial is called Text, which is probably where you were confused.

pikejd
+1  A: 

You are probably looking at 2.x samples where String2D has been removed and replaced with Text. String2D is for 1.x, and you use the Text property to change what it displays.

Fortunately the interfaces are very similar. You should be able to simply replace anything declared as Text with String2D without changing any of the other code. An example for each version:

SFML.NET 1.x

 Imports SFML
 Imports SFML.Window
 Imports SFML.Graphics

  Public Sub Main()
   Dim Output As New RenderWindow(New VideoMode(640, 480), "SFML.NET Text Example")

   Dim ExampleText As New String2D("", New Font("myfont.tff"))    
   ExampleText.Position = New Vector2(5, 5)

   Do While (true)
    Output.Clear(New SFML.Graphics.Color(0,128,160))
    ExampleText.Text= String.Format("Hello, world! {0}", DateTime.Now.ToString("hh:MM.ss"))
    Output.Draw(ExampleText)
    Output.Display()
   End While

   End Sub

SFML.NET 2.x

 Imports SFML
 Imports SFML.Window
 Imports SFML.Graphics

  Public Sub Main()
   Dim Output As New RenderWindow(New VideoMode(640, 480), "SFML.NET Text Example")

   Dim ExampleText As New Text("", New Font("myfont.tff"))    
   ExampleText .Position = New Vector2(5, 5)

   Do While (true)
    Output.Clear(New SFML.Graphics.Color(0,128,160))
    ExampleText.DisplayedString = String.Format("Hello, world! {0}", DateTime.Now.ToString("hh:MM.ss"))
    Output.Draw(ExampleText )
    Output.Display()
   End While

   End Sub

Obviously a very stripped back example but hopefully demonstrates just how simple the difference is.

FerretallicA