Created
March 27, 2014 18:43
-
-
Save b3ll/9815020 to your computer and use it in GitHub Desktop.
This file contains 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
s = [SBIconController sharedInstance]; | |
l = s.currentRootIconList; | |
icons = [NSMutableArray array]; | |
for (var i = 0; i < l.icons.length; i++) { | |
[icons addObject:[l viewForIcon:l.icons[i]]]; | |
} | |
// icons = choose(SBIconView); works, but doesn't, because superview | |
animator = [[UIDynamicAnimator alloc] initWithReferenceView:icons[0].superview]; | |
collisionBehavior = [[UICollisionBehavior alloc] initWithItems:icons]; | |
[collisionBehavior setTranslatesReferenceBoundsIntoBoundary:YES]; | |
[animator addBehavior:collisionBehavior]; | |
// Graviboard... mostly | |
gravityBehavior = [[UIGravityBehavior alloc] initWithItems:icons]; | |
gravityBehavior.gravityDirection = {0:0.0, 1:0.2}; | |
[animator addBehavior:gravityBehavior]; | |
// 1: fizyx demo | |
forcePush = [[UIPushBehavior alloc] initWithItems:@[icons[0]] mode:1]; // mode 1, instantaneous | |
forcePush.angle = Math.random() * 2.0; | |
forcePush.magnitude = 30; | |
forcePush.active = YES; | |
[animator addBehavior:forcePush]; | |
// 2: reset fizyx | |
[animator removeBehavior:forcePush]; | |
// 3... EXPLOSIONS | |
pushes = [NSMutableArray array]; | |
for (var i = 0; i < icons.length; i++) { | |
pushBehavior = [[UIPushBehavior alloc] initWithItems:@[icons[i]] mode:1]; // 1 == UIPushBehaviorModeInstantaneous | |
[animator addBehavior:pushBehavior]; | |
[pushes addObject:pushBehavior]; | |
} | |
function explode() { | |
for (var i = 0; i < pushes.length; i++) { | |
pushBehavior = pushes[i]; | |
pushBehavior.angle = Math.random() * 2.0; | |
pushBehavior.magnitude = 30; | |
pushBehavior.active = YES; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment