当前位置: 首页>>代码示例>>C++>>正文


C++ OnEvent函数代码示例

本文整理汇总了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;
};
开发者ID:tomtom7,项目名称:tictactoe,代码行数:30,代码来源:game.cpp

示例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 );
    }
  }
} //}}}
开发者ID:alexd74,项目名称:FSMSystem,代码行数:33,代码来源:Event.cpp

示例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;
}
开发者ID:RaphaelMarinier,项目名称:audacity,代码行数:12,代码来源:AButton.cpp

示例4: OnEvent

void CCareerTask::OnEvent( GameEventType event, CBasePlayer *pAttacker, CBasePlayer *pVictim )
{
    if( !m_isComplete )
    {
        OnEvent( event, pAttacker, pVictim );
    }
}
开发者ID:Chuvi-w,项目名称:CSSDK,代码行数:7,代码来源:career_tasks.cpp

示例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;
    };
开发者ID:Esplin,项目名称:wagic,代码行数:27,代码来源:SDLmain.cpp

示例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;
  }
开发者ID:artint-liu,项目名称:Marimo,代码行数:26,代码来源:clSocketServer.cpp

示例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
	}
}
开发者ID:AustinMorrell,项目名称:Agar.io,代码行数:25,代码来源:GameLoop.cpp

示例8: OnDisconnectedFromServer

 virtual void OnDisconnectedFromServer() {
     EventObserverInterface* delegated;
     if ((delegated = EventObserverInterfaceDelegated()))
         delegated->OnDisconnectedFromServer();
     else
     OnEvent("DisconnectedFromServer"); 
 }
开发者ID:gvsurenderreddy,项目名称:XosWebRTC,代码行数:7,代码来源:EventInterface.hpp

示例9: OnFailedToConnectToServer

 ///////////////////////////////////////////////////////////////////////
 // Server Connection
 ///////////////////////////////////////////////////////////////////////
 virtual void OnFailedToConnectToServer(const std::string& server) {
     EventObserverInterface* delegated;
     if ((delegated = EventObserverInterfaceDelegated()))
         delegated->OnFailedToConnectToServer(server);
     else
     OnEvent("FailedToConnectToServer"); 
 }
开发者ID:gvsurenderreddy,项目名称:XosWebRTC,代码行数:10,代码来源:EventInterface.hpp

示例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;
}
开发者ID:Niautanor,项目名称:Warpig,代码行数:28,代码来源:Main.cpp

示例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;
}
开发者ID:wikiti,项目名称:ullPong,代码行数:32,代码来源:instance_menu_mj.cpp

示例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;
}
开发者ID:travisgoodspeed,项目名称:basicsynth,代码行数:33,代码来源:GMSynth.cpp

示例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;
}
开发者ID:nissafors,项目名称:LawyerRace,代码行数:25,代码来源:GameState.cpp

示例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;
}
开发者ID:ultradr3mer,项目名称:Flow,代码行数:33,代码来源:CApp.cpp

示例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();
		}
	}
开发者ID:rroa,项目名称:SDL2_OpenGL_BoilerPlate,代码行数:25,代码来源:App.cpp


注:本文中的OnEvent函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。