如何在Sprite Kit中创建边界

时间:2022-09-29 07:59:55

Just started making a game using sprite kit and what i need to know is how do i set up a boundary so my character stays on the screen,as in doesn't fall away due to gravity and doesn't float away when you tap the screen enough.

刚刚开始使用精灵套件制作游戏,我需要知道的是如何设置边界以便我的角色留在屏幕上,因为它不会因重力而脱落,并且当你敲击时不会漂浮屏幕足够了。

1 个解决方案

#1


7  

Define physicsBody for SKScene:

为SKScene定义physicsBody:

self.physicsBody = [SKPhysicsBody bodyWithEdgeLoopFromRect:self.frame];

Described well in Apple's documentation, Listing 8-1

在Apple的文档中有详细描述,清单8-1

#1


7  

Define physicsBody for SKScene:

为SKScene定义physicsBody:

self.physicsBody = [SKPhysicsBody bodyWithEdgeLoopFromRect:self.frame];

Described well in Apple's documentation, Listing 8-1

在Apple的文档中有详细描述,清单8-1