Sprite Kit的归还设置为1不现实

问题描述 投票:1回答:1

我是SpriteKit的新手,我在上面发现了东西。

我将恢复原状设置为1.0,希望当我的球到达地面时回到原来的位置,但这没有发生。

背后的原因是什么?(如果它有重复的问题,我找不到另一个,所以请原谅。)

对于代码,您可以考虑以下didMove()功能中的代码。

    scene?.physicsBody = SKPhysicsBody(edgeLoopFrom: frame)
    physicsWorld.contactDelegate = self

    let ball = SKShapeNode(circleOfRadius: 10)
    ball.position = CGPoint(x: 400, y: 400)
    ball.fillColor = .red
    ball.physicsBody = SKPhysicsBody(circleOfRadius: 10)
    ball.physicsBody?.restitution = 1;
    addChild(ball)
ios swift sprite-kit
1个回答
0
投票

其背后的原因是在SpriteKit的物理世界中默认设置的空气摩擦。

我应该添加ball.physicsBody?.linearDamping = 0,它将弹跳到世界尽头

© www.soinside.com 2019 - 2024. All rights reserved.