CodingTrain / CodingTrain/Suggestion-Box
Objects and images 7.8
- Lingua principale
- Nessun dato sulla lingua
- Stelle
- 570
- Fork
- 85
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
In your video you created an array of file names and used CONCATENATE to pass through a link to the image.
I want to use the array [i] to load the image from an array of URL’s, they have no logical file name so I need to reference the array index no. Instead.
I want to click the mouse and a new array index no. Is chosen and the image loaded.
Thanks!
Code:
var urls = [ "https://i.imgflip.com/tau4.jpg", "https://i.imgflip.com/2cp1.jpg", "https://i.imgflip.com/5kdc.jpg", "https://i.imgflip.com/1bgs.jpg", "https://i.imgflip.com/cv1y0.jpg", "https://i.imgflip.com/320xfw.jpg " ];
var bubbles = [];
var memeImg;
function preload() {
vvvvvvvvvvvvv
memeImg = loadImage(urls[3]); **** this loads the urls array index 3 *****
}
^^^^^^^^^^^^^^^ this part needs to random select an index no.
function setup() {
createCanvas(600, 400);
}
function mousePressed(){
var b = new Bubble(mouseX, mouseY, memeImg) ;
bubbles.push(b)
print(bubbles)
}
function draw() {
background(0);
for (var i = 0; i < bubbles.length; i++) {
// bubbles[i].move();
bubbles[i].display();
}
}
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
Start from the provided preload() and mousePressed() functions and review how the urls array and memeImg are used. The requested behavior is for a mouse click to choose an array index and load the corresponding image, but the payload names no repository file or test to run.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript
- Ambito
- frontend, web-dev
- Tipo di issue
- Funzionalità
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100