<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.xna.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>General</title><link>http://forums.xna.com/forums/32.aspx</link><description>Don't know where to post your question? Post it here!</description><dc:language>en</dc:language><generator>CommunityServer 2007.1 (Build: 0.0)</generator><item><title>Re: Spritesheets - How are they implemented?</title><link>http://forums.xna.com/forums/thread/27494.aspx</link><pubDate>Tue, 09 Oct 2007 14:15:44 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:27494</guid><dc:creator>The Thing</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/27494.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=32&amp;PostID=27494</wfw:commentRss><description>Thanks emachine,&lt;br&gt;&lt;br&gt;There is a not so subtle difference between what I said about multiples of 2 and your reply of powers of 2&lt;br&gt;&lt;br&gt;Me (The Thing - multiples) = 2, 4, 6, 8, 10, 12, 14, etc, etc.&lt;br&gt;&lt;br&gt;You (emachine - powers) =&amp;nbsp; 2, 4, 8, 16, 32, 64, 128, 256, etc, etc.&amp;nbsp; //This is the correct way. &lt;br&gt;&lt;br&gt;I was curious as to the file size of a 512 x 512 texture so I just created a 24 bit *.png in Paint Shop Pro, saved it to the desktop and I see that it's only 953 bytes in size, but occupies 4,096 bytes on disk.&lt;br&gt;&lt;br&gt;Anyway, just to recap for any other newbies who might be reading this - create your textures / sprite sheets in &lt;u&gt;powers of two&lt;/u&gt;, &lt;br&gt;and after they're loaded into your game you can extract a sprite of any size by specifying a rectangle which will define the sprite's width and height. &amp;nbsp; &amp;nbsp;  &lt;br&gt; &lt;br&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;  &lt;br&gt;&amp;nbsp;  &lt;br&gt;&lt;br&gt;&lt;br&gt;</description></item><item><title>Re: Spritesheets - How are they implemented?</title><link>http://forums.xna.com/forums/thread/27413.aspx</link><pubDate>Mon, 08 Oct 2007 23:14:35 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:27413</guid><dc:creator>emachine74</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/27413.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=32&amp;PostID=27413</wfw:commentRss><description>Yea they should be.&amp;nbsp; I can't explain the technical side of it (it has something to do with the black magic that goes on inside the video card) but the image file that you load (the sheet) should have a width and height that are both a power of 2.&amp;nbsp; &lt;br&gt;&lt;br&gt;On my nVidia based computer at work, if I use a 1024x&lt;b&gt;768&lt;/b&gt; sheet (768 is an even number, but it's not a power of 2) the image quality is very bad (but it works).&amp;nbsp; &lt;br&gt;&lt;br&gt;On ATI based laptop running the same code, I actually get an error because the card simply does not support loading non-power of 2 images.&amp;nbsp; So in my experience not using power of 2 can do anything from lowering quality to breaking the program.&lt;br&gt;&lt;br&gt;Once a power of 2 sheet is loaded into the card, I believe the rectangles you use to make sprites from the sheet can be any size you want.&amp;nbsp; From my 1024x1024 sheet I can use any arbitrary size... 91x47 or 15x4 or whatever, doesn't seem to matter once the sheet is loaded.&lt;br&gt;</description></item><item><title>Re: Spritesheets - How are they implemented?</title><link>http://forums.xna.com/forums/thread/27391.aspx</link><pubDate>Mon, 08 Oct 2007 18:06:01 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:27391</guid><dc:creator>The Thing</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/27391.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=32&amp;PostID=27391</wfw:commentRss><description>Thanks for the replies emachine and The Zedox. I got it working the way The ZMan suggested shortly after he posted his reply.&lt;br&gt;&lt;br&gt;Can anyone tell me if I am correct in thinking that the width and height of a sprite should &lt;u&gt;ideally&lt;/u&gt; be some multiple of 2 - so instead of a sprite being 3 X 5 it should be 4 X 6, or 2 x 4, etc, etc. I'm not 100% sure but I think I saw mention of this on these forums a while back. I don't know why that'd be an issue, but I'm curious. &lt;br&gt;&lt;br&gt;Thanks. &amp;nbsp;  &lt;br&gt;</description></item><item><title>Re: Spritesheets - How are they implemented?</title><link>http://forums.xna.com/forums/thread/27256.aspx</link><pubDate>Sun, 07 Oct 2007 12:12:51 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:27256</guid><dc:creator>The Zedox</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/27256.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=32&amp;PostID=27256</wfw:commentRss><description>Go to this page. Read the tutorial (if you want to be more flexible with your animations) but really look down to where a replyer called "Jay" says something about his animation Framework. http://www.xna3way.com/blog/?p=19&lt;br&gt;&lt;br&gt;I used the base of his entry with the tutorial and added some other things to make a simple a very easy way to make sprite sheets work with more effects.&lt;br&gt;</description></item><item><title>Re: Spritesheets - How are they implemented?</title><link>http://forums.xna.com/forums/thread/27150.aspx</link><pubDate>Sat, 06 Oct 2007 00:51:39 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:27150</guid><dc:creator>emachine74</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/27150.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=32&amp;PostID=27150</wfw:commentRss><description>Here's an example... in VB :P&lt;br&gt;&lt;br&gt;This is a snippet from my sprite class.&amp;nbsp; It holds a pointer to it's sheet (Me.Sheet) as well as the rectangle that defines where on the sheet the texture comes from (Me.objSheetRectangle)&lt;br&gt;&lt;br&gt;XNALib is just a static class of tools in my engine where SpriteBatch lives, among other things.&lt;br&gt;&lt;br&gt;&lt;div style="background-color:White;"&gt;&lt;div style="margin:0px;padding:2px 2px 2px 8px;background-color:White;overflow-x:scroll;overflow-y:hidden;width:505px;"&gt;&lt;pre&gt;&lt;span style="color:Black;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;&lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;With&lt;/span&gt; &lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;Me&lt;/span&gt;&lt;br&gt;&lt;br&gt;&lt;span style="color:Green;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;	'If I have a rectangle definition for my sheet&lt;/span&gt;&lt;br&gt;&lt;br&gt;&lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;	If&lt;/span&gt; .objSheetRectangle &amp;lt;&amp;gt; Rectangle.Empty &lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;Then&lt;/span&gt;&lt;br&gt;&lt;br&gt;&lt;span style="color:Green;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;		'Begin the sprite batch (implements my transform matrix)&lt;/span&gt;&lt;br&gt;&lt;br&gt;		XNALib.SpriteDrawer.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None, .DrawMatrix)&lt;br&gt;&lt;br&gt;&lt;span style="color:Green;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;		'Draw from the sheet to the target (matrix does all the positioning work)&lt;/span&gt;&lt;br&gt;&lt;br&gt;		XNALib.SpriteDrawer.Draw(.Sheet, Vector2.Zero, _&lt;br&gt;			.objSheetRectangle, &lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;New&lt;/span&gt; Color(.Tint.R, .Tint.G, .Tint.B, .byt&lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;&lt;/span&gt;ParentAdjustedAlpha))&lt;br&gt;&lt;br&gt;&lt;span style="color:Green;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;		'End the sprite batch&lt;/span&gt;&lt;br&gt;                    &lt;br&gt;		XNALib.SpriteDrawer.&lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;End&lt;/span&gt;()&lt;br&gt;&lt;br&gt;	&lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;End&lt;/span&gt; &lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;If&lt;/span&gt;&lt;br&gt;&lt;br&gt;&lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;End&lt;/span&gt; &lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;With&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br&gt;&lt;br&gt;</description></item><item><title>Re: Spritesheets - How are they implemented?</title><link>http://forums.xna.com/forums/thread/27134.aspx</link><pubDate>Fri, 05 Oct 2007 17:49:39 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:27134</guid><dc:creator>The Thing</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/27134.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=32&amp;PostID=27134</wfw:commentRss><description>Thank you ZMan, I am working on it now :)&lt;br&gt;</description></item><item><title>Re: Spritesheets - How are they implemented?</title><link>http://forums.xna.com/forums/thread/27132.aspx</link><pubDate>Fri, 05 Oct 2007 17:38:25 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:27132</guid><dc:creator>The ZMan</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/27132.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=32&amp;PostID=27132</wfw:commentRss><description>&lt;P&gt;Extracting sprites from sprite sheets is the wrong way to go. The way that DirectX batches up drawing commands means that you need to minimize these. If you draw 200 sprites each with a differentTexture2D you will cause 200 draw commands to Directx and performance will suffer.&lt;/P&gt;
&lt;P&gt;If you draw 200 sprites from 5 sprite sheets then SpriteBatch will batch this into at most 5 draw calls and your graphics care will barley notice it. If you can put all your sprites in one texture even better.&lt;/P&gt;
&lt;P&gt;So you need to pass the original Texture2D AND a Rectangle to your sprite setup - then when you draw it just use an overload that allows you to choose which part of a texture to Draw. The rectangle describes where in the texture each sprite goes.&lt;/P&gt;
&lt;P&gt;Make sure you don't do a SpriteBatch.Begin/End for each sprite - that is also just as bad.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description></item><item><title>Spritesheets - How are they implemented?</title><link>http://forums.xna.com/forums/thread/27131.aspx</link><pubDate>Fri, 05 Oct 2007 17:28:04 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:27131</guid><dc:creator>The Thing</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/27131.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=32&amp;PostID=27131</wfw:commentRss><description>Hi folks,&lt;br&gt;&lt;br&gt;In relation to an earlier &lt;a href="http://forums.xna.com/thread/26883.aspx"&gt;post&lt;/a&gt; of mine I am attempting to refine various aspects of my demo and one of the things I'd like to do is use a spritesheet to store several different sprites - perhaps three or four - in a single image file. I would rather this approach than loading those same three or four sprites individually even though this latter approach would be the easiest for me to achieve in my limited experience of XNA. My basic plan is as follows:&lt;br&gt;&lt;br&gt;1 - Load the spritesheet in my main class&lt;br&gt;2 - Extract from the spritesheet a selected sprite and store it in another Texture2D object for passing to my sprite set-up class.&lt;br&gt;&lt;br&gt;I'd be grateful if someone could post a short piece of code to help me out because the examples I've seen so far are a little complicated and I don't understand them and they appear to use different approaches which has added to my confusion.&lt;br&gt;&lt;br&gt;Thanks for reading my post.</description></item></channel></rss>