Jump to content

Failing to remove sprites


MasterQ32
 Share

Recommended Posts

Hello!

I am currently working on a multiplayer game with PIXI and i'm trying to reload the level. But when i do, my code is failing to remove the previous level, but i don't really know why.
 
The level is created into a separate stage that is used for rendering the whole level at once. So my approach was to just remove this stage from the main stage to remove the level:
 

level.destroy = function () {	for(var key in level.sprites) {		level.sprites[key].alpha = 0.25;		level.sprites[key].blendMode = PIXI.blendModes.ADD;		console.log("dafuq?");	}	console.log(level.stage);	game.levelStage.removeChild(level.stage);}

This should remove the stage and print some information.

The information is printed, but the stage won't dissappear, neither the sprites get translucent.

 

Can you give me any hint why this could fail?

 

Resulting image

 

Regards

Felix

Link to comment
Share on other sites

There should only be one stage per renderer. If you want multiple containers within the stage, use DisplayObjectContainers.

 

A PIXI.Stage is the root of the scene graph, think of it as immutable within your renderer. You can have each "level" be a DisplayObjectContainer that is added/removed to/from the stage at will.

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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

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