Torna indietro   Hardware Upgrade Forum > Software > Programmazione

Oracle AI World 2026: in Europa prima la sovranità, poi la sicurezza e solo dopo l'IA
Oracle AI World 2026: in Europa prima la sovranità, poi la sicurezza e solo dopo l'IA
In tre giorni a Las Vegas Oracle ha presentato agenti che eseguono il lavoro, l'alleanza con OpenAI e un cloud aperto agli acceleratori di tutti. Ma i clienti europei chiedono garanzie prima ancora delle funzionalità
DS N°7 E-Tense: il SUV premium made in Melfi che punta su autonomia e comfort
DS N°7 E-Tense: il SUV premium made in Melfi che punta su autonomia e comfort
Fino a 740 km WLTP con la batteria da 97,2 kWh, sospensioni che leggono la strada con una telecamera e un abitacolo da salotto parigino. La nuova DS N°7 raccoglie l'eredità della DS 7 e la porta, per la prima volta, nel mondo 100% elettrico. Ecco come è fatta, cosa offre e quanto costa.
Recensione Samsung Galaxy Tab S12 Ultra: non chiamatelo tablet... è molto di più
Recensione Samsung Galaxy Tab S12 Ultra: non chiamatelo tablet... è molto di più
Abbiamo provato Samsung Galaxy Tab S12 Ultra nella versione 12 GB + 256 GB con tastiera, e il risultato è un tablet che in questa configurazione si comporta come un notebook con la fluidità tipica di Android. Spessore di 5,1 mm, display Dynamic AMOLED 2X da 14,6 pollici, MediaTek Dimensity 9500 e un software senza incertezze compongono un prodotto di vertice, con prezzi da 1.539 euro, frenato solo da un'autonomia nella parte bassa del confronto
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


Oracle AI World 2026: in Europa prima la sovranità, poi la sicurezza e solo dopo l'IA Oracle AI World 2026: in Europa prima la sovrani...
DS N°7 E-Tense: il SUV premium made in Melfi che punta su autonomia e comfort DS N°7 E-Tense: il SUV premium made in Melfi...
Recensione Samsung Galaxy Tab S12 Ultra: non chiamatelo tablet... è molto di più Recensione Samsung Galaxy Tab S12 Ultra: non chi...
Hyundai IONIQ 5 N, l'elettrica che finge di essere termica (e ci riesce da paura) Hyundai IONIQ 5 N, l'elettrica che finge di esse...
CES Unveiled Milan, l'IA diventa tecnologia fondativa e il commercio torna centrale CES Unveiled Milan, l'IA diventa tecnologia fond...
Tracking pixel nelle email: cosa cambia ...
La GeForce RTX 5080 da 24 GB potrebbe ar...
Apple mette alle strette OpenAI, la caus...
Xbox ancora in calo: ecco com'è a...
Car of the Year 2027: sette finaliste e ...
Google Beam cambia tutto: arrivano le vi...
Curry Barker, il regista di Obsession, p...
Intel Nova Lake: fino al 33% di prestazi...
L'IA accelera gli attacchi e complica la...
GTA 6 avrà circa 600.000 animazio...
SpaceX non ha più bisogno della NASA, e ...
Apple TV 4K e iPad mini OLED, Xcode 27.2...
Prime Video vale ormai decine di miliard...
Amazon: AWS cresce del 39,3%, ma gli inv...
6,3 miliardi di dollari sottratti in men...
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: 16:49.


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