恢复原状(弹跳)不起作用

时间:2015-06-13 09:55:09

标签: ios swift sprite-kit

import SpriteKit

class GameScene: SKScene {
    override func didMoveToView(view: SKView) {
        /* Setup your scene here */

        let border = SKPhysicsBody(edgeLoopFromRect: self.frame)

        border.friction = 0
        self.physicsBody = border
        self.physicsWorld.gravity = CGVectorMake(0, 0)
        let ball = childNodeWithName ("ball") as SKSpriteNode
        ball.physicsBody?.applyImpulse(CGVectorMake(30, -30))
        ball.physicsBody?.allowsRotation = false
        ball.physicsBody?.restitution = 1

        ball.physicsBody?.linearDamping = 0
        ball.physicsBody?.angularDamping = 0

    }

    override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
        /* Called when a touch begins */

           }

    override func update(currentTime: CFTimeInterval) {
        /* Called before each frame is rendered */
    } }

0 个答案:

没有答案