Why can't the ProcessingJS editor call getImage() from a concatenated string before getting the same image from a constant string?
Hi, I am trying to create a program that involves getting an image from a variable name. Here is an example of the code that poses problems:
var leafers = "leafers";
image(getImage("avatars/" + leafers + "-seed"), 50, 50);
This code will cause Oh noes to say, "Image 'avatars/leafers-seed' was not found." However, this code poses a workaround that in theory should not have any effect on the output at all:
getImage("avatars/leafers-seed");
var leafers = "leafers";
image(getImage("avatars/" + leafers + "-seed"), 50, 50);
Although I could simply do this for all of the images I will be loading via concatenation, I am instead trying to loop through an array of avatar names and levels to show all of them, and calling getImage for every single avatar would be extremely tedious. If anyone has any solutions, they are greatly appreciated.
Thank you!
Vous devez vous connecter pour laisser un commentaire.