File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -52,22 +52,25 @@ func _ready():
5252 bullets .push_back (bullet )
5353
5454
55- func _process (delta ):
55+ func _process (_delta ):
56+ # Order the CanvasItem to update every frame.
57+ update ()
58+
59+
60+ func _physics_process (delta ):
5661 var transform2d = Transform2D ()
62+ var offset = get_viewport_rect ().size .x + 16
5763 for bullet in bullets :
5864 bullet .position .x -= bullet .speed * delta
5965
6066 if bullet .position .x < - 16 :
6167 # The bullet has left the screen; move it back to the right.
62- bullet .position .x = get_viewport_rect (). size . x + 16
68+ bullet .position .x = offset
6369
6470 transform2d .origin = bullet .position
6571
6672 Physics2DServer .body_set_state (bullet .body , Physics2DServer .BODY_STATE_TRANSFORM , transform2d )
6773
68- # Order the CanvasItem to update since bullets are moving every frame.
69- update ()
70-
7174
7275# Instead of drawing each bullet individually in a script attached to each bullet,
7376# we are drawing *all* the bullets at once here.
You can’t perform that action at this time.
0 commit comments