Hi all,
I need to draw a hollow rectangle around each sprites borders on the screen.
This will help me to set up the correct collision detection areas.
Does anyone know a simple way of doing this?
Thanks,
Dan
A fast, easy to use, free, and community supported 2D game engine
Hi all,
I need to draw a hollow rectangle around each sprites borders on the screen.
This will help me to set up the correct collision detection areas.
Does anyone know a simple way of doing this?
Thanks,
Dan
Hi!
There is a test which comes with cocos2d that explains how to draw lines, rectangles, etc with opengl. Sorry i can't remember its name but it is there...
Thanks pabloruiz55,
I've looked at the 'drawPrimitivesTest.m' example code and created the following code from it:
-(void) draw
{
glEnable(GL_LINE_SMOOTH);
glColor4ub(255, 0, 255, 255);
glLineWidth(2);
CGPoint vertices2[] = { ccp(79,299), ccp(134,299), ccp(134,229), ccp(79,229) };
drawPoly(vertices2, 4, YES);
}
This code works fine and draws a hollow, anti-aliased rectangle on the screen.
I also have a problem with the layering. Basically, anything I draw in this method appears behind
all other sprite and background layers.
Is there any way I can draw 'on top' of all layers and also use transparency?
thanks,
dan
For transparencies try looking at this:
http://www.cocos2d-iphone.org/forum/topic/639
for the layering... i would also like to know, i hope somebody else does
Yes, I tried that but cannot prove it works due to the layering issue!
Anyone else got this working?
Yes, I tried that but cannot prove it works due to the layering issue!
Anyone else got this working?
You could create a class derive it from CocosNode then add your primitive draw commands to the draw method. Instantiate the class and add the object to your game layer.
As SpaceHunter said, you can add the draw method to a custom CocosNode/Layer class, and add it above your other contents z level. That should get it displaying above everything else.
Thanks guys, that worked.
When I try drawPoly I get a linking error saying that architecture i386 is not supported (or something like that), what is wrong?
@matsekberg are you on 1.0.0 ? If so. drawPoly is ccDrawPoly.
You must log in to post.