Ejemplo n.º 1
0
 /// <summary>
 /// Creates a UIButton element.
 /// </summary>
 /// <param name="parent">The containing UIElement for this button (required).</param>
 /// <param name="position">The position of this button's center relative to its parent center.</param>
 /// <param name="width">The render width of the button in pixels.</param>
 /// <param name="height">The render height of this button in pixels.</param>
 public UIButton(UIElement parent, Vector2 position, int width, int height)
     : base(parent, position, width, height)
 {
     buttonStateMachine = new ButtonStateMachine(Controller, (int)width, (int)height);
     buttonStateMachine.Click += OnButtonClick;
     base.StateMachine = buttonStateMachine;
     StateMachine.Tag = this;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a UIButton element.
        /// </summary>
        /// <param name="game">XNA Game that owns this element.</param>
        /// <param name="controller">UIController associated with the state machine for this element.</param>
        /// <param name="positionX">Element position X-coordinate (relative or screen coordinate).</param>
        /// <param name="positionY">Element position Y-coordinate (relative or screen coordinate).</param>
        /// <param name="width">Desired width of the element in pixels.</param>
        /// <param name="height">Desired height of the element in pixels.</param>
        /// <param name="parent">The containing UIElement for this button (optional).</param>
        /// <remarks>If parent is not null (x,y) position coordinates are expected to be relative to the parent,
        /// otherwise they are interpreted as screen coordinates.</remarks>
        public UIButton(Game game, UIController controller, float positionX, float positionY, int width, int height, UIElement parent)
            : base(game, controller, null, new Vector2(positionX, positionY), width, height, parent)
        {
            buttonStateMachine = new ButtonStateMachine(controller, (int)width, (int)height);
            buttonStateMachine.Click += OnButtonClick;

            base.StateMachine = buttonStateMachine;
            StateMachine.Tag = this;
        }