Implemented 2 test scripts.

This commit is contained in:
Relintai 2023-12-17 02:45:48 +01:00
parent 88e8d53c52
commit cba738c98c
3 changed files with 70 additions and 1 deletions

View File

@ -1 +0,0 @@
extends SceneTree

51
test_2d_phys.gd Normal file
View File

@ -0,0 +1,51 @@
extends SceneTree
func _initialize():
print("_initialize")
debug_collisions_hint = true
# Ground
var static_body = StaticBody2D.new()
root.add_child(static_body)
static_body.transform.origin = Vector2(500, 621)
var cs = CollisionShape2D.new()
static_body.add_child(cs)
cs.shape = RectangleShape2D.new()
cs.shape.extents = Vector2(1000, 40)
# "player"
var rigid_body = RigidBody2D.new()
root.add_child(rigid_body)
rigid_body.transform.origin = Vector2(500, 0)
rigid_body.angular_velocity = 0.1
cs = CollisionShape2D.new()
rigid_body.add_child(cs)
cs.shape = CapsuleShape2D.new()
cs.shape.radius = 145
cs.shape.height = 108
var s = Sprite.new()
rigid_body.add_child(s)
var img = Image.new()
img.load("icon.png")
print(img)
print(img.get_size())
var tex = ImageTexture.new()
tex.create_from_image(img)
s.texture = tex

19
test_ui.gd Normal file
View File

@ -0,0 +1,19 @@
extends SceneTree
func _initialize():
print("_initialize")
var pc = PanelContainer.new()
root.add_child(pc)
pc.set_anchors_and_margins_preset(Control.PRESET_WIDE)
var vb = VBoxContainer.new()
pc.add_child(vb)
var b = Button.new()
vb.add_child(b)
b.text = "test"