Torna indietro   Hardware Upgrade Forum > Software > Programmazione

Marathon: arriva il Fortnite hardcore
Marathon: arriva il Fortnite hardcore
Marathon è il titolo multiplayer competitivo del momento. Ecco quali sono le caratteristiche di gioco principali, insieme alle nostre prime considerazioni dopo qualche "run" nell'extraction shooter di Bungie
HP Imagine 2026: abbiamo visto HP IQ all’opera, ecco cosa può (e non può) fare
HP Imagine 2026: abbiamo visto HP IQ all’opera, ecco cosa può (e non può) fare
A New York HP ha messo al centro della scena HP IQ, la piattaforma di IA locale da 20 miliardi di parametri. L’abbiamo vista in funzione: è uno strumento che funziona, pensato per un target specifico, con vantaggi reali e limiti altrettanto evidenti
PNY RTX 5080 Slim OC, sembra una Founders Edition ma non lo è
PNY RTX 5080 Slim OC, sembra una Founders Edition ma non lo è
La PNY GeForce RTX 5080 Slim OC si distingue nel panorama delle GPU di fascia alta per il design compatto a due slot, ispirato alla NVIDIA GeForce RTX 5080 Founders Edition. In questo test analizziamo comportamento termico e prestazioni in gioco, valutando se il formato ridotto comprometta o meno l'esperienza complessiva rispetto alle soluzioni più ingombranti presenti sul mercato.
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


Marathon: arriva il Fortnite hardcore Marathon: arriva il Fortnite hardcore
HP Imagine 2026: abbiamo visto HP IQ all’opera, ecco cosa può (e non può) fare HP Imagine 2026: abbiamo visto HP IQ all’opera, ...
PNY RTX 5080 Slim OC, sembra una Founders Edition ma non lo è PNY RTX 5080 Slim OC, sembra una Founders Editio...
Wi-Fi 7 con il design di una vetta innevata: ecco il nuovo sistema mesh di Huawei Wi-Fi 7 con il design di una vetta innevata: ecc...
Core Ultra 7 270K Plus e Core Ultra 7 250K Plus: Intel cerca il riscatto ma ci riesce in parte Core Ultra 7 270K Plus e Core Ultra 7 250K Plus:...
GeForce RTX 3080 raffreddata con un diss...
Proofpoint mette in sicurezza gli agenti...
Annunci falsi su Bakeca con dati veri di...
Attenzione alla truffa dell'assegno di A...
Addio al mito delle batterie a stato sol...
400 milioni e un obiettivo ambizioso: Re...
TCL 2026: la tecnologia SQD-Mini LED arr...
Gli aggiornamenti arriveranno, ma non si...
Monopattini elettrici: addio "Far W...
Mistral AI raccoglie 830 milioni di doll...
Hacker iraniani di Handala violano la Gm...
Chi è Eddie Dalton: il cantante d...
OVHcloud mette l'Italia al centro della ...
Zeekr 007 GT sold out in Cina, si passa ...
Hisense QLED 4K da 98'' e 85'' con 144Hz...
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: 04:28.


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