you can extend AbstractAppState to your custom base or abstract class, that way you only cast to your class to this base class. and call your methods without caring if it’s app state 1/2/3 since they overrode them their own way. You can do that.
Thanks for that. I’m glad you understood what I meant.
I sort of get what you mean, but would you be able to create a code stub or point me to one that shows your suggestion in practice. I appreciate your help.
Yeah, what you want to do isn’t hard. It’s just that for anyone with the requisite skills to actually use JME effectively then it’s not even something they’d have to ask. So this can kind of serve as a litmus test to beefing up your Java skills to the point where you can use the engine effectively. JME is not really for Java beginners.
Thanks. I appreciate your comments. I’m not new to programming. I have over 20 years experience in many other languages. Java is relatively new to me and admittedly I’m learning what I need to know about Java as I go and there are some gaps.
I’ve spent over 6 months on JME intensive development (my time is expensive) and I’m due to release a fully cross platform app in the next few weeks even with the severe limitations of IOS support.
Just so you know, you can come across as condescending and if you want real developers to get involved it’s best to be encouraging and helpful rather than patronising new contributors.
Yeah, probably better to just let them go unanswered or poorly answered. :-/
…I was trying to be nice. The people who actually ARE inexperienced often thank me. We had no idea of knowing from your question… only that the AppStateManager.getState(Class) method is somehow a stumbling block. So I guess incorrectly.
Perhaps it only seemed condescending to you because you have more experience than it seemed. Perhaps it was.
Either way, what you want to do is pretty simple:
public class MyAppState extends AbstractAppState implements SomeCommonInterface {
..............
@Override
public void myCommonMethod() {
}
}
SomeCommonInterface myThing = appStateManager.getState(SomeCommonInterface.class);
myThing.myCommonMethod();
And since you have lots of programming experience (which we didn’t know before) then that answer will make sense to you and you will tuck it into your Java-idioms belt for later. If you were new to Java/programming, then I just did you a HUGE disservice by bypassing a bunch of essential learning.
More than half the questions here are basically of the variety: “I just got my first saw and I want to make a baby grand piano… can someone tell me how to make the hammers?” We aren’t being mean to suggest they make a bird house or two first.
OP stated that he will only ever have one of these attached at a time so there is no reason to disambiguate to a specific concrete class. The interface works fine and allows for better polymorphism.
Excellent. That worked perfectly. I had already implemented 2 interfaces for communicating with the IOS and Android native methods but didn’t realise you could use it like this so thanks again for the information. A big help.