Hide Entity Behind A Specific Area In The World


(Zouhair Elamrani Abou Elassad) #22

Hi again, i’m still using this wonderful class of yours :slight_smile:, i was just wondering if it’s possible to make the MagicMirror prevent mouse collisions (using masks) with buttons that exist behind it ?


(rostok) #23

Don’t know how what kind of buttons you use and how they are implemented. Provided that you can inject your code in button being pressed handler you could get all the MagicMirror objects with world.getClass() and simply iterate through them and see if there is actually any mirror above the button and also if cursor position is colliding with it. In case you have simple MagicMirror with rectangular area test is simple. In case you use mask you will have to test position with master’s graphic’s. If it is an Image you will have to use getPixel() in BitmapData.


(Zouhair Elamrani Abou Elassad) #24

Thanks for the quick feedback, in fact these are my buttons, once i click on the settings button(bottom right), i hide my Story and Survival buttons using magic mirror (picture 2).

But when i hover my mouse on top of the Magic Mirror (just where the buttons are) it’s like there is no mirror on top of them, i’m using Mask to detect collision when it comes to the button.

Thank you.


(rostok) #25

i think this is overcomplicated or i dont get the idea. what would you like to achieve?


(Zouhair Elamrani Abou Elassad) #26

The idea is that i want to show a credit popup, it’s transparent but i don’t want it to show the buttons behind it instead, it should show the parallax in the background, what i did is i created a Mirror of the parallax in the popup but i noticed that even when the buttons are hidden behind the Mirror, their collisions with the mouse is always active, there a few solutions i can try, like hide all the entities behind the Mirror(alpha = 0) and in this case i will no longer need the Mirror, but in other cases there are a lot of entities so it’ll be so frustrating.


(rostok) #27

But aren’t you really just trying to hide these buttons when credits is shown?


(Zouhair Elamrani Abou Elassad) #28

That’s the idea, but also there will be a text in that Popup that the user may interact with, so i have to disable access to the hidden buttons.


(rostok) #29

So why you just don’t hide/deactivate buttons once popup is visible?


(Zouhair Elamrani Abou Elassad) #30

Yes that’s the alternative idea, in fact; there other worlds where i’m willing to use the same mechanism, but in those worlds it’s not just about two buttons, but instead there are images, sliders, texts and stuff, so i’ll have to hide all of them which can be good, but i thought why not find out a better solution :), but eventually if nothing works out, i’m gonna have to go for that :slight_smile: