Only show particle when ball is top speed
This commit is contained in:
parent
5747a036c3
commit
84f9fef897
@ -1,6 +1,7 @@
|
|||||||
extends Actor
|
extends Actor
|
||||||
|
|
||||||
export var top_speed: = 1000
|
export var top_speed: = 1000
|
||||||
|
onready var particles: Particles2D = $Particles2D
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
randomize()
|
randomize()
|
||||||
@ -15,8 +16,12 @@ func _on_BounceCheck_body_entered(body: PhysicsBody2D) -> void:
|
|||||||
bounce(body)
|
bounce(body)
|
||||||
|
|
||||||
func bounce(object: PhysicsBody2D) -> void:
|
func bounce(object: PhysicsBody2D) -> void:
|
||||||
if speed.x <= top_speed:
|
if speed.x >= top_speed:
|
||||||
|
speed.x = top_speed
|
||||||
|
particles.visible = true
|
||||||
|
else:
|
||||||
speed.x *= 1.1
|
speed.x *= 1.1
|
||||||
|
|
||||||
if object is Actor:
|
if object is Actor:
|
||||||
_direction.x = -_direction.x
|
_direction.x = -_direction.x
|
||||||
$"SFX/BounceSound-2".play()
|
$"SFX/BounceSound-2".play()
|
||||||
|
Loading…
Reference in New Issue
Block a user