Jump to content

appendChild in Phaser


Kobaltic
 Share

Recommended Posts

Alright, so I am working on a raycast engine. I ported one over into Phaser. I got everything working correctly except the rendering. It currently renders to a div and doesn't use Phaser. I am trying to fix that. Here is the section of the code that I am working on. The first line vars the "screen" div. The last line appends the child of "strip" . I am thinking that I need to change screen.appendChild(strip); to something like game.appendChild(strip). That is were my issue is. If more code would help let me know and I will put some more up.

function initScreen() {  var screen = $("screen");    for (var i = 0; i < screenWidth; i += stripWidth) {        var strip = dc("div");        strip.style.position = "absolute";        strip.style.left = i + "px";        strip.style.width = stripWidth + "px";        strip.style.height = "0px";        strip.style.overflow = "hidden";        strip.style.backgroundColor = "magenta";        var img = new Image();        img.src = ("assets/wall.jpg");        img.style.position = "absolute";        img.style.left = "0px";        strip.appendChild(img);        strip.img = img;	// assign the image to a property on the strip        // element so we have easy access to the image later        screenStrips.push(strip);        screen.appendChild(strip);    //  game.add.existing(strip);    }}
Link to comment
Share on other sites

yes, my bad. I misunderstood your initial post.

 

I'm not really sure what you're after, but Phaser is drawn into a single canvas element. AFAIK, you can't add DOM elements to Phaser. if you could modify the raycast engine to render to a Canvas then perhaps you could use that as a texture and have Phaser render it

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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