Created
April 27, 2011 05:49
-
-
Save Alos/943779 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Creates the objects that represent the model | |
*/ | |
- (void) createObjects:(CPNumber)numberOfObjects{ | |
var fixDef = new b2FixtureDef; | |
fixDef.density = 1.0; | |
fixDef.friction = 0.5; | |
fixDef.restitution = 0.2; | |
fixDef.shape = new b2CircleShape( | |
Math.random() + 0.1 //radius | |
); | |
for(var i=0; i<numberOfObjects; i++){ | |
var bodyDef = new b2BodyDef; | |
bodyDef.type = b2Body.b2_dynamicBody; | |
var initialPosition = [self getNewInitialPosition]; | |
CPLog.info("Position #%@: %@, %@",i ,initialPosition.x, initialPosition.y); | |
bodyDef.position.Set(initialPosition); | |
var body = world.CreateBody(bodyDef); | |
body.CreateFixture(fixDef); | |
body.SetBullet(false); | |
var initialForce = [self getNewInitialForce]; | |
CPLog.info("Force #%@: %@, %@",i ,initialForce.x, initialForce.y); | |
body.ApplyForce(initialForce, ZERO_VECTOR); | |
[arrayOfObjects addObject: body]; | |
} | |
debugger; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment