我试图为我的Java文档制作过滤器。
这是我的代码,但它不起作用。不要介意m4 == 1,ak == 1,awp == 1.
PImage weapon1;
PImage weapon2;
PImage weapon3;
PImage billed;
int weapon;
int m4 = 0;
int ak = 0;
int awp = 1;
void setup() {
weapon1 = loadImage("dayz.jpg");
weapon2 = loadImage("ak47.jpg");
weapon3 = loadImage("295020.jpg");
billed = loadImage("dayz.jpg");
它是执行错误的int武器,但我需要使用int武器让我的代码像我想的那样工作。
void pixel2(){
if(m4 == 1){
weapon = weapon1;
}
else if(ak == 1){
weapon = weapon2;
}
else if(awp == 1){
weapon = weapon3;
}
for(int y = 0; y < weapon.height; y = y+3){
for(int x = 0; x < weapon.width; x = x+3){
color pilex1 = weapon.get(x, y);
strokeWeight(1);
stroke(1);
fill(pilex1);
rect(x,y,3,3);
}
}
}
答案:
if(m4 == 1){
weapon = loadImage("295020.jpg"); }
else if(ak == 1){
weapon = loadImage("ak47.jpg"); }
else if(awp == 1){
weapon = loadImage("dayz.jpg"); }
答案 0 :(得分:1)
int weapon;
应为PImage weapon;
。
PImage billed;
并没有被使用。