コード例 #1
0
        public async Task Initialize(CanvasAnimatedControl canvasAnimatedControl, T scene)
        {
            if (canvasAnimatedControl == null)
            {
                throw new ArgumentNullException(nameof(canvasAnimatedControl));
            }

            if (scene == null)
            {
                throw new ArgumentNullException(nameof(scene));
            }

            _canvasAnimatedControl = canvasAnimatedControl;
            Scene = scene;

            await _canvasAnimatedControl.RunOnGameLoopThreadAsync(() =>
            {
                _inputSource = canvasAnimatedControl.CreateCoreIndependentInputSource(CoreInputDeviceTypes.Mouse |
                                                                                      CoreInputDeviceTypes.Pen |
                                                                                      CoreInputDeviceTypes.Touch);
                _inputSource.PointerPressed  += OnPointerPressed;
                _inputSource.PointerMoved    += OnPointerMoved;
                _inputSource.PointerReleased += OnPointerReleased;
            });

            DoInitialize();
        }
コード例 #2
0
        public async Task RunAsync(DispatchedHandler dispatchedHandler)
        {
            if (_canvasAnimatedControl == null)
            {
                throw new InvalidOperationException("This class GameLoopThread is not initialized");
            }

            await _canvasAnimatedControl.RunOnGameLoopThreadAsync(dispatchedHandler);
        }
コード例 #3
0
        public async Task Clean()
        {
            DoClean();
            if (_inputSource != null)
            {
                await _canvasAnimatedControl.RunOnGameLoopThreadAsync(() =>
                {
                    _inputSource.PointerPressed  -= OnPointerPressed;
                    _inputSource.PointerMoved    -= OnPointerMoved;
                    _inputSource.PointerReleased -= OnPointerReleased;
                    _inputSource = null;
                });
            }

            _canvasAnimatedControl = null;
            Scene = null;
        }
コード例 #4
0
 public async Task UpdateAsync()
 {
     await _canvasAnimatedControl.RunOnGameLoopThreadAsync(() => { _scene.Update(); });
 }