My XNA Game Crashes whenever I press cancel on the username input HELP

38 views
Skip to first unread message

LeeSoft Pro

unread,
Jun 28, 2012, 6:51:59 PM6/28/12
to moga...@googlegroups.com
saving scores and usernames all work fine except when the cancel button is pressed on the input keyboard. the game just crashes for some reason.

I'm using these two codes straight from the example xna game with a little adjustments. what can i do to fix the cancel problem?

if (Guide.IsVisible == false)
            {
                object stateObj;
                Guide.BeginShowKeyboardInput(PlayerIndex.One, "Game Over", "Please enter a name for the scoreboard (No longer than 10 characters)", "", GetText, stateObj = (object)"GetText for Input PlayerOne");
            }

private void GetText(IAsyncResult result)
        {
            string resultString = Guide.EndShowKeyboardInput(result);
            if (resultString.Length > 30)
            {
                resultString = resultString.Remove(30);
            }
            sblist.Clear();
            int score = 0;
            foreach (Obj o in ObjectList.objList)
            {
                if (o.GetType() == typeof(Player))
                    score = ((Player)o).score;
            }
            var userscore = new Score { Data = wave.ToString(), Points = score, UserName = resultString };
            Mogade.SaveScore(MogadeHelper.LeaderboardId(Leaderboards.Main), userscore, ScoreResponseHandler);
        }

LeeSoft Pro

unread,
Jun 29, 2012, 2:06:49 AM6/29/12
to moga...@googlegroups.com
nvm i fixed it by adding

if (resultString == null)
     return;

after the instantiation of resultString in GetText
Reply all
Reply to author
Forward
0 new messages