mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-08 12:46:02 +00:00
Intro with new animator
This commit is contained in:
parent
d07fe420dd
commit
cd43b3361d
16 changed files with 788 additions and 19 deletions
49
Scripts/UI/MusicVisualizerCanvas.cs
Normal file
49
Scripts/UI/MusicVisualizerCanvas.cs
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
using Godot;
|
||||
using System;
|
||||
using GTweens.Builders;
|
||||
using GTweens.Easings;
|
||||
using GTweens.Tweens;
|
||||
using GTweensGodot.Extensions;
|
||||
|
||||
public partial class MusicVisualizerCanvas : CanvasLayer
|
||||
{
|
||||
private Label _nameLabel;
|
||||
private GTween _tween;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_nameLabel = GetNode<Label>("Title");
|
||||
_nameLabel.Hide();
|
||||
}
|
||||
|
||||
private void ResetLabel(string trackName, string authorName)
|
||||
{
|
||||
_nameLabel.Text = $"{trackName} ({authorName})";
|
||||
_nameLabel.SetAnchorsAndOffsetsPreset(Control.LayoutPreset.BottomRight, margin: 0);
|
||||
_nameLabel.Modulate = Colors.White;
|
||||
_nameLabel.Hide();
|
||||
}
|
||||
|
||||
public void ShowName(string trackName, string authorName)
|
||||
{
|
||||
_tween?.Kill();
|
||||
//_tween?.Complete();
|
||||
ResetLabel(trackName, authorName);
|
||||
_nameLabel.Show();
|
||||
|
||||
_tween = GTweenSequenceBuilder.New()
|
||||
.Append(_nameLabel.TweenPositionX(_nameLabel.Position.X + 32, 0f)) // Add offset
|
||||
.Join(_nameLabel.TweenModulateAlpha(0, 0f)) // Invisibilify
|
||||
.Append(_nameLabel.TweenPositionX(_nameLabel.Position.X - 32, 1f)) // Animate back
|
||||
.Join(_nameLabel.TweenModulateAlpha(1, 0.5f))
|
||||
.AppendTime(3f) // Wait before hiding
|
||||
.Append(_nameLabel.TweenPositionX(_nameLabel.Position.X + 32, 1f)) // Start moving and hiding
|
||||
.Join(_nameLabel.TweenModulateAlpha(0, 0.5f))
|
||||
.Append(_nameLabel.TweenPositionX(_nameLabel.Position.X - 32, 0f)) // Move back to default position
|
||||
.AppendCallback(() => _nameLabel.Hide())
|
||||
.Build();
|
||||
|
||||
_tween.SetEasing(Easing.OutCubic);
|
||||
_tween.Play();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue