How to remove all nodes with a specific name spritekit
up vote
1
down vote
favorite
Is there a simple way to remove all spritekit nodes with a given name. I am making a project that has waves of spaceships and at a certain score, I want the old spaceships to dissappear so that new, harder spaceships replace them. I gave all of the level one spaceships the same name and was wondering if there was a way that I could remove them all based on this factor.
swift xcode sprite-kit
add a comment |
up vote
1
down vote
favorite
Is there a simple way to remove all spritekit nodes with a given name. I am making a project that has waves of spaceships and at a certain score, I want the old spaceships to dissappear so that new, harder spaceships replace them. I gave all of the level one spaceships the same name and was wondering if there was a way that I could remove them all based on this factor.
swift xcode sprite-kit
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
Is there a simple way to remove all spritekit nodes with a given name. I am making a project that has waves of spaceships and at a certain score, I want the old spaceships to dissappear so that new, harder spaceships replace them. I gave all of the level one spaceships the same name and was wondering if there was a way that I could remove them all based on this factor.
swift xcode sprite-kit
Is there a simple way to remove all spritekit nodes with a given name. I am making a project that has waves of spaceships and at a certain score, I want the old spaceships to dissappear so that new, harder spaceships replace them. I gave all of the level one spaceships the same name and was wondering if there was a way that I could remove them all based on this factor.
swift xcode sprite-kit
swift xcode sprite-kit
asked Nov 11 at 2:53
Tony Martini
175
175
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
It depends on how you created the spaceships. If you made them all with the same name maybe you can try:
self.enumerateChildNodesWithName("spaceShip")
spaceShip.removeFromParent()
//or try
for child in self.children
if child.name == "spaceShip"
child.removeFromParent
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
It depends on how you created the spaceships. If you made them all with the same name maybe you can try:
self.enumerateChildNodesWithName("spaceShip")
spaceShip.removeFromParent()
//or try
for child in self.children
if child.name == "spaceShip"
child.removeFromParent
add a comment |
up vote
1
down vote
accepted
It depends on how you created the spaceships. If you made them all with the same name maybe you can try:
self.enumerateChildNodesWithName("spaceShip")
spaceShip.removeFromParent()
//or try
for child in self.children
if child.name == "spaceShip"
child.removeFromParent
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
It depends on how you created the spaceships. If you made them all with the same name maybe you can try:
self.enumerateChildNodesWithName("spaceShip")
spaceShip.removeFromParent()
//or try
for child in self.children
if child.name == "spaceShip"
child.removeFromParent
It depends on how you created the spaceships. If you made them all with the same name maybe you can try:
self.enumerateChildNodesWithName("spaceShip")
spaceShip.removeFromParent()
//or try
for child in self.children
if child.name == "spaceShip"
child.removeFromParent
edited Nov 11 at 10:11
DaFois
1,73831418
1,73831418
answered Nov 11 at 8:33
CharlesBnf
262
262
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53245447%2fhow-to-remove-all-nodes-with-a-specific-name-spritekit%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown