Kobaltic Posted June 26, 2014 Share Posted June 26, 2014 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 More sharing options...
lewster32 Posted June 26, 2014 Share Posted June 26, 2014 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 More sharing options...
lewster32 Posted June 26, 2014 Share Posted June 26, 2014 You may find this interesting btw: http://www.html5gamedevs.com/topic/7331-pixi-raycaster/ Link to comment Share on other sites More sharing options...
Kobaltic Posted June 27, 2014 Author Share Posted June 27, 2014 Thanks for the information. I hope bitmapdata solves my problem. I saw that raycast engine too. I had problems running it locally though. Link to comment Share on other sites More sharing options...
Recommended Posts