Timeline for Loading class instance from XML with Texture2D
Current License: CC BY-SA 3.0
18 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jul 3, 2012 at 22:05 | vote | accept | Thegluestickman | ||
| Jun 20, 2012 at 13:41 | answer | added | Marton | timeline score: 1 | |
| Jun 10, 2012 at 10:12 | comment | added | Andrew Russell | See also this answer: stackoverflow.com/questions/6783131/… | |
| Jun 10, 2012 at 10:06 | comment | added | Andrew Russell |
It's worth pointing out that there is a way to make this work "nicely", where the ContentManager will load and manage your texture for you. But it's pretty damn complicated - some might say not worth the effort (given that Blau's solution is almost as good). It involves having Texture2DContent at build time and Texture2D at runtime, and messing about with ExternalReference. Sadly I can't seem to find the code I had for this - so I can't put together an answer for you. Perhaps someone else has this working?
|
|
| Jun 9, 2012 at 22:57 | comment | added | Thegluestickman | @Blau Whaddya know, that works perfectly. | |
| Jun 9, 2012 at 17:19 | comment | added | Blau | Don't save the texture, save the path to it... and after loading the weeapon, call an initialize method in that weapon that loads the texture from content. | |
| Jun 9, 2012 at 16:09 | comment | added | Thegluestickman | @AndrewRussell Thank you for clarifying my question. The problem I have is displaying a texture of the weapon without the texture instance being part of the class. I tried to make it load from a static class so the XML wouldn't have to parse the loading code but it results in error. | |
| Jun 9, 2012 at 14:48 | comment | added | Andrew Russell |
It's worth pointing out that, if you remove the Texture2D field from the class and the XML, in a properly set up set of projects, everything else works fine.
|
|
| Jun 9, 2012 at 14:19 | comment | added | Andrew Russell |
I've given your question a better name - the tricky bit is the Texture2D.
|
|
| Jun 9, 2012 at 14:18 | history | edited | Andrew Russell | CC BY-SA 3.0 |
Renamed question
|
| Jun 8, 2012 at 22:06 | comment | added | Thegluestickman | @Torious Updated | |
| Jun 8, 2012 at 22:06 | history | edited | Thegluestickman | CC BY-SA 3.0 |
added 289 characters in body
|
| Jun 8, 2012 at 21:56 | comment | added | Torious |
Show the Weapon class too
|
|
| Jun 8, 2012 at 16:34 | history | tweeted | twitter.com/#!/StackGameDev/status/211134034397507585 | ||
| Jun 8, 2012 at 14:39 | history | edited | Thegluestickman | CC BY-SA 3.0 |
added 7 characters in body
|
| Jun 8, 2012 at 14:38 | comment | added | Thegluestickman | @NeilKnight Yes, I didn't indent it properly and while it was there in the question it wasn't displayed right. It has been fixed. | |
| Jun 8, 2012 at 14:18 | comment | added | Neil Knight |
In your example XML, you are missing </XnaContent>, is this a typing mistake?
|
|
| Jun 8, 2012 at 13:42 | history | asked | Thegluestickman | CC BY-SA 3.0 |