How to make a specific object challenge gravity? (SpriteKit / Objective-C)

I am working on a piece of code, and I want the view to have gravity, but I want specific shells to defy gravity and fly around the screen. I know, to get rid of gravity on a whole look is simple:

self.physicsWorld.gravity = CGVectorMake(0, 0);

But as said, I want gravity to be on stage.

So, I wonder if there is a way to remove gravity from one specific element? (i.e. element SKSpriteNode _debrisin my case)

+4
source share
2 answers

Having established that the physical body is not affected by gravity. For instance.

myNoGravityObject.physicsBody.affectedByGravity = NO;

See the SKPhysicsBody documentation .

+8

, node , , (.. ),

node.physicsBody.dynamic = NO;

, node , , .. -, , node , - .

+3

Source: https://habr.com/ru/post/1534284/


All Articles