Exemplo n.º 1
0
 def test_write(self):
     """Test writing scene out to a file"""
     scene = GDScene()
     outfile = tempfile.mkstemp()[1]
     scene.write(outfile)
     with open(outfile, "r") as ifile:
         gen_scene = GDScene.parse(ifile.read())
     self.assertEqual(scene, gen_scene)
Exemplo n.º 2
0
    def setUpClass(cls):
        super(TestInheritedScenes, cls).setUpClass()
        cls.project_dir = tempfile.mkdtemp()
        with open(os.path.join(cls.project_dir, "project.godot"),
                  "w") as ofile:
            ofile.write("fake project")
        cls.root_scene = os.path.join(cls.project_dir, "Root.tscn")
        cls.mid_scene = os.path.join(cls.project_dir, "Mid.tscn")
        cls.leaf_scene = os.path.join(cls.project_dir, "Leaf.tscn")
        scene = GDScene.parse("""
[gd_scene load_steps=1 format=2]
[node name="Root" type="KinematicBody2D"]
collision_layer = 3
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
disabled = true
[node name="Sprite" type="Sprite" parent="."]
flip_h = false
[node name="Health" type="Control" parent="."]
[node name="LifeBar" type="TextureProgress" parent="Health"]
""")
        scene.write(cls.root_scene)

        scene = GDScene.parse("""
[gd_scene load_steps=2 format=2]
[ext_resource path="res://Root.tscn" type="PackedScene" id=1]
[node name="Mid" instance=ExtResource( 1 )]
collision_layer = 4
[node name="Health" parent="." index="2"]
pause_mode = 2
""")
        scene.write(cls.mid_scene)

        scene = GDScene.parse("""
[gd_scene load_steps=2 format=2]
[ext_resource path="res://Mid.tscn" type="PackedScene" id=1]
[sub_resource type="CircleShape2D" id=1]
[node name="Leaf" instance=ExtResource( 1 )]
shape = SubResource( 1 )
[node name="Sprite" type="Sprite" parent="." index="1"]
flip_h = true
""")
        scene.write(cls.leaf_scene)