Hello
So what I want to be able to do is have a login for my game, which uses my website database for logins. This is a wordpress site so it uses wordpress database structure. In the game I use JMonkey game engine and I'm using nifty-gui for my GUI interface. So what I would like to know is how I can get the username and password out of the nifty textfields and send them to my website to get checked to see if they're correct or not. Then for it to pick up the response and if correct goes into the game otherwise have to retry.
The nifty code is
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| <?xml version="1.0" encoding="UTF-8"?> <nifty> <useStyles filename="nifty-default-styles.xml" /> <useControls filename="nifty-default-controls.xml" /> <screen id="start" controller="racer.LoginStateScreenController"> <layer id="layer1" backgroundColor="#003f" childLayout="center"> <panel height="25%" width="35%" align="center" valign="center" backgroundColor="#f60f" childLayout="vertical"> <panel id="firstPanel1" width="100%" height="40%" childLayout="center"> <control id="username" type="textfield" visibleToMouse="true" align="center" valign="center"/> </panel> <panel id="firstPanel2" width="100%" height="40%" childLayout="center"> <control id="password" type="textfield" visibleToMouse="true" align="center" valign="center" passwordChar="*"/> </panel> <panel id="firstPanel3" width="100%" height="20%" childLayout="center"> <control id="button1" type="button" align="center" valign="center" label="login" visibleToMouse="true"> <interact onClick="submit1()"/> </control> </panel> </panel> </layer> </screen> </nifty> |
And the Login Controller is
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| package racer;
import de.lessvoid.nifty.Nifty; import de.lessvoid.nifty.screen.Screen; import de.lessvoid.nifty.screen.ScreenController;
public class LoginStateScreenController implements ScreenController { Nifty nifty; Screen screen; @Override public void bind(Nifty nifty, Screen Screen) { } @Override public void onEndScreen() { } @Override public void onStartScreen() { } public void submit1() { } } |
Thanks Sam. Just ask if you need any addition information.