Hi again, i’m still using this wonderful class of yours , i was just wondering if it’s possible to make the MagicMirror prevent mouse collisions (using masks) with buttons that exist behind it ?
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.
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.
i think this is overcomplicated or i dont get the idea. what would you like to achieve?
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.
But aren’t you really just trying to hide these buttons when credits is shown?
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.
So why you just don’t hide/deactivate buttons once popup is visible?
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