Screenmask

  • Ok needs some guidance on Declaring a Screenmask and how you turn it on? It should be part of the panel so it moves into the background?


    panel.setScreenmask(new ImageInformation(plugin, "/assets/goldmask.png"));

  • I love that I am talking to myself here. It is what I do in real anyway.


    Well could not figure out mask.. but what I wanted was a background anyway and that is done with an image .. labels will show up on top. The size is clipped a little from the 400 by 400 panel and centered like the panel so that the border shows. Labels show up top layer. Not sure if there is a layering technique other than visibility.


    GuiImage goldback = new GuiImage(0.5f,0.5f,true,396,396,false);
    goldback.setImage(new ImageInformation(plugin, "/assets/gold.jpg"));
    goldback.setClickable(false);
    goldback.setPivot(PivotPosition.Center);
    goldback.setVisible(false);
    goldback.setColor(1f,1f,1f,0.5f);


    GuiLabel logo = new GuiLabel(0.26f,0.8f,true);
    logo.setText(" Angriff's Lair ");
    logo.setClickable(false);
    logo.setFontSize(36);
    logo.setFont(Font.Handdrawn);
    logo.setFontColor(1f,1f,0f,1f);
    logo.setColor(1f,1f,1f,0.1f);
    logo.setVisible(false);



    FYI - Toggle boolean visible for showing.



    I am sure there is a better way but this works and I wanted to share it with those beginners like me. :| If you need a look it is up on my server.

    Edited once, last by angriff: added label and note ().

  • The screen-wide mask is intended to put a mask texture on the screen which determines which parts of an element are visible. For example, the map uses this feature: the map is just an image, but consists of several map tiles (small separate images). There is a screen-wide mask image which has a similar shape as the map image, and it is applied to the map tiles. As a result, the map tiles don't have sharp borders, instead they're faded when they're close to the map edge.


    Unfortunately this feature isn't fully implemented in the API. The setScreenmask() method only became available by accident, I'm sorry for the confusion :(


    However, what did you try to achieve exactly? If you just want a certain element to be invisible, using the setVisible() method is indeed the way to go.

  • The screen-wide mask is intended to put a mask texture on the screen which determines which parts of an element are visible. For example, the map uses this feature: the map is just an image, but consists of several map tiles (small separate images). There is a screen-wide mask image which has a similar shape as the map image, and it is applied to the map tiles. As a result, the map tiles don't have sharp borders, instead they're faded when they're close to the map edge.


    Unfortunately this feature isn't fully implemented in the API. The setScreenmask() method only became available by accident, I'm sorry for the confusion :(


    However, what did you try to achieve exactly? If you just want a certain element to be invisible, using the setVisible() method is indeed the way to go.

    I put a background picture on a GUI. It works .. I was worried that the labels would not show through so I thought the mask would work like a mask in Paintshop Pro. It is fine what I have done. Thanks for the reponse


  • Oh, actually the "z position" (i.e. the order in which the elements are visible) depends on when the element was created (if element A is created after element B, it's usually visible in front of element B) ;) However, if you want to make sure that a certain element is always visible in front of another element, you can add it as a "child" element: https://javadoc.rising-world.n…world.api.gui.GuiElement-
    In this case the element position depends on the parent position (i.e. moving the parent moves the child element automatically), and child elements are always visible in front of their parent (although keep in mind that you have to update the label position in this case, since all coordinates will be relative too the parent coordinates if added as child)

  • Well they were added as child... the background added last as I kept trying mask. I even turned the background into an Alpha channel but that did not work either but that was when I was using maks.. I did have some issue with the background.. but finally turning the color white for the image made if visible. Black mixed and I could not see it. I guess I just lucked into it...which is how most of my programming is going.. read a little .try allot. Bought a fast test server setup so I can try it before publishing on the public server.. eventually the public will move to the fast server.

Participate now!

Don’t have an account yet? Create a new account now and be part of our community!