XNA Creators Club Online
Page 1 of 1 (11 items)
Sort Posts: Previous Next

Simple logistical question re: spritesheets

Last post 10/24/2007 7:14 PM by Catalin Zima. 10 replies.
  • 10/24/2007 3:28 PM

    Simple logistical question re: spritesheets

    Say you've got a spritesheet containing 50 discrete images of varying sizes.  Right now I create a companion text file for each sheet like this:

    name1, x, y, w, h
    name2, x, y, w, h

    At the top of the game I turn that list into a name-keyed hash of rectangles.  When sprites are born they dip into the hash (just once, they cache the rectangle) so the sprite knows which area of the sheet to use when it draws.  So I have to hard-code certain sprites to use certain rectangle names.  I kinda want the spritesheets to be user-definable later on, so I'm favoring some kind of external definition thing.

    This works ok but feels a little "low-tech".  Is there a time-tested way of doing this sort of thing, or is this pretty much it?
  • 10/24/2007 4:10 PM In reply to

    Re: Simple logistical question re: spritesheets

    Your approach seems good enough, and right now I can't think of a much better method.

    Maybe storing those values in an XML file, and making a sort of "visual editor" for defining regions in the texture as sprites.

     

  • 10/24/2007 4:39 PM In reply to

    Re: Simple logistical question re: spritesheets

    Whatever works, really.

    One company I used to work for had a tool the artists used, which had a graphical UI for marking boxes around areas of a spritesheet, editing their names, etc.

    Personally I'm a big fan of automating this kind of thing. It seems to me that sprite sheets are really just an implementation detail relating to how you optimize your data, so it seems kind of wrong to make artists worry about that. I don't believe that your source artwork should need to be constructed in a special way just because of some rendering optimisation you want to do in your engine. So on games I made myself, I ran a tool as part of the content build process which would read in many individual textures, arrange them all onto a single sheet, and then save out that generated sheet along with an index describing where each texture was located (basically the same process the font sample on this website uses to arrange the character glyph images). That way the source content just remains hundreds of individual bitmaps, and there's no need for manual housekeeping work keeping the rectangle information up to date, or figuring out what to call each sprite.
    XNA Framework Developer - blog - homepage
  • 10/24/2007 4:42 PM In reply to

    Re: Simple logistical question re: spritesheets

    Yea XML would be optimal. And GUI would be sweet :) editing the text file is tedious, but oh well.  Other priorities, you know how it is.

    I'm working on this project alone so it's nice to bounce things off someone before I get way off on the wrong track.  Thanks for the input.
  • 10/24/2007 4:44 PM In reply to

    Re: Simple logistical question re: spritesheets

    Shawn's idea is very cool (...DUH!...). And this would probably be a nice job for the Content Pipeline.
  • 10/24/2007 4:59 PM In reply to

    Re: Simple logistical question re: spritesheets

    Yea I concur, "build-a-sheet" rocks the casbah.  Thanks Shawn :)
  • 10/24/2007 5:21 PM In reply to

    Re: Simple logistical question re: spritesheets

    Hadn't someone made one of these and posted it in the forums? Hmm...maybe I should have looked before I posted this. Off to search now. I don't know why I haven't been doing things this way. I was just struggling last night with getting tiles lined up just right in my tilesheet.

    Thanks for reminding me I'm doing it the hard way :) Now if I can just find that tool.....
  • 10/24/2007 5:27 PM In reply to

    Re: Simple logistical question re: spritesheets

    are you reffering to this ?
  • 10/24/2007 5:44 PM In reply to

    Re: Simple logistical question re: spritesheets

    That would be the one! Thanks for finding it, I did some quick searches on the forums, but I wasn't haven't much luck. Maybe I've lost my keyword mojo....
  • 10/24/2007 6:38 PM In reply to

    Re: Simple logistical question re: spritesheets

    Hey, that's pretty sweet!  I must have missed that post on Ziggy's site.  Thanks for the link, Catalin.

    Tom

     

  • 10/24/2007 7:14 PM In reply to

    Re: Simple logistical question re: spritesheets

    I also remembered reading about this small program sometime in the past, but couldn't remember exactly where.

    So I googled "XNA Spritesheet", and there it was, the second result

    :-)

Page 1 of 1 (11 items) Previous Next