xna

Saving a variable data to disk

寵の児 提交于 2019-12-10 17:24:11
问题 Is it possible to save a variable from C# to disk so that you are able to use it later in another instance of your project? For example, I have a struct with 3 fields like in the following example : struct MyStruct { byte[] ByteData; int MyInt; double MyDouble; }; I have an instance of this struct, let's say MyStruct S and I assign value to all my fields. After this step, I would like to save this variable somehow in disk so that I could use those stored values later in my program. I know,

XNA app not responding

与世无争的帅哥 提交于 2019-12-10 17:16:38
问题 I have a XNA 3.1 app on Windows 7 x64 with VS 2008. At ~7 seconds the window will go gray if the game does not have focus (sometimes!). The title adds Not Responding . If the game has focus, the window may slightly change position on the screen, and the application icon on my tray moves over as if it is opening a new program. This only happens for a split second, and then the application icon moves back to its original position. It does this in both debug, and release mode. This is strange

DrawUserPrimitives Invalid Operation Exception

有些话、适合烂在心里 提交于 2019-12-10 17:16:08
问题 I'm trying to draw a triangle using this code in XNA: VertexPositionColor[] vertices = new VertexPositionColor[3]; vertices[0].Position = new Vector3(-0.5f, -0.5f, 0f); vertices[0].Color = Color.Red; vertices[1].Position = new Vector3(0, 0.5f, 0f); vertices[1].Color = Color.Green; vertices[2].Position = new Vector3(0.5f, -0.5f, 0f); vertices[2].Color = Color.Yellow; GraphicsDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.TriangleList, vertices, 0, 1); However, as soon as I run it

How to reduce XNA game CPU usage while nothing worth computing is happening?

删除回忆录丶 提交于 2019-12-10 17:09:45
问题 A fresh XNA game project application consumes quite some CPU percentage while its window is active. On my desktop PC it's about 30% of one core of a 2-core processor. When the window loses focus, the game goes into idle mode and consumes about 1% of CPU. In an image viewer application I recently made using XNA, redrawing frames when no image manipulation is going on doesn't make much sense, so I'm using the SuppressDraw() method which, as the name suggests, suppresses spending resources for

Can you turn NumLock on in XNA?

天涯浪子 提交于 2019-12-10 17:07:10
问题 Can you turn NumLock on in XNA? (I'm looking for a solution to XNA Number lock affects input.) 回答1: You'll have to P/Invoke SendInput. This is somewhat involved: void ToggleNumLock() { var inputSequence = new INPUT[2]; // one keydown, one keyup = one keypress inputSequence[0].type = 1; // type Keyboard inputSequence[1].type = 1; inputSequence[0].U.wVk = 0x90; // keycode for NumLock inputSequence[1].U.wVk = 0x90; inputSequence[1].U.dwFlags |= KEYEVENTF.KEYUP; var rv = SendInput(2,

Pix, A couple of issues I'm not understanding

試著忘記壹切 提交于 2019-12-10 17:07:09
问题 I've been asked to split questions which I asked here: HLSL and Pix number of questions I thought two and three would both fit in the same question as a solution of one may help resolve the other. I'm trying to debug a shader and seem to be running into issues. Firstly Pix seems to be skipping a large amount of code when I'm running analyse mode. This is analysing an experiment with F12 captures and with D3DX analysis turned off. I have to turn it off as I'm using XNA. The shader code in

Using Content.Load<> in a class/subclass

核能气质少年 提交于 2019-12-10 16:26:34
问题 I'm wondering if there is anyway to use the "Content.Load<>" in a class that is not the game itself, say I want to load a texture from within the class, rather than sending the texture to it. namespace ProjectGame1 { public class Ship { public Texture2D texture; public Ship() { this.texture = Content.Load<Texture2D>("ship"); } } } That's an example of what I'm trying to achieve 回答1: You just need to pass your ContentManager to the Ship object: public Ship(ContentManager content) { this

How to prevent drawing XNA component when it is off-screen?

匆匆过客 提交于 2019-12-10 15:44:50
问题 I'm making a 2d game in XNA. When using drawable game components which one is better for performance? 1.When a component is not onscreen remove it from the components list and when its onscreen add it. 2.When its offscreen dont run its draw function (by using an "awake" bool field and an if statement around everything in the draw function) I'm using method 2 at the moment and it works fine. Its handy cus the draworder of components wont change (if I remove and re-add them it will, and I'll

D3DERR_INVALIDCALL error, TeamCity builder

泄露秘密 提交于 2019-12-10 15:08:14
问题 I've been trying to use TeamCity 4.5 in order to automate builds of an XNA project but I have a small problem. My projects compile correctly under Visual Studio 2008, but not when compiled with TeamCity as the builder. The configuration file uses the sln2008 setting, and compiling goes well for a while, but as soon as it goes compiling .png textures to .xnb, I get the following error: [11:28:41]: [Project "Content.contentproj" (default targets):] Content\head.png Building content threw

How to get camera up vector from roll, pitch, and yaw?

ぐ巨炮叔叔 提交于 2019-12-10 14:25:20
问题 I need to get an up vector for a camera (to get the right look) from a roll, pitch, and yaw angles (in degrees). I've been trying different things for a couple hours and have had no luck :(. Any help here would be appreciated! 回答1: Roll, Pitch and Yaw define a rotation in 3 axis. from these angles you can construct a 3x3 transformation matrix which express this rotation (see here how) After you have this matrix you take your regular up vector, say (0,1,0) if 'up' is the Y axis and multiply it