소스 검색

Ability to keep collisionshapes and collisionpolygons when running the game.
Works for 2D and 3D
These are still just helpers in case you want to animate them or access them
directly.
Modifying the real shapes is still done via CollisionObject and CollisionObject2D APIs
But an API was added so you can query which shapes from CollisionObject correspond to which CollisionShape.

Have Fun!

reduz 10 년 전
부모
커밋
d2977d2b37

+ 21 - 0
2d/dynamic_collision_shapes/ball.gd

@@ -0,0 +1,21 @@
+
+extends RigidBody2D
+
+# member variables here, example:
+# var a=2
+# var b="textvar"
+
+var timeout=5
+
+func _process(delta):
+	timeout-=delta
+	if (timeout<1):
+		set_opacity(timeout)
+	if (timeout<0):
+		queue_free()
+func _ready():
+	set_process(true)
+	# Initialization here
+	pass
+
+

BIN
2d/dynamic_collision_shapes/ball.png


BIN
2d/dynamic_collision_shapes/ball.scn


BIN
2d/dynamic_collision_shapes/box.png


BIN
2d/dynamic_collision_shapes/circle.png


+ 23 - 0
2d/dynamic_collision_shapes/dynamic_colobjs.gd

@@ -0,0 +1,23 @@
+
+extends Node2D
+
+# member variables here, example:
+# var a=2
+# var b="textvar"
+const EMIT_INTERVAL=0.1
+var timeout=EMIT_INTERVAL
+
+func _process(delta):
+	timeout-=delta
+	if (timeout<0):
+		timeout=EMIT_INTERVAL
+		var ball = preload("res://ball.scn").instance()
+		ball.set_pos( Vector2(randf() * get_viewport_rect().size.x, 0) )
+		add_child(ball)
+			
+func _ready():
+	set_process(true)
+	# Initialization here
+	pass
+
+

BIN
2d/dynamic_collision_shapes/dynamic_colobjs.scn


+ 4 - 0
2d/dynamic_collision_shapes/engine.cfg

@@ -0,0 +1,4 @@
+[application]
+
+name="Run-Time CollisionShape"
+main_scene="res://dynamic_colobjs.scn"

BIN
2d/dynamic_collision_shapes/poly.png


BIN
2d/isometric/dungeon.scn


BIN
2d/lights_shadows/light_shadows.scn


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 4 - 20
2d/platformer/stage.xml


이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.