CodingTrain / CodingTrain/Suggestion-Box
Objects and images 7.8
- Vorherrschende Sprache
- Keine Sprachdaten
- Sterne
- 570
- Forks
- 85
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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();
}
}
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
Beginne mit den bereitgestellten preload() und mousePressed()-Funktionen und überprüfe, wie das urls-Array und memeImg verwendet werden. Das gewünschte Verhalten besteht darin, dass ein Mausklick einen Array-Index auswählt und das entsprechende Bild lädt, aber der Payload nennt keine Repository-Datei und keinen auszuführenden Test.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript
- Bereich
- frontend, web-dev
- Issue-Typ
- Feature
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100