How can I store different loadgif in an different instances of an object?

I have this code here to create objects with gifs, and it all works well until I try to make this.gif different for each object.

function setup() { createCanvas(800, 600); //make objects

for (var i=0; i<8; i++) { x.push(new Track(i*50.0, 0.0)); x[i].gif = loadGif('gif/flower78.gif'); // why not with many different gifs? } }

where the Track object looks like this:

//define object= function Track(px, py){ this.xpos = px; this.ypos = py; this.xspeed = 0.0;
this.yspeed = 0.0; this.name = 0; this.gif;

this.load = function() { this.gif = loadGif('gif/flower'+this.name+'.gif'); } this.display = function() { image(this.gif, this.xpos, this.ypos); } }

Tagged:

Answers

Sign In or Register to comment.