<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wikidot="http://www.wikidot.com/rss-namespace">

	<channel>
		<title>xna tutorial - texture atlas</title>
		<link>http://rbwhitaker.wikidot.com/forum/t-422192/xna-tutorial-texture-atlas</link>
		<description>Posts in the discussion thread &quot;xna tutorial - texture atlas&quot; - Trying to get the &quot;texture atlas&quot; to work.

http://www.gamedev.net/topic/617120-animated-sprite-not-working/</description>
				<copyright></copyright>
		<lastBuildDate>Sun, 19 Apr 2026 11:53:54 +0000</lastBuildDate>
		
					<item>
				<guid>http://rbwhitaker.wikidot.com/forum/t-422192#post-1331425</guid>
				<title>Re: xna tutorial - texture atlas</title>
				<link>http://rbwhitaker.wikidot.com/forum/t-422192/xna-tutorial-texture-atlas#post-1331425</link>
				<description></description>
				<pubDate>Mon, 19 Dec 2011 19:32:32 +0000</pubDate>
				<wikidot:authorName>ff8jake</wikidot:authorName>				<wikidot:authorUserId>1215695</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>If it is showing the entire sheet instead of just a particular section, it sounds like you might have a problem in your spriteBatch.Draw method. The method is overloaded so there are multiple ways you can supply arguments to it, and you'll need to make sure you're using one of the overloads that allows for a sourceRectangle. A sourceRectangle let's you specify which rectangular area of the sprite sheet that you want to draw, and you'll have to update the rectangle each frame of the animation so it draws the next appropriate part of the sheet.</p> <p>So, excuse my code it might be slightly rusty, been a couple months since I messed with XNA. You'll be looking at something like this:</p> <div class="code"> <div class="hl-main"> <pre><span class="hl-comment">// We'll assume you loaded your texture into this at some point.</span><span class="hl-code"> </span><span class="hl-comment">// Also assume this is a 100x100 atlas with 16 frames (i.e., 25x25 per frame).</span><span class="hl-code"> </span><span class="hl-identifier">Texture2D</span><span class="hl-code"> </span><span class="hl-identifier">yourSpriteAtlas</span><span class="hl-code">; </span><span class="hl-comment">// Now we define our &quot;source rectangle&quot;, which tells what part of 'yourSpriteAtlas' we plan to display.</span><span class="hl-code"> </span><span class="hl-comment">// Frame one would be 0, 0, since we'll want to start at the very top left of our sprite atlas.</span><span class="hl-code"> </span><span class="hl-identifier">Rectangle</span><span class="hl-code"> </span><span class="hl-identifier">sourceRectangleToDraw</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">Rectangle</span><span class="hl-brackets">(</span><span class="hl-number">0</span><span class="hl-code">, </span><span class="hl-number">0</span><span class="hl-brackets">)</span><span class="hl-code">; </span><span class="hl-comment">// Let's draw the sprite to the screen.</span><span class="hl-code"> </span><span class="hl-comment">// Note that we're passing the source rectangle in as well.</span><span class="hl-code"> </span><span class="hl-identifier">spriteBatch</span><span class="hl-code">.</span><span class="hl-identifier">Draw</span><span class="hl-brackets">(</span><span class="hl-identifier">yourAtlasTexture</span><span class="hl-code">, </span><span class="hl-identifier">yourPositionVector</span><span class="hl-code">, </span><span class="hl-identifier">sourceRectangleToDraw</span><span class="hl-code">, </span><span class="hl-identifier">color</span><span class="hl-code">, </span><span class="hl-identifier">rotationFloat</span><span class="hl-code">, </span><span class="hl-identifier">origin</span><span class="hl-code">, </span><span class="hl-identifier">scale</span><span class="hl-code">, </span><span class="hl-identifier">spriteEffects</span><span class="hl-code">, </span><span class="hl-identifier">layerDepth</span><span class="hl-brackets">)</span><span class="hl-code">; </span><span class="hl-comment">// Now you'll need to find some way to update that source rectangle each step of the animation.</span><span class="hl-code"> </span><span class="hl-comment">// Your next frame will be 25, 0, so you will probably need to add several variables to keep track and specify how big each piece of the atlas is.</span><span class="hl-code"> </span><span class="hl-comment">// I would recommend checking back at the atlas tutorial for that info. :)</span></pre></div> </div> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://rbwhitaker.wikidot.com/forum/t-422192#post-1331020</guid>
				<title>xna tutorial - texture atlas</title>
				<link>http://rbwhitaker.wikidot.com/forum/t-422192/xna-tutorial-texture-atlas#post-1331020</link>
				<description></description>
				<pubDate>Mon, 19 Dec 2011 05:15:24 +0000</pubDate>
				<wikidot:authorName>Tom</wikidot:authorName>								<content:encoded>
					<![CDATA[
						 <p>Details here:</p> <p>Trying follow the tutorials here, specifically on texture atlas, and it is not working right.</p> <p>It is showing the entire sprite sheet instead of a 32x32 square where the 32x32 segments are shown in turn.</p> 
				 	]]>
				</content:encoded>							</item>
				</channel>
</rss>