objective c - Adding UIGravityBehavior and UIPushBehavior after a collision takes place in iOS 7 -


i'm messing around new physics api in ios 7.

i decided make simple game, have character can move around screen @ tap of finger, periodically, shapes fly bottom , if hit character it's game over.

i have implemented of above , works great, however, thing doesn't character falling when shape collides him.

all collisions work, problem trying make character fall when collision takes place. because don't want character able fall before (lets he's levitating while trying avoid shapes) decided add character gravity when collision happens, , does, first, character shoots upwards collision animation continues.

is there way prevent collision animation happening? there better way?

here code in collisionbehavior:begancontactforitem:withboundaryidentifier:atpoint: method:

//  main character // if ([item isequal:self.maincharacter]) {     [self.collision removeitem:item];      //          push     //     uipushbehavior *pushbehaviour = [[uipushbehavior alloc] initwithitems:@[self.maincharacter] mode:uipushbehaviormodeinstantaneous];     [pushbehaviour setpushdirection:cgvectormake(0.0f, 1.0f)];     [self.animator addbehavior:pushbehaviour];     [pushbehaviour setactive:yes];      [self.gravity additem:item]; } 

it turns out should have been using collisionbehavior:begancontactforitem:withitem:atpoint: , testing both items in method see if maincharacter


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -