Jump to content

Problem rendering for a raycast engine


Kobaltic
 Share

Recommended Posts

I have been trying to port a raycast engine over to Phaser. I have one completey done but it uses DOM elements. I started working on a second one and I am stuck on the rendering part. I believe if I get this part figured out I will have the rest of the raycast in Phaser. Here is the part of the code I believe I need to change.

<canvis id = "screen" width="640" height = "320"></canvas> var canvas = document.getElementById(canvasId);        objects.context = canvas.getContext("2d");

I think I just need to get the phaser context and it should work. Any thoughts on how to do that?

Link to comment
Share on other sites

Don't write directly to Phaser's canvas context, as this is cleared every update and managed by Phaser's scene graph. What you want to do instead is create a BitmapData object, add that as the texture to a Sprite or Image and then access its .ctx or .context property to get the context to write your ray cast results to. The BitmapData can be the same size as your screen and the Sprite or Image it's attached to would be managed like any other Phaser object, allowing you to place text over it and so on.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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