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(); }
public async Task RunAsync(DispatchedHandler dispatchedHandler) { if (_canvasAnimatedControl == null) { throw new InvalidOperationException("This class GameLoopThread is not initialized"); } await _canvasAnimatedControl.RunOnGameLoopThreadAsync(dispatchedHandler); }
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; }
public async Task UpdateAsync() { await _canvasAnimatedControl.RunOnGameLoopThreadAsync(() => { _scene.Update(); }); }