1

So I'm writing a script to print some tiles, so far it should only draw one tile in the top left corner. It works fine in JSfiddle which i've linked below but not in chrome.

If I got into my chrome console and type initalRoom.tileGrid[1].tileImage.drawClipped(0,0,32,32,0,0); it give the desired results in which the tile appears in the top left corner but this command is already being called when the document is ready.

Anyone able to help? Thanks.

JSfiddle example

Simon Kay
  • 111
  • 1
  • 1
  • 8

1 Answers1

1

I took a course in JS last year, I found that in canvas chrome lacked behind other browsers such as FireFox try Firefox and see if your code works.

Hobson
  • 11
  • 2
  • Yep, firefox works. But still kind of annoying. Have you any idea on how to get this working in chrome? – Simon Kay Dec 11 '15 at 01:15
  • Dam had an answer was just going to post it. Nothing wrong with chrome, you are just not waiting for the image to load before you try to draw it. – Blindman67 Dec 11 '15 at 03:03
  • @Blindman67 if you think you can improve the [dupe](http://stackoverflow.com/questions/32880641/canvascontext2d-drawimage-issue-onload-and-cors) go ahead, we made it a community wiki (both question and answer) for this purpose :-) – Kaiido Dec 11 '15 at 03:20
  • @Kaiido Not the same issue. This one is just a simple failure to wait for the image to load, But there must be many of those already answered. – Blindman67 Dec 11 '15 at 03:41