Geeks With Blogs
Scott Miller Appsguild - Software craftsmanship, project management, and the biz of software
I continue to mess around with XNA 2.0. I have been using George Clingerman's tutorial on selecting a sprite with a selection box. The tutorial is also on his XNADevelopment.com site here.

Basically, there are two sprites that you can select by left clicking on them:

or you can drag a selection box around them to select them:

You can then select one sprite in this manner and right click somewhere on the screen to move it, similar to a RTS game. Very handy. But I want something more.

I want to click on a sprite and have a selection cursor appear around the sprite.

And when I click somwhere else, I want the selection cursor to go to that sprite, or not appear at all if I don't click on a sprite.

And I want to be able to reference the sprite that I clicked on.

So this is how I did it:
I created a sprite manager class with a collection to store all of my sprites. It has lookup code so that I can drill down to the sprite that was clicked on. <

Here is the source code (spriteselection.zip).

And here are some of the planet sprites (planetsprites.zip).

These planet sprites were created with Paint.Net.

How to make planets with Paint.Net

How to make starscapes and nebulae with Paint.Net

 

Posted on Saturday, April 12, 2008 10:22 PM | Back to top


Comments on this post: XNA - Selecting a sprite

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Scott Miller | Powered by: GeeksWithBlogs.net