ios - SpriteKit - Stop an object bouncing -
how stop , object falls top of screen bottom of screen bouncing. here code object:
- (sknode*)addrock { skspritenode* rock = [skspritenode spritenodewithimagenamed:@"asteroid"]; rock.position=cgpointmake ([self makerandomxwbetween:0 and:self.size.width],self.size.height); rock.name = @"rock"; rock.physicsbody = [skphysicsbody bodywithrectangleofsize:rock.size]; rock.physicsbody.usesprecisecollisiondetection = yes; rock.physicsbody.allowsrotation = no; [self addchild:rock]; return self;
}
thanks in advance help.
best regards, louis.
you need set restitution property of skphysicsbody.
rock.physicsbody.restitution = 0.0;
according apple's documentation:
this property used determine how energy physics body loses when bounces off object. property must value between 0.0 , 1.0. default value 0.2.
Comments
Post a Comment