xna

XNA - Keyboard Input

£可爱£侵袭症+ 提交于 2019-12-13 02:15:30
问题 I just started using XNA Framework 4.0 today, and I was wondering what the easiest way was to get input from the keyboard. I recognize a lot of C++ in C# but the whole Java side of it is alien to me. This coupled with XNA is a little confusing so, please be specific and give examples. Thanks. 回答1: If you're comfortable mucking around with the Object Browser in VS, I'd advise looking at Microsoft.Xna.Framework.Input.Keyboard/Keyboardstate. These entries will show you what you have available to

Object in sphere(bounding sphere), want it to restrict movement within sphere

有些话、适合烂在心里 提交于 2019-12-13 02:03:37
问题 i have 2 bounding spheres, one big and one small , the small will be moving inside the big but i dont want it to go outside the big bounding sphere how do i do it? I tried with the bounding box and the intersection method but it doesn't seem to work. 回答1: Do you have some of your code that we can take a look at, so we can determine why it is not working? Otherwise here is some information on BoundingSpheres: http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.boundingsphere

Texture/model flickering in distance (3D)

二次信任 提交于 2019-12-13 02:02:54
问题 Ok, in my XNA project i've added simple shader + model loading code, anything works. I created a very simple low-detailed model in 3Ds Max. Exported and imported to XNA with FBX format. The problem is: if i move my simple camera to some distance from this model, one of its components starts to flicker. I tried another model and there is the same situation, some of components start to flicker and only if i get to some distance from model. This flickering (or blinking or ..) appears only with

XNA: How to get the BackBuffer RenderTarget

半城伤御伤魂 提交于 2019-12-13 01:40:05
问题 in XNA, I need to get a reference to the RenderTarget (2D) of the BackBuffer in order to draw it to a texture or change its Usage to Usage.PreserveContents , is there any method which allows me to do that? 回答1: Check out this blog post about what happened to ResolveBackBuffer in XNA 4.0. Basically, you should just use render targets. If you really need the back-buffer, you can use GetBackBufferData . But it only works on the HiDef profile. If you need to change the RenderTargetUsage of the

Windows Phone 7.1 emulator not working on Visual Studio 2013, Windows 8.1

对着背影说爱祢 提交于 2019-12-13 00:20:49
问题 I tried to run the Windows Phone 7.1 emulator on Visual Studio 2013 on Windows 8.1. When I start the emulator, it shows the following error. Followed by this error when I press "Run the program without getting help": WHY WINDOWS PHONE 7.1 SDK, NOT WINDOWS PHONE 8: The reason why I am setting this up as such is because I want to develop XNA games for Windows Phone 7 to 8. Hence the reason why I am still using the Windows Phone 7.1 developer kit. I have previously created and published XNA

Cut holes in a Texture2D

南笙酒味 提交于 2019-12-12 22:28:34
问题 I want to know how to remove part of a Texture from a Texture2D. I have a simple game in which I want to blow up a planet piece by piece, when a bullet hits it "digs" into the planet. The physics are already working but I am stuck on how to cut the texture properly. I need to create a function that takes a Texture2D a position and a radius as input and returns the new Texture2D. Here is an example of the Texture2D before and after what I want to accomplish. http://img513.imageshack.us/img513

C# XNA - Sprite moves out of window/screen

こ雲淡風輕ζ 提交于 2019-12-12 21:26:31
问题 When I press left or up arrow keys the sprite gets out of the window/screen. My code: Texture2D m_PlayerShipTex; Rectangle m_PlayerShipHitBox; Vector2 m_PlayerShipPos = new Vector2(400, 486); Vector2 m_PlayerShipOrigin; int m_PlayerShipCurrentFrame = 1; int m_PlayerShipFrameWidth = 62; int m_PlayerShipFrameHeight = 64; float m_Timer = 0f; float m_Interval = 100; public void LoadContent(ContentManager Content) { m_PlayerShipTex = Content.Load<Texture2D>(".\\gameGraphics\\gameSprites\

XNA How to Render and Update while resizing

一笑奈何 提交于 2019-12-12 21:26:11
问题 Is it even possible to continue rendering and updating while resizing the window so that it doesn't stretch? 回答1: This is pretty deeply baked into XNA's Game class's behaviour. I'm dealing with this exact problem now, but I don't have a good solution yet. EDIT: I how now found a solution - but it doesn't answer the bit about scaling - so I've posted it as a question/answer pair over here. You could possibly dive in with reflection and disconnect the events that pause the game's timer when you

How Do I Load A XNA Model From A File Path Instead Of From The Content (eg. Model.FromStream but it doesnt exist)

别说谁变了你拦得住时间么 提交于 2019-12-12 20:00:32
问题 How do I load an XNA model from a file path instead of from the content (eg. Model.FromStream but it doesnt exist)?? Texture2D has .FromStream , how can I do the equivalent for Model ? 回答1: You can use Content.Load<Model>("Path here, make sure you use drive letter"); If you really need to have a FromStream method on Model you can use extension methods (Not exactly a perfect duplicate of FromStream but it should work): public static Model FromPath(this Model model, ContentManager content,

Breakout Paddle Collision Angle

与世无争的帅哥 提交于 2019-12-12 19:02:59
问题 I'm making a Breakout clone and having a little trouble with the ball-to-paddle collisions. I have a rectangle represent both the ball and the paddle and when they intersect, the Y vector representing the ball's velocity is negated (as shown below). That all works fine. The problem is when the paddle is moving to the right I want it to nudge the ball a little to the right (as opposed to it just reflecting off normally) and I want the same to happen in the opposite direction is the paddle is