hushaojie04 / libgdx

Automatically exported from code.google.com/p/libgdx
0 stars 0 forks source link

Stage for 0.9.7 is missing removeActor() #1123

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Stage still has the addActor() method but is missing the accompanying 
removeActor() method. It is still possible to remove an actor by calling 
Stage.getRoot().removeActor(). However, if this is the intended method for 
removing an actor, but it should be explained in the Stage.addActor() 
documentation for clarity.

Original issue reported on code.google.com by zairon.e...@gmail.com on 13 Nov 2012 at 11:22

GoogleCodeExporter commented 9 years ago
http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene
2d/Actor.html#remove%28%29

Original comment by nathan.s...@gmail.com on 14 Nov 2012 at 12:00

GoogleCodeExporter commented 9 years ago
I added @see #remove() to Group#addActor().

Original comment by nathan.s...@gmail.com on 14 Nov 2012 at 12:03

GoogleCodeExporter commented 9 years ago
I understand that, but shouldn't it be added to Stage#addActor()? The problem 
is that it is definitely unclear that you should be removing through the root 
Group, especially since Stage has addActor but no removeActor. At least, it is 
confusing to me.

Original comment by zairon.e...@gmail.com on 14 Nov 2012 at 12:13

GoogleCodeExporter commented 9 years ago
I should also say that the current method is much cleaner, but it isn't clear 
from the docs in Stage that you should be removing actors this way.

Original comment by zairon.e...@gmail.com on 14 Nov 2012 at 3:30

GoogleCodeExporter commented 9 years ago
Agreed, I added @see javadoc to Stage#addActor also.

Stage has a number of convenience methods that just call the same method on the 
stage root, just to avoid calling Stage#getRoot(). This was maybe not the 
cleanest solution, but it's too late now and I suppose does make using the API 
a little less clunky.

We could add Stage#removeActor, but it seems cleaner to have fewer ways of 
doing the same task. If people think the @see javadocs to Actor#remove() aren't 
enough, I guess I would be ok with adding Stage#removeActor.

Original comment by nathan.s...@gmail.com on 14 Nov 2012 at 9:27

GoogleCodeExporter commented 9 years ago
Nah, I think what you have added is good, unless you want to make a parallelism 
argument for having Stage#removeActor(). It looks like you wanted to decouple 
the Actor from the Stage for removal, and doing all removals through the Actor 
method is good enough for me with the new documentation. As you say it is 
cleaner.

The convenience functions for adding through the Stage are necessary to me 
though, it makes the code more readable and self-documenting.

Original comment by zairon.e...@gmail.com on 14 Nov 2012 at 9:34