Sometimes you'll want to change a child's parent to a different node. See how the process works in this tutorial.
- [Instructor] So we've talked about adding…and removing children, but what about…changing a child's parent?…Well, as you may have already noticed,…we can do that both in the utility area,…and in the document outline.…So if I select the drone, I can head over…to the attributes inspector,…and change its' parent using the dropdown menu.…So I'll change it from Player to Player 2.…Now notice that the drone didn't move at all,…but if I move Player 2,…then the drone moves along with it.…I can also change the parent using the…document outline.…
I can just click and drag the drone,…right underneath Player, and then it goes…inside of the player node.…Now I click and drag the left player,…and the drone moves along with it.…So let's look at changing parents, using code.…I'm going to head over to game scene dot swift,…where I already have some constants declared,…to reference our objects on the screen.…So I'll go down below all the existing code,…and I'm going to call drone,…dot, remove from parent.…
So we can remove from parent,…
- Creating a SpriteKit project
- Adding and modifying sprites
- Creating sprites in code
- Transitioning between scenes
- Working with children and parents
- Adding physics
- Detecting and responding to collisions
- Applying particle effects
- Creating actions
- Working with sound
- Adding cameras and lights
Skill Level Intermediate
Careers in the Game Industrywith Christian Bradley1h 19m Beginner
Building a Game App with the Android SDKwith David Gassner2h 6m Intermediate
1. Introduction to SpriteKit
2. Add Physics
3. Work with Particle Effects
4. Work with Actions
5. Work with Audio
6. Additional Features
Next steps1m 41s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.