All of my objects, like coins, are stored in an array, but I can't figure out why this isn't working.
If I do this:
Code:
GameObject[] objectsArray = {new ObjCoin(100,100), new ObjCoin(100,200), new ObjCoin(100,300), new ObjCoin(100,400), new ObjCoin(100,500), new ObjCoin(100,600)};
objects = objectsArray;
for(int i = 0; i < 6; i++){
objectsArray[i] = new ObjBlock(50+30*i, 100);
}
This works fine. I get a straight line of blocks with this.
But with this code:
Code:
GameObject[] objectsArray = new GameObject[1000];
objects = objectsArray;
for(int i = 0; i < 6; i++){
objectsArray[i] = new ObjBlock(50+30*i, 100);
}
I get a null pointer exception when trying to access the objects in the array in my render and update function. Any ideas why?
I'd also like to know how to handle sounds.