adding a filled rectangle to the space
Posted: Wed Sep 21, 2011 7:42 am
I have a board. I need to add filled rectangles around the perimeter of the board so the ball won't go through the wall at high speeds.
I am able to add rectangles, with thickness 1.0f, but that is more like a bound.
cpFloat thickness = 10.0f;
[space addBounds:CGRectMake([[ithDict objectForKey:k_PLIST_CONST_RECTANGLES_X] intValue],
[[ithDict objectForKey:k_PLIST_CONST_RECTANGLES_Y] intValue],
[[ithDict objectForKey:k_PLIST_CONST_RECTANGLES_W] intValue],
[[ithDict objectForKey:k_PLIST_CONST_RECTANGLES_H] intValue])
thickness:1.0f
elasticity:1.0f
friction:0.0f
layers:CP_ALL_LAYERS
group:CP_NO_GROUP
collisionType:blockBarrierType];
The objectForKey:k_PLIST_CONST_RECTANGLES_ values are the x,y,w,h of the rectangles.
How can I make it work with thickness?
is it added at the outside layer, or inside, or half/half?
I checked the documentation, but no details on thickness in ChipmunkShape.
(void) - addBounds:thickness:elasticity:friction:layers:group:collisionType:
Add a border of collision segments around a box. See ChipmunkShape for more information on the other parameters.
I am able to add rectangles, with thickness 1.0f, but that is more like a bound.
cpFloat thickness = 10.0f;
[space addBounds:CGRectMake([[ithDict objectForKey:k_PLIST_CONST_RECTANGLES_X] intValue],
[[ithDict objectForKey:k_PLIST_CONST_RECTANGLES_Y] intValue],
[[ithDict objectForKey:k_PLIST_CONST_RECTANGLES_W] intValue],
[[ithDict objectForKey:k_PLIST_CONST_RECTANGLES_H] intValue])
thickness:1.0f
elasticity:1.0f
friction:0.0f
layers:CP_ALL_LAYERS
group:CP_NO_GROUP
collisionType:blockBarrierType];
The objectForKey:k_PLIST_CONST_RECTANGLES_ values are the x,y,w,h of the rectangles.
How can I make it work with thickness?
is it added at the outside layer, or inside, or half/half?
I checked the documentation, but no details on thickness in ChipmunkShape.
(void) - addBounds:thickness:elasticity:friction:layers:group:collisionType:
Add a border of collision segments around a box. See ChipmunkShape for more information on the other parameters.