Jump to content

Rendering directly to a secondary canvas


Preece
 Share

Recommended Posts

In my game, I am hiding the primary phaser canvas, and the creating a new one that the hidden canvas is rendered to each frame. This is for two reasons: ensure crisp rendering of the pixel art in the game, and allow sub-pixel movement of the camera by offsetting the render amount. This all works fine. The problem is with UI overlay elements. Because the UI elements are rendered to the primary canvas, their position can only be in unscaled pixel coordinates. This leads the UI to be jittery, because the camera can move sub-pixels, while the UI can not. The solution I would prefer for this, would be some method to render the UI elements directly to the scaled canvas, instead of the hidden, unscaled canvas. Then, I would just use pre-scaled versions of the UI for whatever scale factor the user chose.

 

To put in simpler terms, is there a way to have an element render to a canvas other than the one specified by the game?

Link to comment
Share on other sites

Thanks for the responses everyone. I am using both solutions, what tips4design and Rich suggested. In the render function, I am drawing the UI elements from the cache and then drawing them scaled up to the secondary canvas. For the bitmap text, I am going to retarget its render call.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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