xna

Saving Microphone Stream to mp3 or wave

痴心易碎 提交于 2019-12-06 03:23:25
问题 I recording sound from Microphone in Windows Phone device. Using Xna.Framework.Audio.Microphone I store the sound in MemoryStream . I can save it to PCM format. However It will be much better to convert it to mp3 file. If converting to mp3 is impossible then maybe somebody at least knows how to convert it to wav. Thanks for your answers. 回答1: Here is a brief example I created showing how to save wp7 recorded audio as a wav stream: http://damianblog.com/2011/02/07/storing-wp7-recorded-audio-as

C# XNA 2D trail effect optimization

百般思念 提交于 2019-12-06 03:10:39
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 from the same sprite sheet so i dont think it's batching issue. I profiled the code and the CPU intensity

Checking for .NET dependencies before launching

有些话、适合烂在心里 提交于 2019-12-06 03:01:13
问题 I have several apps that I work on and like to distribute to friends that require Microsoft Provided .dlls and or frameworks. Specifically, XNA. I'm tired of getting emails back from them saying "It crashed" when in reality, all that's happened is they don't have XNA (or .NET 3.5, or whatever) installed. However, Main can't catch these errors because the .exe loads them before main is even executed. So, my question is, how would I go about creating a launcher that could check for things like

Code runs correctly only when stepping through it with debugger? [duplicate]

时光怂恿深爱的人放手 提交于 2019-12-06 02:52:14
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: Random number generator only generating one random number I was a bit baffled with this few moments ago. I have the following code: public blockType generateRandomBlock() { Random random = new Random(); int makeBlockOfType = random.Next(0, 100); blockType t = blockType.normal; if (makeBlockOfType <= 80 && makeBlockOfType >= 60) { t = blockType.blue; } else if (makeBlockOfType > 80 && makeBlockOfType <= 95) { t =

Workaround for Texture2D.GetData method

若如初见. 提交于 2019-12-06 02:33:42
问题 I’m converting a game from XNA to iOS with Monogame. In the code snippet below, smallDeform is a Texture2D on which I call the GetData method. smallDeform = Game.Content.Load<Texture2D>("Terrain/..."); smallDeform.GetData(smallDeformData, 0, smallDeform.Width * smallDeform.Height); I’m having some problem with Monogame because the feature in iOS has not been implemented yet because it returns this exception. #if IOS throw new NotImplementedException(); #elif ANDROID I tried to serialize the

Check if system has sound C#

余生颓废 提交于 2019-12-06 02:19:00
问题 We are currently developing a game using XNA and we've stumbled upon a little sound problem. When a system has no sound device plugged in (speakers, etc. -- when Win7 shows a red cross on the speaker icon) it crashes when trying to play/load the sound. So, we would like to check if the system has the capacity of outputting sound. Is it possible in C#? 回答1: Are you sure that it is actually crashing, and not simply throwing an unhandled exception? In theory it should throw a

What is a correct way of replacing the switch block and Enum in this situation (C#)?

那年仲夏 提交于 2019-12-06 02:13:20
问题 If it helps, the following question is in the context of a game I am building. In a few different places I have the following scenario. There exists a parent class, for this example called Skill, and I have a number of sub-classes implementing the methods from the parent class. There also exists another parent class that we will call Vocation. The skills need to be listed in different sub-classes of Vocation. However, those skills need to be available for anything in the game that uses any

Creating a 2D polygon in XNA

寵の児 提交于 2019-12-06 01:49:41
问题 I have some sort of a problem. I'm new to XNA and want to draw a polygon shape that looks something like this (In the end, I want these point to be random): So I read some articles and this is what I ended up with: private VertexPositionColor[] vertices; public TextureClass() { setupVertices(); } public override void Render(SpriteBatch spriteBatch) { Texture2D texture = createTexture(spriteBatch); spriteBatch.Draw(texture, new Rectangle((int)vertices[0].Position.X, (int)vertices[0].Position.Y

Xna adding gravity to a 2d sprite

我与影子孤独终老i 提交于 2019-12-06 01:47:37
问题 I am trying to simulate gravity in my first xna 2d game. I have the following //Used for Jumping double elapsedAirTime = 0.0; double maxAirTime = 8.35; //End Jumping So I am trying to move the sprite up by a certain amount while the elapsedAirTime < maxAirTime However, there is some issue where my code only seems to move the sprite up once and not multiple times during this segment of time. here is the code in my "player.cs" class, or the update method of the class. if (newState.IsKeyDown

what is source rectangle in spritebatch.draw in xna

China☆狼群 提交于 2019-12-06 00:26:01
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? Andrew Russell 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.net ) I explain why it is a performance optimisation in this answer . Basically it lets you