Я делаю игру для Android, которая сначала позволяет пользователям войти в систему, я понял эту часть. сценарий сохраняет пользовательские данные на основе идентификатора пользователя для пользователя в более позднем игровом процессе.
теперь я не могу понять, как снова получить доступ к данным (уровня) (я хотел бы иметь возможность его охватить)
app.factory("Auth", function($firebaseAuth) {
var FIREB = new Firebase("https://app.firebaseio.com");
return $firebaseAuth(FIREB);
});
app.controller('HomeScreen', function($scope, Auth, $firebaseArray, $firebaseObject) {
Auth.$onAuth(function(authData){
$scope.authData = authData;
});
var users = new Firebase("https://app.firebaseio.com/users/");
// create a synchronized array
$scope.users = $firebaseArray(users);
$scope.googlelogin = function() {
Auth.$authWithOAuthPopup("google").then(function(authData){
users.child($scope.authData.google.cachedUserProfile.id).set({
Username: $scope.authData.google.displayName,
Id: $scope.authData.google.cachedUserProfile.id,
Gender: $scope.authData.google.cachedUserProfile.gender,
level: "1"
});
}).catch(function(error){
});
}
$scope.googlelogout = function() {
Auth.$unauth();
}
$scope.changeLVL = function(authData, Auth) {
var user = new Firebase("https://app.firebaseio.com/users/" + $scope.authData.google.cachedUserProfile.id);
$scope.user = $firebaseArray(user);
$scope.level = $firebaseObject(user.child("level"));
var level = $firebaseObject(user.child("level"));
user.update({
level: level
});
}
});
Есть ли способ легко настроить таргетинг на свойство level? в настоящее время я смог показать его только как массив вместо значения. (пример: показывает "[]" вместо "2" или показывает весь массив {"level": "2"})
мой массив firebase настроен так, где число — это идентификатор учетной записи.
users
998995300163718
Email: "[email protected]"
Gender: "male"
Id: "998995300163718"
Username: "name lastname"
level: "1"