Подскажите, как сделать кнопку используя SpriteKit в 2017 году
выдает ошибку в строчке …?
let location = touch.locationInNode(self)
Cannot call value of non-function type ‘CGFloat!’
Вот код годовой давности с этого форума представленный тов. ‘administrator’…
class GameScene: SKScene {
var isTouching = false
var button: SKNode!
override func didMove(to view: SKView) {
// Create a simple blue rectangle that's 100x40
button = SKSpriteNode(color: SKColor.blue, size: CGSize(width: 100, height: 40))
// Put it in the center of the scene
button.position = CGPoint(x:self.frame.midX, y:self.frame.midY);
self.addChild(button)
}
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
for touch: AnyObject in touches {
// Get the location of the touch in this scene
let location = touch.location(self)
// Check if the location of the touch is within the button's bounds
if button.containsPoint(location) {
isTouching = true
print("begun!")
}
}
}
override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
// Loop over all the touches in this event
for touch: AnyObject in touches {
// Get the location of the touch in this scene
let location = touch.location(self)
// Check if the location of the touch is within the button's bounds
if button.containsPoint(location) {
print("ended!")
isTouching = false
}
}
}
}
Даже на забугорных форумах все устарело.
Очень надо, очень…