GameLoop.Update C# (CSharp) Method

Update() public method

public Update ( ) : void
return void
    void Update()
    {
        // Reserve "Esc" key for pausing game
        if(CrossPlatformInputManager.GetButtonDown ("Pause"))
            {
                is_paused = !is_paused;
                pause_popup.SetActive(is_paused);
                if(is_paused)
                {
                    HidePauseButton();
                }
                else
                {
                    ShowPauseButton();
                    SetInitialPauseMenu();
                    // unpause game
                    Time.timeScale = 1.0f;
                }
            }

            // On pause menu
            if(is_paused)
            {
                // Stop in-game objects from updating
                Time.timeScale = 0.0f;
            }
    }

Usage Example

Exemplo n.º 1
0
        private async void onUpdateFrame(object sender, FrameEventArgs e)
        {
            if (_updateFrameRetries > 3)
            {
                return;
            }
            try
            {
                _updateMessagePump.PumpMessages();
                _repeatArgs.DeltaTime = e.Time;
                await Events.OnRepeatedlyExecuteAlways.InvokeAsync(_repeatArgs);

                if (State.Paused)
                {
                    return;
                }
                adjustSpeed();
                GameLoop.Update();

                //Invoking repeatedly execute asynchronously, as if one subscriber is waiting on another subscriber the event will
                //never get to it (for example: calling ChangeRoom from within RepeatedlyExecute calls StopWalking which
                //waits for the walk to stop, only the walk also happens on RepeatedlyExecute and we'll hang.
                //Since we're running asynchronously, the next UpdateFrame will call RepeatedlyExecute for the walk cycle to stop itself and we're good.
                ///The downside of this approach is that we need to look out for re-entrancy issues.
                await Events.OnRepeatedlyExecute.InvokeAsync(_repeatArgs);

                _pipeline?.Update();
            }
            catch (Exception ex)
            {
                _updateFrameRetries++;
                Debug.WriteLine(ex.ToString());
                throw ex;
            }
        }
All Usage Examples Of GameLoop::Update