简体   繁体   English

在快速的Xcode中向屏幕添加边框

[英]adding borders to the screen in swift xcode

I am creating a game using swift in Xcode , and i have a ball in the screen the moves on the left side of the screen "upwards" , and the user makes the ball jump every time they click on the screen , but now what i want is to add a physics body to the left side of the screen , but it doesn't work . 我正在Xcode中使用swift创建游戏,并且屏幕上有一个球,屏幕左侧的动作是“向上”,每次单击屏幕时,用户都会使球跳动,但是现在我要做的是在屏幕的左侧添加一个物理物体,但是无效。

Heres my code for the left side of the screen . 这是我在屏幕左侧的代码。

    ground.physicsBody = SKPhysicsBody(rectangleOfSize: CGSizeMake(1 ,self.frame.size.height))
    ground.physicsBody?.dynamic = false
    self.addChild(ground)

here my code for the right side of the screen . 这是我在屏幕右侧的代码。

    groundRight.position = CGPointMake(0, 0.5)
    groundRight.physicsBody = SKPhysicsBody(rectangleOfSize: CGSizeMake(1 , self.frame.size.height))
    groundRight.physicsBody?.dynamic = false
    self.addChild(groundRight)

so basically , i want to prevent the ball from falling through the screen on the left side and preventing the user to click to much to make the ball go through the screen on the right side. 因此,基本上,我想防止球从左侧的屏幕掉落,并防止用户单击太多以使球从右侧的屏幕通过。

I'm having the same issue. 我有同样的问题。 I believe it's a glitch in the newer XCode Versions from what I've read online. 我相信这是我从网上阅读的最新XCode版本中的一个小问题。 Try to downgrade to an earlier version of XCode. 尝试降级到XCode的早期版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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