0
Hello,
I’m a multimedia student and I’m working on my Professional Aptitude Test.
For this I decided to create a 2D RPG Zelda-like Game (for Android devices). For this I have used the Godot platform that makes use of Gdscript (Python derived language itself, optimized for games).
I have a whole player interface created, which has some small bugs.
When clicking the button to shoot, the player should start a small animation and only then the arrow would be created, for the moment, the player just shoots the arrow and jumps the whole animation.
func get_attack_input():
if Input.is_action_pressed("ui_accept") and not charging_bow and can_shoot || attack and not charging_bow and can_shoot:
charging_bow = true
velocity = Vector2.ZERO
sprite.play("Attack_Bow")
tween.interpolate_property(self, "bow_power", 3, 8, 5, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
tween.start()
elif Input.is_action_just_released("ui_accept") and can_shoot || attack and can_shoot:
charging_bow = false
tween.stop(self, "bow_power")
sprite.play("Idle")
var arrow_instance = arrow.instance()
var direction = -1 if sprite.flip_h else 1
arrow_instance.init(direction, bow_power)
get_parent().add_child(arrow_instance)
arrow_instance.global_position = global_position
arrow_instance.global_position.x += 16 * direction
bow_power = 0
print("Shoot")
#Optimize Arrow
if get_tree().get_nodes_in_group("arrows").size() >= 3:
for arrow in get_tree().get_nodes_in_group("arrows"):
arrow.queue_free()
print("deleted arrows")
#Disable Shoot
can_shoot = false
#Start Timer
timer.start()
I don’t know much about Python or Godot Engine, but there is not a missing indentation in all the lines after defining the function (first line)?
– Costamilam
where you got the function
get_tree()
?– Lucas
I reversed the question to the original version and changed the tag to [tag:Godot]
– Icaro Martins