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

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -