private bool _wasOnTarget = false; //was the mouse on target last frame?

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Create a new MouseHandler for the given target.
        /// </summary>
        /// <param name="target">Target.</param>
        public MouseHandler(GameObject target)
        {
            _target = target;
            _game = _target.game;
            _game.OnAfterStep += HandleOnStep;
            _lastX = Input.mouseX;
            _lastY = Input.mouseY;
        }
Example #2
0
        //------------------------------------------------------------------------------------------------------------------------
        //                                                        Game()
        //------------------------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="Game"/> class.
        /// This class represents a game window, containing an openGL view.
        /// </summary>
        /// <param name='width'>
        /// Width of the window in pixels.
        /// </param>
        /// <param name='height'>
        /// Height of the window in pixels.
        /// </param>
        /// <param name='fullScreen'>
        /// If set to <c>true</c> the application will run in fullscreen mode.
        /// </param>
        public Game(int pWidth, int pHeight, bool pFullScreen, bool pVSync = true)
            : base()
        {
            if (main != null) {
                throw new Exception ("Only a single instance of Game is allowed");
            } else {

                main = this;
                _updateManager = new UpdateManager ();
                _collisionManager = new CollisionManager ();
                _glContext = new GLContext (this);
                _glContext.CreateWindow (pWidth, pHeight, pFullScreen, pVSync);
                _gameObjectsContained = new List<GameObject>();

                //register ourselves for updates
                Add (this);

            }
        }