Geeks With Blogs
George Clingerman       XNADevelopment.com

firstsprite I have completely re-written the tutorial covering creating a 2D sprite and posted it to my site at XNADevelopment.com. I'm much happier with it this time around. This tutorial covers displaying your first sprite on the screen and then positioning the sprite. The tutorial then takes you a step further and helps you get accustomed to object oriented development and walks you through creating a "Sprite" class for creating and drawing your sprites on the screen. Teaching you a fundamental step you will take throughout your game development process.

Go ahead and take a quick walk through on Creating a 2D Sprite.

These tutorials take time to create, so if you've benefited from them, let me know and take the time to leave a comment. I appreciate each and every comment and bit of feedback I get. Thanks for taking the time to show your appreciation.

Technorati Tags:
Posted on Friday, March 7, 2008 6:42 PM XNA Development , XNA | Back to top


Comments on this post: XNADevelopment.com - Creating a 2D Sprite (2.0)

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
Excellent tutorial. My first time on XNA, and C# [I know C++ though] and it makes perfect sense and explains why I'm doing what I'm doing instead of just blindly pasting lines in. Thank you very much :)
Left by Spoon on Mar 13, 2008 9:07 PM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
This has helped me out a lot, excellent tutorial please keep them coming.
Left by Rob on Mar 16, 2008 4:04 PM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
@Spoon - Thanks! I appreciate the comment. Makes me feel like it's worth the time I put into them.
Left by George Clingerman on Mar 17, 2008 7:33 AM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
@Rob - Glad to hear they're helping! Thanks a lot for taking the time to let me know. I really appreciate it.
Left by George Clingerman on Mar 17, 2008 7:33 AM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
Hey Thank you so much George this is massive help!

Left by Sal on Mar 18, 2008 7:46 PM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
Hey George, i LOVE these tutorials they are great help, please keep more coming!!!!!!!! Maybe some platform collisions, gravity, all types of tutorials. They are GREAT please keep more coming for 2.0!
Left by Cameron on Mar 20, 2008 8:34 PM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
hello, it was such a beautiful website for beginners.I Thank you a lot for rendering such a wonderful website for the beginners like us.
Left by subramanya on Mar 23, 2008 10:11 PM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
Hi,

In the "Creating a 2D Sprite - Drawing your first sprites to the screen" if you want to use the ContentManager in the LoadContent method in the Sprite class, you need to add

using Microsoft.Xna.Framework.Content;

ps: nice tutorials :)
Left by Pedro Luz on Apr 13, 2008 7:16 AM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
Hi,
very nice & easy tutorials
just what i'm looking for

thanks :)
Left by Dome F on May 09, 2008 1:05 PM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
Hi,

Its great... thanks for help us...

:)
Left by Ricardo on May 11, 2008 9:12 PM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
Hi there i have a bit of a problem you said add
Vector2 mPosition = new Vector2(0,0)
Texture2D mSpriteTexture;
at the top is this correct

using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

// dont know if this is right
Vector2 mPosition = new Vector2(0,0);
Texture2D mSpriteTexture;


namespace MyFirstGame
{
could you let us know i get the errors which are related to those two bits as follows:
Error 1 A namespace does not directly contain members such as fields or methods C:\XNA Games\MyFirstGame\MyFirstGame\Game1.cs 13 1 MyFirstGame

Error 2 Expected class, delegate, enum, interface, or struct C:\XNA Games\MyFirstGame\MyFirstGame\Game1.cs 13 25 MyFirstGame
my work email is david.williams@elliott-algeco.com

cheers guys


Left by David Williams on May 18, 2008 11:06 AM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
Neat stuff .. was going thru an Apress book.. but i stumbled upon this method meself, thnx to u, got it confirmed :D
Left by Carlyle Oliver on Jul 04, 2008 10:35 AM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
Great stuff! I've only programmed a bit in C before so this is a good transition for me and im looking forward to getting on with the Wizard tutorials next!
Left by Peanut on Jul 28, 2008 4:16 PM

# Hi, an error I spotted
Requesting Gravatar...
You have a call to base.Update(), but Update is not declared in your sprites.cs class.
Left by Quentyn on Aug 03, 2008 3:08 PM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
@mike:

you can do this by instantiating an array of your ObjectType with size of 40. You could then create a for loop to loop through each element and draw it to the screen. It's all about taking your pre-existing C#/Programming knowledge, and applying it to his examples to do the things you want to do.
Left by Quentyn on Aug 03, 2008 3:10 PM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
Sorry for triple posting(no edit button)

@mike:

im pretty sure there's a function in C# somewhere for you to obtain a random number. once again, take your knowledge of the language, and apply it to your new knowledge of CSharp, and you can do some cool things.
Left by Quentyn on Aug 03, 2008 3:12 PM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
@David Williams:

He said to add it to the top of your class. The reason you're getting erros is because you're using entities which do not yet exist. Entities you want to use (such as Vector2 or Texture2D) must come after the using statement in which they exist, and should exists within the class level of the class you want to use them in.
Left by Quentyn on Aug 03, 2008 3:16 PM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
Thank you so much for the Examples. I have learned more from your teaching then reading some of the XNA books out there.
Left by Attila on Aug 08, 2008 2:09 AM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
finally a good tutorial that shows you the basics of making a game, thanks george!!!
Left by bubbleshield on Aug 13, 2008 2:01 AM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
Interesting article. Very good thanks.

I've finsihed and released my game on the gp2x. I'm now considering a port onto the Xbox 360 XNA C#.

Your article gave me a good taster of the actual code.

Regards, Jamie
Left by Jamie Lutzuver on Aug 13, 2008 6:37 AM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
THNX THNX THNX THNX THNX THNX THNX THNX THNX THNX THNX THNX THNX THNX THNX THNX THNX THNX THNX THNX THNX THNX THNX THNX THNX THNX THNX THNX THNX THNX THNX THNX THNX THNX THNX THNX THNX THNX THNX THNX THNX THNX ALOT
Left by Zealot on Aug 22, 2008 9:14 PM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
hey nice tutorials george. I ran into a little problem though.

//create a new Spriteach, which can be used to draw textures
spriteBatch = new SpriteBatch(GraphicsDevice);

it says that i was using GraphicsDevice as a variable but its a type. Ive done some XNA before mainly 1.0 so i knew that i had to put graphics.GraphicsDevice to fix it. Not sure if anyone else has had a problem with this, but i did. Nice tutorials and i really like them. Thank you
Left by Bryan on Aug 30, 2008 5:47 PM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
Thank you so much. Your tutorials are great!!
Left by Edel on Oct 13, 2008 10:20 PM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
excellent tutorials
Left by cl on Jan 27, 2009 1:21 AM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
I think this is a very cool tutorial. I have been reviewing the XNA Creators Club tutorials and they are boring and very explicit. I dont like that. Thank you very much for creating this tutorial. :)
Left by Israel Segundo on Apr 11, 2009 4:03 PM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
Very nice tutorial, thanks for sharing.
Left by live cams treff on Apr 19, 2009 10:12 AM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
This is an excellent tutorial. nice posting
Left by no fax payday loans on Aug 10, 2009 3:20 AM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
Great work, keep posting good tutorial like this. Thanks
Left by cefcu on Aug 10, 2009 3:21 AM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
I am using 2D for some graphics. This is a good tutorial . thank you
Left by top travel destinations on Aug 14, 2009 9:25 AM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
This is a great tutorial, nice work. Thank you very much
Left by Electric Cars on Aug 14, 2009 9:27 AM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
Yes you make a very good job, I read some of your happy and you learned a lot, thank you.
Left by radiateur inertie on Aug 20, 2009 4:38 AM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
Good work! You are the best !!!
Left by voyance gratuite on Aug 28, 2009 7:51 AM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
Why not ?
Left by pari sportif on Oct 21, 2009 7:45 AM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
Excellent website, thanks for the information.
Left by bwin fr on Dec 08, 2009 4:36 PM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
I agree with you.
Left by site de paris en ligne on Dec 08, 2009 4:41 PM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
When I put this code in I get an error saying the name 'Position' does not exist in the current context. I have no idea why it's doing this. Help pleaseeee
//Draw the sprite to the screen
public void Draw(SpriteBatch theSpriteBatch)
{
theSpriteBatch.Draw(mSpriteTexture, Position, Color.White);
}

Left by Kriptic on Jul 04, 2010 7:49 PM

# Development
Requesting Gravatar...
The information here fits my query. I was searching for a specific site that would best suit my research. I came up here and got to know more details. So far this has enough information. I would like to track your future post related to the said article posted here. Thank you.
Left by Lovely Lois on Aug 06, 2010 3:56 AM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
Good work! great article, thnks a lot
Left by annonces gratuites on Aug 06, 2010 6:07 AM

# Helpful
Requesting Gravatar...
Although it was a little too long to make but it was good and I found it very helpful especially for a beginner like me. Keep us updated for your new developments and news.





Diamond Engagement Rings
Left by Harry Winston on Aug 27, 2010 9:30 PM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
your website is really informative i like read it!
Left by jouer casino on Aug 29, 2010 5:14 PM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
your stuff is very good i like it!
Left by roulette en ligne on Aug 30, 2010 11:27 AM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
on: public void LoadContent.....

I get an error that "void" is an expected class,delegate,enum,interface, or strct.

any help?
Left by joe on Sep 06, 2010 3:55 PM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
your site is good thanks!
Left by pronostic sportif on Sep 16, 2010 1:06 PM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
I LOVE THIS ENTIRE SITE!! THANK U SO MUCH FOR THIS TUTORIAL!!
Left by Mobin Skaria on Feb 26, 2011 7:19 PM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
Clean website. Do you ever accept guest posts? I am maintaining a site on my latest hobby water filters and wanting to trade some content with good sites. I looked around your blog and you’ve got some good content and I was thinking our readers would both find value. Thanks!.
Left by cell phone spyware on Apr 11, 2011 3:23 AM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
So, all that you have to do is select the TGA files to use and let Sprite Page Creator take care of the rest. So, if your looking for a image sequence compiler take this tool for a spin and see if its capabilities are enough to satisfy your needs.........
Left by cell phone spyware on May 05, 2011 1:59 AM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
Hi there! I really love your articles. Very well written. I look forward to reading more. Thanks for share with us.
Left by Mobile Spy on May 13, 2011 10:46 PM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
Excellent post.The post is written in very a good manner and it entails many useful information for me. I am happy to find your distinguished way of writing the post. Now you make it easy for me to understand and implement the concept.
Left by anemia homeopathic on May 16, 2011 7:51 AM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
This is one excellent tutorial, too. I like your blog. Everything is so informative here. Keep up the good work. Age of War 2
Left by Age of War 2 on May 21, 2011 5:17 AM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
Nice tutorial. You presented everything in a clear and easy-to-understand manners. I was able to learn a lot from you. Physics Games
Left by Physics Games on May 23, 2011 12:12 AM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
Thanks for posting such an informative tutorial that is also easy to understand. I hope to read more of these. Keep up the good work. Web Designers in Toronto
Left by Web Designers in Toronto on May 23, 2011 12:14 AM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
For some cause only one-half of the post is being shown. Is this my browser causing it or can it be the web site?
Left by wholesale playing cards on May 24, 2011 6:12 AM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
I would like to thank you for the pains you have made in writing this article. I am hopeful the same best work from you in the hope as well.
Left by san francisco giants tickets on May 26, 2011 4:43 AM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
thank you for the post. it is very informative but my head quite aching understanding it. thanks for the tutorial.Second Hand Golf Clubs
Left by Second Hand Golf Clubs on Jun 11, 2011 9:52 AM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
I have completely re-written the tutorial covering creating a 2D sprite and posted it to my site at XNADevelopment.com.
Left by Mercato on Jun 21, 2011 6:23 AM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
very informative
Left by Promat on Jun 28, 2011 8:49 AM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
I simply stumbled upon your blog and wished to say that I’ve really enjoyed browsing your blog posts. In any case I will be subscribing in your rss feed and I hope you write once more very soon!
Home Automation

Gourmet Gift Baskets
Left by hamant on Jul 07, 2011 6:52 AM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
I never knew that creating 2D Sprite could be this easy. Thanks for a clearly-written tutorial on this one. It really shows that you know your craft really well.
JogoDeMoto
Left by JogoDeMoto on Jul 16, 2011 2:50 AM

# great
Requesting Gravatar...
Thanks a lot for sharing this amazing knowledge with us. This site is fantastic. I always find great knowledge from it.
flowers delivery thailand | turkey florist
Left by lindamartin on Jul 16, 2011 6:17 AM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
This is one of the good articles you can find in the net explaining everything in detail regarding the topic. I thank you for taking your time sharing your thoughts and ideas to a lot of readers out there. used car search
Left by used car values on Jul 21, 2011 1:48 AM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
I needed in order to thanks with this superb study!! We certainly cherished each and every little this. Regards for that data!!!! & This is actually the ideal weblog for anybody who would like to learn about this particular subject. You realize a lot it's nearly difficult in order to dispute along with you.........

clubmz e-spy
Left by loria jacob on Jul 22, 2011 11:44 PM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
I am very excited that I have found your post because I have been searching for some information about it for almost three hours. You have helped me a lot and reading this your article I have found much new and useful information about this subject.

ways to stop snoring
Left by Guest998 on Jul 23, 2011 12:48 AM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
Interesting post and thanks for sharing. Some things in here I have not thought about before.Thanks for making such a cool post which is really very well written.
Fluoxetine Side Effects
Left by hammaa on Jul 27, 2011 2:31 PM

# klavier kurs online und gasgrill kaufen
Requesting Gravatar...
klavier lernen und frei spielen lernen sowie günstige gasgrills kaufen klavier frei spielen | günstige gasgrills
Left by gasgrill kaufen on Jul 30, 2011 10:36 AM

# Mr
Requesting Gravatar...
I have been through the whole content of this blog which is very informative and knowledgeable stuff, So i would like to visit again. how to get rid of skin tags
Left by Victor Rouff on Aug 30, 2011 11:58 PM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
very good story
Left by rugby on Sep 13, 2011 4:19 PM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
good tutorial
Left by direct football on Sep 13, 2011 4:20 PM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
I really like the content in your post. .. thanks for sharing it to us . . .really much appreciated. .
Left by cell monitoring on Oct 25, 2011 5:57 AM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
is that a game you've created?. . .I think it is cool . .thanks for sharing it to us . . .really great post. . .
Left by cell phone tracker software on Oct 25, 2011 5:59 AM

# To the theme
Requesting Gravatar...
I guess 3D one is already in use
Left by casino en ligne francais on Oct 31, 2011 12:28 PM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
I understand how to do it... it is really easy. thanks!
Left by casino on Jan 30, 2012 4:37 PM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
I am very excited that I have found your post because I have been searching for some information about it for almost three hours. You have helped me a lot and reading this your article I have found much new and useful information about this subject.
why am i always tired
Left by asdgfasd on Feb 12, 2012 10:04 PM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
it’s really a good write-up, would be interested to read such more informative draft from you ahead, can be a wonderful help to the new readers like me.
Left by Zoji Rush In PHBC on Feb 14, 2012 3:15 AM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
Excellent tutorial, thanks.
Left by bwin.fr on Apr 23, 2012 10:55 AM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
Thanks a lot for enjoying this beauty article with me. I am appreciating it very much! Looking forward to another great article. Good luck to the author! all the best!
beer keg prices
Left by kolli on May 28, 2012 6:30 AM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
just want to say thank you for this opportunity and would I be able to add anything extra to my audition tape, so a monologue or an improvisation performance ?
Left by Bank Exams on Jul 03, 2012 5:45 AM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
Very impressive comments to read that but i would like to add that you must focus upon the positive site of the topic, which can be easily understood by the readers.Laveneder Salve
Left by Laveneder Salve on Oct 18, 2012 2:50 PM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
I am sure this piece of writing has touched all the internet visitors, its really really pleasant article on building up new website. website launch press release

Left by Ricky on Mar 18, 2013 11:58 AM

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)
Requesting Gravatar...
I have been browsing online more than 2 hours today, yet I never found any interesting article like yours. It’s pretty worth enough for me. In my opinion, if all site owners and bloggers made good content as you did, the internet will be much more useful than ever before.send free sms online
Left by Rashat on Mar 24, 2013 3:26 PM

Your comment:
 (will show your gravatar)


Copyright © George Clingerman | Powered by: GeeksWithBlogs.net