I'm trying to create a function that can dynamically create variables for adding sprites into a game. Here is what I have so far:
function SpriteSetUp(name,src){
var Sprites = [];
var i = Sprites.length;
if(Sprites[Sprites.indexOf(name)] == name){
return Sprites[Sprites.indexOf(name)];
}else{
Sprites[i] = name;
Sprites[i].src = src;
return Sprites[Sprites.indexOf(name)];
}
};