Jump to content

User Interface - Canvas or DOM?


ChrisP
 Share

Recommended Posts

In peoples experience / opinion which is the better approach to building a User Interface for an HTML5 game? I've found mixed opinion and approaches across the web (as with most things HTML5 games related).

 

As far as I can see the advantages in using the DOM are styles can be set by CSS (so no need for sprites and images), and it isn't redrawn by the main game loop on each redraw (as this is then handled by the browser, and presumably is generally accelerated by the GPU). It's also easier to handle user interaction such as click events through the DOM.

 

However I know accessing the DOM can be very slow from javascript, so it's how you mitigate that when you want to update parts of the interface.

 

It's also worth noting that I've encountered performance issues using the DOM for a UI on my mobile phone. Currently the UI is just static and does nothing, but I still get frame drops. I realise it could just be my phone, and I need to check whether not layering the DOM objects over the canvas improves performance - but in my game engine I get a steady 60fps on my phone when the DOM UI is hidden, but this drops massively when it's displayed. This could easily be something I've done though?!

Edited by ChrisP
Link to comment
Share on other sites

  • 1 year later...

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.

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...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...