Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | lincolnpepper |
I have completed most of the dodge the creeps game, to the point where it is playable. However, there are two problems. First of all, the creeps don’t play their animation and stay the same, even though i put in all of the frames for all the animations. Secondly, when i die the creeps keep spawning and the score keeps counting. I suspect it is because the Game_Over function in Main doesn’t get called since it controls both those things when it triggers, but idk where the problem could be. Here is the main code if it helps:
extends Node
export (PackedScene) var Mob
var score
func _ready():
randomize()
func new_game():
score = 0;
$Player.start($StartPosition.position)
$StartTimer.start()
$HUD.show_message("Get Ready")
$HUD.update_score(score)
func _on_StartTimer_timeout():
$MobTimer.start()
$ScoreTimer.start()
$HUD.update_score(score)
func Game_Over():
$ScoreTimer.stop();
$MobTimer.stop();
$HUD.Game_Over()
func _on_ScoreTimer_timeout():
score += 1
func _on_MobTimer_timeout():
$MobPath/MobSpawnLocation.set_offset(randi())
var mob = Mob.instance()
add_child(mob)
var direction = $MobPath/MobSpawnLocation.rotation+PI/2
mob.position = $MobPath/MobSpawnLocation.position
direction += rand_range(-PI/4, PI/4)
mob.rotation = direction
mob.set_linear_velocity(Vector2(rand_range(mob.MIN_SPEED, mob.MAX_SPEED), 0).rotated(direction))
edit: i have solved the problem with the animation. I forgot to check the “play” box. I still need help with the second problem. If you need any more information, leave a comment asking for it.
I see you have a HUD method called GameOver() as well as a Main method called GameOver(). Perhaps you are accidentally calling the HUD method when you should be calling the Main method.
Diet Estus | 2018-03-20 20:27
The Game_Over function is triggered whenever the player is hit via a signal. Nothing else connects to it. Even if i lowercase it and redo the connection to it, it still does the same thing.
lincolnpepper | 2018-03-20 20:38