Initializing an Object

Hei there, Sry for the stupid question but I just cant find my mistake...

So I have two Objects in my project (Player1 and Player2), I initialize them in the setup() function with var player1 = new Player1(); . But when I want to call a function from this Object (player1.show() ), there is a error code "player1 is not defined". So I guess my problem is, that I initialized the Objects in a wrong way... Here is my code:

function setup() {
  createCanvas(1400, 800);

  var player1 = new Player1();
  var player2 = new Player2();
}

function draw() {
  background(0, 0, 0);

  player1.show();
  player2.show();
}

Thanks for the help!

Answers

Sign In or Register to comment.