sfera said: yep, you are right there.
still, SimpleGame is excellent for writing quick test and showing engine features.
True, but I wanted to point out, that both are dirty hacks, fitting together perfectly :D
darkfrog said: Nodwick, then use StandardGame instead. :)
I actually use BaseGame.
But I'm a bit puzzled, because I couldn't find StandardGame in the Javadoc, neither in the CVS (but I only looked in the CVS tree /com/jme/app) :?
I wrote StandardGame as a system to support both GameStates and multithreading. I'm using it as the foundation for the game I'm working on currently and it's working amazingly well. It should not need to be extended, simply instantiated and started.
StandardGame game = new StandardGame("My Game");
game.start();
Then you can simply create your GameStates, activate them, and add them to the GameStateManager and you're good to go.
There are also quite a few changes to the GameState system in CVS now if you're willing to update.
darkfrog said: I wrote StandardGame as a system to support both GameStates and multithreading. I'm using it as the foundation for the game I'm working on currently and it's working amazingly well. It should not need to be extended, simply instantiated and started.
StandardGame game = new StandardGame("My Game");
game.start();
Then you can simply create your GameStates, activate them, and add them to the GameStateManager and you're good to go.
There are also quite a few changes to the GameState system in CVS now if you're willing to update.
This sounds really cool, and I'd be willing to update, but I have 2 issues with that:
* Jikes seems to hate it, but that might be solved by setting an option
* The current CVS version seems to hate my MouseMotionListener and not calling its mouseDragged(), making my nice moveable user interface unmoveable, which kinda sucks.
2.) If there's a problem with the most recent version of CVS with mouse dragging it won't get fixed unless someone is willing to help debug the problem.
I recently applied a patch from Galun that dealt with mouse event dispatching. Please check if your problem is solved by commenting out these two code blocks in JMEDesktop:
// FIX ME: this is a workaround as we cannot access eventEnabled in JMEDesktop.dispatchEvent
while ( comp != null && comp.getMouseListeners().length == 0 ) {
comp = comp.getParent();
}
// FIX ME: this is a workaround as we cannot access eventEnabled in JMEDesktop.dispatchEvent
while ( comp != null && comp.getMouseMotionListeners().length == 0 ) {
comp = comp.getParent();
}
darkfrog said: It should not need to be extended, simply instantiated and started.
Well, you assumed wrong. I wanted to extend it, and thus created a subclass which unfortunately cannot read certain member variables because they're neither protected, nor do they have a getter. I had to change my local CVS copy of StandardGame.
Oh and you've got some bugs in your DebugGameState. First, in the update method you check for update and if it equals true then you return from the method. Doing it this way, once the pause is activated, the check for the key being pressed is never executed again. Place the toggle_pause command check at the start of the method to fix this. Another bug is how you handle the exit command, which is the escape key. If detected, you halt the entire application by calling System.exit. Doing this will skip all the shutdown related methods in StandardGame. Namely quit and cleanup. I guess you did this as a quick hack, since you don't seem to have a reference to the StandardGame in your GameStates.
Well, you assumed wrong. I wanted to extend it, and thus created a subclass which unfortunately cannot read certain member variables because they're neither protected, nor do they have a getter. I had to change my local CVS copy of StandardGame.
Why would you want to extend it? What is it that you are trying to do with it that can't be done by simply instantiating it?
Gaheris said:
Oh and you've got some bugs in your DebugGameState. First, in the update method you check for update and if it equals true then you return from the method. Doing it this way, once the pause is activated, the check for the key being pressed is never executed again. Place the toggle_pause command check at the start of the method to fix this.
Oops, I'll try to make sure I get that fixed. I never use pause myself, so I never actually tested that. :P
Gaheris said: Another bug is how you handle the exit command, which is the escape key. If detected, you halt the entire application by calling System.exit. Doing this will skip all the shutdown related methods in StandardGame. Namely quit and cleanup. I guess you did this as a quick hack, since you don't seem to have a reference to the StandardGame in your GameStates.
Explain a better way for me to do this and I'll happily change it. I don't add any explicit calls to StandardGame since it's possible that people using the GameStates might not be using StandardGame (I know, it's shocking).
Why would you want to extend it? What is it that you are trying to do with it that can't be done by simply instantiating it?
I'm sure that for anyone actually developing a game there might not be any reason to extend the class, although I wouldn't say never. However that's not what I'm developing right now. I subclassed StandardGame to be able to add some debugger/oberserver/manager code in a non-API-breaking/changing and transparent (to the client) way. It's an example on how to use/implement it, as well as an easy way add some value for anyone using StandardGame.
darkfrog said:
Explain a better way for me to do this and I'll happily change it. I don't add any explicit calls to StandardGame since it's possible that people using the GameStates might not be using StandardGame (I know, it's shocking).
I thought about that as I considered doing such a change to my local CVS copy, but I didn't really like any solutions that came to my mind. One would have to implement some sort of an event-handling or messaging code to the game states to which the StandardGame (or any other object implementing some special interface) can attach itself to.
I thought about that as I considered doing such a change to my local CVS copy, but I didn't really like any solutions that came to my mind. One would have to implement some sort of an event-handling or messaging code to the game states to which the StandardGame (or any other object implementing some special interface) can attach itself to.
Yes, using a SyntheticButton should work smoothly.
I recently applied a patch from Galun that dealt with mouse event dispatching. Please check if your problem is solved by commenting out these two code blocks in JMEDesktop (...)