Example #1
0
        private bool CheckThumbStickHit(ThumbStickDefinition theStick, Vector2 location)
        {
            Vector2   stickPosition = theStick.Position + theStick.Offset;
            Rectangle thumbRect     = new Rectangle((int)stickPosition.X, (int)stickPosition.Y, theStick.TextureRect.Width, theStick.TextureRect.Height);

            return(thumbRect.Contains(location));
        }
        /// <summary>
        /// Loads graphics content for this screen. The background texture is quite
        /// big, so we use our own local ContentManager to load it. This allows us
        /// to unload before going from the menus into the game itself, wheras if we
        /// used the shared ContentManager provided by the Game class, the content
        /// would remain loaded forever.
        /// </summary>
        public override void LoadContent()
        {
            title      = ScreenManager.Game.Content.Load <Texture2D>("title");
            background = ScreenManager.Game.Content.Load <Texture2D>("background");
            // Setup virtual gamepad
            gamepadTexture = ScreenManager.Game.Content.Load <Texture2D>("gamepad");
            ButtonDefinition BButton = new ButtonDefinition();

            BButton.Texture     = gamepadTexture;
            BButton.Position    = new Vector2(270, 240);
            BButton.Type        = Buttons.Back;
            BButton.TextureRect = new Rectangle(72, 77, 36, 36);

            ButtonDefinition AButton = new ButtonDefinition();

            AButton.Texture     = gamepadTexture;
            AButton.Position    = new Vector2(30, 420);
            AButton.Type        = Buttons.A;
            AButton.TextureRect = new Rectangle(73, 114, 36, 36);

            GamePad.ButtonsDefinitions.Add(BButton);
            GamePad.ButtonsDefinitions.Add(AButton);

            ThumbStickDefinition thumbStick = new ThumbStickDefinition();

            thumbStick.Position    = new Vector2(220, 400);
            thumbStick.Texture     = gamepadTexture;
            thumbStick.TextureRect = new Rectangle(2, 2, 68, 68);

            GamePad.LeftThumbStickDefinition = thumbStick;
        }
        /// <summary>
        /// Load graphics content for the game.
        /// </summary>
        public override void LoadContent()
        {
            if (content == null)
            {
                content = new ContentManager(ScreenManager.Game.Services, "Content");
            }
            spriteBatch = new SpriteBatch(ScreenManager.GraphicsDevice);
            lineBatch   = new LineBatch(ScreenManager.GraphicsDevice);
            spriteFont  = content.Load <SpriteFont>("Fonts/retroSmall");
            starTexture = content.Load <Texture2D>("Textures/blank");

            // update the projection in the line-batch
            lineBatch.SetProjection(Matrix.CreateOrthographicOffCenter(0.0f,
                                                                       ScreenManager.GraphicsDevice.Viewport.Width,
                                                                       ScreenManager.GraphicsDevice.Viewport.Height, 0.0f, 0.0f, 1.0f));
#if ANDROID || IOS
            gamePadTexture = content.Load <Texture2D>("Textures/gamepad");

            ThumbStickDefinition thumbStickLeft = new ThumbStickDefinition();
            thumbStickLeft.Position    = new Vector2(10, 400);
            thumbStickLeft.Texture     = gamePadTexture;
            thumbStickLeft.TextureRect = new Rectangle(2, 2, 68, 68);

            GamePad.LeftThumbStickDefinition = thumbStickLeft;

            ThumbStickDefinition thumbStickRight = new ThumbStickDefinition();
            thumbStickRight.Position    = new Vector2(240, 400);
            thumbStickRight.Texture     = gamePadTexture;
            thumbStickRight.TextureRect = new Rectangle(2, 2, 68, 68);

            GamePad.RightThumbStickDefinition = thumbStickRight;
#endif
        }
Example #4
0
 private void RenderThumbStick(ThumbStickDefinition theStick, SpriteBatch batch)
 {
     if (batch == null)
     {
         throw new InvalidOperationException("SpriteBatch not set.");
     }
     batch.Draw(theStick.Texture, theStick.Position + theStick.Offset, theStick.TextureRect, _alphaColor);
 }
Example #5
0
        /// <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);

            // TODO: use this.Content to load your game content here
            Services.AddService(typeof(SpriteBatch), spriteBatch);

            // Setup virtual gamepad
            gamepadTexture = Content.Load <Texture2D>("gamepad.png");
            ButtonDefinition BButton = new ButtonDefinition();

            BButton.Texture     = gamepadTexture;
            BButton.Position    = new Vector2(100, 420);
            BButton.Type        = Buttons.Back;
            BButton.TextureRect = new Rectangle(72, 77, 36, 36);

            ButtonDefinition AButton = new ButtonDefinition();

            AButton.Texture     = gamepadTexture;
            AButton.Position    = new Vector2(150, 420);
            AButton.Type        = Buttons.A;
            AButton.TextureRect = new Rectangle(73, 114, 36, 36);

            GamePad.ButtonsDefinitions.Add(BButton);
            GamePad.ButtonsDefinitions.Add(AButton);

            ThumbStickDefinition thumbStick = new ThumbStickDefinition();

            thumbStick.Position              = new Vector2(220, 400);
            thumbStick.Texture               = gamepadTexture;
            thumbStick.TextureRect           = new Rectangle(2, 2, 68, 68);
            GamePad.LeftThumbStickDefinition = thumbStick;

            // Create the audio bank
            audio = new AudioLibrary(Content);
            Services.AddService(typeof(AudioLibrary), audio);

            // Create the Start Scene
            smallFont              = Content.Load <SpriteFont>("menuSmall");
            largeFont              = Content.Load <SpriteFont>("menuLarge");
            startElementsTexture   = Content.Load <Texture2D>("startsceneelements.png");
            startBackgroundTexture = Content.Load <Texture2D>("startbackground");
            startScene             = new StartScene(this, smallFont, largeFont, startBackgroundTexture, startElementsTexture);
            Components.Add(startScene);

            // Start the game in the start Scene :)
            startScene.Show();
            activeScene = startScene;
        }
Example #6
0
        /// <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);

            // TODO: use this.Content to load your game content here
            texture  = Content.Load <Texture2D>("gamepad.png");
            caracter = Content.Load <Texture2D>("monogameicon");
            font     = Content.Load <SpriteFont>("font");

            // Set the virtual GamePad
            ButtonDefinition BButton = new ButtonDefinition();

            BButton.Texture     = texture;
            BButton.Position    = new Vector2(200, 150);
            BButton.Type        = Buttons.B;
            BButton.TextureRect = new Rectangle(72, 77, 36, 36);

            ButtonDefinition AButton = new ButtonDefinition();

            AButton.Texture     = texture;
            AButton.Position    = new Vector2(150, 150);
            AButton.Type        = Buttons.A;
            AButton.TextureRect = new Rectangle(73, 114, 36, 36);

            GamePad.ButtonsDefinitions.Add(BButton);
            GamePad.ButtonsDefinitions.Add(AButton);

            ThumbStickDefinition thumbStick = new ThumbStickDefinition();

            thumbStick.Position    = new Vector2(200, 200);
            thumbStick.Texture     = texture;
            thumbStick.TextureRect = new Rectangle(2, 2, 68, 68);

            GamePad.LeftThumbStickDefinition = thumbStick;
        }
Example #7
0
        /// <summary>
        /// Load your content.
        /// </summary>
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            font = Content.Load <SpriteFont> ("Font");

#if ANDROID || IPHONE
            gamePadTexture = Content.Load <Texture2D>("gamepad.png");

            ThumbStickDefinition thumbStickLeft = new ThumbStickDefinition();
            thumbStickLeft.Position    = new Vector2(10, 400);
            thumbStickLeft.Texture     = gamePadTexture;
            thumbStickLeft.TextureRect = new Rectangle(2, 2, 68, 68);

            GamePad.LeftThumbStickDefinition = thumbStickLeft;

            ThumbStickDefinition thumbStickRight = new ThumbStickDefinition();
            thumbStickRight.Position    = new Vector2(240, 400);
            thumbStickRight.Texture     = gamePadTexture;
            thumbStickRight.TextureRect = new Rectangle(2, 2, 68, 68);

            GamePad.RightThumbStickDefinition = thumbStickRight;
#endif
        }