xna

How to load all files in a folder with XNA?

你说的曾经没有我的故事 提交于 2019-12-06 00:24:48
问题 I want to load all files in a folder "Content/textures" into the game using Content.Load("filename"); However, I am unable to "find" files located inside Content this way (the program rather looks at "bin/debug/../Content/textures" , but I get an error when trying to load the jpg/png files there with Content.Load. How can I achieve what I'm trying to do? I want to load all files in a folder inside Content (which content folder is the right one?) into the game, so that I dont have to specify

How to draw 2D pixel-by-pixel in XNA?

我的未来我决定 提交于 2019-12-05 23:09:13
问题 I'm trying to draw on the screen pixel-by-pixel using XNA, but am having problems with resources. I thought the best way would be to have 1 texture that updates every frame, but I'm having trouble updating it. Here's what I've got so far, just as a test: Texture2D canvas; Rectangle tracedSize; UInt32[] pixels; protected override void Initialize() { tracedSize = GraphicsDevice.PresentationParameters.Bounds; canvas = new Texture2D(GraphicsDevice, tracedSize.Width, tracedSize.Height, false,

How to create Paint-like app with XNA?

微笑、不失礼 提交于 2019-12-05 22:26:35
The issue of programmatically drawing lines using XNA has been covered here . However, I want to allow a user to draw on a canvas as one would with a drawing app such as MS Paint. This of course requires each x and/or y coordinate change in the mouse pointer position to result in another "dot" of the line being drawn on the canvas in the crayon color in real time. In the mouse move event, what XNA API considerations come into play in order to draw the line point by point? Literally, of course, I'm not drawing a line as such, but rather a sequence of "dots". Each "dot" can, and probably should,

Where can I find code samples for XNA with WinForms?

百般思念 提交于 2019-12-05 21:02:59
I'm trying to make a WinForms application with embedded XNA according to this sample: http://creators.xna.com/en-US/sample/winforms_series1 What I'm looking for are code samples that use code sample above to study more on the subject. I'm creating a desk game. Thanks for help Well, here is one but also check this project at Codeproject. There are numerous sites, just search XNA and Winforms in your favorite search engine. Responding your question, I'd recommend you join XNA forum . My experience is people there are cool and reliable. Here is a nice post with source code of your particular

Convert A XNA Color object to a string

混江龙づ霸主 提交于 2019-12-05 16:22:14
I know how to convert a string to an XNA Color object , but how do I convert a C# Color object like Color.Blue into its string representation(e.g. "Blue"). Bennor McCarthy You need to do the reverse of what was done in your previous question: Convert from XNA color to System color Try and convert the system color to a known color If the conversion worked, call ToString on the known color e.g. // Borrowed from previous question using XnaColor = Microsoft.Xna.Framework.Graphics.Color; System.Drawing.Color clrColor = System.Drawing.Color.FromName("Red"); XnaColor xnaColor = new XnaColor(clrColor

Some simple XNA/HLSL questions

岁酱吖の 提交于 2019-12-05 16:10:15
问题 I've been getting into HLSL programming lately and I'm very curious as to HOW some of the things I'm doing actually work. For example, I've got this very simple shader here that shades any teal colored pixels to a red-ish color. sampler2D mySampler; float4 MyPixelShader(float2 texCoords : TEXCOORD0): COLOR { float4 Color; Color = tex2D(mySampler, texCoords.xy); if(Color.r == 0 && Color.g == 1.0 && Color.b == 1.0) { Color.r = 1.0; Color.g = 0.5; Color.b = 0.5; } return Color; } technique

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

一世执手 提交于 2019-12-05 15:23:42
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 needs its own texture, and of course enemies and everything else. One way I could do it is just to load

Extremely low FPS, what profiling application should I use to find performance issues?

自古美人都是妖i 提交于 2019-12-05 12:37:23
I'm creating an XNA game and am getting an unexpected result, extremely low FPS (About 2-12 fps). What program should I use to test performance and track down what is slowing it down? Jeff_Hd Have you tried using SlimTune ? You could also use StopWatch to measure sections manually. Okay, let me bring my personal experience with game development in XNA. The first thing you need to do is go into Debug -> Start Performance Analysis. This profiles your CPU activity and see's what threads are in use and what is doing the most processing. You also need to factor in a couple of more things: -You are

MouseMove event too slow for painting

会有一股神秘感。 提交于 2019-12-05 12:36:12
I'm using C# WinForms to create a level builder for my XNA game. I have a tile grid that you can paint with a Pencil tool, like in MSPaint. The problem is that when you drag the mouse fast(ish) to paint a line tiles get skipped. I've tried using one approach i saw on Google saying to spawn a thread to do the painting, but that didn't seem to help. Any ideas? OTTOMH, you could keep track of the last point the mouse was and in your MouseMove handler you can assume linear motion and determine all the tiles between the last point and the current point. My guess is that you're not likely to ever

Checking if a point is inside a rotated rectangle

风流意气都作罢 提交于 2019-12-05 12:04:16
I know this question has been asked a few times before, and I have read various posts about this. However I am struggling to get this to work. bool isClicked() { Vector2 origLoc = Location; Matrix rotationMatrix = Matrix.CreateRotationZ(-Rotation); Location = new Vector2(0 -(Texture.Width/2), 0 - (Texture.Height/2)); Vector2 rotatedPoint = new Vector2(Game1.mouseState.X, Game1.mouseState.Y); rotatedPoint = Vector2.Transform(rotatedPoint, rotationMatrix); if (Game1.mouseState.LeftButton == ButtonState.Pressed && rotatedPoint.X > Location.X && rotatedPoint.X < Location.X + Texture.Width &&