Skip to content

Commit 215d63b

Browse files
author
Chris Bradfield
committed
Add KYN: PathFollow2D
1 parent 810761a commit 215d63b

File tree

17 files changed

+301
-0
lines changed

17 files changed

+301
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
; Engine configuration file.
2+
; It's best edited using the editor UI and not directly,
3+
; since the parameters that go here are not all obvious.
4+
;
5+
; Format:
6+
; [section] ; section goes between []
7+
; param=value ; assign values to parameters
8+
9+
10+
[application]
11+
12+
13+
name="KYN: PathFollow2D"
14+
icon="res://icon.png"
2.67 KB
Loading
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
gen_mipmaps=false
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
extends Path2D
2+
3+
onready var follow = get_node("follow")
4+
5+
var tween
6+
7+
func _ready():
8+
set_process(true)
9+
tween = Tween.new()
10+
add_child(tween)
11+
tween.interpolate_property(follow, "unit_offset",
12+
0, 1, 6,
13+
tween.TRANS_SINE,
14+
tween.EASE_IN_OUT)
15+
tween.set_repeat(true)
16+
tween.start()
17+
18+
func _process(delta):
19+
#follow.set_offset(follow.get_offset() + 350 * delta)
20+
pass
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[gd_scene load_steps=4 format=1]
2+
3+
[ext_resource path="res://path.gd" type="Script" id=1]
4+
[ext_resource path="res://playerShip1_orange.png" type="Texture" id=2]
5+
6+
[sub_resource type="Curve2D" id=1]
7+
8+
bake_interval = 5.0
9+
_data = {
10+
"points": Vector2Array( 0, 0, -29.7442, 102.212, 30.9651, 113.102, -124, -15, 270, 7.99998, 190.544, 480.562, -93.0001, 112, 179.504, -222.366, 646.732, 126.945, 0, 0, 106.967, 256.533, 919.528, 131.73, 122, -28, -336.892, 46.7009, 863.545, 495.562, 0, 0, -58.1719, -71.6515, 136.829, 44.826, 0, 0, 0, 0, 39.7685, 69.4146, 0, 0, 0, 0, 31.0336, 112.718 )
11+
}
12+
13+
[node name="path" type="Path2D"]
14+
15+
curve = SubResource( 1 )
16+
script/script = ExtResource( 1 )
17+
18+
[node name="follow" type="PathFollow2D" parent="."]
19+
20+
transform/pos = Vector2( 30.9651, 113.102 )
21+
transform/rot = -105.319
22+
offset = 0.0
23+
h_offset = 0.0
24+
v_offset = 0.0
25+
rotate = true
26+
cubic_interp = true
27+
loop = true
28+
lookahead = 4.0
29+
30+
[node name="sprite" type="Sprite" parent="follow"]
31+
32+
transform/rot = -90.0
33+
transform/scale = Vector2( 0.8, 0.8 )
34+
texture = ExtResource( 2 )
35+
36+
2.52 KB
Loading
3.27 KB
Loading
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
extends RigidBody2D
2+
3+
func _ready():
4+
set_process_input(true)
5+
6+
func _input(event):
7+
pass
8+
9+
func _on_ball_input_event( viewport, event, shape_idx ):
10+
#print(event.type)
11+
if event.type == 3:
12+
set_linear_velocity(Vector2(rand_range(-200, 200), -400))
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
[gd_scene load_steps=4 format=1]
2+
3+
[ext_resource path="res://ball.gd" type="Script" id=1]
4+
[ext_resource path="res://elementMetal001.png" type="Texture" id=2]
5+
6+
[sub_resource type="CircleShape2D" id=1]
7+
8+
custom_solver_bias = 0.0
9+
radius = 35.0
10+
11+
[node name="ball" type="RigidBody2D"]
12+
13+
transform/pos = Vector2( 365, 290 )
14+
input/pickable = true
15+
shapes/0/shape = SubResource( 1 )
16+
shapes/0/transform = Matrix32( 1, 0, 0, 1, 0, 0 )
17+
shapes/0/trigger = false
18+
collision/layers = 1
19+
collision/mask = 1
20+
mode = 0
21+
mass = 1.0
22+
friction = 0.25
23+
bounce = 0.3
24+
gravity_scale = 5.0
25+
custom_integrator = false
26+
continuous_cd = 0
27+
contacts_reported = 5
28+
contact_monitor = true
29+
sleeping = false
30+
can_sleep = true
31+
velocity/linear = Vector2( -1000, 0 )
32+
velocity/angular = 0.0
33+
damp_override/linear = -1.0
34+
damp_override/angular = -1.0
35+
script/script = ExtResource( 1 )
36+
__meta__ = {
37+
"_edit_group_": true
38+
}
39+
40+
[node name="Sprite" type="Sprite" parent="."]
41+
42+
visibility/light_mask = 33
43+
texture = ExtResource( 2 )
44+
45+
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
46+
47+
shape = SubResource( 1 )
48+
trigger = false
49+
_update_shape_index = 0
50+
51+
[connection signal="input_event" from="." to="." method="_on_ball_input_event"]
52+
53+
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
[gd_scene load_steps=3 format=1]
2+
3+
[ext_resource path="res://Crate.png" type="Texture" id=1]
4+
5+
[sub_resource type="RectangleShape2D" id=1]
6+
7+
custom_solver_bias = 0.0
8+
extents = Vector2( 50, 50 )
9+
10+
[node name="crate" type="RigidBody2D"]
11+
12+
transform/pos = Vector2( 185, 270 )
13+
input/pickable = false
14+
shapes/0/shape = SubResource( 1 )
15+
shapes/0/transform = Matrix32( 1, 0, 0, 1, 0, 0 )
16+
shapes/0/trigger = false
17+
collision/layers = 1
18+
collision/mask = 1
19+
mode = 0
20+
mass = 1.0
21+
friction = 1.0
22+
bounce = 0.3
23+
gravity_scale = 3.0
24+
custom_integrator = false
25+
continuous_cd = 0
26+
contacts_reported = 0
27+
contact_monitor = false
28+
sleeping = false
29+
can_sleep = true
30+
velocity/linear = Vector2( 0, 0 )
31+
velocity/angular = 0.0
32+
damp_override/linear = -1.0
33+
damp_override/angular = -1.0
34+
__meta__ = {
35+
"_edit_group_": true
36+
}
37+
38+
[node name="Sprite" type="Sprite" parent="."]
39+
40+
texture = ExtResource( 1 )
41+
42+
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
43+
44+
shape = SubResource( 1 )
45+
trigger = false
46+
_update_shape_index = 0
47+
48+

0 commit comments

Comments
 (0)