Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It's a relatively simple method. I really just adds 4 segment shapes for you and sets up their collision properties and locations. It was added as a library routine in Objective-Chipmunk because it's one of those things that half of all games end up doing.</p> <p>It's a relatively simple method. I really just adds 4 segment shapes for you and sets up their collision properties and locations. It was added as a library routine in Objective-Chipmunk because it's one of those things that half of all games end up doing.</p> <p>The original source is as follows. It just adds segments between all of the corners of the boxes.</p> <pre><code>static ChipmunkStaticSegmentShape * boundSeg(ChipmunkBody *body, cpVect a, cpVect b, cpFloat radius, cpFloat elasticity,cpFloat friction, cpLayers layers, cpGroup group, cpCollisionType collisionType) { ChipmunkStaticSegmentShape *seg = [ChipmunkStaticSegmentShape segmentWithBody:body from:a to:b radius:radius]; seg.elasticity = elasticity; seg.friction = friction; seg.layers = layers; seg.group = group; seg.collisionType = collisionType; return seg; } - (void)addBounds:(CGRect)bounds thickness:(cpFloat)radius elasticity:(cpFloat)elasticity friction:(cpFloat)friction layers:(cpLayers)layers group:(cpGroup)group collisionType:(cpCollisionType)collisionType; { cpFloat l = bounds.origin.x - radius; cpFloat r = bounds.origin.x + bounds.size.width + radius; cpFloat b = bounds.origin.y - radius; cpFloat t = bounds.origin.y + bounds.size.height + radius; [self add:boundSeg(_staticBody, cpv(l,b), cpv(l,t), radius, elasticity, friction, layers, group, collisionType)]; [self add:boundSeg(_staticBody, cpv(l,t), cpv(r,t), radius, elasticity, friction, layers, group, collisionType)]; [self add:boundSeg(_staticBody, cpv(r,t), cpv(r,b), radius, elasticity, friction, layers, group, collisionType)]; [self add:boundSeg(_staticBody, cpv(r,b), cpv(l,b), radius, elasticity, friction, layers, group, collisionType)]; } </code></pre> <p>Also, when you say it doesn't work at all, what do you mean? Like there don't seem to be any bounds anywhere or they don't show up where you expect? Are you certain that your rendering coordinates are where you expect?- (void)addBounds:(CGRect)bounds thickness:(cpFloat)radius</p> <p>Also, when you say it doesn't work at all, what do you mean? Like there don't seem to be any bounds anywhere or they don't show up where you expect? Are you certain that your rendering coordinates are where you expect?- (void)addBounds:(CGRect)bounds thickness:(cpFloat)radius</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload