xna

How can I control where XNA positions the game window at startup?

隐身守侯 提交于 2019-12-08 02:23:39
问题 I have the following annoyance: Whenever I start debugging an XNA game, the game window pops up in the center of my screen. Since I have a dual monitor system, I'd like to set the default startup position somewhere my second monitor. But, this should only happen in debug modus. 回答1: You need to add a reference to System.Windows.Forms and System.Drawing (as pointed out by Steve H) and then do the following somewhere outside the constructor, like in the Initialize override. var form = (System

C# HashSet2 to work exactly like the standard C# HashSet, not compiling

て烟熏妆下的殇ゞ 提交于 2019-12-08 00:37:38
问题 I'm creating my own HashSet that works as the standard HashSet, using a Dictionary. I'm doing this because C# for XNA XBox doesn't support HashSets. This code is based on code from an example I found. I've edited the example to fix some of the problems but it still won't compile. public class HashSet2<T> : ICollection<T> { private Dictionary<T, Int16> dict; // code has been edited out of this example // see further on in the question for the full class public IEnumerator<T> GetEnumerator() {

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

我怕爱的太早我们不能终老 提交于 2019-12-07 21:06:12
问题 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

How to use shaders in MonoGame?

删除回忆录丶 提交于 2019-12-07 19:27:18
问题 Can someone tell me, how to use shaders in monogame? I have this error: https://gamedev.stackexchange.com/questions/46994/has-anyone-got-the-krypton-lighting-engine-working-in-monogame-for-windows-8 I tried to use 2MGFX, but the tool reports: The effect must contain at least one technique and pass. From what I can see from myshader.fx the file, it does. Here is my shader code: sampler TextureSampler : register(s0); float _valueAlpha = 1; float _valueRGB = 1; float4 main(float4 color : COLOR0,

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

别说谁变了你拦得住时间么 提交于 2019-12-07 18:53:27
问题 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

How to create Paint-like app with XNA?

≯℡__Kan透↙ 提交于 2019-12-07 16:31:18
问题 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,

what is source rectangle in spritebatch.draw in xna

北战南征 提交于 2019-12-07 16:12:08
问题 What is the purpose of the source rectangle parameter in the SpriteBatch.Draw() method? MSDN says: A rectangle that specifies (in texels) the source texels from a texture. Use null to draw the entire texture. What does that mean? 回答1: The idea of the sourceRectangle is to allow you to implement what is both a performance optimisation and an artist convenience by arranging multiple sprites into a single texture . This is known as a "Texture Atlas" or a "Sprite Sheet". (source: andrewrussell

C# XNA 2D trail effect optimization

无人久伴 提交于 2019-12-07 15:24:25
问题 Currently as a trail effect in my game I have for every 5 frames a translucent texture copy of a sprite is added to a List<> of trails. The alpha values of these trails is decremented every frame and a draw function iterates through the list and draws each texture. Once they hit 0 alpha they are removed from the List<>. The result is a nice little trail effect behind moving entities. The problem is for about 100+ entities, the frame rate begins to drop drastically. All trail textures come

What are the risks of loading textures from images at runtime in XNA?

眉间皱痕 提交于 2019-12-07 14:41:30
问题 What is there to know about (apart from only being able to do that on PC) loading textures from images at runtime? 回答1: I've been exclusively loading my textures from streams as well, and the only "danger" that I can come up with is Premultiplied Alphas. You'll either need to process each texture as you load it, or render with premultiplied alphas disabled. Shawn Hargreaves wrote a great blog article on this subject. In the comments, he mentions: If you don't go through our Content Pipeline,

XNA Game does not update while “dragging” window, any event handlers?

懵懂的女人 提交于 2019-12-07 13:37:09
问题 I'm new with XNA and C#, and I've come to the point in my XNA project where I need event handlers to predict when the game loses focus so that I can sync music and visuals once it gains focus again. But I got one problem; the game does not "update" while being dragged, but I can't seem to find an suitable event listener for this. I've tried: System.Windows.Forms.Control.FromHandle(Window.Handle).Move += new EventHandler(DeactivateGame); This one calls "DeactivateGame" tons of times while