0

I'm still a little fuzzy on ocanvas, I'm new to it. I know it's not the best choice or most documented, but I have a potential job that depends on me learning it.

I was wondering where ocanvas.create(); should be placed. right now I have a function called Main(); in the html head and the html body runs it every time the body loops. it seems that ocanvas.create(); only works if i place it in the Main(); function, but is that creating a canvas every time the body loops?

Jeff
  • 19
  • 1
  • 1
  • 6

1 Answers1

0

Can you explain a bit more about 'every time the body loops'? Do you have a setTimeout/setInterval/requestAnimationFrame that runs Main many times? In that case, just run oCanvas.create outside of Main and then access it from inside Main when needed.

  • well as i understand it, the body is a looping entity. Every time it loads, I have it calling the Main function. the Main function seems like it only works if it contains the oCanvas.create inside of it. Correct me if I am wrong? – Jeff May 16 '15 at 00:42
  • 'The body' being the `` element or what are you referring to? And inside that you have a ` – Johannes Koggdal May 16 '15 at 10:57
  • I was under the impression the body refreshes itself and continually calls Main(); – Jeff May 16 '15 at 14:02
  • Ah no, that code adds an event handler for the load event of body. When it has finished loading, it runs your Main function once, so that's the entry point for your app code. If you want a loop you can use requestAnimationFrame or setTimeout to run code many times. You can also do this through oCanvas if you want: http://ocanvas.org/docs/Timeline/setLoop – Johannes Koggdal May 16 '15 at 15:07