Arrays 是否仅从阵列中显示第一个图像?
我发现除了.svg文件之外,我还想做什么。它似乎可以工作,因为我必须单击右箭头6次才能再次显示第一个图像。其他svg图像不显示有什么原因吗 以下是我改编的代码:Arrays 是否仅从阵列中显示第一个图像?,arrays,svg,processing,Arrays,Svg,Processing,我发现除了.svg文件之外,我还想做什么。它似乎可以工作,因为我必须单击右箭头6次才能再次显示第一个图像。其他svg图像不显示有什么原因吗 以下是我改编的代码: int maxImages = 6; // Total # of images int imageIndex = 0; // Initial image to be displayed is the first boolean isPlaying = false; // Declaring an array of images. PS
int maxImages = 6; // Total # of images
int imageIndex = 0; // Initial image to be displayed is the first
boolean isPlaying = false;
// Declaring an array of images.
PShape[] images = new PShape[maxImages];
void setup() {
size(1080,1920);
// Loading the images into the array
// Don't forget to put the JPG files in the data folder!
for (int i = 0; i < images.length; i ++ ) {
images[i] = loadShape( "HairStyles" + i + ".svg" );
}
frameRate(5);
}
void draw() {
background(100);
shape(images[imageIndex],500,500);
}
// Only happens when you release key
void keyReleased() {
if (keyCode == RIGHT) {
// Cycle
if (imageIndex >= 5) {
imageIndex = 0;
}
else {
imageIndex += 1;
}
}
else if (keyCode == LEFT) {
// Cycle backwards
if (imageIndex <= 0) {
imageIndex = 5;
}
else {
imageIndex -= 1;
}
}
}
int-maxImages=6;//图像总数
int imageIndex=0;//要显示的初始图像是第一个
布尔isplay=false;
//声明一个图像数组。
PShape[]图像=新PShape[最大值];
无效设置(){
尺寸(10801920);
//将图像加载到阵列中
//别忘了把JPG文件放在数据文件夹里!
对于(int i=0;i=5){
imageIndex=0;
}
否则{
imageIndex+=1;
}
}
else if(keyCode==左){
//倒转
if(imageIndex)加载图像时,我怀疑循环可能会中断。请尝试这样加载图像,以查看是否存在问题:string imgName=“HairStyles”+I+“.svg”;
images[I]=loadShape(imgName);
并密切关注控制台是否有意外的文件名或加载错误(如果文件加载不正确,函数将返回null并将向控制台写入错误消息).你能再检查一遍文件名吗?你确定你的循环加载的文件是正确的吗?@KevinWorkman再检查一遍,这也是我第一次这样做。它似乎在循环它们,但它们不是showing@laancelot似乎没有改变任何东西。我交换了图像的顺序,但仍然只有一个显示,我将导出解决:它们没有显示,因为它们没有填充颜色,只有一个笔划。我禁用了样式并添加了一个笔划。