Can everyone Help me?

Pls Help me i become a Error

java.lang.ArraylndexOutOfBoundsException: length=16; index=16

int numFrames = 16; // The number of frames in the animation
int frame = 17;
PImage[] images = new PImage[numFrames];
int j= year();
int mt= month();
int t= day();
int s= second();
int m= minute();
int h= hour();

void setup(){
  images[0] = loadImage("1.gif");
  images[1] = loadImage("2.gif");
  images[2] = loadImage("3.gif");
  images[3] = loadImage("4.gif");
  images[4] = loadImage("5.gif");
  images[5] = loadImage("6.gif");
  images[6] = loadImage("7.gif");
  images[7] = loadImage("8.gif");
  images[8] = loadImage("9.gif");
  images[9] = loadImage("10.gif");
  images[10] = loadImage("11.gif");
  images[11] = loadImage("12.gif");
  images[12] = loadImage("13.gif");
  images[13] = loadImage("14.gif");
  images[14] = loadImage("15.gif");
  images[15] = loadImage("16.gif");
  images[16] = loadImage("17.gif");
  orientation(LANDSCAPE);
  PFont font = createFont("SansSerif", 100 * displayDensity); 
  textFont(font);
  fullScreen();
}


void draw(){
  frame = (frame+1) % numFrames;
  image(images[frame], 400, 200);
  background(0);
  text(+t+":"+mt+":"+j+"\n  "+h+":"+m+":"+s, 330, 300);
}

you loaded 17 images. set numFrames to 17 and it should work.

Arrays start at 0 array[10] only accepts 0,1,2,3,4,5,6,7,8,9 (10 inputs). If you enter array[10] it will return out of bounds

Hi @Rogo and @CodeMasterX Happy New Year! :fireworks:
@Rogo Since your image names have a pattern. You can load them in a for loop. Like:

PImage[] images = new PImage[17]; 

 for (int i = 1; i < 18; i++) { 
    String image_name = str(i)+".gif"; 
    images[i-1] = loadImage(image_name);
  }

sorry my head is not fully conscious because of New Year’s Eve can you explain to me better what to do? or put it in the code for me :joy:

It sure isn’t, because I already did. :joy:

Change the first lines in your code to
int numFrames = 17;
since you have 17 images to load

I found my problem sorry I haven’t quite arrived yet​:joy::joy::tada: Happy New Year

Error:
Could not load the image because the bitmap was empty.
Nothing to do with your first error.

Maybe this helps?

1 Like
int numFrames = 16; // The number of frames in the animation
int frame = 15;
PImage[] images = new PImage[16];
int j= year();
int mt= month();
int t= day();
int s= second();
int m= minute();
int h= hour();

void setup(){
  orientation(LANDSCAPE);
  PFont font = createFont("SansSerif", 100 * displayDensity); 
  textFont(font);
  fullScreen();
  frameRate(30);
  images[0] = loadImage("1.gif");
  images[1] = loadImage("2.gif");
  images[2] = loadImage("3.gif");
  images[3] = loadImage("4.gif");
  images[4] = loadImage("5.gif");
  images[5] = loadImage("6.gif");
  images[6] = loadImage("7.gif");
  images[7] = loadImage("8.gif");
  images[8] = loadImage("9.gif");
  images[9] = loadImage("10.gif");
  images[10] = loadImage("11.gif");
  images[11] = loadImage("12.gif");
  images[12] = loadImage("13.gif");
  images[13] = loadImage("14.gif");
  images[14] = loadImage("15.gif");
  images[15] = loadImage("16.gif");
}

void draw(){
  for (int i = 1; i < 17; i++) { 
    String image_name = str(i)+".gif"; 
    images[i-1] = loadImage(image_name);
  }
  background(0);
  images[frame].resize(displayWidth, displayHeight);
  image(images[frame], 50, 50);
  text(+t+":"+mt+":"+j+"\n"+h+":"+m+":"+s, 330, 300);
}

In viewing mode and in the app as APK, the gif is not played, “1.gif” is displayed and the date / time no longer changes

Slow down, take your remedy, and rest a little bit. Your loading too much.

then can you help me later?

Hello,

@noel provided a nice example for you to work with there.

You are loading 17 images once in setup()

You are then loading 17 images 30 times per second in draw()

Puts some comments in your code (twice):
//Loading 17 images into array

Commenting will help in the long run and help you debug your code.

Hopefully you will have an epiphany

And the rest needs some work.

Use the same loop (with changes and modifications) for displaying the images.

References:

:)

happy new year to you to!