Array of Images
Hello,
I'm working with a set of 7 images. Based on specific external input, I aim to toggle the visibility of these images - making certain images visible and others invisible.
When I manipulate the visibility of each image individually using the following code, it operates as expected:
Image_1.setVisible(true);
Image_2.setVisible(false);
// ... [and so on]
Image_7.setVisible(false);
Image_1.invalidate();
Image_2.invalidate();
// ... [and so on]
Image_7.invalidate();
However, when I attempt to streamline this process by storing the images in an array and then cycling through that array using a for loop, the expected behavior isn't observed:
touchgfx::Image Images[7];
Images[0] = Image_1;
Images[1] = Image_2;
// ... [and so on]
Images[6] = Image_7;
for (int i = 0; i < 7; i++) {
if (i == numActiveImages) {
Images[i].setVisible(true);
Images[i].invalidate();
} else {
Images[i].setVisible(false);
Images[i].invalidate();
}
}
Could someone shed light on this behavior or provide a potential solution?
Thank you in advance.
