• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ OnEvent函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中OnEvent函数的典型用法代码示例。如果您正苦于以下问题:C++ OnEvent函数的具体用法?C++ OnEvent怎么用?C++ OnEvent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了OnEvent函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: time

//---------------------------------------------------------------------------
void TCustomMsgServer::DoEvent(int Sender, longword Code, word RetCode, word Param1, word Param2, word Param3, word Param4) 
{
    TSrvEvent SrvEvent;
    bool GoLog = (Code & LogMask) != 0;
    bool GoEvent = (Code & EventMask) != 0;

    if (!Destroying && (GoLog || GoEvent))
    {
        CSEvent->Enter();

        time(&SrvEvent.EvtTime);
        SrvEvent.EvtSender = Sender;
        SrvEvent.EvtCode = Code;
        SrvEvent.EvtRetCode = RetCode;
        SrvEvent.EvtParam1 = Param1;
        SrvEvent.EvtParam2 = Param2;
        SrvEvent.EvtParam3 = Param3;
        SrvEvent.EvtParam4 = Param4;

        if (GoEvent && (OnEvent != NULL))
            try
            { // callback is outside here, we have to shield it
                OnEvent(FUsrPtr, &SrvEvent, sizeof (TSrvEvent));
            } catch (...)
            {
            };

        if (GoLog)
            FEventQueue->Insert(&SrvEvent);

        CSEvent->Leave();
    };
}
开发者ID:agrippa1994,项目名称:iOS-PLC,代码行数:34,代码来源:snap_tcpsrvr.cpp


示例17: while

void Loop::Run()
{
    Debug::Log("Enter loop");
    char buffer[64];

    while(running)
    {
        while(SDL_PollEvent(&event))
        {
            //Calls the redefined event function for the class
            OnEvent(&event);
        }
        Update();

        //Calls the redefined Draw function for the class
        Draw(); 
			
		FPS::Update();
		FPS::PrintFPS();

		Graphics::Flip();
    }

    Debug::Log("Exit Loop");
}
开发者ID:bennybroseph,项目名称:Engine,代码行数:25,代码来源:Loop.cpp


示例18: OnConnectedToServer

 virtual void OnConnectedToServer(int id, const std::string& name) {
     EventObserverInterface* delegated;
     if ((delegated = EventObserverInterfaceDelegated()))
         delegated->OnConnectedToServer(id, name);
     else
     OnEvent("ConnectedToServer"); 
 }
开发者ID:gvsurenderreddy,项目名称:XosWebRTC,代码行数:7,代码来源:EventInterface.hpp


示例19: while

void CApplication::MainLoop()
{
    SDL_Event event;
    Uint32 startTime, elapsedTime;

    while( !m_Quit )
    {
        // Le temps avant l'éxécution
        startTime = SDL_GetTicks();
        // Tant qu'il y a des messages, les traiter
        while( SDL_PollEvent(&event) )
        {
            OnEvent(event);
        }
        // Mise à jour de la scène
        OnUpdate();
        // Démarrer le rendu
        m_Renderer.BeginScene();
        OnRender();
        m_Renderer.EndScene();

        // Si on a mis moins de temps que le nombre de FPS demandé, on attend
        // permet de limiter les fps et de gagner du temps de process CPU
        if( (elapsedTime = SDL_GetTicks()-startTime) < m_FPSLimit )
        {
            SDL_Delay(m_FPSLimit - elapsedTime);
        }
    }
}
开发者ID:Hiuld,项目名称:SDL2OGL,代码行数:29,代码来源:CApplication.cpp


示例20: AbortActionsInstigatedBy

uint32 UPawnActionsComponent::AbortActionsInstigatedBy(UObject* const Instigator, EAIRequestPriority::Type Priority)
{
    uint32 AbortedActionsCount = 0;

    if (Priority == EAIRequestPriority::MAX)
    {
        // call for every regular priority
        for (int32 PriorityIndex = 0; PriorityIndex < EAIRequestPriority::MAX; ++PriorityIndex)
        {
            AbortedActionsCount += AbortActionsInstigatedBy(Instigator, EAIRequestPriority::Type(PriorityIndex));
        }
    }
    else
    {
        UPawnAction* Action = ActionStacks[Priority].GetTop();
        while (Action)
        {
            if (Action->GetInstigator() == Instigator)
            {
                OnEvent(*Action, EPawnActionEventType::InstantAbort);
                ++AbortedActionsCount;
            }
            Action = Action->ParentAction;
        }
    }

    return AbortedActionsCount;
}
开发者ID:didixp,项目名称:Ark-Dev-Kit,代码行数:28,代码来源:PawnActionsComponent.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ OnExit函数代码示例发布时间:2022-05-30
下一篇:
C++ OnError函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap