Jump to content

Render screen on texture?


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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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