0

命名規則と、コード内でインデントして新しいスペースを作成する方法を許してください。それが正常ではないことはわかっていますが、私は変です D:

とにかく、私は回復を 1 に設定しましたが、うまくいかないようでした。それによって、境界線/フレームから跳ね返るオブジェクトを参照しています。

私が使用しているswiftでは許可されていないため、CGVectorMakeも実行できません。誰にも役立つヒントはありますか?

私が持っていた唯一のアイデアは、フレーム自体の重力を変更することでしたが、私が試したすべてがうまくいきません. ありがとう!

//
//  GameScene.swift
//  Pong
//
//  Created by Mac2 on 1/16/17.
//  Copyright © 2017 Mac2. All rights reserved.
//

import SpriteKit
import GameplayKit

class GameScene: SKScene
{
     var trump = SKSpriteNode()
     var player = SKSpriteNode()
     var opponent = SKSpriteNode()

override func didMove(to view: SKView)
{
    //essentially link them to the physical nodes we created in the gamescene
    trump = self.childNode(withName: "trump") as! SKSpriteNode
    player = self.childNode(withName: "player") as! SKSpriteNode
    opponent = self.childNode(withName: "opponent") as! SKSpriteNode

    //to initialize the game we need the ball to be going somewhere so we make it go on an angle to the player (not opponent)

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

    let border = SKPhysicsBody(edgeLoopFrom: self.frame)
    //create variable representing the frame or border of the gamescene

    border.friction = 0 //we don't want friction to the borders
    border.restitution = 1.0 //we want bouncyness to the borders

    self.physicsBody = border //wrap it all up and save it as the physics representation of the gamescene frame
}

override func update(_ currentTime: TimeInterval)
{
    // Called before each frame is rendered
}
}
4

0 に答える 0