0

我希望有人可以帮助我解决我的问题。我正在尝试制作一个简单的可视化来显示足球队如何在 2012 年的 FIFA 排名中上升或下降。为此,我创建了 17 张图像并将其加载到我想要根据按钮事件移动的草图中。下面是我的代码:

//Setting up the images that will go into the sketch

PImage img1;
PImage img2;
PImage img3;
PImage img4;
PImage img5;
PImage img6;
PImage img7;
PImage img8;
PImage img9;
PImage img10;
PImage img11;
PImage img12;
PImage img13;
PImage img14;
PImage img15;
PImage img16;
PImage img17;

//loading the images from the file
void setup() {
  size(600, 1100)
  img1 = loadImage('Click.png');
  img2 = loadImage('Team_xxxxx.png');
  img3 = loadImage('Team_xxxxxx.png');
  img4 = loadImage('Team_xxxxxx.png');
  img5 = loadImage('Team_xxxxxxx.png');
  img6 = loadImage('Team_xxxxx.png');
  img7 = loadImage('Team_xxxxxx.png');
  img8 = loadImage('Team_xxxxxxx.png');
  img9 = loadImage('Team_xxxxxx.png');
  img10 = loadImage('Team_xxxxxx.png');
  img11 = loadImage('Team_xxxxx.png');
  img12 = loadImage('Team_xxxxx.png');
  img13 = loadImage('Team_xxxxx.png');
  img14 = loadImage('Team_xxxxxx.png');
  img15 = loadImage('Team_xxxxx.png');
  img16 = loadImage('Team_xxxxx.png');
  img17 = loadImage('Team_xxxxxx.png');
}

//Drawing the images into the sketch
void draw() {
  image(img1, 400, 100);
  image(img2, 100, 250);
  image(img3, 100, 300);
  image(img4, 100, 350);
  image(img5, 100, 400);
  image(img6, 100, 450);
  image(img7, 100, 500);
  image(img8, 100, 550);
  image(img9, 100, 600);
  image(img10, 100, 650);
  image(img11, 100, 700);
  image(img12, 100, 750);
  image(img13, 100, 800);
  image(img14, 100, 850);
  image(img15, 100, 900);
  image(img16, 100, 950);
  image(img17, 100, 1000);
}

我不断收到此错误消息:格式错误的字符(期望引用,得到我)。以下是控制台中的输出:

 processing.app.SketchException: Badly formed character constant (expecting quote, got l)
        at processing.mode.java.preproc.PdePreprocessor.checkForUnterminatedMultilineComment(PdePreprocessor.java:478)
        at processing.mode.java.preproc.PdePreprocessor.write(PdePreprocessor.java:515)
        at processing.mode.java.JavaBuild.preprocess(JavaBuild.java:270)
        at processing.mode.java.JavaBuild.preprocess(JavaBuild.java:185)
        at processing.mode.java.JavaBuild.build(JavaBuild.java:144)
        at processing.mode.java.JavaBuild.build(JavaBuild.java:123)
        at processing.mode.java.JavaMode.handleRun(JavaMode.java:114)
        at processing.mode.java.JavaEditor$19.run(JavaEditor.java:474)
        at java.lang.Thread.run(Thread.java:680)

我在 OS X 上运行的 Macbook Pro 上使用 Processing 2.0B7。

4

1 回答 1

2

错误可能来自

img1 = loadImage('Click.png');

特别是'Cl位。字符常量由一个单引号 ( ')、一些字符和另一个单引号 ( ') 组成。
你所拥有的是一个单引号('),一个C,然后一个l

由于您似乎想要一个字符串常量,请尝试使用双引号:

img1 = loadImage("Click.png");
于 2013-01-21T20:23:28.020 回答