Good day, I can’t figure out how to remove a node or a sprite from a polygon, or rather several sprites, all sprites are static and I’m not in contact with each other.

I searched all over the Internet but did not find

examples of self.removeFromParent() do not help

I have

  var spriteNames = ["asterisk","Circle-icon","minus","ok","plus","star","triangle","x"] // Установка элементов по горизонтали for i in 1...numberOfElements { let sprite = SKSpriteNode(imageNamed: defaultFrontSprite) let calc1:Float = Float(i) - 0.5 let calc2:Float = Float(i) - 0.5 sprite.position = CGPointMake(CGFloat(calc1 * Float(sprite.frame.size.width) + calc2 * padding + offset), yOffset) nodesPoints += [(x: sprite.position.x, y: sprite.position.y)] sprite.xScale = 0.5 sprite.yScale = 0.5 nodes.append(false) sprite.physicsBody?.friction = 0 sprite.physicsBody?.restitution = 1 sprite.physicsBody?.linearDamping = 0 sprite.physicsBody?.allowsRotation = false sprite.name = defaultFrontSprite + String(element) //sprite.physicsBody?.categoryBitMask = spriteCategory element += 1 self.addChild(sprite) } // какой то код... 

How to delete for example all node and sprites from a polygon?

    1 answer 1

    delete everything

     self.removeAllChildren() 

    either remove specific through

     self.removeChildrenInArray([spriteToDelete]) 

    or you can get a list of all the children through self.children and then delete what you need. like so

     for child in self.children { child.removeFromParent() } 

    All this is in the SKNode documentation SKNode

    • Thanks for the clarification, but I can’t really understand how to use the documentation, for example, I understood the classes there, but how to understand what properties do. I just got used to the php.net documentation, everything is simple and understandable there, but here everything is strange, but nevertheless, thanks, I think I will sort out over time - jcmax
    • everything is written there, what it takes, what it returns and how to use it. in my detail in detail - Max Mikheyenko
    • ok, thanks how I started poking around myself in xcode started to catch up a little what's what - jcmax