Friday 17 March 2017

Canvas doesn't print my image

I try to print an image on my canvas when a user is connected.

My code :

  socket.on('load', function(x, y, img) {
     var playerimg = new Image();
     playerimg.src = img;
     playerimg.onload = function() {
        context.drawImage(playerimg, x, y, 100, 100);
     }
  });

The x, y and the variable img are all ok. I can console.log every value and it's correct but nothing happens on my canvas.

Thanks a lot for your answers



via Jérémy M

No comments:

Post a Comment