Tag Info

New answers tagged

3

XNA only supports one keyboard. It supports up to four chatpads, which look exactly like keyboards in terms of the state they track (note the subtle differences in the overloads of Keyboard.GetState). Anyhow, KeyboardState object just reflects the state of a keyboard or chatpad. On its own, it doesn't know or care about whether or not it's representing the ...


3

"Just because." Byte ordering is more-or-less arbitrary. Some hardware will do it one way, other hardware will do it another way... there's basically an equally valid argument in both directions so you just pick one. There's no particularly relevant technical reason why some formats are in RGB order and others in BGR. It likely comes down to when the ...


0

If you're using the default content importer, there's no way to control the mipmap generation behavior of the textures. The .x file format doesn't really provide a template that allows control over mipmapping of textures, and XNA's importer assumes you'll want mipmaps for all the referenced textures. Your two best options are likely: Build a custom ...


0

I study how Unity editor handles rotation with mouse movements. You can rotate by directly clicking on the object, but I didn't look too deeply to that rotation since it doesn't answer your question. You can hold the circular handles to rotate on only one local axis. It proceeds like this: It creates a line from the projection of the point clicked on the ...


0

You cann't draw one texture on front of the plane and different on back. Use twho planes with different winding order of vertices. You need to implement 4 vertices for create plane 0,0; 0,1; 1,0; 1,1 // Scale it as you wish For front plane use counter clockwise winding order when you creating it 0,0; 1,0; 1,1; 0,0; 1,1; 0,1 For back plane use ...


0

I recommend a 3D models even though they will be super simple. You can texture all sides easily. You can also bend or morph those. Also lighting for effects or from the game table is possible if such things are required.


0

Sorry for the late reply, but saw an answer (by GameDevSE's own Josh Petrie) to another question here that reminded me of this one, and it seemed like it could also apply here. Don't know if its truly relevant, but it could be worth a look. It basically discusses the half-pixel offset problem, in which a pixel can end up being misaligned by 0.5 units due to ...


1

XNA is based on D3D9, which has the dreaded "half-pixel offset problem." Pixels are dots, not squares, even though we like to think of them as the latter. In D3D9 you can visualize pixel coordinates as referring to the center of the cell they would illuminate; however we often consider origin of our coordinate systems to be at the "upper left" (or a similar ...


0

Put simply, you only have the bare bones of a WinForms XNA based game. Your going to have to port your games code across from your XNA game project into your WinForms project. You'll have to create the MainLoop, and use it to call your MissileDisplay's Update and Invalidate Methods to simulate XNA's Update, and to call the GraphicsDeviceControl's Draw ...


0

nailed it, for those having the same trouble, you should add two lines in the processor: EffectContent effectSource = new EffectContent(); effectSource.EffectCode = input.SourceCode; //Add these two lines: effectSource.Identity = new ContentIdentity(); effectSource.Identity.SourceFilename = input.name; //End of correction EffectProcessor processor = new ...


3

I've never had this problem before, but I've also noticed you're using BufferUsage.None. This enum has two possible states: None and WriteOnly. In all my coding, I've always used WriteOnly. From the documentation for BufferUsage, it states that WriteOnly does the best memory location for writing/rendering, but the downside is you can't read the data from ...


0

If you are not already, you should use a shader to make all the pixels on your screen darker for night. You can draw a white circle (or a nice gradient circle) in a new render target at the appropriate position, then pass that render target as a Texture2D into the shader. In the shader you can use the extra texture as a "mask" (or whatever you would like to ...


1

It is the the position and size within the Texture2D object. Set data can only alter the color data within the minimap. It can not alter the size or create new ones. The Nullable<Rectangle> rect is the destination within the Texture2D and the int startIndex, int elementCount is the source from the dataColors array. Here are a few examples. The ...


0

Considering the age of this question, you likely have already found an answer, but I thought I would share my approach either way. Assuming your model has a convex shape, you can try pre-rendering the model's texture to a render target with a SpriteBatch, using the appropriate alpha value. Then apply that render target to your model. That way, you won't ...


0

From my short experience, these are my ideas/tips: What you are trying to do is called pixel perfect collision detection. Both player and texture should be inside a rectangle. Everytime Update function is called you should check "broad collision" to see if the two rectangles intersect (there is a Rectangle.Intersects method in XNA for rectangles) . If they ...


1

As player, I prefer to have my saved games along with other game files. The reason for this is that when I need to reinstall my system, the save is still there and I don't have to remember to backup some, more or less, arbitrary location. I've lost saves for several games just because they were stored in some locations you mentioned. Sometimes they were even ...


0

I wrote HLSL code for transparency and then I will transparent one image inside the body and another image used for my foreground : sampler stream : register(s0); sampler back : register(s1); sampler character : register(s2); float4 DepthToRGB(float2 texCoord : TEXCOORD0) : COLOR0 { // We can't easily sample non-normalized data, // Texture is a short ...


1

From my understanding a spritefont is essentially a collection of sprites where each letter translates to a coordinate on a spritesheet, such as the following: You can do this manually, of course, but it would be a pain to check each coordinate. You can use BMFont to do the conversion for you, which creates an image such as the one above, followed by an ...


0

Should have been: botInvadersRect[r, c].Y = (70 * r) + 24;


0

_ScreenWidth = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width; _ScreenHeight = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height; extra references: System.Drawing , System.Windows.Forms


3

Maybe so? int dimensionX = monsters[0].AreaRect.Width; int dimensionY = monsters[0].AreaRect.Height; int monstersPerLine = 7; int padding = 10; int currentX = 0; int currentY = 0; int monsterIndex = 0; for(Monster monster : monsters) { if(monsterIndex % monstersPerLine == 0) { currentX = 0; currentY = currentY + ...


0

Are you looking to place objects in a grid? If so, just use a double for loop? for (int i = 0; i < desiredWidth ; i+= monster.width + paddingX){ for (int j ... ){ monster.x = i; monster.y = j; } }


0

The error is clear. One of your meshes/vertices is missing a texture coordinate, which is the expectation in this case. In Maya, apply a texture channel to transform1 mesh even if you have no intentions of assigning any textures to it. Also, why do you have a mesh called "transform"? Are you sure you didn't mistakenly misname a bone as mesh or vice versa?


0

I would advise against coming up with your own logic like pausing at the last frame of animation, or such if you plan on doing more animations later. I've done this when I started and it can very quickly go out of hand. You could accomplish this with a state machine. This is a simple yet very easily customizable way of doing animations in case you implement ...


1

Try calling p.Apply() in your drawing code to set the effect correctly on the GPU before drawing. foreach (EffectPass p in drawingEngine.CurrentTechnique.Passes) { p.Apply(); // this will set the effect graphics.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, numVertices, 0, numIndices / 3); }


2

Draw the images or text with static location in an other spritebatch.Begin, which doesn't have a matrix transform.


1

I believe it's because you're using the Bresenham line drawing, which swaps the start/end points sometimes. See the calls to Swap(). I'd suggest instead using linear interpolation for line drawing, which would look something like this (untested): double lerp(double begin, double end, double t) { return begin + (end-begin) * t; } private ...


5

You can reduce the instruction count by using vector operations: e.g. instead of edr = bool4((w1.x < w2.x) && ir_lv1.x, (w1.y < w2.y) && ir_lv1.y, (w1.z < w2.z) && ir_lv1.z, (w1.w < w2.w) && ir_lv1.w); you can write edr = (w1 < w2) && ir_lv1; Operators in HLSL ...


5

I got this working. It does not use the hqx filter, it uses the xBR filter (which I prefer). For me, this is not a problem. If you require the hqx filter then you'll want to convert the .cg files into their appropriate XNA equivalent. For completeness and searching reasons, I will be editing the question to be more concise and then posting all the relevant ...


1

You need to either interpolate or extrapolate the collision. Basically this means instead of just checking the collision of the object where it is NOW, check the collision of the object with where it is and where it WILL BE or WAS, then check x number of times in between those positions. Vector2 pos = ball.position; Vector2 prevPos = ball.previousPosition; ...


0

In your loop, you are using this overload: http://msdn.microsoft.com/en-us/library/ff433987.aspx, which instead of specifying a scale, specifies destination and source rectangles. It's hard to tell from the names you chose if you provided the correct rectangles, but you specified g_BotInvadersRect[r, c] as the destination (screen bounds) and ...


1

Set Game.Content.RootDirectory to the path you want and then just specify the file name portion. But keep in mind that you still have to include them in the Content project. If you don't want to/can't do that, then forgo the ContentPipeline altogether.


2

Dynamically importing and processing content at runtime is explained in the sample WinForms Series 2: Content Loading. This is the preferred method. You can also build an XNA Content Project file using MSBuild. this blog post explains how. You can create a temporary project file, so you don't need to modify or rebuild files in your Solution. Additional ...


0

In Visual Studio... Right mouse click on the Content Project Select 'Add' then 'Existing Item...' Navigate to the folder containing your content, change the filetype from the drop down box if needed, select your content file, then click on 'Add'. Use your content.


0

I figured it out. Hopefully this can help someone else. private short[] indexData = new short[] { 0, 1, 2, 2, 3, 0 }; private VertexPositionTexture[] CreateTriangles(Vector2 location, int width, int height) { /* this is what the index data tells us * * 2 ________________ 3 * |\ ...


0

In the code here : new VertexPositionTexture(new Vector3(1f, -1f, 0f), new Vector2(1, 1)), new VertexPositionTexture(new Vector3(-1f, -1f, 0), new Vector2(0, 1)), new VertexPositionTexture(new Vector3(-1f, 1f, 0), new Vector2(0, 0)), ...



Top 50 recent answers are included