Я только начал писать код и мне интересно, как я могу решить эту проблему.
В файле AppDelegate.swift
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}
func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
Файл GameScene
import SpriteKit
import GameplayKit
class GameScene: SKScene {
let player = SKSpriteNode(imageNamed: "rocket_launcher")
let enemy = SKSpriteNode(imageNamed: "attack_shuttle")
let gameArea: CGRect
override init(size: CGSize) {
let maxAspectRatio: CGFloat = 16.0/9.0
let playableWidth = size.height/maxAspectRatio
let margin = (size.width-playableWidth)/2
gameArea = CGRect(x: margin, y: 0, width: playableWidth, height: size.height)
super.init(size: size)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func random() -> CGFloat {
return CGFloat(Float(arc4random()) / 0xffffffff)
}
func random(min min: CGFloat, max: CGFloat) -> CGFloat{
return random() * (max - min) + min
}
override func didMove(to view: SKView) {
let background = SKSpriteNode(imageNamed: "background")
background.size = self.size
background.position = CGPoint(x: self.size.width/2, y: self.size.height/2)
background.zPosition = 0
self.addChild(background)
let foreground = SKSpriteNode(imageNamed: "ufo_Background")
foreground.size = gameArea.size
foreground.position = CGPoint(x: self.size.width/2, y: self.size.height/2)
foreground.zPosition = 10
self.addChild(foreground)
player.setScale(1)
player.position = CGPoint(x: self.size.width/2, y: self.size.height*0.10)
player.zPosition = 2
self.addChild(player)
startNewLevel()
}
func startNewLevel(){
let spawn = SKAction.run(spawnEnemy)
let waitToSpawn = SKAction.wait(forDuration: 1)
let spawnSequence = SKAction.sequence([waitToSpawn,spawn])
let spawnForever = SKAction.repeatForever(spawnSequence)
self.run(spawnForever)
}
func fireBullet(){
let bullet = SKSpriteNode(imageNamed: "Starship_Rocket")
bullet.setScale(1)
bullet.position = player.position
bullet.zPosition = 1
self.addChild(bullet)
в КОНСОЛЕ
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Я не знаю, как преодолеть эту проблему.все мои магазины работают.и ни одна из других страниц не была полезной.Если кто-нибудь знает, как это исправить, то, пожалуйста, дайте мне знать.Спасибо