Search code examples
htmlgwtwebplayn

PlayN html integration


I am having trouble integrating the playn-root component with the rest of my standard gwt panels and components. In other words I have standard gwt components like buttons and tables and cannot figure out how to add the playn root where I would like it to be.

There is an element called rootElement in HtmlGraphics that is a package protected memember that I think if I could get access to it, then I would be able to work with it like I need to. I have tried to extend the HtmlPlatform class, but because this class has no default constructor, it is not extendable.

How are we supposed to integrate playn with the rest of gwt for html targeted games?


Solution

  • If you put a <div> in your HTML host page with the id playn-root then PlayN will add the game view to that div. The Cute example game demonstrates this:

    <body bgcolor="black">
      <div id='playn-root'></div>
      <script src="cutegame/cutegame.nocache.js"></script>
    </body>
    

    If you need to get access to that div in your GWT app, you can use Document:

    Document.get().getElementById("playn-root")