Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to Include Chipmunk libraries to iPhone Xcode project?
    primarykey
    data
    text
    <p>[SOLVED]</p> <p>I copy the chipmunk folder structure from cocos2d+chipmunk template and build OK.</p> <ul> <li>Classes/Chipmunk/include/src for 'src' folder</li> <li>Classes/Chipmunk/chipmunk for 'include' folder</li> </ul> <p>Thanks to Beta for trying to help.</p> <p>:::::</p> <p>I download chipmunk 5.3.1 and try with a simple example but I receive this compiled errors:</p> <pre><code>Undefined symbols: "_cpSpaceStep", referenced from: -[ChipmunkTestViewController delta:] in ChipmunkTestViewController.o "_cpBodyNew", referenced from: -[ChipmunkTestViewController configurarChipmunk] in ChipmunkTestViewController.o "_cpSpaceAddShape", referenced from: -[ChipmunkTestViewController configurarChipmunk] in ChipmunkTestViewController.o "_cpSpaceAddBody", referenced from: -[ChipmunkTestViewController configurarChipmunk] in ChipmunkTestViewController.o "_cpSpaceHashEach", referenced from: -[ChipmunkTestViewController delta:] in ChipmunkTestViewController.o "_cpInitChipmunk", referenced from: -[ChipmunkTestViewController configurarChipmunk] in ChipmunkTestViewController.o "_cpCircleShapeNew", referenced from: -[ChipmunkTestViewController configurarChipmunk] in ChipmunkTestViewController.o "_cpSpaceNew", referenced from: -[ChipmunkTestViewController configurarChipmunk] in ChipmunkTestViewController.o ld: symbol(s) not found collect2: ld returned 1 exit status </code></pre> <p>I'm not sure about adding Chipmunk libraries correctly, what sources from chipmunk .tgz I have to include?</p> <p>Here's the code:</p> <p>ChipmunkTestViewController.h</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; #import "chipmunk.h" @interface ChipmunkTestViewController : UIViewController { UIImageView *barra; UIImageView *esfera; cpSpace *space; } - (void) configurarChipmunk; - (void) delta:(NSTimer *)timer; void updateShape(void *ptr, void *unused); @end </code></pre> <p>ChipmunkTestViewController.m</p> <pre><code>#import "ChipmunkTestViewController.h" @implementation ChipmunkTestViewController - (void) configurarChipmunk { cpInitChipmunk(); // Init Chipmunk engine space = cpSpaceNew(); // Create new Space space-&gt;gravity = cpv(0, -100); // Direcction and magnitude of gravity in Space [NSTimer scheduledTimerWithTimeInterval:1.0f/60.0f target:self selector:@selector(delta:) userInfo:nil repeats:YES]; // NSTimer for animations // Create esfera Body cpBody *esferaBody = cpBodyNew(50.0f, INFINITY); esferaBody-&gt;p = cpv(160,250); // Create esfera Shape cpShape *esferaShape = cpCircleShapeNew(esferaBody, 15.0f, cpvzero); esferaShape-&gt;e = 0.5f; // Elasticity esferaShape-&gt;u = 0.8f; // Friction esferaShape-&gt;data = esfera; // UIImageView association esferaShape-&gt;collision_type = 1; cpSpaceAddBody(space, esferaBody); cpSpaceAddShape(space, esferaShape); } - (void) delta:(NSTimer *)timer { cpSpaceStep(space, 1.0f/60.0f); // Refresh Space info cpSpaceHashEach(space-&gt;activeShapes, &amp;updateShape, nil); // Refresh Shapes info } void updateShape(void *ptr, void *unused) { cpShape *shape = (cpShape*)ptr; if (shape == nil || shape-&gt;body == nil || shape-&gt;data == nil) { NSLog(@"Invalid Shape..."); return; } // Refresh Shape position if ([(UIView*)shape-&gt;data isKindOfClass:[UIView class]]) { [(UIView*)shape-&gt;data setCenter:CGPointMake(shape-&gt;body-&gt;p.x, 480 - shape-&gt;body-&gt;p.y)]; } else { NSLog(@"Shape updated outside updateShape function..."); } } // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; barra = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"barra.png"]]; barra.center = CGPointMake(160, 350); esfera = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"esfera.png"]]; esfera.center = CGPointMake(160, 230); [self.view addSubview:barra]; [self.view addSubview:esfera]; [self.view setBackgroundColor:[UIColor whiteColor]]; [self configurarChipmunk]; } ... @end </code></pre>
    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.
 

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