tink icon indicating copy to clipboard operation
tink copied to clipboard

Interactive objects still interacting when removed from stage

Open Armegalo opened this issue 8 years ago • 4 comments

Found that interactive objects are still interacting (and causing bugs as they do so) when removed from stage. Tried with makeInteractive and makeDraggable

Additionally makeUndraggable seems to prevent the sprite ever being made draggable again!

Armegalo avatar May 30 '17 10:05 Armegalo

Is there any solution?, i just bought the book to learn more and find this bug, and that makes me feel a little worried about my decision, its been 2 months since this question and doesn't have any reply.

Since the book was written Pixi has changed a lot - I suspect keeping code in line with current versions can sometimes take a lot of effort.

I got around this by not removing things from the stage and not using makeUndraggable. Switching visible to false works well enough, and if it doesn't, set it's co-ords off screen.

Luckily makeInteractive is (now?) a pixi native command, so you don't need tink to use it.

Armegalo avatar Aug 21 '17 19:08 Armegalo

Hi, Armegalo, thanks for you answer, i manage to figure out there was an enabled property, since visible = false doesn't prevent buttons from being interactive and i didn't want to remove childs, found there was this property and make buttons to not interact, its not in the docs, at least i haven't found it neither in the PIXI Free tutorials, book nor Tink tutorial. So using this property i came with this solution.

PIXI.Container.prototype.hide = function(){
	this.children.forEach(function(child){
		child.enabled = false;
	});

	this.visible = false;
};

Maybe use another word instead of hide since is too generic.

Thanks for the tip :)

Armegalo avatar Aug 23 '17 10:08 Armegalo