I found it on forum and i want use it. I tried do this:
In constructor:
circle = new Circle(new Vector2(10,10), 100);
In Draw method:
spriteBatch.Draw(balltexture, circle, Color.Black);
Circle isn’t rectagle… so… How to draw this circle with my custom texture or with custom color ?
You can’t use that Circle structure as if it were a rectangle.
Just make sure that your texture represents a circle and draw it like you would normally do: spriteBatch.Draw(myCircleTexture, myRectangle, myColor);
So, I should load a file with my circle and use it as rectagle in spriteBatch.Draw() method and moving positions Circle struct with my rectagle to check collisions ?
It’s good idea or not?
Where Bounds is calculated like I said above.
Since your Bounds and your myCircle always have the same position, you can collision check with the Circle’s “Intersect” method.
Also, if you didn’t get it, the Bounds is a rectangle that is exactly as big as your circle’s diameter.
That’s great - Yesterday I had to change the source of my version of Primitive3d to update it to us .net 4.5+ with the new 3.5 monogame.
One other question - What is Monogame Extended? I’ve not heard of this.Is it part of the download of monogame files or do I have to download it from somewhere else?
Edit - Don’t worry, I’ve done some googling and found:
@luki I’m answering the original question in regard to ShapeBatch since it’s been referenced in this thread.
The Circle struct you are talking about is an “implicit shape”; a shape defined by mathematical function. In this case the function is r^2 = x^2 + y^2, where r is the radius and x and y are the centre position of the circle.
To draw things in OpenGL, DirectX, etc you need to use an “explicit shape” which is defined by vertices with each a position attribute. These vertices need to be “uploaded” to the GPU using a vertex buffer and one of the primitive types which define the topology and ordering of vertices in the vertex buffer. So what you are asking for is the ability to go from an “implicit” shape to an “explicit” shape on the fly and draw the explicit shape to the screen; a not so easy task!
SpriteBatch can only do textured rectangles (quadrilaterals) on the fly using two triangles with PrimitiveType.TriangleList (4 vertices, 6 indices).
To draw a circle on the fly you either need to use a texture of a circle and draw it as a sprite (textured quadrilateral) using SpriteBatch, or create the vertices for the circle and draw them using one of the GraphicsDevice.Draw...Primitives() methods. Unfortunately, the latter prevents you from using the SpriteBatch API for streaming dynamic textured vertices and the former does not have good performance if you want to draw different type of shapes beyond just circles and rectangles since you would need a separate texture for each shape. It’s for these reasons I am working on ShapeBatch over at MonoGame.Extended.
ShapeBatch will (eventually) be able to do everything SpriteBatch can do and more. It will be able to draw sprites, strings (from bitmap fonts too), rectangles, arcs, circles, polygons, etc.
Thank you very much for help!
I almost solved this problem, I create method, what create Texture circle and “form” circle with use class, what is at the beginning of the topic. I have problem with checking colisions yet, but I think that I to make it. I should have more time now, so I will try this make.