Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > .NET Languages
You last visited: Today at 16:31

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



C# XNA Texture2D per Url?

Discussion on C# XNA Texture2D per Url? within the .NET Languages forum part of the Coders Den category.

Reply
 
Old   #1
 
Psycho_Ente's Avatar
 
elite*gold: 4
Join Date: Oct 2009
Posts: 278
Received Thanks: 321
C# XNA Texture2D per Url?

Hi Leute.
Ich arbeite momentan an einem kleinen Spiel und kenne bisher nur die Möglichkeit eine 2D texture vom Content zu zuweisen.
Allerdings würde ich diese gerne per URL zuweisen, da ich vor habe, dass
verschiedene User ihren eigenen Skin hochladen können.

Kennt jemand einen Weg?
Psycho_Ente is offline  
Old 01/23/2012, 20:29   #2
 
elite*gold: 50
Join Date: Mar 2010
Posts: 1,373
Received Thanks: 521
Schau mal hier:

Die URI in einen String um zu wandeln sollte ja kein Problem darstellen.
jacky919 is offline  
Thanks
1 User
Old 01/23/2012, 21:14   #3
 
Psycho_Ente's Avatar
 
elite*gold: 4
Join Date: Oct 2009
Posts: 278
Received Thanks: 321
Danke für deine Antwort.
Ich habe das nun so im Code stehen, da ich nur FromStream erblicken konnte:
Code:
 public void LoadContent(ContentManager Content)
        {
           
            try
            {
                WebClient client = new WebClient();
                Uri url = new Uri("http://*********.de/ekonomiapictures/Player.png");// + PlayerName + ".png"
                Stream stream = client.OpenRead(url.ToString());
                characterz = Texture2D.FromStream(graphics.GraphicsDevice, stream);
                stream.Flush();
                stream.Close();
                Draw(spriteBatch);
                ldSkin = true;
                
            }
            catch (Exception e) {  }
            ...
Leider Entsteh kein Bild. Was mache ich falsch?
Nebeninformation: ldSkin ist eine Öffentliche Variable, welche bei der Draw Methode in der Game1.cs abgefragt wird... Denn der Spieler wird in einer Extra Klasse behandelt

Danke für weitere Antworten (:
Psycho_Ente is offline  
Old 01/23/2012, 22:29   #4
 
elite*gold: 14
The Black Market: 108/0/1
Join Date: May 2011
Posts: 2,671
Received Thanks: 818
Warum callst du Draw?

Btw, du kannst nicht einfach so ne URL laden.
Du musst zuerst die File speichern und dann mit nem FileStream auslesen.
vwap is offline  
Old 01/24/2012, 18:09   #5

 
x]vIrus[x's Avatar
 
elite*gold: 37
Join Date: Apr 2004
Posts: 2,154
Received Thanks: 250
Quote:
Originally Posted by Headpuster View Post
Warum callst du Draw?

Btw, du kannst nicht einfach so ne URL laden.
Du musst zuerst die File speichern und dann mit nem FileStream auslesen.
warum sollte er das nicht können?

probiers mal mit diesem stream:
Stream stream = new MemoryStream(new WebClient().DownloadData("http://www.google.de/images/srpr/logo3w.png"));
x]vIrus[x is offline  
Old 01/24/2012, 18:13   #6
 
elite*gold: 14
The Black Market: 108/0/1
Join Date: May 2011
Posts: 2,671
Received Thanks: 818
Quote:
Originally Posted by x]vIrus[x View Post
warum sollte er das nicht können?
Lol, das ist jetzt aber nicht dein Ernst oder?
Ein FileStream beinhaltet keine System.Net Funktionen, wie das automatische holen von Bytes aus dem Netz.
Schau dir einfach mal die Exception Types von einem FileStream an. Da ist keine System.Net-Exception dabei. Somit erledigt sich das.
vwap is offline  
Old 01/24/2012, 18:54   #7

 
x]vIrus[x's Avatar
 
elite*gold: 37
Join Date: Apr 2004
Posts: 2,154
Received Thanks: 250
aaaaaaaaaaha o,o

/edit: +aaaaaa
x]vIrus[x is offline  
Old 01/24/2012, 19:11   #8
 
Psycho_Ente's Avatar
 
elite*gold: 4
Join Date: Oct 2009
Posts: 278
Received Thanks: 321
Ich habe mir überlegt das ganze anders zu machen.
Trotzdem danke an euch beide... (:
Psycho_Ente is offline  
Reply




All times are GMT +1. The time now is 16:32.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.