xna-4.0

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

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

XNA How to make xna not to read transparent color

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-12 17:14:31
问题 I am fairly new to xna. I just created a sprite with transparent background(magenta). Problem is my Rectangle is reading the coordinates of whole sprite not of visible one. How do I make it read only the visible sprite. myrectangle = new Rectangle(0, 0, box.Width, box.Height); I want to place my visible part not transparent at that position. Thanks in advance. 回答1: To transform a color to transparent, go to the texture properties, content processor, and enable Color Key, and set the key Color

Clamping TextureAddressMode in XNA

岁酱吖の 提交于 2019-12-12 14:51:52
问题 I've been working on implementing a 2D lighting system in XNA, and I've gotten the system to work--as long as my window's dimensions are powers of two. Otherwise, the program will fail at this line: GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleStrip, Vertices, 0, 2); The exception states that "XNA Framework Reach profile requires TextureAddressMode to be Clamp when using texture sizes that are not powers of two," and every attempt that I've made to slve this problem has failed--the

Realtime Resource Updating in XNA

时光毁灭记忆、已成空白 提交于 2019-12-12 14:47:59
问题 I'm looking for a way to update textures and other content files at runtime in XNA, such that if it's modified outside of the application, it will automatically update in the game when it regains focus. This seems to be possible with Texture2D and loading from a Stream, but I'm unable to get a direct path to a given resource. I realize that this won't work with the content pipeline and .xnb's, but for debugging and development purposes it would be extremely useful. Has anyone seen something

“Press Enter to start the game” XNA INTRO SCREEN

末鹿安然 提交于 2019-12-12 13:36:26
问题 I created an introscreen with "Press Enter to start the game",(and exit) ofcourse exit is no problem but to let the game start its a bit harder. Any advice? 回答1: The easiest way to do this would be to set up a State Machine. It would look really simple. enum GameState { TitleScreen = 0, GameStarted, GameEnded, } Something then in the Game1.cs, or wherever you're handling this button click, you can put a variable in you class to store the current game state that you are in. GameState

Rotating a sprite around its center

。_饼干妹妹 提交于 2019-12-12 11:03:21
问题 I am trying to figure out how to use the origin in Draw method to rotate a sprite around its center. I was hoping somebody could explain the correct usage of origin parameter in Draw method. If I use the following Draw method (without any rotation and origin specified) the the object is drawn at the correct/expected place: spriteBatch.Draw(myTexture, destinationRectangle, null, Color.White, 0.0f, Vector2.Zero, SpriteEffects.None, 0); However, if I use the origin and rotation like shown below,

XAP file from XNA game is huge, how can I compile resources without images being so big?

回眸只為那壹抹淺笑 提交于 2019-12-12 04:33:29
问题 I typically have been writing xna games for windows phone 7 and set all my content to a build action of compile, which is default; what I've noticed is that my XAP file is now huge after finishing a new project, it seems to have taken 15MB worth of images and blown them up to 200MB in size. Is there anyway to get the build to be smaller while keeping the images compiled? From what I read it compiles images as basically full bitmaps. What's another direction I can take to resolve this issue,

Detecting clicks in a non-rectangular shape

旧时模样 提交于 2019-12-12 03:04:20
问题 I am pretty new to XNA 4.0 and have a problem I can't seem to figure out. So far I have been detecting mouse clicks by creating rectangles and checking the rectangle.contains method, but what if I don't want to check inside a rectangle? In one part of my map I have a triangle button that I want to let the user click, but I want to only count it as a click if it is actually inside the triangle. If I create a rectangle around the triangle the user will be able to click outside the texture area,

XNA Rotate a bone with an offset translation

送分小仙女□ 提交于 2019-12-12 02:16:09
问题 I have a model that has a bone which has a translated offset from the parent bone (it is not positioned at the tail of the parent bone). In Blender, where the model was made, I can rotate the bone and see the attached mesh rotate correctly. However, when I attempt to rotate the bone in my code, it seems to rotate it about the tail of the parent. I'm messing something up in the Matrix math (my worst enemy). Update: protected override void Update(GameTime gameTime) { bone.Transform = Matrix