Tag Info

New answers tagged

0

I'm not sure if there are any specifically about porting to iOS yet but there are a few good tutorials around that might help. Check out this discussion on the forums lists current tutorials. https://monogame.codeplex.com/discussions/439595 There's also another related thread about ideas for new tutorials. https://monogame.codeplex.com/discussions/439728 ...


0

You're right on that main point: pixel collision is way complicated. Often times, it's going to be far, far more effort than it's worth. You'll likely have to program a form of collision that's not 100% the same as the visuals you draw. A rocket sounds like something that could very easily use rectangle collision detection. However, a random guess suggests ...


2

I've got a big, somewhat controversial discussion over here about why Game Components are "bad". The most annoying thing about GameComponent, for me, is that it looks really important. It looks like a first-class part of the XNA API - like Vector3 or SoundEffect - but they're actually not (everything in the Game assembly is technically optional). So many ...


2

Since I am not familiar with shaders at all - I recommend this approach: Create a texture in your favorite editor whether it be GIMP or Photoshop. Leave some sort of radial transparency in the center of the image so the player can actually see what he/she is doing amidst the red bordering the edges of the screen. Add that image to your XNA project, and ...


0

http://monogame.codeplex.com/discussions/390201 In this thread the user is struggling with getting the mouse-position(Mouse.SetPosition) to work. Unfortunately it is a bug within MonoGame so it is going to have to take some internal editing. Please look at the code/instructions he has posted within the thread so you can solve your error. It seems like this ...


1

To seek you should use the PlayPosition property of VideoPlayer (http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.media.videoplayer.playposition%28v=xnagamestudio.31%29.aspx) I think the best way to do this, if you want quick turnaround time, it to cache the VideoPlayer instances. Another idea would be just to cache the textures for x ...


0

It would be easier and faster to just remove the fixture on collision, instead of looping and checking for a string you set earlier. I would update the OnCollision function as follows: bool Player_OnCollision(Fixture fixtureA, Fixture fixtureB, FarseerPhysics.Dynamics.Contacts.Contact contact) { //If category group 1 if (fixtureB.CollisionCategories == ...


2

I use Neoforce controls. They act just like winform controls. If you can use winform, you can use NF. http://neoforce.codeplex.com/ Works great in my XNA 4.0 project.


1

Body.Dispose(bodyhere) is what you are looking for. It removes the body as well as all attached features. If you do not want to move Body.Dispose you can use World.RemoveBody(bodyhere) which removes the body after the current step. I would recommend you use the latter though.


1

You can draw triangles directly using DrawUserIndexedPrimitives and other similar functions. Yes, it is much more work than simply drawing rectangles. Example code: http://msdn.microsoft.com/en-us/library/bb196414(v=xnagamestudio.40).aspx


0

I agree with Katana, making a GUI system is harder than it may appear. I was working on one until I found that I was spending more time writing & fixing the GUI library than working on my game. Alternatives that I looked at were Ruminate XNA, and Awesomium (more specifically Awesomium .NET). I ended up picking Awesomium, and MindWorX and I built an ...


1

There's a number of things you're sort of missing, but it's not something I blame you for - to be honest, UI frameworks involve quite a lot of logic you wouldn't quite think of, depending on how advanced they need to be. For one thing, to avoid having 'MouseOver' when the user's mouse is simply sitting still, you may want to save the last MouseState value, ...


6

Disclaimer: This answer is based on the book Artificial Intelligence for Games by Millington and Funge. You should take a look at it for details, and implementations notes at AI4G.com and it's aimed to give readers the general idea trying to avoid copyright infringement. I'm going to answer in reverse order because I think that's the level of difficulty. ...


1

When you use the XNA class Vector2 to represent the positions of the player and the enemies, you can use its method Distance to calculate the distance to another Vector2. Then you just have to check if this is smaller than the radius of the attack circle. To calculate the distance between two points yourself, you can use the pythagorean theorem. // ...


0

Well, there are two ways of doing this: Draw the entire Water object to a render target, then draw the final water target scaled and on the position you want. (this is the simplest way). Draw the Water in a constrained area. For this you'll need do to something like this: Create the Water by specifying a Rectangle as target in the constructor. Every ...


-3

I don't know. Other then that, what you can do it simply construct a cache of these files, of which you can draw meshes on and tell xna to read them. This may be sorta slow but I actually think Minecraft does it. It constantly reads and writes data files, doubt you game is gonna be slowed down.


0

In the destination variable of Draw() use a new Rectangle() so that you can specify the not just the position of the draw but the size also. Rectangles properties Height Specifies the height of the rectangle. Width Specifies the width of the rectangle. X Specifies the x-coordinate of the rectangle. Y Specifies the y-coordinate of the ...


7

There are no conversions of XNA to the android platform without using either MonoGame or EXNA. You will need to rewrite your game including all the rendering logic in either C# using Xamarin.Android or a complete rewrite in Java.


0

Would there be a better way than to loop through all of the surfaces on the map and see if the player is colliding with it? This is essentially the basic concept and pretty much the only way to do it overall. But besides this, there is space for optimization, what John simply called "Spatial Hashing". The idea behind this is reducing the amount of ...


1

Problem solved with: world.ContactManager.PreSolve += new PreSolveDelegate(PreSolve);


2

You are trying to use a stack like a list. A stack has no random access. By that, I mean you can only take 'pop' off the stack what you just 'pushed'. Think of a stack of plates. You can only access the plate that you just put on the top of the stack. Also, stack data structure is almost certainly something you do not wish to use for your purpose (updating ...


0

To do what you want you need to use combine the char line of sight with the visibility of the tile. Line of sight You will use some algorithm to determine which tiles are visible or not at a given time. There are several algorithms for that, research one suitable for your game type. Each tile will have three states: Visibility states Unknow. This is ...


0

int mapx = (tileOnX + x); int mapy = (tileOnY + y); depthOffset = 0.7f - ((mapx + (mapy * tileWidth)) / maxdepth); I forgot to add on the incrementing x & y values from the for-loop :/.


0

I've used XNB Builder to manually convert them into .xnb files. Simply run the app, choose your files and it will convert them into XNB files that are ready to use with MonoGame.


4

Each object should have its own bone. Each bone should be unconnected to the others and able to move freely. This allows you to animate each bone, with position and rotation, while still keeping the model as one. Each bone is really just a matrix to apply to the vertices under it's control. It's simple to imagine applying a translation and rotation to each ...


0

I think you are misinterpretting the result of setting the origin to (0.5f, 1). I did the same thing, and I got the expected results. Here's a modified version of the code I ran at this answer: Color[] colors = new Color[] { Color.White }; texture = new Texture2D(GraphicsDevice, 1, 1); texture.SetData<Color>(colors); spriteBatch.Draw(texture, new ...


0

It's not the fault of SpriteBatch. It's much more likely to be the fault of your Resources object. By the way, keeping track of resources is the job of the Game class. I would be skeptical that you have good reason to also assign a GraphicsDevice into your custom object. Afterall, Game already has one, and it ought to be a singleton. Do you call ...


0

Turns out the issue was not initializing and loading content in the correct order. I am building an engine and had to refactor it to work as a library for Windows 8 apps. When I shuffled some code around I removed some XNA-specific code and put in back in the wrong place. Here's the basic flow of things: Constructor Instantiate GraphicsDeviceManage Set ...


2

I'm assuming your setup is similar to the following(however if it is not, you should be able to follow the following explanation) If you want to display place-holder sprites (the faded-out sprites you were talking about) then you need either a list or an array to store the sprites positions, and draw them with the alpha value of your choice. Add some ...


3

I'm guessing it has something to do with the fact that I use spriteBatch.Begin, maybe I'm not allowed to do that this way? You'd be correct. The spriteBatch should only be used from within a Draw method, and I'm guessing that buttonWasClicked is called from an Update() method? You'll need to store some information in the buttonWasClicked method that ...


1

You actually need to draw your smallPotTexture in the protected override void Draw. So the best for you to do is. protected override void Update(GameTime gameTime) { MouseState mouseState = Mouse.GetState(); if (lastMouseState.LeftButton == ButtonState.Released && currentMouseState.LeftButton == ButtonState.Pressed) ...


6

If you look at the Farseer Physics Engine 3.3.1 Testbed XNA code, you'll find an example called OneSidedPlatformTest. Inside this test is the code required to create Fixtures that act in the manner you're requesting. Essentially, you override the PreSolve function in the following way: protected override void PreSolve(Contact contact, ref Manifold ...


2

You need a variable that stores the position that was clicked ( the target of the object. ) This position could be set when you check the rest of your input like this MouseState mouseState = Mouse.GetState(); if (lastMouseState.LeftButton == ButtonState.Released && currentMouseState.LeftButton == ButtonState.Pressed) { // This will give the ...


-2

Could this be causing your issues? if (lastMouseState.LeftButton == ButtonState.Released && currentMouseState.LeftButton == ButtonState.Pressed) You are saying here: If the left mouse button was released AND is being pressed currently; This seems like contradicting actions, mouse buttons are usually pressed first, then released to signify a ...


8

Using a while loop inside your game loop is a basic no-no. Think about how the code is being executed and you'll realize why it just teleported or was frozen and then teleported. (hint: how much of that code do you think is run before the next time your graphics are updated?) You want to have a target position, then on each iteration of your game loop check ...


0

Vertices is in Farseer, in the namespace FarseerPhysics.Common: using FarseerPhysics.Common;


1

Which part gets colored and how can I control it? All of it and you can't unless you make your own shader. I have a rounded block and my goal is to have the center filled with a certain color chosen by that parameter. Tinting does not to solve this problem. What you want is making which was covered pretty thoroughly here.


1

In addition, the ball jumps weird when it touches two platforms at the same time. Is there a possibility to avoid that weird jumping? Nope your going to get that behavior with 2 platforms. You should combine them together into 1 shape. If the shape is more complex you can create a polygon that encompasses the entire area. Anyways friction is going ...


2

Are you just adding force to the ball? If you need elastic collisions don't do this. Farseer body has property called restitution, it controls ratio of the speed before and after collision.


2

What you would do in this case, is draw a colored rectangle behind this texture first, and then draw this texture on top of the colored texture. This is assuming the center portion of your graphic is transparent. SpriteBatch.Draw(BlankTexture, new Rectangle(Area, Of, Your, Texture), null, YourColor, 0, Vector2.Zero, SpriteEffects.None, 1); ...


0

Honestly, this is a solution in search of a problem. I can't see any benefits towards doing such a thing, and it doesn't seem like you can think of any either. Best just to take existing solutions and run with those. (and chances are "a new way of doing collision detection" will suck, when pretty damn smart people like the chipmunk physics and box2d devs are ...


1

Use the FBX-Koverter. XNA can read fbx.


0

You need to draw each mesh separately, and with the appropriate bone transformations: (The below pulled from Reimer's tutorials as it's simple and clean): private void DrawModel() { Matrix worldMatrix = Matrix.CreateScale(0.0005f, 0.0005f, 0.0005f) * Matrix.CreateRotationY(MathHelper.Pi) * Matrix.CreateTranslation(new ...


3

There is no form controls available for XNA. There are 3rd party source code you can get however: http://neoforce.codeplex.com/ http://xnainterfaceelements.codeplex.com/ http://simplegui.codeplex.com/


0

I fixed the problem by putting a normalized normal into the m.Normal field and multiplied it by a value to flip the normal depending on what axis/axes it was intersecting on. public static bool TestAABBvsAABB (AABB a, AABB b, ref Manifold m) { m.A = a; m.B = b; m.Normal = b.Position - a.Position; ...


2

I believe that your manifold normals are incorrect. These AABBs will attempt to "push back" along the axis of the greatest intersection, however: if(m.Normal.X < 0) m.Normal = new Vector2(-1,0); else m.Normal= Vector2.Zero; That code is saying "if B is further left than A, then the direction to resolve penetration is in the negative X axis, ...


0

There are plenty of tutorials for both libraries. For Farseer, I recommend to check out the "Getting started" section of their document, which also links to a Box2D manual for further reading: http://farseerphysics.codeplex.com/documentation?referringTitle=Home You can then take a look at the Farseer Examples and try to understand how they work. The Basic ...


2

You don't. Content is for loading objects compiled by the content processor. However, you can add the xml files to the content project and have the project copy them to the deploy location without compiling them. If you do this you can use relative paths to access the content. To do so put the XML file in your project as you normally would, change Content ...


0

I think the reason your sprite is shaking is because you're moving it back from the object based on previousVelocity. I'm assuming that when you press or hold the movement, it sets the velocity. If this is true, then I think what's happening is: Your player is moving towards an obstacle. Player's next move intersects obstacle. ...


3

You are going to need to do your move/collision in two steps, once for the horizontal direction, and another time for the vertical direction. Move Horizontal Check for horizontal collision - adjust position if needed Move Veritcal Check for veritcal collision - adjust position if needed Doing the collision check like this should solve your stuttering ...



Top 50 recent answers are included