So as part of my game, I have this:
This function works until I try to use it's result (line 1), which give me a ClassCastException. If this is always the case, how does the append function get around this?
Another possibility: would there be a way to pass in the name of the Class I want as an argument, and create the newEnt array based on that in line 6?
- projectiles=(Projectile[]) updateEntity(projectiles);
- ...
- Entity[] updateEntity(Entity[] e) {
- boolean[] marked=new boolean[e.length];
- for (int i=0; i<e.length; i++) marked[i]=(e[i].update());
- Entity[] newEnt=new Entity[0];
- for (int i=0; i<e.length; i++) if (marked[i]) newEnt=(Entity[]) p.append(newEnt,e[i]);
- return(newEnt);
- }
This function works until I try to use it's result (line 1), which give me a ClassCastException. If this is always the case, how does the append function get around this?
Another possibility: would there be a way to pass in the name of the Class I want as an argument, and create the newEnt array based on that in line 6?
1