在Swift5中使用SpriteKit进行简单的Pong构建。桨之间形成有线尖刺

时间:2019-11-17 02:44:57

标签: xcode macos swift5 macos-catalina

我正在创建这个简单的Pong游戏。底部和顶部有两个桨。一个球在弹跳。

运行时,桨叶形成了在田野中戳穿的有线尖刺。

代码:GameScene.swift

import SpriteKit
import GameplayKit

class GameScene: SKScene {

//create obj

var ball = SKSpriteNode()
var enemy = SKSpriteNode()
var main = SKSpriteNode()

override func didMove(to view: SKView) {
    ball = self.childNode(withName: "ball") as! SKSpriteNode
    enemy = self.childNode(withName: "enemy") as! SKSpriteNode
    main = self.childNode(withName: "main") as! SKSpriteNode

    ball.physicsBody?.applyImpulse(CGVector(dx:20, dy:20)   )

    let border = SKPhysicsBody(edgeLoopFrom: self.frame)

    border.friction = 0
    border.restitution = 1

    self.physicsBody = border
}

override func update(_ currentTime: TimeInterval) {
    // Called before each frame is rendered
}
}
  • 操作系统:Mac Catalina
  • Xcode 11.2(11B52)
  • 雨燕5

想知道这是否是渲染问题。

有什么想法吗? Record of spikes

0 个答案:

没有答案