George Clingerman

      XNADevelopment.com
posts - 154, comments - 493, trackbacks - 181

My Links

News



Tag Cloud

Article Categories

Archives

Post Categories

. XNADevelopment.com .

XNADevelopment.com - Creating a 2D Sprite (2.0)

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:

Print | posted on Friday, March 07, 2008 6:42 PM | Filed Under [ XNA Development XNA ]

Feedback

Gravatar

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)

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 :)
3/13/2008 9:07 PM | Spoon
Gravatar

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)

This has helped me out a lot, excellent tutorial please keep them coming.
3/16/2008 4:04 PM | Rob
Gravatar

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)

@Spoon - Thanks! I appreciate the comment. Makes me feel like it's worth the time I put into them.
3/17/2008 7:33 AM | George Clingerman
Gravatar

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)

@Rob - Glad to hear they're helping! Thanks a lot for taking the time to let me know. I really appreciate it.
3/17/2008 7:33 AM | George Clingerman
Gravatar

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)

Hey Thank you so much George this is massive help!

3/18/2008 7:46 PM | Sal
Gravatar

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)

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!
3/20/2008 8:34 PM | Cameron
Gravatar

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)

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.
3/23/2008 10:11 PM | subramanya
Gravatar

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)

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 :)
4/13/2008 7:16 AM | Pedro Luz
Gravatar

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)

Hi,
very nice & easy tutorials
just what i'm looking for

thanks :)
5/9/2008 1:05 PM | Dome F
Gravatar

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)

Hi,

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

:)
5/11/2008 9:12 PM | Ricardo
Gravatar

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)

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


5/18/2008 11:06 AM | David Williams
Gravatar

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)

Neat stuff .. was going thru an Apress book.. but i stumbled upon this method meself, thnx to u, got it confirmed :D
7/4/2008 10:35 AM | Carlyle Oliver
Gravatar

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)

I was hoping this was going to lead to spawning about 40 sprites using the same object name. I was a little disappointed when you said the way to draw the second sprite was to instantiate another object name. If you have to do that then I don't see the advantage at all of having a sprite class. I also wanted to spawn with random colors and Y positions. Help
7/26/2008 6:57 PM | Mike
Gravatar

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)

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!
7/28/2008 4:16 PM | Peanut
Gravatar

# Hi, an error I spotted

You have a call to base.Update(), but Update is not declared in your sprites.cs class.
8/3/2008 3:08 PM | Quentyn
Gravatar

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)

@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.
8/3/2008 3:10 PM | Quentyn
Gravatar

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)

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.
8/3/2008 3:12 PM | Quentyn
Gravatar

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)

@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.
8/3/2008 3:16 PM | Quentyn
Gravatar

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)

Thank you so much for the Examples. I have learned more from your teaching then reading some of the XNA books out there.
8/8/2008 2:09 AM | Attila
Gravatar

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)

finally a good tutorial that shows you the basics of making a game, thanks george!!!
8/13/2008 2:01 AM | bubbleshield
Gravatar

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)

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
8/13/2008 6:37 AM | Jamie Lutzuver
Gravatar

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)

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
8/22/2008 9:14 PM | Zealot
Gravatar

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)

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
8/30/2008 5:47 PM | Bryan
Gravatar

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)

Thank you so much. Your tutorials are great!!
10/13/2008 10:20 PM | Edel
Gravatar

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)

excellent tutorials
1/27/2009 1:21 AM | cl
Gravatar

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)

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. :)
4/11/2009 4:03 PM | Israel Segundo
Gravatar

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)

Very nice tutorial, thanks for sharing.
4/19/2009 10:12 AM | live cams treff
Gravatar

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)

This is an excellent tutorial. nice posting
8/10/2009 3:20 AM | no fax payday loans
Gravatar

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)

Great work, keep posting good tutorial like this. Thanks
8/10/2009 3:21 AM | cefcu
Gravatar

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)

I am using 2D for some graphics. This is a good tutorial . thank you
8/14/2009 9:25 AM | top travel destinations
Gravatar

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)

This is a great tutorial, nice work. Thank you very much
8/14/2009 9:27 AM | Electric Cars
Gravatar

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)

Yes you make a very good job, I read some of your happy and you learned a lot, thank you.
8/20/2009 4:38 AM | radiateur inertie
Gravatar

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)

Good work! You are the best !!!
8/28/2009 7:51 AM | voyance gratuite
Gravatar

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)

Why not ?
10/21/2009 7:45 AM | pari sportif
Gravatar

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)

Excellent website, thanks for the information.
12/8/2009 4:36 PM | bwin fr
Gravatar

# re: XNADevelopment.com - Creating a 2D Sprite (2.0)

I agree with you.
12/8/2009 4:41 PM | site de paris en ligne
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 

Powered by: