Is it possible to fill a CGRect with some color?
That would help me sooo much debugging some stuff.
Fill CGRect with color?
(5 posts) (4 voices)-
Posted 1 year ago #
-
If you don't mind me asking, what is it that you're actually trying to accomplish? Cocos2d already has some handy debugging features, you just need to turn them on (I believe the file is ccConfig.h). I often use the sprite bounding box one, and I'm guessing that's what you want.
Posted 1 year ago # -
Alright, nevermind the debugging part. Is it possible to fill a CGRect with some color? i have realized I don't need this necessarily for debugging.
Posted 6 months ago # -
You could write some OpenGL stuff to do it, but honestly it's sort of a waste of time. Load up a single white opaque pixel into a texture that is set to have nearest neighbor filtering (there is some method to do that on CCTexture, I forget it's name though). Then just draw a sprite with a scale equal to the size of the rect you want and set the color to the color you want. Tada.
If you think that it's wasteful to load a tiny texture for such a purpose, don't. It avoids unnecessary state changes, can be batched, and doesn't require you to write any unnecessary code.
Posted 6 months ago # -
If you are looking for a quick easy way to debug shapes you can't go far wrong with the RDDrawingSprite Class that was posted here last year: http://www.cocos2d-iphone.org/forum/topic/7038#post-41346
I normally drop it in my games for testing out grids, hitboxes, etc. The drawCircle also comes in handy for debugging hex-grids
I even use it in my released game for drawing the fishing line.
Posted 6 months ago #
Reply
You must log in to post.