Menu
  • HOME
  • TAGS

Why is XNA Write/ReadObject() not preserving Vertex/Index Buffer data?

c#,xna,xna-4.0

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...

C# XNA Collision detection with random falling sprite

c#,xna-4.0

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....

Make something happen when a boolean is changed, but not changed back

c#,timer,xna,boolean,xna-4.0

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...

DrawBone Angle variable using Kinect

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,...

XNA: Transforming individual triangles gives different results than transforming model

c#,xna,xna-4.0,intersection

I simply wasn't recalculating the normal after the transformation. Adding the calculateNormal(); statement at the end of the Transform function solved the problem.

XNA GS installer doesn't recognize c#?

c#,xna,xna-4.0

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...

Monogame Content Pipeline has stopped working

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...

Cut beginning of a sound effect / silence

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...

Invalid rank specifier

xna,xna-4.0

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),...

Performance-wise, is it Necessary to Stop Drawing Textures That Aren't On Screen Anymore?

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...

XNA 4.0 - How to render a viewport in a second window

c#,winforms,xna,xna-4.0

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...

C# Getting System.NullRefrenceException from Loading map from 2array [duplicate]

c#,xna-4.0

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...

Mouse.SetPosition() assigned variable is considered void

c#,xna,xna-4.0

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.

XNA Disable Auto Fit to Screen

c#,.net,xna-4.0

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,...

XNA animation inside WPF

c#,wpf,animation,xna,xna-4.0

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).

Cross Viewport oclussion culling

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 to divide Vector2 to Vector2 Arrays?

c#,vector,xna-4.0,monogame

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...

How can I optimize this bottleneck Draw call?

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....

Adding Special Characters to SpriteFont

xna,xna-4.0,spritefont

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>&#9650;</Start> <End>&#9668;</End> </CharacterRegion> <CharacterRegion> <Start>&#32;</Start> <End>&#126;</End> </CharacterRegion> </CharacterRegions>...

XNA 4.0 2D space shooter

xna,space,xna-4.0

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...

an object reference is required to access non-static field, member, or property when using inheritance

c#,inheritance,xna-4.0

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....

Why Xna doesn't load .fx files

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.

How do i check if there are no key inputs on xna

c#,xna-4.0

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;...

Do I understand this Strategy Pattern correctly?

c#,xna-4.0,strategy-pattern

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?...

Is there a way to remove the lagg?

c#,xna,xna-4.0

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); } } ...

Make a Rectangle that covers all the drawn objects in a 2D Array

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...

XNA Sprite doesn't seem to be updating?

c#,xna,sprite,xna-4.0

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...

XNA 2d Camera not drawing

c#,camera,xna,xna-4.0

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....

Drawing image with an angle

c#,xna,2d,xna-4.0

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)); ...

Issues implementing moveable platforms in XNA 4.0

c#,visual-studio-2012,xna,xna-4.0

It looks like someone didn't escape their HTML correctly. Just replace every &lt; with < and the code should work.

XNA - Reconnecting Content Project

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.