Ejemplo n.º 1
0
        protected override void OnDestroy()
        {
            base.OnDestroy();

            _cloudService.Disconnect();

            _joystickInputDriver?.Dispose();
            _joystickInputDriver = null;

            foreach (var pair in _paints)
            {
                pair.Value.Dispose();
            }

            _paints.Clear();

            _handler.RemoveCallbacks(_advanceAction);
            _handler.Dispose();
            _handler = null;

            _handlerThread.Looper.Quit();
            _handlerThread.Dispose();
            _handlerThread = null;

            _advanceAction = null;

            _snakeView.Dispose();
            _snakeView = null;

            _scoreView.Dispose();
            _scoreView = null;
        }
Ejemplo n.º 2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            _cloudService.Connect();

            SetContentView(Resource.Layout.Snake);

            _handlerThread = new HandlerThread("background");
            _handlerThread.Start();
            _handler = new Handler(_handlerThread.Looper);

            _paints[PositionState.Empty] = new Paint {
                Color = Color.Argb(50, 255, 255, 255)
            };
            _paints[PositionState.Snake] = new Paint {
                Color = Color.Argb(255, 0, 100, 0)
            };
            _paints[PositionState.Food] = new Paint {
                Color = Color.Argb(100, 255, 255, 0)
            };

            _joystickInputDriver = new JoystickInputDriver(new[] { Keycode.Button10, Keycode.Button11, Keycode.Button12, Keycode.Button13, Keycode.Button14 });
        }