How do you start your game with spring framework?
Generally? You don’t.
Spring is probably overkill for most games- especially if you’re asking this question. I don’t mean that to be offensive, but I don’t think adding Spring into the mix is going to make your life easier.
Where did you hear that you should use Spring for game development?
Are you kidding? ???
It just DI framework. Development with DI is good approach, do not care what do you develop. What wrong with games?
Confusion with libgdx only one - start LwjglApplication class in right way, with Spring. That is the question.
No, I’m not kidding. I’ll repeat: where did you see that it’s a good idea to use Spring for game development?
I understand what Spring is. I use it all the time. Where did you see that dependency injection is something that you need to use in game development?
You almost definitely shouldn’t be using Spring with game development, unless you really know what you’re doing and have a good reason for doing it. You definitely definitely shouldn’t be using Spring with game development if you don’t know what you’re doing.
@KevinWorkman
I know what I’m doing and know what I want
Looks nobody used dependency injection in gamedev here, like you. But I use in my experiments, works fine.
I was surprised your reaction.
PS: I’m not alone. Take a look at this project: http://mini2dx.org/
They created Libgdx fork for dependency injection and other features.
And like I said, that’s probably overkill for most game development. Saying something works fine is a far cry from something actually being useful.
If you want to hamfist it, go for it- but you’re just creating more work for yourself in the long run.
I’m totally agree with you!
But, for now I prefer flexibility and experiments.
If you want to understand how LibGDX is structured it’s probably best you create a project with the libgdx setup and try to fiddle around with it a bit.
When you generate your libgdx project, you have one main project containing your game code and you have separate projects for each target environment (desktop, android, web etc.). You can find *Launcher.java files in the target projects.
This is the startup code from my DesktopLauncher.java
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.width = 800;
config.height = 600;
new LwjglApplication(new Matcher(), config);
In this case Matcher is my main class extending ApplicationAdapter. I think this should be what you need to start your LibGDX application.
Just one thing to consider if you want to use spring. I am not 100% sure but I could imagine that it won’t work (or will be a pain to port) with android and web projects. If you don’t care about these platforms then you should be fine, otherwise I would investigate if you can even use it and if yes how hard it will be. Could save you some time in the long run.
I have experience with LibGDX. Problem only in game bootstrap. The best Spring start is:
- Start Spring container.
- Initial beans
- run you game (ApplicationsListener in our case)
But with LwjglApplication class I cant start container before create and this class.
I asked for best approach for this stuff.
And Spring has android support.
spring is not ment to be fun used for games.
WTH!?
No.
Have never really seen Spring used for client-only software, like games.
Even for web stuff, which is it used for, people don’t generally enjoy using it… :
I would look out for more lightweight DI frameworks.
From Spring 4 it is not heavyweight, but not lightweight like google guice