소행성 유형의 게임을 만들려고합니다. 소행성이 플레이어와 충돌 할 때마다 끝 장면이 잘로드되고 코드를 다시 시작하려고 할 때 잘라냅니다. 코드가 콜백 함수를 반복적으로 반복합니다. 끝 장면. 여기 여기Swift SpriteKit presentScene 오류
func didBeginContact(contact: SKPhysicsContact) {
print("5")
//Creating a variable that holds which two items collide
let contactMask = contact.bodyA.categoryBitMask | contact.bodyB.categoryBitMask
//Creating a switch case statement
//This will run a different case depending on whitch two objects collide
switch(contactMask) {
//If the satellite and the asteroid collide do this
case bitMask.satellite.rawValue | bitMask.asteroid.rawValue:
//removing the satellite
let secondNode = contact.bodyB.node
secondNode?.physicsBody?.allowsRotation = true
let firstNode = contact.bodyA.node
firstNode?.removeFromParent()
//Stopping the mission timer
removeActionForKey("missionDurationTime")
self.removeAllChildren()
print("6")
self.view?.presentScene(EndScene())
print("7")
default:
return
}
}
그리고 충돌 함수는 내가 가서 멀리 EndScene에 라벨을 모두 다시 시작 버튼을 누르면 후 내 마지막 장면
func Restart(){
print("hello")
RestartBtn.removeFromSuperview()
speach.removeFromSuperview()
score.removeFromSuperview()
gameOver.removeFromSuperview()
self.view?.presentScene(GameScene())
}
에서 내 게임 장면에 다시가는 기능입니다 화면처럼 아무것도 표시되지 않고 콘솔이 그냥 인쇄합니다. '5 끝 장면의 레이블이 다시 나타날 때까지 세는 횟수가 너무 많습니다. 나는 혼란스러워하고 내 머리 위로. 어떤 도움을 많이 주시면 감사하겠습니다!
업데이트 : 지금 게임 장면 하중이
print("hello")
RestartBtn.removeFromSuperview()
speach.removeFromSuperview()
score.removeFromSuperview()
gameOver.removeFromSuperview()
let scene = GameScene(size: self.view!.bounds.size)
scene.backgroundColor = SKColor(red: 1, green: 1, blue: 1, alpha: 1)
scene.scaleMode = .AspectFill
scene.backgroundColor = UIColor.whiteColor()
let transition = SKTransition.pushWithDirection(SKTransitionDirection.Left, duration:0.5)
self.scene?.view?.presentScene(scene, transition: transition)
내 다시 시작 버튼의 코드를 변경하고 그것이 있어야로 모든 모든 다섯 배 더 큰 것을 제외하고는,이다
. 이것은 어떻게 보일지입니다 : What it should look like그리고 이것은 당신이 view.bounds의 크기와 GameScene을 초기화하는하는 코드를 다시 시작에서이 What it does look like
어떻게 호출하는 첫 번째 장면을하려고 할 때 앱 출시 (gameView 컨트롤러 코드)? 그 코드를 질문에 넣어 주시겠습니까? 현재 재시작 코드에서 뷰 경계를 크기로 GameScene을 초기화하는 것에 관심이 있습니다. 더 이상 씬을 스케일링하지 않기 때문에 스케일 모드 라인 2 라인이 작동하지 않습니다. 게임을로드 할 때 장면을 다른 크기로 조정한다고 가정하고 다시 시작하면 모양이 다르게 보입니다. – crashoverride777
Xcode에서 제공하는 코드를 게임보기 컨트롤러에서 사용하고 있습니다. 정확한 코드를 게시 할 수 없어. 지금은 Mac에서 멀리 떨어져 있습니다. –
답변을 추가했습니다. 어떻게 진행되는지 알려주세요. – crashoverride777