xna-4.0

What is a good example of saving game data in XNA 4.0?

吃可爱长大的小学妹 提交于 2019-12-01 02:45:07
问题 I am trying to work my way through the XNA MSDN documentation on saving and reading game data, and I am not having much luck. In essence I have a manager class which keeps track multiple instance of of base classes. I want to be able to save the state of the entire list of objects that the manager is keeping track of then then load them in the next time the game loads. Basically saving the state of the world. 回答1: If you use the XmlSerializer as shown in the XNA 4.0 help, base classes need to

XNA 3.1 to 4.0 requires constant redraw or will display a purple screen

让人想犯罪 __ 提交于 2019-12-01 02:25:29
问题 For menus in my game, I draw them once to the screen, then only redraw if they've been deemed dirty. This is handled through a boolean set to true whenever the user performs an action that should cause a redraw, and then the draw loop will check that value before drawing the menu. This logic worked perfectly in 3.1, but in 4.0 the menu will flicker (drawn for 1 frame) then show a purple screen until drawn again. I've created a very simple test game in 4.0 to demonstrate the issue shown below.

How many (low poly) models can XNA handle?

…衆ロ難τιáo~ 提交于 2019-11-30 20:51:03
I'm aware that the following is a vague question, but I'm hitting performance problems that I did not anticipate in XNA. I have a low poly model (It has 18 faces and 14 vertices) that I'm trying to draw to the screen a (high!) number of times. I get over 60 FPS (on a decent machine) until I draw this model 5000+ times. Am I asking too much here? I'd very much like to double or triple that number (10-15k) at least. My code for actually drawing the models is given below. I have tried to eliminate as much computation from the draw cycle as possible, is there more I can squeeze from it, or better

Very simple menu in XNA [closed]

亡梦爱人 提交于 2019-11-30 15:35:51
Me and some other guys are creating a game, and i would like to add a very simple menu with only Start and Exit Game. Now I already downloaded the Game state management sample, but thats a very long and complicated code. My question: someone knows a site or something where i can make such a simple menu or someone created such a menu by himself and wants to help me. Im working in Xna4.0. Edit: A Titlescreen with "press enter to start the game" or something like that would be nice too. The Game State Management sample is not long or complicated. My recommendation is to make your way through it

'Nearest Neighbor' zoom

╄→гoц情女王★ 提交于 2019-11-30 12:40:40
问题 When I draw a stretched Texture2D , the pixels receive a Blur-like effect. I want to use 'pixelated' graphics in my game and would like to know how to disable this in favor of the simplest nearest neighbor zoom. I've created this picture for illustration: (x4 zoom) In what way can I accomplish this? 回答1: In XNA 4, change your SpriteBatch.Begin() to set the sampler state to SamplerState.PointClamp 回答2: If you're using a shader to draw the image, you can modify the sampler state: sampler2D

How do I load a texture in XNA at runtime?

你离开我真会死。 提交于 2019-11-30 08:28:38
问题 I'm working on an application that uses the XNA framework to do it's 3D rendering. I now want to load a texture from file. I've found two methods so far: Texture2D.FromStream(GraphicsDevice, Stream) The problem with this approach is that it only loads gif, png and jpg and I also need support for tga images. Create a ContentManager object. The problem with this approach is that it seems like all the textures need to be statically added to the project, from the documentation: "Before a

Need help using instancing in XNA 4.0

对着背影说爱祢 提交于 2019-11-30 07:34:55
I have come to inquire about instancing in XNA I am a beginning XNA developer, only recently stepping up from 2D to 3D games. I'm trying to draw a large number of cubes made solely out of vertices in code. As one might suspect, drawing a large number of these cubes causes quite a bit of stress on my computer. As I was looking for a way to increase performance I came across the term "instancing". Not knowing how instancing works in XNA 4.0, I've looked around for a tutorial suitable for someone of my level. However, the only tutorial I've come across (http://blogs.msdn.com/b/shawnhar/archive

How many (low poly) models can XNA handle?

会有一股神秘感。 提交于 2019-11-30 04:46:44
问题 I'm aware that the following is a vague question, but I'm hitting performance problems that I did not anticipate in XNA. I have a low poly model (It has 18 faces and 14 vertices) that I'm trying to draw to the screen a (high!) number of times. I get over 60 FPS (on a decent machine) until I draw this model 5000+ times. Am I asking too much here? I'd very much like to double or triple that number (10-15k) at least. My code for actually drawing the models is given below. I have tried to

'Nearest Neighbor' zoom

我与影子孤独终老i 提交于 2019-11-30 03:16:55
When I draw a stretched Texture2D , the pixels receive a Blur-like effect. I want to use 'pixelated' graphics in my game and would like to know how to disable this in favor of the simplest nearest neighbor zoom. I've created this picture for illustration: (x4 zoom) In what way can I accomplish this? In XNA 4, change your SpriteBatch.Begin() to set the sampler state to SamplerState.PointClamp 3Dave If you're using a shader to draw the image, you can modify the sampler state: sampler2D mySampler = sampler_state { Texture=<SomeTexture>; Filter=POINT; }; Point sampling should prevent the GPU from

Very simple menu in XNA [closed]

和自甴很熟 提交于 2019-11-29 21:34:31
问题 Me and some other guys are creating a game, and i would like to add a very simple menu with only Start and Exit Game. Now I already downloaded the Game state management sample, but thats a very long and complicated code. My question: someone knows a site or something where i can make such a simple menu or someone created such a menu by himself and wants to help me. Im working in Xna4.0. Edit: A Titlescreen with "press enter to start the game" or something like that would be nice too. 回答1: The