|
@@ -25,11 +25,16 @@ class Login extends PIXI.Container{
|
|
|
let loginBtn = new Button({GameLayer, width: 100});
|
|
|
this.addChild(loginBtn);
|
|
|
|
|
|
+ let registerBtn = new Button({GameLayer, width: 100});
|
|
|
+ this.addChild(registerBtn);
|
|
|
+
|
|
|
// Set Properties
|
|
|
emailText.setText("Username/Email");
|
|
|
passwordText.setText("Password");
|
|
|
loginBtn.setText("Login");
|
|
|
loginBtn.scaleTo(0.75);
|
|
|
+ registerBtn.setText("Register");
|
|
|
+ registerBtn.scaleTo(0.5);
|
|
|
|
|
|
// Position It
|
|
|
emailText.position.set (0, -150);
|
|
@@ -37,11 +42,13 @@ class Login extends PIXI.Container{
|
|
|
passwordText.position.set(0,-50);
|
|
|
password.position.set (0,0);
|
|
|
loginBtn.position.set (0, 100);
|
|
|
+ registerBtn.position.set(0, 220);
|
|
|
|
|
|
// Events
|
|
|
this.email = email;
|
|
|
this.password = password;
|
|
|
loginBtn.onClick((e) => this.login(e));
|
|
|
+ registerBtn.onClick((e) => this.register(e));
|
|
|
}
|
|
|
|
|
|
login() {
|
|
@@ -63,6 +70,24 @@ class Login extends PIXI.Container{
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ register() {
|
|
|
+ let e = this.email.getValue();
|
|
|
+ let p = this.password.getValue();
|
|
|
+
|
|
|
+ // UserService Singleton to be called
|
|
|
+ UserService.register(e,p)
|
|
|
+ .then((data) => {
|
|
|
+ console.log(data);
|
|
|
+ this.login();
|
|
|
+ return true;
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ console.log(err);
|
|
|
+ alert(JSON.stringify(err));
|
|
|
+ //throw err;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
onLogin = (fn) => {
|
|
|
this._onLogin = fn;
|
|
|
}
|