XNA Creators Club Online
Page 1 of 1 (5 items)
Sort Posts: Previous Next

I'm getting crazy. SignedInGamer.SignedInGamers.Count always return 0!!

Last post 14/10/2009 21:36 by Stylish. 4 replies.
  • 14/10/2009 21:11

    I'm getting crazy. SignedInGamer.SignedInGamers.Count always return 0!!

    Hello,

    I'm correcting a bug in my first game, but I have a problem.

    The method SignedInGamer.SignedInGamers.Count always returns 0, but there is a profile signed in.

    This is the code: (this is in update method)

    if (gamer.Count == 0 && SignedInGamer.SignedInGamers.Count > 0)  

    {  

           SignedInGamer gamerS = SignedInGamer.SignedInGamers[0];  

           gamer.Add(gamerS);  

           profile.Add(gamer[gamer.Count - 1].GetProfile());  

    Could you help me, please?

  • 14/10/2009 21:24 In reply to

    Re: I'm getting crazy. SignedInGamer.SignedInGamers.Count always return 0!!

    Did you add the GamerServicesComponent to your game? At what point are you calling this code?
  • 14/10/2009 21:30 In reply to

    Re: I'm getting crazy. SignedInGamer.SignedInGamers.Count always return 0!!

    If you have added the GamerServicesComponent and it still isn't working be sure that you are calling base.Update in your Game class.

    Also, SignedInGamers[0] won't work the way it should - it will always call SignedInGamers[PlayerIndex.One] instead. This means that your code will work when a gamer is signed in on the first controller, and fail if they happen to be logged in on others. This is actually a bug in method resolution across property overloads spread across multiple inherited classes. See here
    You need to hack around it by doing the following:

      int index = 0;
      SignedInGamer gamer = SignedInGamer.SignedInGamers[index];

    www.dadoogames.com
    Curling 2010 - in playtest soon, this month or next, this year for sure (maybe)
  • 14/10/2009 21:31 In reply to

    Re: I'm getting crazy. SignedInGamer.SignedInGamers.Count always return 0!!

    Yes, I have added the GamerServiceComponent. I paste the full code.

    1  protected override void Initialize()  
    2         {  
    3             GameData.Init();  
    4  
    5             this.Components.Add(new GamerServicesComponent(this));  
    6  
    7             graphics.PreferredBackBufferHeight = Height;  
    8             graphics.PreferredBackBufferWidth = Width;  
    9             //graphics.IsFullScreen = true;  
    10             graphics.ApplyChanges();  
    11  
    12             for (int i = 0; i < 120; i++)  
    13             {  
    14                 _mainMenuAnim.Add(Content.Load<Texture2D>("MainMenu/Anim/logoanim" + (i + 1).ToString().PadLeft(4, '0')));  
    15             }  
    16               
    17             base.Initialize();  
    18         }  
    19  
    20  
    21 protected override void Update(GameTime gameTime)  
    22         {
    23             #region Casuística_del_tirapalante  
    24             if (SelectedDevice && gamer.Count > 0)  
    25             {  
    26                 TiraPalante = true;  
    27             }  
    28             else 
    29             {  
    30                 TiraPalante = false;  
    31             }
    32             #endregion  
    33  
    34             if (!TiraPalante)  
    35             {  
    36  
    37                 //Se carga el perfil 1. Sin él no se juega  
    38                 if (gamer.Count == 0 && SignedInGamer.SignedInGamers.Count > 0)  
    39                 {  
    40                         SignedInGamer gamerS = SignedInGamer.SignedInGamers[0];  
    41                         gamer.Add(gamerS);  
    42                         profile.Add(gamer[gamer.Count - 1].GetProfile());  
    43                 }  
    44            }  
    45

    I've noticed I have this error:

    No se puede buscar el valor del campo 'signedIn' puesto que no se dispone de información sobre la clase contenedora.

    In english, is something like: "I can't find the value of 'signedIn' field because I don't have the information about the containing class, or something like that...

  • 14/10/2009 21:36 In reply to

    Re: I'm getting crazy. SignedInGamer.SignedInGamers.Count always return 0!!

    That's it!!!!!

    Thank you, thank you very much!!!!!
Page 1 of 1 (5 items) Previous Next