We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello, I have generative text, but would like associate some words with some pictures.
exemple : If I have : String[] alea = {"cat","dog"};
and I would like associate "cat" with PImage cat;
How to do ?
I'm lost.
Thank you fo all.
Answers
http://processing.org/reference/HashMap.html
http://docs.oracle.com/javase/8/docs/api/java/util/Map.html
Thank you fo all. I try.
I have this error : "The file "blabla.jpg" is missing or inaccessible, make sure the URL is valid or that the file has been added to your sketch and is readable."
I have the file in the folder data. So it's good no ? Or I forgot something ? I search.
Thank you fo all.
Rather than just describe it, you should also provide the relevant code snippet of your problem!
Ok. I'm sorry. In fist time, I have no problem with my code. In second time, I have problem whith my code when I interact.
Snippet :
randomText1 = round(random(0, ancre1.length-1)); }
It's hard to figure out your snippet b/c there are many variables which were declared & initialized somewhere else!
What I can tell you is that we should avoid loading resources outside setup()!
Use loadImage() and put() its reference in the HashMap structure within setup()!
In addition to using a Map, you could also create an Object that contains a String and PImage. Depends on exactly what you need to do with the data.
Finally, I haven't use "HashMap" because I had problem with data folder. I have just read :
Thank you fo all.