XNA Creators Club Online
Page 1 of 1 (6 items)
Sort Posts: Previous Next

Drawing a 2D Circle

Last post 11/11/2009 12:03 PM by conkerjo. 5 replies.
  • 11/10/2009 10:45 PM

    Drawing a 2D Circle

    I'm trying to figure out how to draw a circle for like range of fire for a tower defense game.  Can anybody help lead me in the right direction? Thanks.
  • 11/10/2009 11:19 PM In reply to

    Re: Drawing a 2D Circle

    I think the easiest way you're going to solve this problem would be to make a picture of a circle with an alpha channel and scale it to the size you want.

  • 11/11/2009 3:46 AM In reply to

    Re: Drawing a 2D Circle

    Jeremy DeHaan:
    I think the easiest way you're going to solve this problem would be to make a picture of a circle with an alpha channel and scale it to the size you want.
    Yes. AFAIK the only other way to draw a circle would be to calculate the location of every pixel in the circle (or on the edge of the circle, if you just want a ring), and draw them as primitives.

    Drawing a circular image is much simpler. :)
  • 11/11/2009 6:47 AM In reply to

    Re: Drawing a 2D Circle

    BShields:
    Jeremy DeHaan:
    I think the easiest way you're going to solve this problem would be to make a picture of a circle with an alpha channel and scale it to the size you want.
    Yes. AFAIK the only other way to draw a circle would be to calculate the location of every pixel in the circle (or on the edge of the circle, if you just want a ring), and draw them as primitives.

    Drawing a circular image is much simpler. :)


    The way to do this with primitives would be to determine how many points are along the outside of the circle (depending on how precise you want it to look) and draw triangles from the middle to the edge, calculating each pixel within the circle would be really expensive.

    I agree though, if it suits your game, draw it was a circular sprite and stretch it accordingly.
  • 11/11/2009 11:14 AM In reply to

    Re: Drawing a 2D Circle

    I also agree, creating a circle image is the cheapest and best method.

    If it's not possible due to scaling issues, your other option would be to use a pixel shader.
  • 11/11/2009 12:03 PM In reply to

    Re: Drawing a 2D Circle

    If it's for debug purposes I personally prefer to draw this with primitives, a circle is just a series of lines.
    Here's a good example of how to do it in primitives

    http://forums.xna.com/forums/t/7414.aspx

    If it's for the gameplay, do as others suggested, make a sprite and scale it appropriately.
Page 1 of 1 (6 items) Previous Next
var gDomain='m.webtrends.com'; var gDcsId='dcschd84w10000w4lw9hcqmsz_8n3x'; var gTrackEvents=1; var gFpc='WT_FPC'; /*<\/scr"+"ipt>");} /*]]>*/
DCSIMG