Hi all,
I’m having an issue trying to fill a two-dimensional array with bitmaps.
I declared it like this:
public var rewardList = new Array<Array<openfl.display.Bitmap>>();
Then filled it like this (inside a function):
public function loadRewards():Array<Array> {
rewardList[0][0] = new Bitmap(Assets.getBitmapData(“img/empty_box1.png”));
rewardList[0][1] = new Bitmap(Assets.getBitmapData(“img/reward3_blue.png”));
…etc…
rewardList[1][0] = new Bitmap(Assets.getBitmapData(“img/empty_box2.png”));
rewardList[1][1] = new Bitmap(Assets.getBitmapData(“img/reward2_green.png”));
…etc…
return rewardList;
}
The script compiles without errors now but the program crashes upon execution. Error is : Null Object Reference.
The output shows that the program gets stuck at loading the images into the array.
Is it somehow not allowed to fill a 2-d array with Bitmaps?
In case that is relevant: there are no ‘holes’; all of the 3x11 places are filled. As a 1D array with bitmaps everything works fine. Just when introducing the 2D element, things go wrong.
Any insight or help would be much appreciated!
Thanks!