Slick Forums
http://slick.ninjacave.com/forum/

Integrating TWL into StateBasedGame (Wiki link)
http://slick.ninjacave.com/forum/viewtopic.php?f=18&t=2551
Page 1 of 1

Author:  MatthiasM [ Thu Jun 17, 2010 8:14 pm ]
Post subject:  Integrating TWL into StateBasedGame (Wiki link)

Integrating TWL into StateBasedGame

Author:  ProfessorRekyl [ Thu Feb 06, 2014 12:03 pm ]
Post subject:  Re: Integrating TWL into StateBasedGame (Wiki link)

Thank you for this great library.
The wiki is down but I found this old cached version, I bet someone may have use of this. I bet its the same information but accessible:
http://webcache.googleusercontent.com/s ... eBasedGame

Text copy from the link:
Quote:
This approach should be easier to use together with Slick's StateBasedGame.

As the source code is a larger for this approach it is provided as zip [Note this: http://twl.l33tlabs.org/TWLSlick.zip] file

Instead of directly using StateBasedGame you subclass TWLStateBasedGame and override getThemeURL() like this:

public class MyGame extends TWLStateBasedGame {
/**
* Implement this method and return the URL for the TWL theme.
*
* @return the URL for the TWL theme. Must not be null.
*/
@Override
protected URL getThemeURL() {
return MyGame.class.getResource("ui/theme.xml");
}

//
// init game states etc ....
//
}

All game states needs to be subclasses of BasicTWLGameState. This allows them to provide their own UI when desired:

public class MainMenuState extends BasicTWLGameState {
private Button btn;

@Override
protected RootPane createRootPane() {
RootPane rp = super.createRootPane();
rp.setTheme("mainMenu");

btn = new Button("Hello World");
btn.addCallback(new Runnable() {
public void run() {
System.out.println("It works!");
}
});

rp.add(btn);
return rp;
}

@Override
protected void layoutRootPane() {
btn.adjustSize();
btn.setPosition(100, 100);
}
}

These classes will replace the normal Slick input handling and use TWL's event routing instead. All input events which are not consumed by an UI widget (like the Button above) are forwarded to the game state's input handling methods. But no other InputListeners are called.

Author:  raLa [ Tue Mar 03, 2015 8:52 pm ]
Post subject:  Re: Integrating TWL into StateBasedGame (Wiki link)

Is this wiki or any version of it still accessable somewhere?

Author:  dayrinni [ Wed Mar 18, 2015 12:37 am ]
Post subject:  Re: Integrating TWL into StateBasedGame (Wiki link)

raLa wrote:
Is this wiki or any version of it still accessable somewhere?


I do not know the status of TWL or the wiki but their home page is this:
http://twl.l33tlabs.org/

It is still up - maybe there is a link to the wiki there.

I did find this on the wayback machine:
http://web.archive.org/web/201309172046 ... eme+Editor

Author:  raLa [ Thu Mar 19, 2015 11:34 am ]
Post subject:  Re: Integrating TWL into StateBasedGame (Wiki link)

This helps a lot, cheers!

Author:  dayrinni [ Tue Mar 24, 2015 12:50 am ]
Post subject:  Re: Integrating TWL into StateBasedGame (Wiki link)

raLa wrote:
This helps a lot, cheers!


You're welcome, I'm glad I could help.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/