Torna indietro   Hardware Upgrade Forum > Software > Programmazione

Recensione HUAWEI Mate X7: un foldable ottimo, ma restano i soliti problemi
Recensione HUAWEI Mate X7: un foldable ottimo, ma restano i soliti problemi
Mate X7 rinnova la sfida nel segmento dei pieghevoli premium puntando su un design ancora più sottile e resistente, unito al ritorno dei processori proprietari della serie Kirin. L'assenza dei servizi Google e del 5G pesa ancora sull'esperienza utente, ma il comparto fotografico e la qualità costruttiva cercano di compensare queste mancanze strutturali con soluzioni ingegneristiche di altissimo livello
Nioh 3: souls-like punitivo e Action RPG
Nioh 3: souls-like punitivo e Action RPG
Nioh 3 aggiorna la formula Team NINJA con aree esplorabili più grandi, due stili di combattimento intercambiabili al volo (Samurai e Ninja) e un sistema di progressione pieno di attività, basi nemiche e sfide legate al Crogiolo. La recensione entra nel dettaglio su combattimento, build, progressione e requisiti PC
Test in super anteprima di Navimow i220 LiDAR: il robot tagliaerba per tutti
Test in super anteprima di Navimow i220 LiDAR: il robot tagliaerba per tutti
La facilità di installazione e la completa automazione di tutte le fasi di utilizzo, rendono questo prodotto l'ideale per molti clienti. Ecco com'è andata la nostra prova in anteprima
Tutti gli articoli Tutte le news

Vai al Forum
Rispondi
 
Strumenti
Old 13-10-2007, 18: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


Recensione HUAWEI Mate X7: un foldable ottimo, ma restano i soliti problemi Recensione HUAWEI Mate X7: un foldable ottimo, m...
Nioh 3: souls-like punitivo e Action RPG Nioh 3: souls-like punitivo e Action RPG
Test in super anteprima di Navimow i220 LiDAR: il robot tagliaerba per tutti Test in super anteprima di Navimow i220 LiDAR: i...
Dark Perk Ergo e Sym provati tra wireless, software via browser e peso ridotto Dark Perk Ergo e Sym provati tra wireless, softw...
DJI RS 5: stabilizzazione e tracking intelligente per ogni videomaker DJI RS 5: stabilizzazione e tracking intelligent...
Windows domina su Steam, ma molti utenti...
Per non incorrere in nuovi aumenti delle...
Cubi Z AI 8M visto da vicino, un mini-PC...
Datacenter nello Spazio, affascinante ma...
Social e minori, Butti apre al dibattito...
Tutte le offerte Amazon del weekend, sol...
Amazon spinge sull'usato garantito: 10% ...
TikTok rischia una maxi-multa in Europa:...
Bose su Amazon: QuietComfort SC over ear...
Scope elettriche super accessoriate in o...
Umidità e muffa addio: questo deu...
DREAME Aqua10 Ultra Roller a 999€ &egrav...
500.000 kit gratis consegnati: Noctua fa...
Il MIT sperimenta il calcolo termico: op...
Sembra ormai certo: la prossima Xbox sar...
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: 15:32.


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