Jump to content

HTML5 Canvas Help


Recommended Posts

Hi I have the following Canvas application: http://dev.driz.co.uk/canvas/But it's not rendering anything out. It should be showing a bunch of balls that move around the screen when the user moves the cursor.I think it's just a small bug somewhere because it was working fine in an older version here: http://dev.driz.co.uk/app/It's taking a while to load as if it's doing something but just snagging somewhere, but the code looks fine to me. After testing in Firebug the following error comes up: 'Cannot read property x of undefined on several lines mainly around the gradient creation. I have no idea what the problem is :/If anyone can help it'd be much appreciated. Thank you

Link to post
Share on other sites

The page is acting like if there was an infinite loop or something else that takes a whole long time to process. You might be doing something that's too heavy on the processor. I'm not getting error messages because the script couldn't finish executing.

Link to post
Share on other sites
The page is acting like if there was an infinite loop or something else that takes a whole long time to process. You might be doing something that's too heavy on the processor. I'm not getting error messages because the script couldn't finish executing.
When I run it in Firebug it throws an error about "Cannot read property x of undefined" and then also "Cannot read property color of undefined" I think their is definitely a bug in the code but I'm not sure what the problem is.I wouldn't think it would be too hard on the processor as I had a previous version working fine before and all I have added is the gradient and also reduced the number of balls down to two so therefore it should run fine. Seems like their is a bug in the code rather than performance problem. I think the bug is also causing the app to run infinite, perhaps I don't need the setInterval but that's required for the update of the canvas when the mouse moves the balls.If you or anyone can take a look at the code and see what the problem is that'd be really awesome. Thanks. Edited by driz
Link to post
Share on other sites

I have a feeling that it's trying to find more balls than there are. It looks for ball, but if is greater than the amound of balls there are it will be undefined.Rather than checking for i < numBalls try using i < balls.length in all the loops (except the one that creates the balls)Also, test it with only a few balls first, like 10 or so.

Edited by Ingolme
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...