Once I save a tree of nodes as a custom scene, the entire tree is folded into a single node in the scene dock. Within the inspector dock, the scene's node is represented only by the original top-level node before creating the scene.
So e.g., if, following the beginner tutorial, I try to create the following hierarchy:
RigidBody2D
├── CollisionShape2D
└── Sprite
and then save my RigidBody2D node as a scene called "Ball", the scene dock only shows:
BallN
for every instance of the Ball scene, hiding the hierarchy encapsulated under the new scene node.
The inspector still reveals that Ball scenes are actually RigidBody2D nodes, but is there a way to reveal CollisionShape2D and Sprite as the child nodes Ball is composed of, preferably within the scene dock itself?
Aside from looking at the inspector dock to see whether the entire object hierarchy is shown, I tried searching online for the answer, to no avail.
While experimenting, I coincidentally found the answer due to my own clumsiness with a laptop's touchpad: if you double click an instance of the custom scene in the viewport, a new scene viewport opens up and gains focus, which only consists of the double-clicked scene and includes its entire node hierarchy.
This viewport can be used to edit the scene. Changes to the scene have an effect of all its instances within other scenes as well.
EDIT: Looking around a bit more, I found that the equivalent action to the double-tap would be right-clicking an instance of the scene in the scene dock and selecting "Open in Editor" from the context menu.
Alternatively, each instance's node hierarchy can be made visible by checking the box "Editable Children" in the context menu, which, considering that the context menu belongs to a single instance only, I assume provides for per-instance editing.
EDIT: I'll wait to see if someone has a better answer, maybe with more details or better convenience, and will accept it instead of my own answer.
Related
I want to build a game and therefore I would like to create a game menu. This menu should be in front of the scene, but not totally hide it, somehow sticking at the lens of the camera. My first idea was to create planes as buttons and position them at the same position as the nearplane and move it with the camera.
Is there also a easier way to do this?
(I also saw this, but I don't know how to do it without qml)
The way games make HUDs or menus is by (I think) using orthographic projection which makes it unnecessary to have them at the near-plane (and gets rid of some side effects). I didn't find anything nicer than this to describe orthographic projections.
So to implement this you would have two framegraph branches:
Draw your objects as normal
Draw your menu using orthographic projection
The elements of the menu could be planes like you said. You can add QObjectPickers to the planes and then react to the clicks.
I have implemented an example for the opposite thing: I created a framegraph that draws a background image behind the 3D scene. It needs adjusting for rescaling the window but should give you the general idea. You can find the project here.
(This is a related question regarding how to put normal Qt widgets like QPushButton in a Qt3D window.)
I'm sketching a UI in Scene Builder and was a bit surprised about the layout behaviors.
In XCode I'm used to define distance constraints so that widgets will stick to a side of a given container and won't overlap each other when window is resized.
In SB it seems that I have to wrap widgets in HBOXes before I can glue them to a corner in a parent Anchor container. Is that correct or am I missing something?
Also, I'd like to maintain a fixed distance between widgets but HBOX doesn't seem to provide one by default.
Is there a layout manager that provides "springy" distance minimums like Qt or Apple?
TIA,
Eddy
I'm trying to understand (in general terms) the difference between a javafx 2 Scene and Pane. I can get them to work, but I haven't found a clear explanation of what functionality each provides.
The javadoc api defines a Scene as "the container for all content in a scene graph". A Pane (subclass of Region, Parent, Node) is also a container (since widgets like Button) get added to it, rather than to Scene. Apparently Pane handles layout and Scene does not.
Or to put it another way: widgets get added to Panes, a Pane is attached to a Scene, and a Scene is attached to the top level container, Stage. Since Pane does layout and can have properties set such as size, css style, etc., what functionality does the Scene provide? It does appear to be required.
Thanks
what functionality does the Scene provide?
Why don't you just compare the Javadoc of both?
E.g.
Scene is not a Node
Scene has a camera and a window property
...
So you have only one Scene per Stage but possibly several Panes (a Pane is-a Node).
The Scene is the start of, well, the scence graph. But it is more light-weight than a Stage/ Windows, AFAIK.
Scene class is the container for all content in a scene graph While Pane Class is subclass of Scene Class.
In Scene u can set element(Pane) using (SceneObject).setroot() method while In pane u can set element(Node) using (Pane Object).getchildren.add(element(Node)Object).
I'm pretty new to javafx so I'm trying to learn here so please be reasonable and don't dis away my question, I really appreciate any help at all, thanks!
I would like to know how I could move an object, let's say this circle on different events, like keypress or mouseclick, mousemove, whatever.
Circle circle = new Circle();
circle.setCenterX(100.0f);
circle.setCenterY(100.0f);
circle.setRadius(50.0f);
Do I need to use that KeyFrame thing I saw on the javafx site tutorial, or how does this work?
I would not have asked this here if I weren't feeling so lost, honestly.
So to make this clear: What is the code for moving objects that I created, by using events?
EDIT: By moving it I mean, press up key and it moves up by a few pixels, transform it maybe, with another key, or click somewhere on the scene and make it move there instantly or travel there with a certain speed. I don't have to redraw it like you need to with html5 canvas, I hope, right?
I don't have to redraw it like you need to with html5 canvas, I hope, right?
Not if you are using a standard JavaFX scene graph as opposed to a JavaFX canvas.
I would like to know how I could move an object, let's say this circle on different events, like keypress or mouseclick, mousemove, whatever
There are three ways to move a Shape:
You can adjust the shape's geometry (e.g. the centerX/centerY properties of a circle).
You can adjust the shape's layout (e.g. it's layoutX/layoutY properties).
You can adjust the shape's translation (e.g. it's translateX/translateY properties).
You can think of the layout as the home position for the object; i.e. where it should normally be in the context of it's parent group. You can think of it's translation transform as a temporary position for an object (often used when the object is being animated).
If you are using a layout pane such as a VBox or TilePane, then the layout pane will handle setting the layout co-ordinates of the child node for you. If you are using a simple Group or a plain Pane or Region, then you are responsible for setting the correct layout values for the child nodes.
To listen for events, set event handlers on Nodes or Scenes.
Here is a small sample app which demonstrates the above. It places the object to be moved inside a Group and modifies the position of the object within a Group in response to various events.
I have an interface where i want to drag an element from a list of elements to a GridPane. The grid and the list are in different branches of the scene graph. Because of that, my draggable Node disapears behind the GridPane, when i want to drag it over the grid.
One possible solution would be to add the draggable node to a frontmost Pane, where it will be in front of all other nodes. Unfortunately this means i have to remove the node from its old position before i know that the drag and drop gesture will be successfull, which leads to all kinds of additional code.
Is there a way to have a node rendered in front of all other nodes without changing its position in the scene graph?
Is the "draggable Node" actually being moved around by the cursor? If so, you could create an Image from the node and drag that around?