CodingTrain / CodingTrain/Suggestion-Box
Objects and images 7.8
- Lenguaje dominante
- Sin datos de lenguaje
- Estrellas
- 570
- Forks
- 85
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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();
}
}
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
Comienza con las funciones preload() y mousePressed() proporcionadas y revisa cómo se utilizan el array urls y memeImg. El comportamiento solicitado es que un clic del ratón elija un índice del array y cargue la imagen correspondiente, pero el payload no especifica ningún archivo del repositorio ni ninguna prueba que ejecutar.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- javascript
- Área
- frontend, web-dev
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100