【发布时间】:2016-11-02 08:37:50
【问题描述】:
我似乎找不到错误,但是当我删除 if 语句时,它运行良好。代码很短,应该很容易找到问题。
int zw1;
int zw2;
int px = 100;
int py = 100;
int ppx = px + random(-20, 20);
int ppy = py + random(-20, 20);
int cx;
int cy;
int xrand = 50;
int yrand = 50;
int opacity = 49;
frameRate(30);
background(74, 71, 74);
int timetoclear = 0;
int x0 = 0;
int y0 = 0;
void setup() {
size(400, 400);
}
void draw() {
cx = px + random(-xrand, xrand);
cy = py + random(-xrand, xrand);
// fill(74, 72, 74,5);
// rect(-10,-10,1000,1000);
//cx = mouseX;
//cy = mouseY;
if (cx <= 0) {
cx = 0;
}
if (cx >= 400) {
cx = 400;
}
if (cy <= 0) {
cy = 0;
}
if (cy >= 640) {
cy = 640;
}
stroke(30 + random(-100, 100), 195 + random(-100, 100), 201, 60);
fill(30 + random(-100, 100), 195 + random(-100, 100), 201, 50);
triangle(ppx, ppy, px, py, cx, cy);
ppx = px;
ppy = py;
px = cx;
py = cy;
}
抛出: Uncaught SyntaxError: Unexpected Identifier
【问题讨论】:
-
请提供准确的错误信息。
-
Uncaught SyntaxError: Unexpected Identifier
-
JavaScript 怎么样?
-
这不是完整的错误,它也会给你一个行号和/或列。
-
不应该
framerate和background在setup函数中吗?
标签: javascript identifier processing.js