I create a loading screen using simple graphic elements. For example:
rotatingRingPicture = new Picture("Ring");
rotatingRingPicture.setImage(assetManager, "Textures/Loading.png", true);
int w = settings.getWidth()/8;
int h = w;
rotatingRingPicture.setWidth(w);
rotatingRingPicture.setHeight(h);
rotatingRingPicture.setPosition(settings.getWidth()/2,settings.getHeight()/2);
guiNode.attachChild(rotatingRingPicture);
I show to the user a rotating loading ring until the game scene is uploading in a separate thread.
I also want that the words: LOADING… PLEASE WAIT change their transparency from min up to max in according to a sinus dependency.
I could create it using LibGDX or Processing but in JMonkey engine I can not find methods to:
change the transparency of a gui-child
change the offset/anchor of a gui-child to rotate it around its center point.
How can I perform this actions? I need to change the guiChild transparency and rotate the guiChild around its center point.
@pspeed thanks, I created a node and added the rotating ring to it and it works. In simpleInitApp():
rotatingRingPicture = new Picture("Ring");
rotatingRingPicture.setImage(assetManager, "Textures/Loading.png", true);
int w = settings.getWidth()/12;
int h = w;
rotatingRingPicture.setWidth(w);
rotatingRingPicture.setHeight(h);
rotatingRingPicture.setLocalTranslation(-w/2, -h/2,0);
rotatingRingNode = new Node();
rotatingRingNode.setLocalTranslation(settings.getWidth()/2, settings.getHeight()/4, 0);
rotatingRingNode.attachChild(rotatingRingPicture);
guiNode.attachChild(rotatingRingNode);
in simpleUpdate(float):
Quaternion rotation = new Quaternion();
rotation.fromAngles(0,0,ringAngle);
rotatingRingPicture.center().setLocalRotation(rotation);
ringAngle-=0.02f;
About changing transparency. I have not understood yet how should I use materials with GUI-children.
GUI children are not different than regular scene graph children. A Picture is just a hacky subclass of Geometry… it has a Material like any other Geometry.