Problems with opacity in ColorRect and TextureRect

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ezesoler

Hi, I have a very strange problem, I have a scene with a ColorRect with a transparency of 50% when I do an addChild () of that scene in another scene, the color looks opaque without the transparency. I tried making a texture with a transparent png and the same thing happens to me.

If I add the scene in the editor and not by code the transparency if it works

I don’t understand why this happens.

my code is:

var lose_scn = load("res://screens/lose.tscn")

Video: Sin título 42.mp4 - Google Drive

I appreciate the help

I cannot reproduce this.

  • I created a scene of Other Node ColorRect. Set its color to a red transparency.
  • Attached/Linked it on top of ie HSlider positioned (0,0) in my main scene to check its transparency: OK
  • Next added a script to my main scene
  • Now both are over the same HSlider with a little overlap
  • The HSlider is visible and transparencies blend/add up


func _ready():
    var lose_scn = load("res://transparent-rect.tscn")
    var o = lose_scn.instance()
    o.rect_position.x = 10

clemens.tolboom | 2021-01-22 14:27

Is it possible the scene you are loading is not the same scene as you expect?

ejricketts | 2021-01-22 16:37

Tried adding the code in the _ready and the transparency if it works. Maybe the problem is because the scene is being added in a function called “lose” which is called from another scene like this

get_node ("/root/word").lose()

Keep investigating

ezesoler | 2021-01-22 21:48

I’m a fool, the problem was that the scene was added after a collision, this collision crept many times so when many scenes were created they overlapped haha.

Thanks for the help

ezesoler | 2021-01-22 22:17