Masking/Clipping with control nodes

Godot Version

4.2.1

Question

I’m trying to create a visual effect where a curtain is swept aside to reveal a dialogue box. The dialogue box, for various reasons, consists of a Control node hierarchy.

My best guess so far is that clipping is the best way to create this effect. To do that, I need the dialogue box to be a child of the masking node. My understanding is that Control nodes shouldn’t ever be children of Sprite nodes, so it seems like that’s out. I don’t want to just use z-levels and global positioning, because I think that would mess up window resizing. On the third hand, so far it seems very difficult to navigate the complexities of having the masking node be a control node - everything keeps coming out the wrong size/wrong aspect ratio. This is just me messing with the inspector - I don’t have any custom code.

I think I’m about to dive into a long Control Node tutorial binge, but I’m wondering if anyone can give me advice on the topic first - is there an obvious, clean solution that I’m missing? Or is this just going to be a series of tradeoffs no matter what?

Many thanks!

My suggestion is:

  • Have the curtain sprite be a sibling of the dialogue box. Make sure it’s below the dialogue box in the scene tree so it will be visible over the dialoguebox.
  • Have the curtain sprite decrease it’s scale to sweep it aside. Make sure it’s scaled and moved into the direction you want it to sweep in.
  • You may need to wrap the curtain sprite into another control to better manipulate the size and scale.
1 Like

That’s a great idea, I’m gonna give that a shot. Thanks!

masking from CanvasItem can also be done with TextureRect, dont have to be Sprite2D

1 Like