Array of actors which inherit an interface.
I'm trying to set up an actor that can pass messages to certain other types of object. I have a system set up like this, so I can pass objects into the array from the editor, and at runtime loop over them and execute the function.
However, when I do this, I found that the array does not accept actor references, but asset paths instead:
I suspect this is because the interface could exist on a non-actor object, but this seems like a fairly large functionality gap. I could just accept Actor references, but that gets messy and requires casting. Is there no way to specify that actors added to the array must inherit a given interface? It seems a bit of an oversight if not.
EDIT: Some more testing of this reveals that this appears to be a bug with the user interface in the editor, and not anything to do with how interfaces operate. Interfaces work exactly as expected, but they appear as a path (to an Actor in the scene) in the editor, rather than a selection box as it is for other types.
No. This is because you have an array of interfaces of the type "Disable": You can only store interfaces in it an not actor references.
To actually call actor references you don't need to have the interface as reference but the actor itself. To make sure every actor you use there you can either create a master class for every actor or just check if "Actor implements interface" before you add it in there or rather before you use the interface.
Remember. The array contains interfaces which is something you can slab on top of an actor. Not anything you can really work with and you will not be able to call the interface itself.
If you know java: This is pretty much the path / name which you place behind "extends" when declaring your class.
I hope this helps.
answered Feb 02 '15 at 04:39 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here