// // Called every frame. 'delta' is the elapsed time since the previous frame. public override void _Process(float delta) { if (animNode.GetAnimation() == "Cat_idle") { myRand = randS.Next(1, 500); if (myRand == 390) { myAudioIdle.Play(); } } _assign_animation(); _check_is_grounded(); if (attack == false) { _get_input(); } MoveCharacter(delta); //Muss jeden Frame ausgeführt werden, nur so können wir feststellen, ob wir etwas //von oben zerquetschen //Nur, wenn wir uns nicht im Attack-Zustand befinden if (move_direction == -1) { animNode.SetFlipH(false); } else if (move_direction == 1) { animNode.SetFlipH(true); } //Animation soll stoppen bei einem Frame wenn wir gerade attackieren }
private void UpdateVisuals() { if (m_sprite == null) { return; } m_sprite.SetFlipH((m_velocity.x == 0) ? m_sprite.IsFlippedH() : (m_velocity.x < 0)); var animation = IsOnFloor() ? (m_velocity.x == 0 ? IdleAnimation : WalkAnimation) : (m_velocity.y < 0 ? JumpAnimation : FallAnimation); if (m_sprite.GetAnimation() != animation) { m_sprite.SetAnimation(animation); m_sprite.Play(); } }