Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My question sounds pretty simple but awfully, I couldn't find much information on the internet.

How can I draw a circle in my FlxSprite?

I couldn't find much information about drawing geometric objects or the usage of classic graphics API in Flixel.

share|improve this question
up vote 7 down vote accepted

You can access the underlying BitmapData of a FlxSprite by using sprite.pixels or sprite.framePixels. You can then use BitmapData's drawing methods for simple things. If you need to draw a circle, you'll probably want to make a DisplayObject like a proper Sprite, draw on it using Graphics, and then use the BitmapData's draw() function to draw it onto the FlxSprite.

Note that this goes against Flixel's intended paradigm. If you're doing this once at the start of the game, or very rarely, it will work just fine to generate sprites procedurally. However, doing this every frame (e.g. in the render() code) will make probably make Flixel much slower. If you know ahead of time what sort of circle you need, you might want to just load the circle as a sprite from a file.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.