Space Invaders NilObjectException

Ok so I guess I’ll start by giving a bit of context. For a project in my programming class I am creating a Space Invaders clone. At the moment, I am creating the houses near the bottom of the screen. For these houses, I have created a new class called “House” which inherits the properties and methods of a Realbasic.Rect, and has custom properties called “HitPoints”, “Destroyed”, and “Frame(2)”. I then created the global property “houseTile(64) as House” and in the open event handler the code “For i as integer = 1 to 64
houseTile(i) = new House

The problem is, whenever I run the program, I receive a NilObjectException. Regardless of the For next loop that creates the houseTiles as new House, all 0 to 64 of the houseTile properties appear as Nil in the debugger, and I’m not really sure why. I have omitted houseTile(0) as it is easier for me to work with numbers 1 through 64 instead of 0 through 63. Any help would be greatly appreciated.

How are you creating your instances?

with a for next loop that starts at 1 and goes through 64 in the open event handler. For i as integer = 1 to 64 houseTile(i) = new House next
where House is a custom class

Make sure you don’t have

dim houseTile(64) as House

in the event where you instantiate the objects.

I found the solution to my problem. The cause was I forgot to call the method that actually instantiates the houseTile(64) property as new house. All I had to do was call that method in the open event handler of the window.