xna

How can I decrement lives on collision, using XNA with C#?

岁酱吖の 提交于 2019-12-24 09:33:30
问题 I have an assignment for my computer graphics class, were we have to alter a game code. The class itself is entirely about theory, so we pretty much have to figure out the code for ourselves and I've never programmed in C#, so sorry for any ignorance on my part. Whenever my player sprite is hit by a box, I want the lives variable to decrement by 1. However, whenever it gets hit it just keeps going down. I understand why this is happening, but I don't know how to stop it. This is the code that

XNA window border changing theme on Fullscreen to Windowed transition

好久不见. 提交于 2019-12-24 08:25:54
问题 When I'm going from fullscreen to windowed mode in XNA the window does not use the default windows theme but the old "non-aero" style. I'm using Windows 8, don't know the new terms for the different themes. I tried this solution: XNA losing title bar theme on fullscreen->windowed transition, but it doesn't seem to work, at least not on Windows 8. How do I make sure the default theme is always used? Doesn't have to be a XNA specific solution. 回答1: Use this: System.Windows.Forms.Application

Full Screen On Multiple Monitors With XNA

跟風遠走 提交于 2019-12-24 08:09:13
问题 I'm building a special application with XNA that is made for computers with multiple monitors. The problem is that if I tell my XNA application to become fullscreen, it only covers the main screen. How can I make sure that my application runs full screen across all of the screens? 回答1: This doesn't sound trivial at all. What happens when the screens are varying resolutions and aspect ratios? You'll have to create a rendertarget for each of the screens individually. There's no way to mesh them

How to point to file in content in XNA

坚强是说给别人听的谎言 提交于 2019-12-24 04:35:19
问题 I am trying to point to a file in the content of my XNA project. By default the method looks in the bin folder enigine.play("Sound.wav") How do I direct it to the content? 回答1: Use ContentManager.Load<SoundEffect>() method: var sound = Content.Load<SoundEffect>("Sound"); sound.Play(); where Content is a reference to your ContentManager instance. 来源: https://stackoverflow.com/questions/6103839/how-to-point-to-file-in-content-in-xna

XNA 4.0 app closes suddenly when it hits a method without throwing any exceptions

亡梦爱人 提交于 2019-12-24 04:09:08
问题 As the title says, I have an XNA app that closes suddenly when it hits an app, but doesn't show any errors so I don't have a clue how to even begin to debug it. The code is very simple - I'm just playing with XNA and trying to render a simple triangle - so I can't imagine why it's stopping. The code that's running is VertexPositionColor[] vertices; public Terrain() { vertices = new VertexPositionColor[3]; vertices[0].Position = new Vector3(-0.5f, -0.5f, 0f); vertices[0].Color = Color.Red;

Target the XNA framework in ordinary Visual Studio 2012 project

爱⌒轻易说出口 提交于 2019-12-24 03:38:16
问题 I have a C# XNA host project, with an F# client project that will contain all my functionality. It won't build because the F# project has references to mscorlib.dll and System.dll that the XNA project doesn't agree with (the actual error -- well, its really a warning that in my opinion should be an error -- is at the bottom of the post). How can I tell the F# project to target the actual XNA platform (specifically for the Xbox 360)? C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft

Exception thrown in debug mode, but where?

你离开我真会死。 提交于 2019-12-24 03:31:03
问题 A first chance exception of type 'System.IO.IsolatedStorage.IsolatedStorageException' occurred in mscorlib.ni.dll Operation not permitted on IsolatedStorageFileStream. It shows me this notice, but I don't know where does it generate it. How find out where is the code which generates this exception? PS. I'm using debug mode. (C#) 回答1: This is a first-chance exception, i.e. one that has a try-catch block that will take care of it. By default, Visual Studio doesn't break on first-chance

2D Gaming - How to reflect a ball off the bat?

♀尐吖头ヾ 提交于 2019-12-24 03:12:33
问题 I am pretty new to XNA & game dev and stuck at ball reflection. My ball is reflecting once it hits the bat, but only in one angle, no matter which angle the bat is at. Here's the code: if (BallRect.Intersects(BatRect)) { Vector2 NormBallVelocity = Ball.velocity; NormBallVelocity.Normalize(); NormBallVelocity = Vector2.Reflect(Ball.velocity, NormBallVelocity); Ball.velocity = NormBallVelocity; } The ball is retracting its way back. How do I make it look like the ball is reflecting off the bat?

Optimal way to set pixel data?

喜夏-厌秋 提交于 2019-12-24 01:47:23
问题 I'm working on a "falling sand" style of game. I've tried many ways of drawing the sand to the screen, however, each way seems to produce some problem in one form or another. List of things I've worked through: Drawing each pixel individually, one at a time from a pixel sized texture. Problem: Slowed down after about 100,000 pixels were changing per update. Drawing each pixel to one big texture2d, drawing the texture2d, then clearing the data. Problems: using texture.SetPixel() is very slow,

Render a section of an image to a Bitmap C# Winforms

霸气de小男生 提交于 2019-12-24 00:54:47
问题 I'm working on a Map Editor for an XNA game I'm designing in my free time. The pieces of art used in the map are stored on a single texture and rectangles are stored with coordinates and widths etc. In the winforms application I can add segments by selecting the segment I want from a listbox, which is populated from the array of possible segments. Problem is I would like to be able to show a preview of the segment selected and, since it is stored on a common texture, I cant simply set a