xna

Best way to handle texture loading and access across multiple classes in XNA?

北城余情 提交于 2019-12-10 09:24:27
问题 So I have a simple XNA project going on. Basically the question I have is how to handle texture loading and making sure there is proper access to those textures from other classes? For example, every tutorial I've seen, as well as what I can tell from the actual logic of XNA, you're supposed to load textures in the LoadContent() method. But let's say I have another class, Level , that needs its own unique set of textures, and within that I create an instance of my Player object, which also

Using system.windows.forms with XNA

巧了我就是萌 提交于 2019-12-10 04:08:05
问题 I am making a game that uses XNA. I would like to add things to the game such as buttons, textboxes, labels, tooltip texts, and other stuff that comes with system.windows.forms. How do I merge system.windows.forms with XNA? Are there any API's or DLL's that I could implement to get this to work? Thanks, BenShums 回答1: The bad news: in short, no, it is not possible (at least, in a straightforward way). While it is true that you can use a System.Windows.Forms control as a canvas for your game,

How do I pause the redraw in XNA?

你离开我真会死。 提交于 2019-12-10 00:56:33
问题 I made an XNA image viewer, but it always redraws the scene, even if it's not changing, and it's making my netbook burn like hell, so I'd like it to pause drawing when nothing's changing. Reducing framerate to 1 is one way to keep it cool, but it results in laggy output. How do I prevent the redraw while there is no input? This problem was solved, but another problem was found — the game consumes a lot of CPU when its window is in focus, but when it's not, it only takes about 1% of the CPU.

XNA Collision Detection - Vector2.Reflect - Help Calculating the Normal of a Circle Sprite - C#

佐手、 提交于 2019-12-09 19:13:48
问题 I'm having trouble wrapping my mind around how to calculate the normal for a moving circle in a 2d space. I've gotten as far as that I'm suppose to calculate the Normal of the Velocity(Directional Speed) of the object, but that's where my college algebra mind over-heats, any I'm working with to 2d Circles that I have the centerpoint, radius, velocity, and position. Ultimately I'm wanting to use the Vector2.Reflect Method to get a bit more realistic physics out of this exercise. thanks ahead

XNA - Mouse.Left Button gets executed more than once in Update

对着背影说爱祢 提交于 2019-12-09 16:43:22
问题 I am making a Tic-Tac-Toe game. I need to check if a player is clicking on a square they have already clicked. Problem is error is shown in the first click itself. My update code is: MouseState mouse = Mouse.GetState(); int x, y; int go = 0; if (mouse.LeftButton == ButtonState.Pressed) { showerror = 0; gamestate = 1; x = mouse.X; y = mouse.Y; int getx = x / squaresize; int gety = y / squaresize; for (int i = 0; i < 3; i++) { if (go == 1) { break; } for (int j = 0; j < 3; j++) { if (getx == i

How to draw circle with specific color in XNA?

我的未来我决定 提交于 2019-12-09 15:52:08
问题 XNA doesn't have any methods which support circle drawing. Normally when I had to draw circle, always with the same color, I just made image with that circle and then I could display it as a sprite. But now the color of the circle is specified during runtime, any ideas how to deal with that? 回答1: You can simply make an image of a circle with a Transparent background and the coloured part of the circle as White . Then, when it comes to drawing the circles in the Draw() method, select the tint

Support for XNA in WP8?

我的未来我决定 提交于 2019-12-09 14:51:51
问题 After watching a little bit of the summit keynote I kind of heard conflicting reports about it, but is it official that XNA is being dropped for WP8? I'm guessing since the future version of WP supports previous generation of apps that this is probably not true. If it is though is using C# even an option for games or is C++ with DirectX the only way to go? 回答1: the official wp7dev twitter account had this to say too "XNA Framework apps are fully supported in WP8. The new WP SDK will support

Apply Post Render Effect to SpriteBatch in XNA

那年仲夏 提交于 2019-12-09 13:50:15
问题 Is there a way, in the XNA framework, to render your 2D scene using the typical SpriteBatch method and then, after that frame is rendered, apply effect to the whole image? For example, blurring, sepia or even making the whole thing look like an old time movie film, with grain, dust, lines, etc? 回答1: Yes - what you'll do is set the render target to render to a texture instead of out your graphics hardware. Then, once your output is in a texture you'll apply your pixel shader effects, and send

Stopping notification bar to popup during game play

吃可爱长大的小学妹 提交于 2019-12-09 13:07:30
问题 Context: I am working on a windows phone game using XNA 4.0 framework. During the gameplay, if the user accidentally drags the top of screen, notification center gets dragged down. I have seen few apps where this behaviour is overridden and instead of notification center popping up, a small cue is shown at the top as shown in the screenshot below. Question: What is the API that stops notification center to come up when user accidentally drags the top of screen during gameplay? Screenshot of

How can I use WPF's D3DImage with managed DirectX or XNA?

做~自己de王妃 提交于 2019-12-09 12:57:07
问题 I'd really like to get into some D3D coding, but I don't have the time lately to learn C++ for what will amount to a hobby project. 回答1: If you're looking for a managed way to do Direct3D programming, I would recommend SlimDX. It's an open source .NET wrapper over DirectX. Since managed DirectX is not being supported any longer by Microsoft, this is a good way to use managed code with D3D. It's updated quite frequently and I've had very good luck using it thus far. There's a thread here that