The ad scales yay

This commit is contained in:
Zoey Kitt 2024-11-16 11:47:54 -06:00
parent 99f3bb77b9
commit 9eaa524fba
3 changed files with 21 additions and 10 deletions

View file

@ -18,9 +18,6 @@ func _on_microgame_spawn_timer_timeout() -> void:
var window_scene = preload("res://scenes/microgames/ad/ad_window.tscn")
var window_instance = window_scene.instantiate()
add_child(window_instance)
var microgame_scene = preload("res://scenes/microgames/ad/ad.tscn")
var microgame_instance = microgame_scene.instantiate()
window_instance.add_child(microgame_instance)
# Randomize window position
var screen_size = DisplayServer.screen_get_size()

View file

@ -6,7 +6,21 @@ extends "res://scenes/microgames/microgame_window.gd"
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Stretch the funny image to fit in the window
var window_size = get_viewport().size
var sprite := $Sprite2D
## Scale!?
sprite.scale = Vector2(
float(window_size.x) / float(sprite.texture.get_width()),
float(window_size.y) / float(sprite.texture.get_height())
)
print(window_size)
print(Vector2(sprite.texture.get_width(), sprite.texture.get_height()))
print(sprite.scale)
print(Vector2(
float(window_size.x) / float(sprite.texture.get_width()),
float(window_size.y) / float(sprite.texture.get_height())
))
# Called every frame. 'delta' is the elapsed time since the previous frame.

View file

@ -2,13 +2,13 @@
[ext_resource type="PackedScene" uid="uid://b2awdq32lxnef" path="res://scenes/microgames/microgame_window.tscn" id="1_gtv65"]
[ext_resource type="Script" path="res://scenes/microgames/ad/ad_window.gd" id="2_h3lwj"]
[ext_resource type="PackedScene" uid="uid://dekqkxftnx3gd" path="res://scenes/microgames/ad/ad.tscn" id="3_j4tnf"]
[ext_resource type="Texture2D" uid="uid://cpmvcepbd43p4" path="res://scenes/microgames/ad/ad_images/metaverse.png" id="4_gakxr"]
[node name="Window" instance=ExtResource("1_gtv65")]
size = Vector2i(1024, 864)
content_scale_size = Vector2i(1024, 1024)
content_scale_mode = 0
content_scale_factor = 0.58
size = Vector2i(824, 604)
content_scale_size = Vector2i(0, 0)
script = ExtResource("2_h3lwj")
[node name="Ad" parent="." index="0" instance=ExtResource("3_j4tnf")]
[node name="Sprite2D" type="Sprite2D" parent="." index="0"]
texture = ExtResource("4_gakxr")
centered = false