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

Help please, having trouble with first tutorial

Last post 17/05/2009 21:07 by DirkGently. 1 replies.
  • 17/05/2009 17:35

    Help please, having trouble with first tutorial

    hey everybody
            It goes without saying that im new to all of this. So ive been working on the tutorial "begginers guide to 2D games" from this site and after finishing the the chapter on firing cannon balls, when I run the program nothing is happening when im trying to fire them. has anybody experienced this before and can you offer any advice on how to help me fix the problem. I dont want to just download the code to move onto the next chapter as I dont think Id be learning anything then. thanks in advanced.
  • 17/05/2009 21:07 In reply to

    Re: Help please, having trouble with first tutorial

    So, the program is working fine... except that when you press space, it doesn't fire the cannonballs?

    Do you know how to insert a breakpoint in visual studio? Scroll down inside the method where it should trigger the cannonballs (so, right after the input method where you press space) and click to the left margin of the code window. You should insert a little red ball. Now run the program again in debug mode.

    When you hit the space bar the program should freeze and go back to your code window. If it doesn't, you know your problem is with the button press and you should look to see what you may have done incorrectly. Press F11 to 'step through' your code. What this does is go through your program line by line. You can also mouse over variables in this mode and it will tell you what their values are. So, as you step through, you should be asking yourself, does the code 'go' where I want it to, or does it skip over something (probably this). Then, you have to decide what is causing it to skip. Is one of your variables set wrong? Is something within the method itself not working? Etc. Try to understand exactly what every piece of your code is doing.

    Once you have done this, if the solution is not obvious (which it almost never is), post the specific bit of code here and people would be glad to take a look at it.

    Of course, to completely solve your problem, you could always compare your code with the downloaded code to find the mistake. That way you are still learning but it cuts down on frustrating typing mistakes (which will get more numerous as the series goes on, trust me). At the same time, it is better to learn how to debug your own programs sooner rather than later.
Page 1 of 1 (2 items) Previous Next