I’m a beginner and am trying to do something that I’m sure is probably simple. I’d like to have a range of images that the user can cycle through, where when you touch on the image, it simply changes to the next image, and it does this each time you click on it for about 10 images before coming back to the first image. So a bit like a photo album but all contained within the one spot on the screen. I know how to turn an image on and off via button press but this is a little different as it isn’t just changing between two images, it’s cycling through a number of images. Hope someone can help me.
Assuming you have an array of sprites, you can just keep an int around to use as an index into your array or list:
Image MyImageComponent;
Sprite[] MySprites;
int currentImageIndex = 0;
// Run this when you press your button or what have you
ShowNextImage() {
// Go to the next image...
currentImageIndex++;
// This part will wraparound back to 0 after the last image...
currentImageIndex = currentImageIndex % MySprites.Length;
// Draw the new image
MyImageComponent.sprite = MySprites[currentImageIndex];
}