Torna indietro   Hardware Upgrade Forum > Software > Programmazione

Marvel's Wolverine, la recensione: Logan torna protagonista in un'avventura brutale e intensa
Marvel's Wolverine, la recensione: Logan torna protagonista in un'avventura brutale e intensa
Marvel's Wolverine porta Logan in un'avventura inedita, violenta e fortemente narrativa, costruita attorno alla sua natura di combattente e al difficile rapporto con il proprio passato. Insomniac Games punta su combattimenti spettacolari, progressione e personalizzazione, inserendo l'azione in un mondo segnato dalla persecuzione dei mutanti. Un viaggio intenso, che alterna mattanza, esplorazione e momenti sorprendentemente emotivi.
DJI Romo 2: tante novità lo rendono un robot completo
DJI Romo 2: tante novità lo rendono un robot completo
Romo 2 è la seconda generazione di robot lavapavimenti di DJI, un modello che si caratterizza per la precisione nel sistema di navigazione e per il funzionamento particolarmente silenzioso. Con le modifiche introdotte in questa seconda versione, e un posizionamento di prezzo più allineato alla concorrenza, rappresenta una valida alternativa sul mercato delle soluzioni di pulizia domestica
Sony Bravia 9 II: il True RGB alla prova, dove l'LCD sfida l'OLED
Sony Bravia 9 II: il True RGB alla prova, dove l'LCD sfida l'OLED
Il primo Sony con retroilluminazione True RGB alla prova del banco di misura e dei contenuti: luminanza enorme, colori accurati in HDR e un antiriflesso molto efficace. I limiti sono due sole HDMI 2.1 e il blooming fuori asse
Tutti gli articoli Tutte le news

Vai al Forum
Rispondi
 
Strumenti
Old 13-10-2007, 17:12   #1
HipT
Member
 
Iscritto dal: Feb 2007
Messaggi: 213
Background su XNA Game Studio

Ciao a tutti.
Vorrei sapere come posso inserire un background su un programma con xna game studio.Ora,riesco a visualizzare una texture ma devo visualizzare un background,
ho cercato alcuni esempi in internet,provato a inserire il codice nel mio programma ma mi da' degli errori...

Vi riporto il codice:
Codice:
#region Using Statements
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
#endregion

public class Game1 : Microsoft.Xna.Framework.Game
{
    GraphicsDeviceManager graphics;
    ContentManager content;
    //The 2D textures for the background
    Texture2D[] mBackgroundTexture = new Texture2D[1];

    //The X position of the background
    int mBackground1X = 0;


    //The object to draw the sprites 
    SpriteBatch mSpriteBatch;

    public Game1()
    {
        graphics = new GraphicsDeviceManager(this);
        content = new ContentManager(Services);
        ////////////////////////////////
    }

    protected override void Initialize()
    {
        base.Initialize();
    }

    // This is a texture we can render.
    Texture2D sfondo,button1;

    // Set the coordinates to draw the sprite at.
    Vector2 posfondo = Vector2.Zero;
    Vector2 posbutton1 = Vector2.Zero;

    // This is the object that will draw the sprites.
    SpriteBatch spriteBatch;
    SpriteBatch imgbutton1Batch;


    protected override void LoadGraphicsContent(bool loadAllContent)
    {
        if (loadAllContent)
        {
            //mette a modalità finestra e imposta la risoluzione
            graphics.IsFullScreen = false;
            graphics.PreferredBackBufferHeight = 768;
            graphics.PreferredBackBufferWidth = 1024;
            graphics.ApplyChanges();   
            /////////////////////
            sfondo = content.Load<Texture2D>("416");
            spriteBatch = new SpriteBatch(graphics.GraphicsDevice);
            ///////////////
            imgbutton1Batch = new SpriteBatch(graphics.GraphicsDevice);
            button1 = content.Load<Texture2D>("entry");
        }
    }
    void LoadResources()
    {
        //Load the image into the texture object
        ContentManager aLoader = new ContentManager(Services);

        //Load the image into the texture object
        mBackgroundTexture[0] = aLoader.Load<Texture2D>("Background1") as Texture2D;

        //Set the starting "X" position for each of the background
        mBackground1X = 0;
        //Initialze the sprite batch object. This will be used to draw the sprite
        mSpriteBatch = new SpriteBatch(graphics.GraphicsDevice);
    }

    protected override void UnloadGraphicsContent(bool unloadAllContent)
    {
        if (unloadAllContent == true)
        {
            content.Unload();
        }
    }

    // Store some information about the sprite's motion.
    Vector2 spriteSpeed = new Vector2(50.0f, 50.0f);

    protected override void Update(GameTime gameTime)
    {
        // Allows the default game to exit on Xbox 360 and Windows.
        if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            this.Exit();
        base.Update(gameTime);
    }

    void UpdateSprite1(GameTime gameTime)
    {

    }

    protected override void Draw(GameTime gameTime)
    {
        graphics.GraphicsDevice.Clear(Color.CornflowerBlue);

        // Draw the sprite.
        spriteBatch.Begin(SpriteBlendMode.AlphaBlend);
        spriteBatch.Draw(sfondo, posfondo, Color.White);
        spriteBatch.End();
        ///////////////
        mSpriteBatch.Begin(SpriteBlendMode.Additive);
        mSpriteBatch.Draw(mBackgroundTexture[0], new Rectangle(mBackground1X, 0, this.Window.ClientBounds.Width, this.Window.ClientBounds.Height), Color.White);
        mSpriteBatch.End();
        ///////////////

        base.Draw(gameTime);
    }
}
L'errore me lo da' nel metodo "Draw",nell'ultima parte,quella compresa tra "/"
In debug non mi da' errori,solo in esecuzione si chiude tutto e mi segna la riga
"mSpriteBatch.Begin(SpriteBlendMode.Additive);" e se tolgo quella,le altre sotto...l'errore:"Riferimento a un oggetto non impostato su un'istanza di oggetto."

Come posso fare?
Questa cosa mi blocca di brutto...

Grazie.
HipT è offline   Rispondi citando il messaggio o parte di esso
 Rispondi


Marvel's Wolverine, la recensione: Logan torna protagonista in un'avventura brutale e intensa Marvel's Wolverine, la recensione: Logan torna p...
DJI Romo 2: tante novità lo rendono un robot completo DJI Romo 2: tante novità lo rendono un ro...
Sony Bravia 9 II: il True RGB alla prova, dove l'LCD sfida l'OLED Sony Bravia 9 II: il True RGB alla prova, dove l...
Geely EX5, un mese al volante: il SUV elettrico cinese che ci ha sorpreso (quasi) senza riserve Geely EX5, un mese al volante: il SUV elettrico ...
Mova Z70 Ultra Roller Complete: motore potente, rullo di lavaggio e l'IA a guidare Mova Z70 Ultra Roller Complete: motore potente, ...
Sciopero negli Apple Store italiani nel ...
vivo V70 5G a 461,70€: smartphone con fo...
Metal Slug Ultimate Collection annunciat...
Basta file di testo in chiaro: Android s...
Dalla CO2 al metano usando l'elettricità...
iOS 27 arriva il 14 settembre: ecco qual...
Ray-Ban Meta dentro il carcere: il video...
NVIDIA cambia la RTX 5070? Chip pi&ugrav...
Qwen3.8-27B gira su un portatile da 12GB...
Gemini lascia il browser e diventa un'ap...
EA e Savvy Games verso un unico colosso ...
Attenzione al falso SMS di BRT: dopo la ...
ASUS ROG Raikiri II Pro PC: controller d...
SteelSeries Aeon Pro: il primo controlle...
Il suo laptop lo stava 'cuocendo': bambi...
Chromium
GPU-Z
OCCT
LibreOffice Portable
Opera One Portable
Opera One 106
CCleaner Portable
CCleaner Standard
Cpu-Z
Driver NVIDIA GeForce 546.65 WHQL
SmartFTP
Trillian
Google Chrome Portable
Google Chrome 120
VirtualBox
Tutti gli articoli Tutte le news Tutti i download

Strumenti

Regole
Non Puoi aprire nuove discussioni
Non Puoi rispondere ai messaggi
Non Puoi allegare file
Non Puoi modificare i tuoi messaggi

Il codice vB è On
Le Faccine sono On
Il codice [IMG] è On
Il codice HTML è Off
Vai al Forum


Tutti gli orari sono GMT +1. Ora sono le: 10:22.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Served by www3v