background works
This commit is contained in:
parent
8affb416da
commit
0e2595df60
1
.idea/.idea.StarSkyPresenter/.idea/.name
generated
Normal file
1
.idea/.idea.StarSkyPresenter/.idea/.name
generated
Normal file
@ -0,0 +1 @@
|
|||||||
|
StarSkyPresenter
|
||||||
@ -76,24 +76,9 @@ public partial class MainScript : Node2D
|
|||||||
IDeserializer deser = new DeserializerBuilder().Build();
|
IDeserializer deser = new DeserializerBuilder().Build();
|
||||||
Objects obj_conf = deser.Deserialize<Objects>(new StreamReader(configFile));
|
Objects obj_conf = deser.Deserialize<Objects>(new StreamReader(configFile));
|
||||||
List<SceneConfig> scene_conf = deser.Deserialize<List<SceneConfig>>(new StreamReader(scenesFile));
|
List<SceneConfig> scene_conf = deser.Deserialize<List<SceneConfig>>(new StreamReader(scenesFile));
|
||||||
|
|
||||||
this._stars.Clear();
|
this._stars.Clear();
|
||||||
|
|
||||||
Image bgImage = Image.LoadFromFile("resources/" + obj_conf.background);
|
|
||||||
GD.Print("bgImage: " + bgImage);
|
|
||||||
GD.Print("Resource Path: " + "resources/" + obj_conf.background);
|
|
||||||
ImageTexture bgTexture = ImageTexture.CreateFromImage(bgImage);
|
|
||||||
TextureRect background = this.GetNode<TextureRect>("/root/Main/Projection/Background");
|
|
||||||
//this._background = new TextureRect();
|
|
||||||
background.SetTexture(bgTexture);
|
|
||||||
background.Position = Vector2.Zero;
|
|
||||||
background.Size = projection.GetSize();
|
|
||||||
background.Visible = true;
|
|
||||||
//background.ZIndex = 5;
|
|
||||||
//this.GetNode<Node>("/root/Main/Projection").AddChild(this._background);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
foreach (StarConfig star_config in obj_conf.stars)
|
foreach (StarConfig star_config in obj_conf.stars)
|
||||||
{
|
{
|
||||||
Sprite2D sprite = new Sprite2D();
|
Sprite2D sprite = new Sprite2D();
|
||||||
@ -115,8 +100,11 @@ public partial class MainScript : Node2D
|
|||||||
this._stars.Add(star_config.id, star);
|
this._stars.Add(star_config.id, star);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _background = projection.GetNode<Node>("Background");
|
||||||
|
|
||||||
foreach (Node child in projection.GetChildren())
|
foreach (Node child in projection.GetChildren())
|
||||||
{
|
{
|
||||||
|
if (child == _background) continue;
|
||||||
projection.RemoveChild(child);
|
projection.RemoveChild(child);
|
||||||
child.QueueFree();
|
child.QueueFree();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
[gd_scene load_steps=4 format=3 uid="uid://lychvawyirrs"]
|
[gd_scene load_steps=5 format=3 uid="uid://lychvawyirrs"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://77crqavwamsd" path="res://MainScript.cs" id="1_0e48y"]
|
[ext_resource type="Script" uid="uid://77crqavwamsd" path="res://MainScript.cs" id="1_0e48y"]
|
||||||
[ext_resource type="Script" uid="uid://dg0qtnm4epowu" path="res://Controller.cs" id="1_wtcfe"]
|
[ext_resource type="Script" uid="uid://dg0qtnm4epowu" path="res://Controller.cs" id="1_wtcfe"]
|
||||||
[ext_resource type="Script" uid="uid://criv4i3x63akl" path="res://Projection.cs" id="2_0e48y"]
|
[ext_resource type="Script" uid="uid://criv4i3x63akl" path="res://Projection.cs" id="2_0e48y"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://d3ddfgy71liqp" path="res://resources/background-01.jpg" id="4_0hol4"]
|
||||||
|
|
||||||
[node name="Main" type="Node2D"]
|
[node name="Main" type="Node2D"]
|
||||||
script = ExtResource("1_0e48y")
|
script = ExtResource("1_0e48y")
|
||||||
@ -67,3 +68,4 @@ script = ExtResource("2_0e48y")
|
|||||||
[node name="Background" type="TextureRect" parent="Projection"]
|
[node name="Background" type="TextureRect" parent="Projection"]
|
||||||
offset_right = 40.0
|
offset_right = 40.0
|
||||||
offset_bottom = 40.0
|
offset_bottom = 40.0
|
||||||
|
texture = ExtResource("4_0hol4")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user