Esempio n. 1
0
File: Game1.cs Progetto: thk123/XGT
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            baseTexture = Content.Load<Texture2D>("BaseTexture");
            buttonTexture = Content.Load<Texture2D>("ButtonTexture");

            PCButton myBtn = new PCButton(buttonTexture, new Rectangle(10, 10, 100, 100)); //create the button with position and size of the button
            myBtn.ConfigureButton(PCButtonState.hover, new Point(100, 0)); //Configure specific button states - eg setting the hover image to be at 100,0 in the texture
            myBtn.ConfigureButton(PCButtonState.pressed, new Point(200,0));
            myBtn.ConfigureButton(PCButtonState.released, new Point(300, 0));

            //Register to specific button events
            myBtn.MouseHover += new EventHandler(myBtn_MouseHover);
            myBtn.RightMousePress += new EventHandler(myBtn_RightMousePress);
            myBtn.LeftMousePress += new EventHandler(myBtn_LeftMousePress);
            myBtn.LeftMouseDoubleClick += new EventHandler(myBtn_LeftMouseDoubleClick);

            myBtn.HotKey = Keys.G; //setting the hotkey means that the button listens for this key and fires mouse click

            mainWindowButtonManager.AddButton(myBtn);

            player = new Character(baseTexture);
        }