lopesam Posted July 13, 2014 Share Posted July 13, 2014 I am pretty new to the HTML5 canvas in fact this is my first game I am making (It's a game that takes place on a soccer field and you are able to move around as a soccer player). The field will draw but the player won't draw onto the screen and I am not sure why, also it doesn't return an error in the console. Perhaps it is something to do with the namespace? I have no clue.If it matters I have win7 64 bit, and chrome.HTML5 MASTERS PLEASE HELP ME!code is here: http://pastebin.com/uUm8w265stackoverflow: https://stackoverflow.com/questions/24727177/html5-canvas-wont-draw-my-image-to-the-screen-without-an-error Quote Link to comment Share on other sites More sharing options...
Sawamara Posted August 4, 2014 Share Posted August 4, 2014 At a glance, this seems like the usual image problem, where you are indeed setting the image's source sooner than it could load, thus giving you problems.Usually, you first set the image.var picture = new Image(); Then you do an onload, specifying that your assets should be used only when loadedpicture.onload = (code that deals with that, either flipping a switch or something else)Then you add the source.picture.src = "imagesrc.png";Now, you gotta make sure to wait for the image to load before you make any references to this in your regular draws. If you omit to do that, the image will not pop up at all. Or does so only after reloads. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.