Exemplo n.º 1
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;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Open a new scene
 /// </summary>
 /// <param name="scene">Scene to be opened</param>
 protected void ShowScene(GameScene scene)
 {
     activeScene.Hide();
     activeScene = scene;
     scene.Show();
 }