Pregunta

I have the following sprite that falls to the bottom of the screen:

// The View
self.physicsBody = [SKPhysicsBody bodyWithEdgeLoopFromRect:self.frame];
self.physicsWorld.contactDelegate = self;

// The Sprite
SKSpriteNode *cube = [[SKSpriteNode alloc] initWithImageNamed:@"cube"];
[cube setPosition:CGPointMake(160,250);
[self addChild:cube];

// The Physics
cube.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:cube.frame.size];
cube.physicsBody.dynamic = YES;
cube.physicsBody.affectedByGravity = YES;
cube.physicsBody.mass = 0.02;

Is there a way to make it so its sides are bulging when it hits the bottom border of the screen? Something that would be Jelly like or a soft body that still maintains its shape to some extent but bulges out under its own weight? I hope this makes sense....

¿Fue útil?

Solución

Visit the site https://gist.github.com/kazukitanaka0611/4b9d4ac9dff0cd317b6c it have explanation and source code for soft bodies (jelly) in sprite kit

Otros consejos

quick and easy way without math: 1 use flash to tween your box warping. 2 export the tweened frames as a sprite sheet (texture atlas) 3 animate the texture atlas on contact with an edge physics body in your scene.

your box will fall and on contact animate the separate images to give the impression its warping/bulging sides.

i used this method and it works - in other words it gives the desired effect, which in my view is what is important - your gamers don't care how you did it, as long as it looks great.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top