Added canvas background layer creation functionality.

This commit is contained in:
Mono 2021-11-19 11:10:04 +01:00
parent 0b3c07d11f
commit 221f4547aa
3 changed files with 36 additions and 3 deletions

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=17 format=2]
[gd_scene load_steps=19 format=2]
[ext_resource path="res://TryingOutSomethingNew.gd" type="Script" id=1]
[ext_resource path="res://Node2D.gd" type="Script" id=2]
@ -107,9 +107,24 @@ void fragment() {
ALBEDO = texture(table, UV).rgb;
}"
[sub_resource type="Image" id=18]
data = {
"data": PoolByteArray( 0, 0, 128, 62, 0, 0, 0, 0, 0, 0, 0, 0, 154, 153, 25, 62, 0, 0, 0, 0, 0, 0, 128, 62, 0, 0, 0, 0, 154, 153, 25, 62, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 63, 0, 0, 128, 62, 0, 0, 0, 0, 0, 0, 0, 0, 154, 153, 25, 190, 0, 0, 0, 0, 0, 0, 128, 62, 0, 0, 0, 0, 154, 153, 25, 190, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 191, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 63 ),
"format": "RGBAFloat",
"height": 1,
"mipmaps": false,
"width": 8
}
[sub_resource type="ImageTexture" id=19]
flags = 0
flags = 0
image = SubResource( 18 )
size = Vector2( 8, 1 )
[sub_resource type="ShaderMaterial" id=7]
shader = SubResource( 6 )
shader_param/table = SubResource( 16 )
shader_param/table = SubResource( 19 )
[sub_resource type="QuadMesh" id=8]

View File

@ -30,6 +30,7 @@ func _gui_input(event):
func _on_SummerDay_scene_changed(new_scene):
scene = new_scene
_update_fill_transform()
scene.connect("aspect_ratio_changed", self, "_update_CanvasLayer")
$Label.text = str(scene) + "\n" + str(scene.aspect_ratio)
@ -64,3 +65,20 @@ func _update_fill_transform():
func _update_view_transformation(transform):
view_transform = fill_transform * canvas_transform
emit_signal("view_transform_changed", view_transform)
func _update_CanvasLayer(new_aspect_ratio):
var new_polygon
if scene == null:
new_polygon = PoolVector2Array()
else:
new_polygon = PoolVector2Array(
[
Vector2.ZERO,
Vector2(scene.internal_width, 0.0),
Vector2(scene.internal_width, scene.internal_height),
Vector2(0.0, scene.internal_height)
]
)
$BackgroundLayer/CanvasLayer.polygon = new_polygon

View File

@ -87,7 +87,7 @@ _global_script_class_icons={
[application]
config/name="CGMationSomeday"
run/main_scene="res://Main.tscn"
run/main_scene="res://addons/summer_day/main_screen.tscn"
config/icon="res://icon.png"
[autoload]