xna

What vertex shader code should be used for a pixel shader used for simple 2D SpriteBatch drawing in XNA?

落花浮王杯 提交于 2019-12-06 11:06:16
问题 Preface First of all, why is a vertex shader required for a SilverlightEffect (.slfx file) in Silverlight 5? I'm trying to port a simple 2D XNA game to Silverlight 5 RC, and I would like to use a basic pixel shader . This shader works great in XNA for Windows and Xbox, but I can't get it to compile with Silverlight as a SilverlightEffect. The MS blog for the Silverlight Toolkit says that "there is no difference between .slfx and .fx", but apparently this isn't quite true -- or at least

XNA - Drawing Quads (and primitives) in right order

﹥>﹥吖頭↗ 提交于 2019-12-06 11:04:03
问题 I'm fairly new to 3D-stuff in XNA and unfortunately I have encountered a problem I can't find the solution for. (Don't even know what the problem is). To cut it short: I am drawing quads in my game using: effect.World = Matrix.Identity * Matrix.CreateRotationX(Rotation.X) * Matrix.CreateRotationY(Rotation.Y) * Matrix.CreateRotationZ(Rotation.Z) * Matrix.CreateTranslation(Position); // Apply camera-matrixes effect.View = viewMatrix; effect.Projection = projectionMatrix; graphics

Massive multiplayer in xna

亡梦爱人 提交于 2019-12-06 10:45:14
What do you think about xna and massive multiplayer? for example server and 100 clients? Is there any nice tutorial how to create client server application in xna? There certainly are tutorials on how to do it. Personally I use Lidgren for my online prototype. I've only tested it with 4 people total and the server running on a low resource ubuntu vps, running on Mono, so I can't tell you how it will scale up but I'm sure others could. For quick reading check out the site, http://code.google.com/p/lidgren-network-gen3/ , you can read the wiki posts and google groups to get an idea of what

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

Deadly 提交于 2019-12-06 10:38:18
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. 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.Windows.Forms.Form)System.Windows.Forms.Control.FromHandle(this.Window.Handle); form.Location = new System

XNA 2D Camera - How to lock/center it to an animated sprite?

旧城冷巷雨未停 提交于 2019-12-06 09:28:43
问题 Hey I'm trying to make my camera follow my sprite and for some reason the sprite is always moving faster than my camera and my camera is unable to clamp to the screen. I would like to make it so that the camera is constantly centered on the sprite and follows him as he moves. using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; namespace wintertermrpg {

How to use shaders in MonoGame?

懵懂的女人 提交于 2019-12-06 09:27:32
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, float2 texCoord : TEXCOORD0) : COLOR0 { // Look up the texture color. float4 tex = tex2D

XNA 2D mouse picking

青春壹個敷衍的年華 提交于 2019-12-06 08:43:25
I'm working on a simple 2D Real time strategy game using XNA. Right now I have reached the point where I need to be able to click on the sprite for a unit or building and be able to reference the object associated with that sprite. From the research I have done over the last three days I have found many references on how to do "Mouse picking" in 3D which does not seem to apply to my situation. I understand that another way to do this is to simply have an array of all "selectable" objects in the world and when the player clicks on a sprite it checks the mouse location against the locations of

XNA Editable text field

末鹿安然 提交于 2019-12-06 08:29:14
问题 I know how to draw text in XNA but I am implementing a level designer that will require the user to enter text into a UI. I have had a little scoot around on Google but couldn't find how to implement an editable text field. Is there nothing built into the framework for this? 回答1: you can use some sort of gui library like http://nuclexframework.codeplex.com or use winforms http://create.msdn.com/en-US/education/catalog/sample/winforms_series_1 回答2: Have you considered implementing a level

How to calculate the size of scroll bar thumb?

本秂侑毒 提交于 2019-12-06 08:09:56
问题 I'm making my own custom UI system for my game in C# and XNA, and I have a small problem with scroll bars. I don't know what is the equation to calculate the thumb size of the scroll bar. So let's say I have a panel that is 200x200 px. and an image that is 600x600 px. How can I calculate the scroll bar thumb size according to the image size? 回答1: The thumb (I've heard people call it a scrubber) size should be the size of the viewport (in your example 200px) divided by the size of the content

How do I swap 2 elements in a list [duplicate]

佐手、 提交于 2019-12-06 07:48:32
This question already has answers here : Closed 7 years ago . Possible Duplicate: Swap two items in List<T> Edit: Maybe this will work for getting the 'b' value? for (int i = 0; i < inventory.Count; i++) { if (inventory[a].ItemRectangle.Intersects(inventory[i].ItemRectangle)) { itemB = inventory[i]; } } Edit: Here's my progress. Item itemA; Item itemB; int a = -1; int b = -1; if (a != -1 && b != -1) { itemA = inventory[a]; itemB = inventory[b]; Swap(ref itemA, ref itemB); inventory[a] = itemA; inventory[b] = itemB; } And here's is where I'm getting the 'a' value. if (item.ItemSelected == true)