Game Development Reference
In-Depth Information
Figure 10-9 . Add .getRemovedActors(), .addToRemovedActors(), and .resetRemovedActors() method structures
If there are multiple Actor objects to be processed the inside of an if{...} construct,
use the .addAll() method to add the contents of the parameter list to your
REMOVED_ACTORS Set<Actor> object. This is accomplished by using the Ar-
rays.asList((Actor[]) actors)) construct inside of the .addAll() method
call, which constructs the Actor[] Array named actors that is compatible with (neces-
sary for) using an .addAll() method call with a Set<E> object type. The second else{...}
portion of this method body adds one single Actor object, since the actors.length was
not greater than one, by using an actors[0] annotation (first Actor parameter) and an
.add() method call using the following code:
public void addToRemovedActors (Actor... actors) {
if ( actors.length > 1 )
{ REMOVED_ACTORS.addAll( Arrays.asList((Actor[]) actors) );
}
 
Search WWH ::




Custom Search