Jump to content
  • Advertisement
Sign in to follow this  
deadstar

wxTimer - will not trigger

This topic is 3694 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I've tried 3 different methods for setting up a wxTimer so far, and nothing's working. Method 1:
class CPhysicsTimer : public wxTimer
{
	public:
		CPhysicsTimer(wxFrame *Owner);
		void Notify();

	private:
		wxFrame *OwnerFrame;
};

//In MainFrame class declaration
CPhysicsTimer PhysicsTimer;

//In source file
CPhysicsTimer::CPhysicsTimer(wxFrame *Owner) : wxTimer()
{
	OwnerFrame = Owner;
}

void CPhysicsTimer::Notify()
{
	sym::Engine->UpdateGlobalTimer();
	sym::Engine->Physics.Update();
	OwnerFrame->Update();
}

MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) 
: wxFrame( parent, id, title, pos, size, style ), PhysicsTimer(this)
{
...

   PhysicsTimer.Start(5, wxTIMER_CONTINUOUS);
}


Method 2:
//In MainFrame class declaration
wxTimer PhysicsTimer;
void OnPhysicsTimer(wxTimerEvent& event);

//In source file
const int TimerID = wxNewId();

MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) 
: wxFrame( parent, id, title, pos, size, style ), PhysicsTimer(this, TimerID)
{
...
   this->Connect( TimerID, wxEVT_TIMER, wxTimerEventHandler( MainFrame::OnPhysicsTimer ) );
   PhysicsTimer.Start(5, wxTIMER_CONTINUOUS);
}

void MainFrame::OnPhysicsTimer(wxTimerEvent& WXUNUSED(event))
{
	sym::Engine->UpdateGlobalTimer();
	sym::Engine->Physics.Update();
	Update();
}


Method 3:
//In MainFrame class declaration
wxTimer PhysicsTimer;
void OnPhysicsTimer(wxTimerEvent& event);
DECLARE_EVENT_TABLE()

//In source file
const int TimerID = wxNewId();

BEGIN_EVENT_TABLE(MainFrame, wxFrame)
    EVT_TIMER(TimerID, MainFrame::OnTimer)
END_EVENT_TABLE()

MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) 
: wxFrame( parent, id, title, pos, size, style ), PhysicsTimer(this, TimerID)
{
...
   PhysicsTimer.Start(5, wxTIMER_CONTINUOUS);
}

void MainFrame::OnPhysicsTimer(wxTimerEvent& WXUNUSED(event))
{
	sym::Engine->UpdateGlobalTimer();
	sym::Engine->Physics.Update();
	Update();
}


I can't get any of the above to work! The timer simply won't trigger anything. Am I missing something important? Thanks in advance. EDIT: Fixed page width

Share this post


Link to post
Share on other sites
Advertisement
I'm still struggling with this one if anyone has any ideas. I've read, and re-read the documentation, Googled for example code, even poked around some of the projects on Koders.com but as far as I can see I'm doing it right.

Has anyone who's tinkered with a wxTimer got any success stories or gotchas to share?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!