0 votes
extends Node2D

func _ready():
    pass # Replace with function body.

func _draw():
    draw_rect(Rect2(Vector2(0,0),Vector2(25,480)), Color("003366"), true)
    draw_rect(Rect2(Vector2(295,0),Vector2(25,480)), Color("003366"), true)
    draw_rect(Rect2(Vector2(25,0),Vector2(5,480)), Color(255, 255, 0), true)
    draw_rect(Rect2(Vector2(30,0),Vector2(5,480)), Color(255, 255, 255), true)
    draw_rect(Rect2(Vector2(285,0),Vector2(5,480)), Color(255, 255, 255), true)
    draw_rect(Rect2(Vector2(290,0),Vector2(5,480)), Color(255, 255, 0), true)

    draw_rect(Rect2(Vector2(0,0),Vector2(360,30)), Color(0,0,0),true)
    draw_rect(Rect2(Vector2(0,30),Vector2(360,5)), Color(0,0,0,0.4),true)

why is the yellow and white rect is drawn on the top of the transparent black?
this is a test project with just a Node2D and a script attached to it.

in Engine by (108 points)

1 Answer

+1 vote

I don't understand very well how godot mixes the colors, but it behaves in this way when the viewport is used for 3d. With this line in the _ready function: get_viewport ().usage = Viewport.USAGE_2D the colors are mixed as expected. If you don't want to put your main viewport in 2d, you can create another one with 2d enabled.

by (2,058 points)

Thank you so much !!!
so following your guidance I ended up changing intended usage under Project Settings >General>Rendering>Quality from 3D to 2D and it worked like charm. I would like to understand why but at least now it work.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.