I have 2 functions(js
) in a webpage for attaching an image to a canvas element:
function attachImage(tile, x, y)
{
base_image = new Image();
base_image.src = 'Images/tiles/'+(tile-1)+'.png';
base_image.onload = function(){
context.drawImage(base_image, 32*x,32*y);
}
}
and i literally copy and pasted it and duplicated it for another canvas
function attachImage2(tile2, x2, y2)
{
base_image2 = new Image();
base_image2.src = 'Images/tiles/'+(tile2-1)+'.png';
base_image2.onLoad = function(){
context2.drawImage(base_image2, 32*x2,32*y2);
}
}
On firefox, if i make one onload
and the other onLoad
, then it works fine. but no matter what i do for chrome, it doesn't load the images properly.
edit: here is and image comparison between firefox and chrome:
FIREFOX: https://i.stack.imgur.com/l5sMt.jpg
`, or select your code and press the **{}** symbol from the toolbar. – Gabriele Petrioli Oct 29 '12 at 03:04
` is kind-of undesirable. Markdown code syntax is a four-space indent.
– Pointy Oct 29 '12 at 03:10