When the engine starts, it grabs the document and makes it the default context to which you can add any other contexts or objects. You could use the HTMLElementContext and point it at an existing HTML element in the page like so:
var root = R.rendercontexts.HTMLElementContext.create("root_element", document.getElementById("foo"));
It would find the element with the Id "foo" and make it the element which represents the HTMLElementContext in the DOM. Then you could add the CanvasContext to the HTMLElementContext and finally, the HTMLElementContext to the default context. I know it seems like a lot of steps, but the structure of the scenegraph needs to be maintained. So, if we combined the example above, it might look something like the following:
var root = R.rendercontexts.HTMLElementContext.create("root_element", document.getElementById("foo")),
playField = R.rendercontexts.CanvasContext.create("playfield", 640, 480);
root.add(playField);
R.Engine.getDefaultContext().add(root);
- Brett
On Tue, May 3, 2011 at 5:53 AM, miskovac
<milan...@gmail.com> wrote:
Is there a way to tell to Engine where to nest canvas in DOM tree?
Thanks