xna

Infinite Scrolling Background in XNA

柔情痞子 提交于 2019-12-22 13:03:59
问题 I'm drawing a ground texture in a sidescrolling platformer like this: spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, _camera.GetViewMatrix(Parallax)); foreach (Sprite sprite in Sprites) sprite.Draw(spriteBatch); spriteBatch.End(); In Sprite.Draw() public void Draw(SpriteBatch spriteBatch) { if (Texture != null) spriteBatch.Draw(Texture, Position, new Rectangle(0, 0, Texture.Width, Texture.Height), Color.White, Rotation, Origin, Scale, SpriteEffects.None, ZIndex); }

XNA Game, Full Screen Animation / Video Playback

此生再无相见时 提交于 2019-12-22 11:37:36
问题 I have an XNA game (its a slot machine). I have some really cool animations my artist made for me that are more or less 1600x1000 and over 50 frames. For all of the animations so far I have been using sprite sheets. (Where all the frames are in one image file and when its rendered it chooses what part of the image to show). The problem is that you can only load an image of a certain size. 2kx2k or 4kx4k depending on your videocard. Obviously putting each frame into one file is out of the

XNA: The current vertex declaration does not include all the elements required by the current vertex shader. Normal0 is missing

时光总嘲笑我的痴心妄想 提交于 2019-12-22 09:13:48
问题 Hey I'm having a little trouble. I've been working with xna for a while, but I'm completely new to 3D. I'm following the code verbatim from the winformsgraphicsdevice sample on the msdn website. It has a control that draws a primitive triangle to the screen. Simple as that, but I get an exception on this line: GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, vertices, 0, 1); Which says: "The current vertex declaration does not include all the elements required by the current

MouseMove event too slow for painting

孤者浪人 提交于 2019-12-22 07:59:39
问题 I'm using C# WinForms to create a level builder for my XNA game. I have a tile grid that you can paint with a Pencil tool, like in MSPaint. The problem is that when you drag the mouse fast(ish) to paint a line tiles get skipped. I've tried using one approach i saw on Google saying to spawn a thread to do the painting, but that didn't seem to help. Any ideas? 回答1: OTTOMH, you could keep track of the last point the mouse was and in your MouseMove handler you can assume linear motion and

Extremely low FPS, what profiling application should I use to find performance issues?

大城市里の小女人 提交于 2019-12-22 06:59:13
问题 I'm creating an XNA game and am getting an unexpected result, extremely low FPS (About 2-12 fps). What program should I use to test performance and track down what is slowing it down? 回答1: Have you tried using SlimTune? You could also use StopWatch to measure sections manually. 回答2: Okay, let me bring my personal experience with game development in XNA. The first thing you need to do is go into Debug -> Start Performance Analysis. This profiles your CPU activity and see's what threads are in

Fastest Type Comparison?

痞子三分冷 提交于 2019-12-22 05:39:12
问题 The following event can possibly get called hundreds of times a frame. public bool OnCollision(Body body1, Body body2) { if(body2.Tag is Dog) ((Dog)body2.Tag).Bark(); } I understand that using "is" causes a cast to be made and then when i want to do something with it, cast it a second time. Is there a more efficient way to check the type? I made a console app trying "if(body2.Tag.GetType() == typeOf(Dog))" but it appears to be even slower than using "is". Thanks. 回答1: if(body2.Tag is Dog) is

Can't access build configuration manager or build configurations in Visual C# 2010 Express

自古美人都是妖i 提交于 2019-12-22 05:17:05
问题 Full Story Typically, when I install Visual C# 2010 Express, the first thing that I do is switch to Expert Settings. That gives me access to build configurations, and the respective manager. This most recent installation seems to be misbehaving. The first project that I created was an XNA 4.0 (Refresh) project. I imported some old code, switched to Expert Settings, and confirmed that I was able to access both the build configuration manager and the build configuration toolbar. However, when I

Detect collision between a moving object and an immobile one

一世执手 提交于 2019-12-22 05:10:09
问题 First of all, my question isn't really specific to C# or XNA, but my code examples will use these. I am currently trying to make a Pong clone and I've run into a problem with collision-detection. Each object basicly has a specific Velocity(which is a Vector2), Position(Vector2, also) and Speed(just a float). On every Update() call of the object, the position is changed this way: Velocity.Normalize(); Position += Velocity * Speed; At first, I only checked if there currently was a collision

WPF vs XNA to render thousands of sprites

风格不统一 提交于 2019-12-22 04:58:22
问题 I need to render thousand of ellipses linked each others with lines. What would be the best way (in terms of performances) to render it inside a WPF application. Is WPF Canvas painting a lot worse than XNA painting ? Actually, the hidden question is : is it possible to do some xna-rendering inside a WPF host ? I saw some examples that used a borderless xna window overlay, but no native soluation... Thanks, Aurélien 回答1: If done right you can get some pretty high performance in WPF rendering

Problem with alpha blending in XNA

泪湿孤枕 提交于 2019-12-21 22:52:12
问题 Hi i have a background and two png sprites I want to make this effect using the provided background and sprites using XNA 3.1 I'm doing something wrong because i only get this As you noticed its not the effect i wanna do It is possible do this effect with a few lines of code using alpha blending in XNA 3.1? A practical example would be really great! 回答1: First, render textures that contain the shapes that you want to be transparent to texture A. The textures containing the shapes should