コード例 #1
0
        void ProcessWindowEvents()
        {
            // Update input
            _inputEvents.UpdateState();

            // Update TextInput
            if (!_textQueue.IsEmpty)
            {
                UpdateTextInput();
            }

            // Update size
            if (_isSizeChanged)
            {
                UpdateSize();
            }

            // Update orientation
            if (_isOrientationChanged)
            {
                UpdateOrientation();
            }

            // Update focus
            if (_isFocusChanged)
            {
                UpdateFocus();
            }

            // Update back button
            UpdateBackButton();
        }
コード例 #2
0
        internal void Tick()
        {
            // Update state based on window events.
            _windowEvents.UpdateState();

            // Update and render the game.
            if (Game != null)
            {
                Game.Tick();
            }
        }
コード例 #3
0
        void ProcessWindowEvents()
        {
            // Update input
            _inputEvents.UpdateState();

            // Update size
            if (_isSizeChanged)
            {
                UpdateSize();
            }

            // Update orientation
            if (_isOrientationChanged)
            {
                UpdateOrientation();
            }

            if (_isFocusChanged)
            {
                UpdateFocus();
            }
        }
コード例 #4
0
        void ProcessWindowEvents()
        {
            // Update input
            _inputEvents.UpdateState();

            // Update TextInput
            if (!_inputEvents.TextQueue.IsEmpty)
            {
                InputEvents.KeyChar ch;
                while (_inputEvents.TextQueue.TryDequeue(out ch))
                {
                    OnTextInput(_coreWindow, new TextInputEventArgs(ch.Character, ch.Key));
                }
            }

            // Update size
            if (_isSizeChanged)
            {
                UpdateSize();
            }

            // Update orientation
            if (_isOrientationChanged)
            {
                UpdateOrientation();
            }

            // Update focus
            if (_isFocusChanged)
            {
                UpdateFocus();
            }

            // Update back button
            UpdateBackButton();
        }
コード例 #5
0
        static private void OnTick()
        {
            // Resort the timer update lists if they have been changed.
            if (_resort)
            {
                _frameTimers.Sort((f, s) => f.FrameActionOrder - s.FrameActionOrder);
                _drawTimers.Sort((f, s) => f.DrawOrder - s.DrawOrder);
                _updateTimers.Sort((f, s) => f.UpdateOrder - s.UpdateOrder);
                _resort = false;
            }

            // Do we need to initialize the window event handlers?
            if (_windowEvents == null && Window.Current != null)
            {
                _windowEvents = new InputEvents(Window.Current.CoreWindow, SharedGraphicsDeviceManager.Current.SwapChainBackgroundPanel, MetroGamePlatform.TouchQueue);
            }
            if (_windowEvents != null)
            {
                _windowEvents.UpdateState();
            }

            // First call all the frame events... we do this
            // every frame regardless of the elapsed time.
            foreach (var timer in _frameTimers)
            {
                timer.FrameAction(timer, EventArgs.Empty);
            }

            // Next do update events.
            var elapsed = _gameTimer.Elapsed;

            _gameTimer.Reset();
            _gameTimer.Start();
            foreach (var timer in _updateTimers)
            {
                timer.DoUpdate(elapsed);
            }

            // Timers that have been updated can now draw.
            var deviceManager = SharedGraphicsDeviceManager.Current;

            if (deviceManager != null && deviceManager.GraphicsDevice != null)
            {
                // We gotta reapply the render targets on update
                // for some reason...  i guess the OS changes them?
                deviceManager.GraphicsDevice.ResetRenderTargets();

                var doPresent = false;

                foreach (var timer in _drawTimers)
                {
                    if (!timer._doDraw)
                    {
                        continue;
                    }

                    timer.Draw(timer, timer._gameTime);

                    doPresent     = true;
                    timer._doDraw = false;
                }

                // If nothing was drawn then we don't present and
                // the swap chain will contain whatever was last rendered.
                if (doPresent)
                {
                    deviceManager.GraphicsDevice.Present();
                }
            }
        }