本文整理汇总了C++中OnEvent函数的典型用法代码示例。如果您正苦于以下问题:C++ OnEvent函数的具体用法?C++ OnEvent怎么用?C++ OnEvent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OnEvent函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
//Holds game logic together
int Game::OnStart() {
//Initialize the game
if (OnInit() == false) {
return -1;
}
SDL_Event Event;
//While game is running
while (running) {
while (gameType == 0 && running) {
while (SDL_PollEvent(&Event)) {
OnEvent(&Event);
}
//meanwhile show menu
showMenu();
}
while (SDL_PollEvent(&Event)) {
//Handle user input
OnEvent(&Event);
}
OnLoop();
OnRender();
}
OnCleanUp();
return 0;
};
示例2: while
void EventProcessor::Run() //{{{
{
DEBUG_TRACER;
long timeToWait = -1;
while( true )
{
EventPointer event;
std::pair<bool,long int> needWait = GetMaxWaitTime();
if( needWait.first )
timeToWait = needWait.second;
else
timeToWait = -1;
DBGOUT_DEBUG( Debug::Prefix() << "EventProcessor(" << GetID() << ")::Run needWait " << needWait.first << ", " << needWait.second << " timeToWait " << timeToWait << std:: endl );
if( GetEvent( event, timeToWait ) == EventPresent )
{
OnEvent( event );
if( event->ID() == EVENT_FINISH )
break;
}
std::pair<bool,unsigned char> timer = GetNextTimer();
DBGOUT_DEBUG( Debug::Prefix() << "EventProcessor(" << GetID() << ")::Run timer " << timer.first << ", " << static_cast<int>( timer.second ) << std:: endl );
if( timer.first )
{
EventPointer ptr = EventPointer( new Event( TIMER_ELAPSED( timer.second ) ) );
OnEvent( ptr );
}
}
} //}}}
示例3: OnEvent
int AButton::Listener::FilterEvent(wxEvent &event)
{
if (event.GetEventType() == wxEVT_KEY_DOWN ||
event.GetEventType() == wxEVT_KEY_UP)
OnEvent();
else if (event.GetEventType() == wxEVT_SET_FOCUS)
// A modal dialog might have eaten the modifier key-up with its own
// filter before we saw it; this is adequate to fix the button image
// when the dialog disappears.
OnEvent();
return Event_Skip;
}
示例4: OnEvent
void CCareerTask::OnEvent( GameEventType event, CBasePlayer *pAttacker, CBasePlayer *pVictim )
{
if( !m_isComplete )
{
OnEvent( event, pAttacker, pVictim );
}
}
示例5: OnExecute
int OnExecute()
{
if (OnInit() == false)
{
return -1;
}
SDL_Event Event;
while(Running)
{
if (g_engine)
{
for (int x = 0; x < 5 && SDL_WaitEventTimeout(&Event, 10); ++x)
{
if(!g_engine->IsPaused())
OnEvent(&Event);
}
if(!g_engine->IsPaused())
OnUpdate();
}
}
OnCleanup();
return 0;
};
示例6: while
int UDPSocket::MainLoop()
{
fd_set ReadSet;
int result = 0;
while(1)
{
FD_ZERO(&ReadSet);
FD_SET(m_Socket, &ReadSet);
result = select(0, &ReadSet, 0, 0, 0);
if(result == 0)
{
// Time Out
}
else if(result == SOCKET_ERROR)
{
break;
}
else if(result != 0)
{
OnEvent(m_Socket, SE_READ);
}
}
return result;
}
示例7: while
void GameLoop::Loop()
{
SDL_Event sdlEvent; // Will hold the next event to be parsed
while (m_bRunning)
{
// Events get called one at a time, so if multiple things happen in one frame, they get parsed individually through 'SDL_PollEvent'
// The next event to parse gets stored into 'sdlEvent', and then passed to the 'EventHandler' class which will call it's appropriate function here
// 'SDL_PollEvent' returns 0 when there are no more events to parse
while (SDL_PollEvent(&sdlEvent))
{
// Calls the redefined event function for the EventHandler class
// Refer to its header file and cpp for more information on what each inherited function is capable of
// and its syntax
OnEvent(sdlEvent);
}
Update();
LateUpdate();
Draw();
Graphics::Flip(); // Required to update the window with all the newly drawn content
}
}
示例8: OnDisconnectedFromServer
virtual void OnDisconnectedFromServer() {
EventObserverInterface* delegated;
if ((delegated = EventObserverInterfaceDelegated()))
delegated->OnDisconnectedFromServer();
else
OnEvent("DisconnectedFromServer");
}
示例9: OnFailedToConnectToServer
///////////////////////////////////////////////////////////////////////
// Server Connection
///////////////////////////////////////////////////////////////////////
virtual void OnFailedToConnectToServer(const std::string& server) {
EventObserverInterface* delegated;
if ((delegated = EventObserverInterfaceDelegated()))
delegated->OnFailedToConnectToServer(server);
else
OnEvent("FailedToConnectToServer");
}
示例10: while
int Main::OnExecute(CL_ParamList* pCL_Params)
{
if(!OnInit(pCL_Params))
return -1;
SDL_Event Event;
Uint32 t1,t2;
float fTime = 0.0f;
while(Running)
{
t1 = SDL_GetTicks();
while(SDL_PollEvent(&Event))
{
if(Event.type == SDL_QUIT)
Running = false;
else OnEvent(&Event);
}
OnMove(fTime);
OnRender();
t2 = SDL_GetTicks();
fTime = (float)(t2-t1)/1000.0f;
}
OnExit();
return 1;
}
示例11: while
int CInstance_Menu_MJ::OnExecute()
{
if(!Init())
{
cerr << ERROR_STR_INIT << " MENU_MJ" << endl;
return ERROR_CODE_GENERAL;
}
int frame = 0;
CTemporizador fps;
int salida = I_SALIDA;
while(i_running)
{
fps.empezar();
while(SDL_PollEvent(&event))
{
OnEvent(salida);
}
OnLoop(salida);
OnRender();
frame++;
if((fps.getTicks() < (1000 / FRAMES_PER_SECOND)))
SDL_Delay((1000 / FRAMES_PER_SECOND ) - fps.getTicks());
}
Close();
return salida;
}
示例12: OpenWaveDevice
int GMSynthDLL::ThreadProc()
{
if (live)
{
if (seqMode & seqPlay)
ldTm = 0.02;
else
ldTm = 0.20;
OpenWaveDevice();
inmgr.SetWaveOut(&wvd);
}
else
{
if (wvf.OpenWaveFile(outFileName, 2))
{
OnEvent(SEQEVT_SEQSTOP, NULL);
return GMSYNTH_ERR_FILEOPEN;
}
inmgr.SetWaveOut(&wvf);
}
inmgr.Reset();
seq.SequenceMulti(inmgr, stTime, endTime, seqMode);
if (live)
{
bsInt32 drain = (bsInt32) (synthParams.sampleRate * (ldTm * 4));
while (--drain > 0)
inmgr.Tick();
CloseWaveDevice();
}
else
wvf.CloseWaveFile();
return GMSYNTH_NOERROR;
}
示例13: while
int GameState::Execute() {
//Initialize all
if(!Init()) return -1;
SDL_Event ev;
//Game loop
while(GameRunning) {
while(SDL_PollEvent(&ev)) {
OnEvent(&ev);
}
Update();
Render();
if (FPS::FPSControl.GetFPS() > 200) SDL_Delay(3); //Tiny delay if computer is giving high fps. No need for super high fps.
if (temp_delay > 0) {
SDL_Delay(temp_delay);
temp_delay = 0;
}
}
//Cleanup memory and shut down
Cleanup();
return 0;
}
示例14: while
int CApp::OnExecute(int argc, char **argv) {
if(OnInit(argc, argv) == false) {
return -1;
}
SDL_Event Event;
bool calculatedFrame;
while(Running) {
//BulletManager::Step();
while(SDL_PollEvent(&Event))
{
OnEvent(&Event);
}
calculatedFrame= false;
while ((SDL_GetTicks() - GameBaseTime) > GameTickLength)
{
gameTime = SDL_GetTicks() / 1000.0f;
GameBaseTime += GameTickLength;
OnUpdate();
calculatedFrame = true;
}
BulletManager::Step();
OnDraw();
}
OnCleanup();
return 0;
}
示例15: while
void App::Execute()
{
if (m_state != GameState::INIT_SUCCESSFUL)
{
std::cerr << "Game INIT was not successful." << std::endl;
return;
}
m_state = GameState::RUNNING;
SDL_Event event;
while (m_state == GameState::RUNNING)
{
// Input polling
//
while (SDL_PollEvent(&event))
{
OnEvent(&event);
}
//
Update();
Render();
}
}