xna

XNA How does the ContentManager handle with memory

瘦欲@ 提交于 2019-12-17 16:52:55
问题 My question is not clear at title [i can not write it exactly] e.g Texture2D picture = Content.Load<Texture2D>("myPicture"); what does happen on memory if the code above runs ? As I know Content caches the "myPicture" to the memory and return a reference to the Texture2D picture. Am I wrong ? If "myPicture" is loaded to another Texture2D object "myPicture" is not duplicated so it returns only a reference. Is each file (or content-file) loaded over Content cached to memory (also allocated on

Force garbage collection of arrays, C#

僤鯓⒐⒋嵵緔 提交于 2019-12-17 12:18:09
问题 I have a problem where a couple 3 dimensional arrays allocate a huge amount of memory and the program sometimes needs to replace them with bigger/smaller ones and throws an OutOfMemoryException. Example: there are 5 allocated 96MB arrays (200x200x200, 12 bytes of data in each entry) and the program needs to replace them with 210x210x210 (111MB). It does it in a manner similar to this: array1 = new Vector3[210,210,210]; Where array1-array5 are the same fields used previously. This should set

Comparison between XNA and DirectX (C#)

陌路散爱 提交于 2019-12-17 10:18:44
问题 In terms of PC development (excluding Xbox and Zune), What is the difference between XNA and C# DirectX? Does C# DirectX have a significant advantage over XNA (in terms of speed, royalties, etc)? How are the two compared to the speed unmanaged C++ DirectX? Where is the industry moving in terms of game programming? 回答1: If you're actually good at writing unmanaged code, then you'll probably be able to write a faster graphics engine on top of DirectX. However, for the hobbyist, XNA has plenty

Asset not found XNA

烈酒焚心 提交于 2019-12-17 10:05:47
问题 I am very new to XNA and I began by following a tutorial that draws an image on the screen. I was able to move my image into the Content folder but when I try to use it in my code, it can't be found. I am using the asset name and I just cannot find what I am doing wrong. The tutorials use XNA 3.0 and I am using Visual Studio 2010, not sure if that matters or not. Here is my code public class Game1 : Microsoft.Xna.Framework.Game { Vector2 mPosition = new Vector2(0, 0); Texture2D mSpriteTexture

How to calculate bounce angle?

妖精的绣舞 提交于 2019-12-17 03:22:52
问题 I played around with it for a while, but I simply can't figure it out. I made a tank that fires missiles, and when the missiles hit the walls, I want them to bounce off, but I want them to bounce off to the right angle. Right now I haven't got any obstacles, the missiles just bounce off when they get outside the viewportRectangle I made. Is the solution I'm looking for quite advanced? Is there a relativly simple way to do it? 回答1: I think an easier way to do this is to use the velocity of the

XNA Textbox loop

和自甴很熟 提交于 2019-12-14 04:05:29
问题 So im trying to make a textbox ( well not exactly a textbox, just changing a spriteFont text ) on XNA 4.0 win game heres my code so far : usernameVar.Draw(spriteBatch, newInputText); That will draw newInputText string each frame newInputText = username.update(mouse); That will set the string but heres my problem class Textbox { public Texture2D texture; public Rectangle rectangle; public bool isClicked; public Textbox(Texture2D newTexture, Rectangle newRectangle) { texture = newTexture;

Button press calls method multiple times

筅森魡賤 提交于 2019-12-14 04:02:04
问题 i'm working on a XNA game and i've encountered a problem. Whenever i press a key in the game, the method that is triggered by the key press is called multiple times. For example, when the user presses the attack button (space) the character attacks like 10 times within one key press. I want the key press to trigger the method just one time. Even if the user holds down a key i want some methods to be called only once. For now i've solved it by writing a thread.sleep after each button press,

Is it possible to restore a GraphicsDevice if something goes wrong with it?

你离开我真会死。 提交于 2019-12-14 03:53:09
问题 I'm having this nasty problem with my game randomly crashing when changing the game window size, and I can't seem to find the source of the issue, so I'd like to try and approach this from another angle. Say the GraphicsDevice got disposed somehow. Can I recreate it or return it to its working state, so the game could continue running? 回答1: Nope. That instance is coupled to so many things, that using a new one after that's been disposed in its life cycle would be pratically reimplementing XNA

Depth Buffer not working

一曲冷凌霜 提交于 2019-12-14 03:24:46
问题 In my XNA 3D game, for some reason, the depth buffer is off and ignored - even though I've done everything I can find to enable it (which admittedly isn't much, but it's supposed to be simple... not to mention default) Before the models are rendered: global.GraphicsDevice.DepthStencilState = DepthStencilState.Default; Somewhere earlier: graphics.PreferredDepthStencilFormat = DepthFormat.Depth24Stencil8; graphics.ApplyChanges(); the models are rendered using a Vertex/Index list with device

3D modeling problem - revisited

 ̄綄美尐妖づ 提交于 2019-12-14 02:24:56
问题 This is a follow-up to a previous question I posted, this time with a better description, I hope. I have made a pair of glasses that have a pinhole camera attached onto them that records the person's eye movements. The camera sits below the eye and is hence looking UP at the eye. There is also a slight rotation around the Y-axis (i.e. the camera has a slight left- or right-wards slant) and the Z-axis (i.e the camera is slightly twisted clock-wise or anti-clockwise). From the video, I extract