Processing “文件”;起始.gif0000.gif“;如果缺少或无法访问,请确保URL有效,或者文件已添加到草图中且可读

Processing “文件”;起始.gif0000.gif“;如果缺少或无法访问,请确保URL有效,或者文件已添加到草图中且可读,processing,Processing,我正试图将一个.gif文档合并到我的处理代码中,但似乎URL有问题。gif文档与我的草图在同一个文件夹中,我不知道出了什么问题 Animation animation1; float xpos; float ypos; float drag = 30.0; void setup() { size(640, 360); background(255); frameRate(24); animation1 = new Animation("Starting.gif&qu

我正试图将一个.gif文档合并到我的处理代码中,但似乎URL有问题。gif文档与我的草图在同一个文件夹中,我不知道出了什么问题

Animation animation1;

float xpos;
float ypos;
float drag = 30.0;

void setup() {
  size(640, 360);
  background(255);
  frameRate(24);
  animation1 = new Animation("Starting.gif", 38);
  ypos = height * 0.25;
}

void draw() { 
  background(255);
  float dx = mouseX - xpos;
  xpos = xpos + dx/drag;

  animation1.display(xpos-animation1.getWidth()/2, ypos);
}

// Class for animating a sequence of GIFs

class Animation {
  PImage[] images;
  int imageCount;
  int frame;

  Animation(String imagePrefix, int count) {
    imageCount = count;
    images = new PImage[imageCount];

    for (int i = 0; i < imageCount; i++) {
      // Use nf() to number format 'i' into four digits
      String filename = imagePrefix + nf(i, 4) + ".gif";
      images[i] = loadImage(filename);
    }
  }

  void display(float xpos, float ypos) {
    frame = (frame+1) % imageCount;
    image(images[frame], xpos, ypos);
  }

  int getWidth() {
    return images[0].width;
  }
}
动画1;
浮动XPO;
浮动YPO;
浮动阻力=30.0;
无效设置(){
尺寸(640360);
背景(255);
帧率(24);
animation1=新动画(“Starting.gif”,38);
ypos=高度*0.25;
}
void draw(){
背景(255);
float dx=mouseX-xpos;
xpos=xpos+dx/拖动;
animation1.display(xpos-animation1.getWidth()/2,ypos);
}
//用于设置GIF序列动画的类
课堂动画{
PImage[]图像;
int图像计数;
int帧;
动画(字符串imagePrefix,整数计数){
imageCount=计数;
图像=新的PImage[图像计数];
对于(int i=0;i
错误消息

文件“Starting.gif0000.gif”丢失或无法访问,请确保URL有效,或者该文件已添加到草图中且可读

文件“Starting.gif0001.gif”丢失或无法访问,请确保URL有效,或者该文件已添加到草图中且可读

文件“Starting.gif0002.gif”丢失或无法访问,请确保URL有效,或者该文件已添加到草图中且可读


它应该在一个名为
data
的文件夹中。此文件夹应位于草图的同一文件夹中

SketchFolder

    Sketch.pde

    data

         Image.gif

使用菜单在PDE中添加或删除图像将为您完成此操作。或者您可以手动执行。

请注意类定义。它获取许多单独的图像,并将其作为gif输出。您需要做的是将得到的start.gif文件分成38个文件(如果实际有38帧),每个文件名为“Starting0000.gif”、“Starting0001.gif”、“Starting0002.gif”。。。“Starting0037.gif”


是否使用编辑器中的菜单将其添加到草图中?仍不工作。我已在草图文件夹下创建了一个数据文件夹。请参阅@Vibius Vibidius Zosimus answer。我没有真正阅读代码,所以我错过了。
animation1 = new Animation("Starting", 38);