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

How to load an avatar from a signed in profile?

Last post 12/06/2009 12:51 by AlphaLeo. 4 replies.
  • 12/06/2009 4:46

    How to load an avatar from a signed in profile?

    Hi guys,

    OK I am missing something very basic here.

    I've followed the docs on how to load up an avatar randomly. I'd like to load an avatar from a signed in user, but I cannot find the avatar description for a signed in user. When I've looked in the docs it seems to infer that it should be SignedInGamer.Avatar but my code refuses to even compile with that.

    Currently here's what I got and I'm stumped:
    avatarDesc = AvatarDescription.CreateRandom();  
    //avatarDesc = SignedInGamer.Avatar;  
    avatarRenderer = new AvatarRenderer(avatarDesc, true);  
    avatarAnimation = new AvatarAnimation(AvatarAnimationPreset.Clap);  
     

    Help?

    Thanks in advance!

    Leo

    Leonard Teo
    My website
  • 12/06/2009 5:38 In reply to

    Re: How to load an avatar from a signed in profile?

    You need to fetch an instance of the gamer, not the class describing what a gamer is. There's a couple ways to do that, but for this case the simplest way would be:

    avatarDesc = Gamer.SignedInGamers[0].Avatar; 
  • 12/06/2009 5:45 In reply to
    • (244)
    • premium membership Team XNA
    • Posts 202

    Re: How to load an avatar from a signed in profile?

    You will also need to check that the SignedInGamer object returned from Gamer.SignedInGamers[0] is not null. It will be null for at least the first few moments in your game even if the user is already signed in.

    Dean Johnson, XNA Framework Developer - Blog: Nerd Herder
  • 12/06/2009 6:53 In reply to

    Re: How to load an avatar from a signed in profile?

    Yep, yep. All the usual checks and good coding practices apply. I originally had a big honking sample where I showcased some error handling and getting all sorts of gamer information using BeginGetProfile/EndGetProfile since I thought all that stuff would be useful to the OP. But then the forum swallowed the post so I took the complete opposite extreme. :-p
  • 12/06/2009 12:51 In reply to

    Re: How to load an avatar from a signed in profile?

    Thanks! I was wondering where the data was living..... :)

    Many thanks again.

    Leo

    Leonard Teo
    My website
Page 1 of 1 (5 items) Previous Next