Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: C# RenderWindow.pollEvent  (Read 4729 times)

0 Members and 1 Guest are viewing this topic.

dandan

  • Newbie
  • *
  • Posts: 2
    • View Profile
C# RenderWindow.pollEvent
« on: March 28, 2013, 03:42:39 pm »
Hi:

I'm having troubles getting the SFML 2.0 RenderWindow.PollEvent to work. Here's my code (based on this tutorial but ported to C#):


VideoMode VMode = new VideoMode(800, 600, 32);
            RenderWindow Window = new RenderWindow(VMode, "SFMLCoder Tutorial - Empty Window");
           
            Texture image = new Texture("39548828.png");            
           
            Sprite sprite = new Sprite(image);
           
            sprite.Position = new Vector2f(100.0f, 30.0f);
            sprite.Rotation = 30.0f;
            sprite.Scale = new Vector2f(.5f, .3f);
            sprite.Color = new Color(255, 0, 0, 128);
         
            Sprite sprite2 = new Sprite(image);
            sprite2.Position = new Vector2f(0.0f, 0.0f);
           
            Texture image2 = new Texture("test_8bit.png");            
           
            Sprite sprite3 = new Sprite(image2);

            sprite3.Position = new Vector2f(100.0f, 50.0f);
            sprite3.Scale = new Vector2f(.4f, .4f);
         
            Image Screenshot;
         
            while (Window.IsOpen())
            {
                Event myEvent;
                while (Window.pollEvent(myEvent))
                {
                    switch (Event.Type)
                    {
                    case myEvent.Closed:
                        Window.Close();
                        break;
                    default:
                        break;
                    }
                }
         
                Window.Clear(new Color(0, 255, 255));
         
                Window.Draw(sprite3);
                Window.Draw(sprite);
                Window.Draw(sprite2);
         
                Window.Display();

            }
 

Here's the output from building. I am mostly concerned with the first line.

C:\Edit\Edit.cs(173,31): error CS1061: 'SFML.Window.Window' does not contain a definition for 'pollEvent' and no extension method 'pollEvent' accepting a first argument of type 'SFML.Window.Window' could be found (are you missing a using directive or an assembly reference?)
C:\Edit\Edit.cs(175,29): error CS0120: An object reference is required for the non-static field, method, or property 'SFML.Window.Event.Type'
c:\Edit\lib\sfmlnet-window-2.dll: (Related file)
C:\Edit\Edit.cs(177,34): error CS1061: 'SFML.Window.Event' does not contain a definition for 'Closed' and no extension method 'Closed' accepting a first argument of type 'SFML.Window.Event' could be found (are you missing a using directive or an assembly reference?)
C:\Edit\Edit.cs(185,24): error CS1061: 'SFML.Window.Window' does not contain a definition for 'Clear' and no extension method 'Clear' accepting a first argument of type 'SFML.Window.Window' could be found (are you missing a using directive or an assembly reference?)
C:\Edit\Edit.cs(187,24): error CS1061: 'SFML.Window.Window' does not contain a definition for 'Draw' and no extension method 'Draw' accepting a first argument of type 'SFML.Window.Window' could be found (are you missing a using directive or an assembly reference?)
C:\Edit\Edit.cs(188,24): error CS1061: 'SFML.Window.Window' does not contain a definition for 'Draw' and no extension method 'Draw' accepting a first argument of type 'SFML.Window.Window' could be found (are you missing a using directive or an assembly reference?)
C:\Edit\Edit.cs(189,24): error CS1061: 'SFML.Window.Window' does not contain a definition for 'Draw' and no extension method 'Draw' accepting a first argument of type 'SFML.Window.Window' could be found (are you missing a using directive or an assembly reference?)
 


What am I doing wrong? Any help is greatly appreciated!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: C# RenderWindow.pollEvent
« Reply #1 on: March 28, 2013, 03:57:59 pm »
Events are handled the C# way in SFML.Net, this is totally different from C++ event handling. Please look at the examples of the SDK.
Laurent Gomila - SFML developer

dandan

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: C# RenderWindow.pollEvent
« Reply #2 on: March 28, 2013, 06:36:13 pm »
Events are handled the C# way in SFML.Net, this is totally different from C++ event handling. Please look at the examples of the SDK.

Cool. Got it working. Thanks for the quick response (and all of your efforts on SFML!)

 

anything