I'm currently developing a IOS game using SpriteKit.
I have a background which is SKShapeNode. Basically the path of this shape is a bezierPath with some curves. This path can be updated by the player using the touchBegan or touchMove trigger.
- (void) touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event{
CGPoint touchPoint = [[touches anyObject] locationInView:self.view];
// Create path
UIBezierPath* newPath = ...
// Update path
[self.backgroundShape setPath:newPath.CGPath];
[self.backgroundShape setPhysicsBody:[SKPhysicsBody bodyWithEdgeLoopFromPath:newPath.CGPath]];
}
While updating the path of the background, some other SKNodes can enter inside my background.
Let's say we have the floor of a table at y0 (original vertical position) with some boxes on it (SKNodes). When updating the physics of the table to another vertical position (for instance y0 + deltaY), the boxes (which are affected by gravity) fall down at the bottom of the screen.
How can I prevent this ? I want to update the physics of the table but I want the boxes to stay on it.
Short video of the current issue
Thanks,