0
我使用Sprite Kit和Swift在xcode中創建了此遊戲,我試圖弄清楚如何檢測英雄何時與牆接觸。到目前爲止,這是我的代碼。但是,當我做SKPhysicsBody時,我似乎無法找到碰撞。如何檢測2個SKSpriteNodes之間的聯繫。 Swift,Sprite工具包
類GameScene:SKScene {
var movingGround: TFMovingGround!
var hero: TFHero!
var isStarted = false
var wallGenerator: TFWallGenerator!
override func didMoveToView(view: SKView) {
backgroundColor = UIColor(red: 159.0/255.0, green:201.00/255.0, blue:244.0/255.0, alpha:1.0)
movingGround = TFMovingGround(size:CGSizeMake(view.frame.width, kMLGroundHeight))
movingGround.position = CGPointMake(0, view.frame.size.height/2)
addChild(movingGround)
hero = TFHero()
hero.position = CGPointMake(70,movingGround.position.y + movingGround.frame.size.height/2 + hero.frame.size.height/2)
addChild(hero)
hero.breath()
//Add WallGenerator
wallGenerator = TFWallGenerator(color: UIColor.clearColor(), size: view.frame.size)
wallGenerator.position = view.center
addChild(wallGenerator)
}
}
這是我在GameScene代碼。
任何幫助將不勝感激。