Something abuot the initialize () function of xNa Template

Source: Internet
Author: User

Recently, I have been learning some article about using xNa framework to develop games. I have dreamed to create a wonderful game long ago. but at that time, I don't know how to do and where to start, that's really a big deal for me. I knew xNa about one year ago, I just tried some start kiters and still didn't know how to deal this great deal.

Have holidays at home, nothing to do, why not have a try. What's more there're really allocated resources about xNa, so I think it's a perfect time to start.

To begin with xNa, I read some introduction articles through net, tried some simple examples. during practice, I found there's something misleading in the Windows game template.

After you created a new window game (2.0) project, in the game1.cs file, the code for initialize () method is:

Protected override void initialize ()
{
// Todo: add your initialization logic here

Base. initialize ();

}

When coding, I just follow the todo tip, write my initialization code before base. initialize (), then I got null exception in the loadcontent () and draw () method. it seems the two method are called before initialize (), at least the first time they are called. after I moved base. initialize () to the very ining of the method initialize (), everything goes well. in my opinion, maybe the first time the two methods are called to display something on the screen, and initialize () was called just before the game logic really start.

Conclusion:

Write your initializing code after base. initialize ()!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.