N
N
nastya_zholudeva2019-03-16 14:40:45
Swift
nastya_zholudeva, 2019-03-16 14:40:45

How to remove certain nodes from the scene in SpriteKit?

There is class Renderer: SKScenealso a function drawField(field: Field)that draws cubes on the stage.

override func didMove(to view: SKView) {
         drawField(field: fieldTop)
        drawField(field: fieldBottom)
        setPlayerInfo(text: "STEPS", x_position: -90, y_position: 360, verticalAlignmentMode: .top, horizontalAlignmentMode: .right)
        setPlayerInfo(text: "TIME", x_position: 100, y_position: 360, verticalAlignmentMode: .top, horizontalAlignmentMode: .left)
    }

Do I need to fieldBottomconstantly re-render (fieldBottom is a node that consists of many cubes, like in a Match 3 game) because the user moves these cubes?
I think to do it like this
override func update(_ currentTime: TimeInterval) {
        clearField()
        drawField(field: fieldBottom)
    }

But the problem is that I don't know how to make the method clearField()so that it only deletes the nodesfieldBottom

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question