本文介绍了有没有一种方法可以使用SKSpriteNode和PhysicsBody参数使用Spritekit制作软体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有下面的精灵落在屏幕底部:

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套件中提供了有关软体(果冻)的解释和源代码

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

这篇关于有没有一种方法可以使用SKSpriteNode和PhysicsBody参数使用Spritekit制作软体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 06:37