Sunday, November 20, 2011

Programming Challenges: Everything in Order

I was trying to add a little icon for one of the objects in my project, and when I added the code I expected to make it show up, my game started crashing upon loading.

After some frustrating debugging, I found out that although I was setting the ID of the object when I constructed it, the ID was leaving the constructor function as -1. It turns out, FlxBasic, which the object is a subclass of, sets the ID to -1 when it is constructed, and I had put super() in AFTER setting the object ID. As soon as I moved super() to the front of the constructor, everything worked again.

Sometimes the most aggravating errors are the smallest, simplest ones.

1 comment:

  1. Ran into this again a few days ago, and remembered the root cause after only a few minutes of debugging.

    ReplyDelete