简体   繁体   中英

Is there a way to make a soft body with Spritekit using SKSpriteNode and PhysicsBody parameters?

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....

访问网站https://gist.github.com/kazukitanaka0611/4b9d4ac9dff0cd317b6c它有sprite kit软体(果冻)的解释和源代码

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM