Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat
removeChild error on exiting and entering scene - Gideros Forum

removeChild error on exiting and entering scene

somezombiegmsomezombiegm Member
edited March 2014 in General questions
Sorry for the long question, I appretiate you reading this.

I have a general problem which involves my game objects and the menu bar which is on top of the screen. I have some "bullet" bitmaps which can fly in every direction, but since every time the user shoots I add a new child to the stage, the bullets end on top of the menu, which I dont want.

So to fix this, on my update function (which is called with the Event.ENTER_FRAME event) every time I add a new bullet as a child, I remove the menu and immediately add it as a child again. However the problem with this is that if i go back to the start scene (yeah I'm using ar2rs Game Template project) and then return to my game it keeps working, but if I change scene and return to my game scene a 3rd time, the "remove and then add" solution throws an error; on my remove line the error says: "The suplied sprite must be a child of the caller". I remove and add the menu like a thousand times before, I dont know why when I enter the scene for the third time it throws me this error, please help.

The menu bitmap IS being added as a child, but acording to the error it isnt.

I can't show any code cause it's too large, and when I reduce it for testing it with only two bitmaps, the error doesn't happen any more :S.

It would be good to know why this happens so I could fix it, however, another way around it would be welcome. Like for example a bitmap function that puts an image on top or behind. That would be cool actually.

Anyway, that was the question...

Comments

Sign In or Register to comment.