0
Il s'agit essentiellement du code avec lequel j'essaie d'engendrer des images ou des ennemis et je souhaite les supprimer, mais pas tous en touchant une seule des images qui ont été touchées. L'image bouge aussi au cas où quelqu'un aurait besoin de savoir.Syntaxe rapide Suppression d'une image avec UITouch
import SpriteKit
import UIKit
class GameScene: SKScene {
override func didMoveToView(view: SKView) {
let myLabel = SKLabelNode(fontNamed:"chalkduster ")
myLabel.text = "HELLO WORLD"
myLabel.fontsize = 45
myLabel.position = CGPoint(x:CGRectGetMidx(self.frame), y:CGRectGetMidy(self.frame))
self.addChild(myLabel)
}
func SpawnEnemies(){
let Enemy = SKSpriteNode(imageNamed: "Enemy.png")
let MinValue = self.size.width /8
let MaxValue = self.size.width -158
let spawnPoint = UInt32(MaxValue- MinValue)
Enemy.runAction(SKAction.sequence([action, actionDone]))
self.addChild(Enemy)
}
func touchesEnded(touches: NSSet, withEvent event: UIEvent?) {
for touch in touches {
_ = touch.locationInNode(self)
let touch = touches.anyobject() as! UITouch?
if let location = touch?.locationInNode(self)
{
for _ in self.nodeAtPoint(location)
{
if let Enemy.name == (name., "SpawnEnemies" {
Enemy.removeFromParent()
}
}
}
}
}
func update(currentTime: CFTimeInterval) {
}