Mark_Davies

Hi i am fairly new to XNA and i am just messing around at the moment with it. what i am trying to achieve is when i push space a new instance of a bullet is created so even though there is just on sprite i can fire 20 bullets for example at the moment it fires the one then if i hit space the one i fired re assigns to the characters x and y. how do i make it so i can create multiple instances of the image.

Regards

Mark

PS if u need more info let me know



Re: XNA Game Studio Express Multiple instances of a sprite

Jim Perry

You can do something like this. Just create a new instance of the Bullet class when the Space is pressed, add it to the BulletManager and you're done. I can flesh it out a bit if I get a chance, but this should get you going at least.




Re: XNA Game Studio Express Multiple instances of a sprite

Mark_Davies

Hi osrry i am a little confussed is there a class/function that exists already in xna to take care of a bullet or do you mean for me to make a class to do it

regards

Mark





Re: XNA Game Studio Express Multiple instances of a sprite

Jim Perry

It's a class I created. Take a look at the project in the link in my previous post.




Re: XNA Game Studio Express Multiple instances of a sprite

Jim Perry

I updated this a little. Check it out here.




Re: XNA Game Studio Express Multiple instances of a sprite

Ecrofirt

Hey Jim, quick question.

Is there any way to go about automating the creation of a DrawableGameComponent I know I can Add>New Item>Game Component, but that doesn't create the component as a DrawableGameComponent, and as such some of the pre-made empty methods are missing.

Thanks for any help you can give, and sorry for hijacking this thread.




Re: XNA Game Studio Express Multiple instances of a sprite

Jim Perry

Currently there's no easy way that I know of (unless someone's modded the IDE and I haven't seen it) to add a Drawable component. I've just gotten used to changing the GameComponent to DrawableGameComponent and adding the overriden methods (LoadGraphicsContent and Draw mainly). It doesn't take more than about 10 seconds after you get used to it. Hopefully the next version will add it as an option.




Re: XNA Game Studio Express Multiple instances of a sprite

Ecrofirt

Jim Perry wrote:
Currently there's no easy way that I know of (unless someone's modded the IDE and I haven't seen it) to add a Drawable component. I've just gotten used to changing the GameComponent to DrawableGameComponent and adding the overriden methods (LoadGraphicsContent and Draw mainly). It doesn't take more than about 10 seconds after you get used to it. Hopefully the next version will add it as an option.


Oh well. Thanks for the quick response!




Re: XNA Game Studio Express Multiple instances of a sprite

Joran Omark

George Clingerman explains something similar in his "TheWizard" tutorial, if you have missed that.

http://xnadevelopment.com/tutorials/thewizard/theWizard.shtml