|
@@ -25,11 +25,16 @@ class Login extends PIXI.Container{
|
|
let loginBtn = new Button({GameLayer, width: 100});
|
|
let loginBtn = new Button({GameLayer, width: 100});
|
|
this.addChild(loginBtn);
|
|
this.addChild(loginBtn);
|
|
|
|
|
|
|
|
+ let registerBtn = new Button({GameLayer, width: 100});
|
|
|
|
+ this.addChild(registerBtn);
|
|
|
|
+
|
|
// Set Properties
|
|
// Set Properties
|
|
emailText.setText("Username/Email");
|
|
emailText.setText("Username/Email");
|
|
passwordText.setText("Password");
|
|
passwordText.setText("Password");
|
|
loginBtn.setText("Login");
|
|
loginBtn.setText("Login");
|
|
loginBtn.scaleTo(0.75);
|
|
loginBtn.scaleTo(0.75);
|
|
|
|
+ registerBtn.setText("Register");
|
|
|
|
+ registerBtn.scaleTo(0.5);
|
|
|
|
|
|
// Position It
|
|
// Position It
|
|
emailText.position.set (0, -150);
|
|
emailText.position.set (0, -150);
|
|
@@ -37,11 +42,13 @@ class Login extends PIXI.Container{
|
|
passwordText.position.set(0,-50);
|
|
passwordText.position.set(0,-50);
|
|
password.position.set (0,0);
|
|
password.position.set (0,0);
|
|
loginBtn.position.set (0, 100);
|
|
loginBtn.position.set (0, 100);
|
|
|
|
+ registerBtn.position.set(0, 220);
|
|
|
|
|
|
// Events
|
|
// Events
|
|
this.email = email;
|
|
this.email = email;
|
|
this.password = password;
|
|
this.password = password;
|
|
loginBtn.onClick((e) => this.login(e));
|
|
loginBtn.onClick((e) => this.login(e));
|
|
|
|
+ registerBtn.onClick((e) => this.register(e));
|
|
}
|
|
}
|
|
|
|
|
|
login() {
|
|
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) => {
|
|
onLogin = (fn) => {
|
|
this._onLogin = fn;
|
|
this._onLogin = fn;
|
|
}
|
|
}
|