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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - pitchShifter

Pages: [1]
1
General / Re: Does setframelimit have a memory leak in 2.1?
« on: November 01, 2014, 11:03:59 pm »
I'm experiencing the same issue. It's weird.

I was working on a game previously and had no memory leak issues (I'm looking at it right now in Windows Task Manager - the memory usage stays the same in my game menu even though I'm drawing multiple images to the screen). I just started a new project and noticed that the memory increases by 4kb every second; and there isn't anything even being drawn to the screen.

In my new project, I added a RectangleShape with a simple border. Once I draw it to the screen, the memory increases by 40kb/sec (when I view through Windows Task Manager).

Thoughts on what it could potentially be? Like I said, my older project had no memory issue. With my new project that has barely any code in it, I'm having the memory issue.

Edit: I'm not using different versions between projects, btw.

2
DotNet / Re: My situation with events
« on: August 16, 2013, 09:10:07 pm »
I already fixed the code before you guys replied but thanks for the replies :)

The solution was that I could put the register events function in the while "window is open" loop but after I dispatch the events I needed to deregister them. Yes, zsbzsb, C# has that feature but with the way my code was setup, I had to deregister them manually. The reason for this was because the events would carry on into other scenes; so I would have clickable buttons that should not exist in other scenes. In order to stop the game from lagging, I had to set a framerate cap.

3
DotNet / My situation with events
« on: August 14, 2013, 11:12:52 pm »
PROBLEM FIXED. IGNORE THIS!!!!

So I'm currently working on a menu system. A problem I'm running into is event handling when trying to hover over/click buttons I placed on the screen.

The menu system is based on "Scenes" which are like pages. The scenes contain the information to create and draw buttons as well as draw anything else I want to display.

Each scene has "register_mouseclick" and "register_mousemove" override methods. They look like this:

public override void register_mouseclick( object sender, MouseButtonEventArgs e )
        {
            RenderWindow window = (RenderWindow)sender;
            if( e.Button.GetHashCode() == 0 )
            {
                foreach( Button btn in buttons )
                {
                    btn.check_mouse_click();
                }
            }
        }

        public override void register_mousemove( object sender, MouseMoveEventArgs e )
        {
            foreach( Button btn in buttons )
            {
                btn.check_hover_state( e );
            }
        }

And I register these events through the SceneHandler:
public void register_events( ref RenderWindow window )
                {
                        foreach( Scene s in scenes )
                        {
                                if( s.id == current_scene )
                                {
                                        window.MouseButtonPressed += new EventHandler<MouseButtonEventArgs>(s.register_mouseclick);
                                        window.MouseMoved += new EventHandler<MouseMoveEventArgs>(s.register_mousemove);
                                }
                        }
                }

Now the problem I'm running into is when I switch scenes; the events are not registered. They're registered on the default scene but once I change to a different scene the events are no longer registered.

I'm calling the register_events function like so:
public void init()
{
    // ...

    SceneHandler SceneManager = new SceneHandler();

    SceneManager.register_events( ref window );

    // ...

    while( window.IsOpen() )
    {
        window.DispatchEvents();

        window.Clear();
        SceneManager.draw_scene( ref window );
        window.Display();
    }
}

Now if I were to put the register_events function into the while "window is open" loop it works BUT the game will obviously lag.

How could I solve this problem?

Pages: [1]
anything