Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9039153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:39:52+00:00 2026-06-16T09:39:52+00:00

I’ve been creating a game in XNA for the past couple weeks. In the

  • 0

I’ve been creating a game in XNA for the past couple weeks. In the process, I tried to solve a problem before I encountered it without fully understanding the problem.

That problem was how I was going to deal with saving and retrieving “blueprint” objects. I need this functionality due to a content creator that I’m making (the game is content-based). So the objective is, I create the content (rough example, an enemy of type “Goblin” with 100 health and a goblin sprite), save it to a serialized object, load it in the game, and then it is usable and duplicable in-game.

Now obviously when objects have something non-serializable like a Texture2D (the sprite), you can’t serialize them. I solved that problem for both maps and objects with sprites (items, NPCs, characters, etc) by adding all my textures to a static class and only storing indices to the textures in the objects (e.g., instead of containing a Texture2D property, the Goblin would contain an index linking to the appropriate texture – slightly oversimplified but you get the idea).

But then the virus spread and I started doing that for all my object references. For example, the Goblin also needs a reference to an AI object. That AI object only has methods and as a result is clearly serializable, but I was storing it in the same static class as my textures and linking to it via index. Looking back on that now, I shudder as to what I was thinking.

So my question is, should everything except textures be stored by direct reference in serializable classes, instead of reference by index? Or is there ever a viable reason to do what I’ve done?

Serialization is a tricky business and I’m trying to wrap my head around the best ways to use it and the right times to avoid it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T09:39:53+00:00Added an answer on June 16, 2026 at 9:39 am

    As you said, serialization cannot keep track of references. Either you serialize the whole object graph, or you come up with your own way of resolving references upon deserializing. So what you did was the right thing to do, although you might want to find a better solution instead of just hanging everything from a static class.

    Also, you might want to change your strategy. Instead of saving the object itself with all the indices, you could save only the required information, and then have a resolver factory that would read this info and populate an object with the right values.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been unable to fix a problem with Java Unicode and encoding. The
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I've tracked down a weird MySQL problem to the two different ways I was
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have thousands of HTML files to process using Groovy/Java and I need to
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
Let's say I'm outputting a post title and in our database, it's Hello Y’all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.