|
@@ -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,6 +42,7 @@ 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);
|
|
|
|
|
|
email.setText(UserService.username || '');
|
|
email.setText(UserService.username || '');
|
|
|
|
|
|
@@ -45,6 +51,7 @@ class Login extends PIXI.Container{
|
|
this.password = password;
|
|
this.password = password;
|
|
loginBtn.onClick((e) => this.login(e));
|
|
loginBtn.onClick((e) => this.login(e));
|
|
this.onLogin(() => alert("Logged in succesfully ! ! !"));
|
|
this.onLogin(() => alert("Logged in succesfully ! ! !"));
|
|
|
|
+ registerBtn.onClick((e) => this.register(e));
|
|
}
|
|
}
|
|
|
|
|
|
login() {
|
|
login() {
|
|
@@ -55,11 +62,14 @@ class Login extends PIXI.Container{
|
|
UserService.login(e,p)
|
|
UserService.login(e,p)
|
|
.then((data) => {
|
|
.then((data) => {
|
|
console.log(data);
|
|
console.log(data);
|
|
- this._onLogin();
|
|
|
|
|
|
+ if(this._onLogin)
|
|
|
|
+ this._onLogin();
|
|
return true;
|
|
return true;
|
|
})
|
|
})
|
|
.catch((err) => {
|
|
.catch((err) => {
|
|
- throw err;
|
|
|
|
|
|
+ console.log(err);
|
|
|
|
+ alert(JSON.stringify(err));
|
|
|
|
+ //throw err;
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
@@ -71,6 +81,32 @@ class Login extends PIXI.Container{
|
|
this._onLoginFn = fn;
|
|
this._onLoginFn = fn;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ 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;
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ update = () => {
|
|
|
|
+ if(UserService.isLogged()) {
|
|
|
|
+ if( this._onLogin )
|
|
|
|
+ this._onLogin();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
_kill = () => {
|
|
_kill = () => {
|
|
|
|
|
|
}
|
|
}
|