Jump to content

Render screen on texture?


hellspawn_bg
 Share

Recommended Posts

Upon game over I am trying to render the screen on a texture which would be passed on the next state as a background. Sofar I have implemented this, but I end up with a black screen instead.

 

In the game state I do this:

this.texture= new Phaser.RenderTexture(this.game, this.game.width, this.game.height);this.texture.renderXY(this.game.stage, 0, 0);

In the new state I set the texture as a background:

this.background = new Phaser.Sprite(this.game, 0, 0, this.texture);

Any ideas?

 

Thanks :)

Link to comment
Share on other sites

this works for me... the texture from one level is added in the next level..

fade out is triggered to change the state....

game.add.existing is done in the new state

function fadeOut(target){    texture = new PIXI.RenderTexture(game.width, game.height, game.renderer);    matrix = new PIXI.Matrix();    matrix.translate(-game.camera.x, -game.camera.y);    texture.render(game.world, matrix);    cover = new Phaser.Sprite(game, 0, 0, texture);    cover.fixedToCamera = true;    cover.anchor.setTo(0.5,0.5);    cover.cameraOffset.x = game.width / 2;    cover.cameraOffset.y = game.height / 2;    game.state.start(''+target+''); }  if (cover) {game.add.existing(cover)} 
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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