Well, I've finally discovered my answer, and it says something ugly about XNA Game Studio. To start with, I've learned from the documentation that there can be only one ContentTypeWriter<T> or ContentTypeReader<T> for any given type T. Supposedly, creating a second writer or reader for T will result in an...
You describe the goal, but not ask questions. If you want to know how to check the intersection of two objects, then you need to define for them bounds (class Rectangle) and check their intersection method Rectangle.Intersect. Anyway better adjust your question....
You should look into properties, by using a public accessor which handles logic, and a private backing field. public bool Enabled { get { return enabled; } set { if (value != enabled) { //Do Something if it changes } enabled = value; } } private bool enabled; The get...
c#,kinect,xna-4.0,kinect-sdk,xna-math-library
Here is the code to calculate the angle between two vectors (Explanation below code): public class Angles { public double AngleBetweenTwoVectors(Vector3D vectorA, Vector3D vectorB) { double dotProduct = 0.0; dotProduct = Vector3D.DotProduct(vectorA, vectorB); return (double)Math.Acos(dotProduct)/Math.PI*180; } public double[] GetVector(Skeleton skeleton) { Vector3D ShoulderCenter = new Vector3D(skeleton.Joints[JointType.ShoulderCenter].Position.X, skeleton.Joints[JointType.ShoulderCenter].Position.Y,...
I simply wasn't recalculating the normal after the transformation. Adding the calculateNormal(); statement at the end of the Transform function solved the problem.
Yes, unfortunately XNA won't install unless you have VS 2010. Once you have it, it will actually work just fine with 2012/2013, you just need to copy the installed files over and update the .vsix manifest to allow the newer version of VS. See XNA for Visual Studio 2013 or...
c#,visual-studio-2013,xna-4.0,monogame,content-pipeline
In case you're still having this problem, or someone else finds the question (like I did trying to solve this a little while ago): for me, the problem was that my windows/system32 directory wasn't in my 'path' environment variable. That's where the setx.exe program resides, and the XNA content project...
c#,audio,windows-phone-8,xna,xna-4.0
You would have to know the exact WaveFormat of the recorded sound. If you've got the exact WaveFormat (e.g. 16 bit pcm mono), you could iterate through all samples, check whether it is within a specific range. If all samples are for example smaller than 0.1 it is silence. If...
In C#, the right way to instantiate a 2D array is to use a comma instead: int[,] array = new [3,2]; You can still make arrays such as int[][], but you'll need to use a for loop to create every individual array inside it (which can be of different lengths),...
c#,xna,textures,xna-4.0,spritebatch
Depends. Ultimately spent time comes down to 3 things: sending data to the GPU, vertex shading, and pixel shading. If the texture is located on a spritesheet that has other textures that are being drawn on screen and the offscreen draw call is within the same .Begin() .End() block as...
This looks like what you are after. In summary, the article suggests you create a child class that inherits from GraphicsDeviceManager. This class will essential look for and store connected monitors. You can then create two game windows on separate threads (one for each monitor - remember to replace the...
If you get a NullReferenceException you access a variable whose value is null. Possible candidates: all variables in the line above, that might be accessed within the constructor. Obviously in the constructor of MapLoader you don't create the array Tile[,] Tiles. Just declaring a property does not create the actual...
Without looking at the XNA documents I can still safely say that the Mouse.SetPosition-method returns void and you are trying to assign the return value of it to this.mouse which is of the type MouseState. Remove that assignment and you will be fine.
Your solution should work if you are setting those values on the Game class constructor and have configured the screens to expand content between themselves. Another, not really recommended, way to do it is to apply the changes on either the Initialize or LoadContent method. In order to do this,...
So after sometime tinkering with WPF and XNA and switched to another method illustrated here http://blogs.msdn.com/b/nicgrave/archive/2010/07/25/rendering-with-xna-framework-4-0-inside-of-a-wpf-application.aspx and still the animation didn't play (it removes hosting winform inside WPF) , So I've decided to switch to winform (no more wpf).
xna,overlay,viewport,xna-4.0,occlusion-culling
This issue, at least in my case, Seems to have been resolved by simply clearing the depth buffer between drawing the 2 Viewports. I did this by adding the following line between the function calls that draws the individual Viewports GraphicsDevice.Clear(ClearOptions.DepthBuffer, Color.Black, 1, 0); I ran in to this solution...
How about something like this: // For N waypoints between a start and end, we need N+1 segments segments = WaypointAmount + 1; xSeg = (end.x - start.x) / segments; ySeg = (end.y - start.y) / segments; // even though we have N+1 segments, adding the last segment would take...
c#,optimization,xna,draw,xna-4.0
You could always render each building to a texture and cache it while it's on screen. That way you only draw the windows once for each building. you will draw the entire building in one call after it's been cached, saving you from building it piece by piece every frame....
You need to use the decimal value for your characters instead, check out this site which will show you all of the representations. (You can change the value in the URL to find different characters) Your correct XML should be: <CharacterRegions> <CharacterRegion> <Start>▲</Start> <End>◄</End> </CharacterRegion> <CharacterRegion> <Start> </Start> <End>~</End> </CharacterRegion> </CharacterRegions>...
Google is your friend and you as a game-developer (or any kind of programmer really) need to get to know that friend well. Learning how to search for information is essential for any programmer and you should experiment with slight changes in your search-query and observe how it changes the...
It sounds like you're trying to pass parameters from your constructor to the base constructor. But your constructor doesn't actually have any parameters, so texture in the derived class doesn't mean anything. You need to add the parameters to the derived type's constructor....
c#,graphics,visual-studio-2013,textures,xna-4.0
Put specific file into Content folder and make sure that content processor for that file is set to Effect - XNA framework.
Maybe something like this would work for you: ks = Keyboard.GetState(); bool isMoving = false; if (ks.IsKeyDown(Keys.Right)) { position.X += 3f; currentWalk = walkRight; isMoving = true; } if (ks.IsKeyDown(Keys.Left)) { position.X -= 3f; currentWalk = walkLeft; isMoving = true; } if (ks.IsKeyDown(Keys.Down)) { position.Y += 3f; currentWalk = walkDown;...
You are using strategy patterns, but probably you do not yet understand why and how to use them. Let me give you a very simple example. Let's say you have a set of objects and you want to sort them. The problem is: how do you specify the sort order?...
Change the Draw function to this Draw(SpriteBatch spriteBatch, GraphicsDevice device) { Point tempPoint; foreach (enemy1 enemy in enemies1) { tempPoint = new Point((int)enemy.Position.X, (int)enemy.Position.Y) if (device.Viewport.Bounds.Contains(tempPoint)) enemy.Draw(spriteBatch); } } ...
c#,arrays,xna,xna-4.0,rectangles
It's all a matter of organizing your code. You should use an object oriented approach. Create a class that represents your game objects. I would use an abstract base class defining the basic properties and methods. Then derive concrete game objects from this base class. The concrete game objects' constructors...
As mentioned in the comment, I am not going to solve every problem. But the main errors. Let the player be responsible for its position, not the game. Furthermore, I would make the player responsible for drawing itself, but that goes a bit too far for this answer. The following...
uggh, noticed the update method in the class wasn't used anywhere in my game. Putting cam.Update(); Into my update method got everything working correctly....
Matrix CreateSkewY(float angle) { Matrix skew = Matrix.Identity; skew.M21 = (float)Math.Tan((double)angle); return skew; } spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, CreateSkewX((float)Math.PI / 6)); ...
c#,visual-studio-2012,xna,xna-4.0
It looks like someone didn't escape their HTML correctly. Just replace every < with < and the code should work.
visual-studio-2010,crash,xna,xna-4.0
I found a way to make it work. More a workaround than a solution, I created a new VS solution, imported everything other than the content project from the old one and used the content project that came with the new solution.