在我的GameScene.swift文件中,存在导致构建失败的错误。
override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
/* Called when a touch begins */
for touch: AnyObject in touches {
let location = touch.locationInNode(self)
let sprite = SKSpriteNode(imageNamed:"Spaceship")
sprite.xScale = 0.5
sprite.yScale = 0.5
sprite.position = location
let action = SKAction.rotateByAngle(CGFloat(M_PI), duration:1)
sprite.runAction(SKAction.repeatActionForever(action))
self.addChild(sprite)
}
}
override func update(currentTime: CFTimeInterval) {
/* Called before each frame is rendered */
}
我被告知'覆盖只能在班级成员上指定。
我该如何解决这个问题?
这就是全部:
//
// GameScene.swift
// Swipe Racer
//
// Created by William Clark on 25/10/2014.
// Copyright (c) 2014 Arc of Clark. All rights reserved.
//
import SpriteKit
import Darwin
class GameScene: SKScene {
override func didMoveToView(view: SKView) {
/* Setup your scene here */
var swipes = SPSwipes()
if swipes.no_of_swipes == 5 {
var array = Array<UInt32>(count: 5, repeatedValue: 0)
for i in 0 ..< 5 {
array[i] = arc4random_uniform(100)}
}
if swipes.no_of_swipes == 10 {
var array = Array<UInt32>(count: 10, repeatedValue: 0)
for i in 0 ..< 10 {
array[i] = arc4random_uniform(100)}
}
if swipes.no_of_swipes == 25 {
var array = Array<UInt32>(count: 25, repeatedValue: 0)
for i in 0 ..< 25 {
array[i] = arc4random_uniform(100)}
}
func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
/* Called when a touch begins */
for touch: AnyObject in touches {
let location = touch.locationInNode(self)
let sprite = SKSpriteNode(imageNamed:"Spaceship")
sprite.xScale = 0.5
sprite.yScale = 0.5
sprite.position = location
let action = SKAction.rotateByAngle(CGFloat(M_PI), duration:1)
sprite.runAction(SKAction.repeatActionForever(action))
self.addChild(sprite)
}
}
func update(currentTime: CFTimeInterval) {
/* Called before each frame is rendered */
}
}
评论部分提到的底部还有语法错误。
答案 0 :(得分:6)
在行
之前添加“}”func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
答案 1 :(得分:0)
有2个答案,一个是你在某个地方使用了覆盖,否则你会丢失一个braket或一个圆形的braket