xna

Initializing a bool is interfering with my logic

妖精的绣舞 提交于 2019-12-06 15:56:33
问题 I'm working on this method which deals with collision detection. I'm having an issue with the direction bool being initialized to true. Sometimes, when firing an object, the angle is reversed, because it's expecting the bool to be false. If the object is initially aimed towards the left (between 0 and 350 in my code), the bool should be true. If it's aimed towards the right (between 350 and 700), the bool should be false. How can I set the initial bool to the appropriate true/false value

How to get the full root directory of a ContentManager in XNA 4.0

纵然是瞬间 提交于 2019-12-06 15:27:41
I was wondering if anyone here knows how to find the complete path (from the drive letter onwards) of a ContentManager instance. using this I could create a string with the right number of "..\" to append to the file path when I want to load a file from anywhere else on the computer (eg. from a registry key). So basically I'm asking if there is a way. You may just want to use System.GetFolderPath with one of these locations , most likely Program Files. From there, you can navigate to your application's installation directory. You could also use .Load("\MyFolder\blah") which will load from the

XNA Window Resize Invokes LoadContent

天大地大妈咪最大 提交于 2019-12-06 14:26:18
Anytime I resize my XNA Window to the smallest possible resolution (0 pixels high) the program starts invoking LoadContent again which causes my app to crash (since I only want it to load content once). What can I do, is there a way I can stop the user from resizing my window too much (such as setMinimumSize in Java). Or is there another solution? Thanks, To stop the user resizing your window too much, set the MinimumSize property on the form associated with the game window. Add the following references to your project: System.Drawing System.Windows.Forms Add constants for your desired minimum

Recording a live video stream in C#/XNA

雨燕双飞 提交于 2019-12-06 13:30:34
问题 I have a project that renders the web cam stream onto a texture. I was wondering if there was a way, either through DirectX's Audio/Video functionality or through XNA directly where I can record the stream into an avi file format? Thanks in advance for the help. 回答1: Direct show will do exactly what you need through the ICaptureGraphBuilder For a C# wrapper, see: http://sourceforge.net/projects/directshownet/ 回答2: I have used this VideoTexture Class before with success and would recommend you

Tile map Collision Detection

跟風遠走 提交于 2019-12-06 12:24:13
问题 I've been looking through the other questions but just can't seem to figure this out.. I'm using XNA in a custom tilemap loader. Here is the code. http://pastebin.com/cuatQHTb using System; using System.Collections.Generic; using System.Linq; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.GamerServices; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using Microsoft.Xna

How to read in a txt file in XNA 4 for Windows Phone 7?

可紊 提交于 2019-12-06 11:58:32
I had a look at this previous question however this doesn't seem to work for XNA 4 for a Windows Phone 7 project: XNA Framework Importers I've been trying to use: string line; using (StreamReader sr = new StreamReader("credits.txt")) { while ((line = sr.ReadLine()) != null) { //reads line by line until eof //do whatever you want with the text } } ` but this is throwing a System.MethodAccessException "Attempt to access the method failed: System.IO.StreamReader..ctor(System.String)" Do I need to look at using IsolatedStorage for this instead? Edit: Please note I am trying to load a pre-prepared

Poor performance on 360 and WP7

本小妞迷上赌 提交于 2019-12-06 11:39:36
I've just got my 2D sprite game running on the 360 and WP7 and it's far slower on these than the Windows counterpart. The FPS is about a frame a second, but on windows its smooth. I'm using Farseer the latest version in this. Is there anything on these two platforms that could cause such a drastic slowdown? Thanks in advance. George Clingerman Yes. There are DEFINITELY things on those two platforms that can cause significant slowdowns. The CLR on the 360 and WP7 have much slower garbage collectors than on the PC. As a result, performance on those two platforms can vary dramatically. A game

Which types are supported by XNA's Automatic XNB Serialization?

*爱你&永不变心* 提交于 2019-12-06 11:29:31
I've read Shawn Harvgreave's blog entry about automatic serialization and the MSDN article on an overview of the content pipeline, but I couldn't find a list of the types supported. Quoting MSDN: Starting with XNA Game Studio 3.1, the serialization of custom data to the .XNB format is done automatically for simple types that do not have an existing content type writer. I haven't had problems with this until I tried to use a Queue from System.Collections.Generic which I'm guessing isn't supported by the automatic serialization. So, is there a list of types supported by this? And if it isn't

XNA - About the relation between world space and the screen space

醉酒当歌 提交于 2019-12-06 11:28:50
Edit: Just wanted to make the question I have more clear. I pretty much am having trouble seeing how something like Matrix.CreateTransformationZ works in the context of not only matrix multiplication but more importantly what this does to the screen space/world space so I can get a clearer picture. So maybe someone could alter the code or give me a short snippet to test out where I can use this to either rotate around an axis and/or orbit around the axis. I have also changed the example. So I'm still kind of having trouble visualizing how matrices work with the xna screen space. I'll give you

Infinite Scrolling Background in XNA

倖福魔咒の 提交于 2019-12-06 11:11:33
I'm drawing a ground texture in a sidescrolling platformer like this: spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, _camera.GetViewMatrix(Parallax)); foreach (Sprite sprite in Sprites) sprite.Draw(spriteBatch); spriteBatch.End(); In Sprite.Draw() public void Draw(SpriteBatch spriteBatch) { if (Texture != null) spriteBatch.Draw(Texture, Position, new Rectangle(0, 0, Texture.Width, Texture.Height), Color.White, Rotation, Origin, Scale, SpriteEffects.None, ZIndex); } How can I get the texture to repeat in the X Direction infinitely? Any resources explaining how to do