mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-02-20 20:43:14 +00:00
Support frame delay
This commit is contained in:
parent
ecd479b4e2
commit
404d938565
7 changed files with 62 additions and 14 deletions
BIN
assets/graphics/misc/musical_note.png
Normal file
BIN
assets/graphics/misc/musical_note.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 192 B |
34
assets/graphics/misc/musical_note.png.import
Normal file
34
assets/graphics/misc/musical_note.png.import
Normal file
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dfjd72smxp6ma"
|
||||
path="res://.godot/imported/musical_note.png-f1be7cc6341733e6ffe2fa5b650b80c2.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/graphics/misc/musical_note.png"
|
||||
dest_files=["res://.godot/imported/musical_note.png-f1be7cc6341733e6ffe2fa5b650b80c2.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
|
@ -282,7 +282,7 @@ func process_animation(project := Global.current_project) -> void:
|
|||
for cel in frame.cels:
|
||||
var image := Image.new()
|
||||
image.copy_from(cel.get_image())
|
||||
var duration := frame.duration * (1.0 / project.fps)
|
||||
var duration := frame.get_duration_in_seconds(project.fps)
|
||||
processed_images.append(
|
||||
ProcessedImage.new(image, project.frames.find(frame), duration)
|
||||
)
|
||||
|
@ -298,7 +298,7 @@ func process_animation(project := Global.current_project) -> void:
|
|||
image.copy_from(crop)
|
||||
if trim_images:
|
||||
image = image.get_region(image.get_used_rect())
|
||||
var duration := frame.duration * (1.0 / project.fps)
|
||||
var duration := frame.get_duration_in_seconds(project.fps)
|
||||
processed_images.append(ProcessedImage.new(image, project.frames.find(frame), duration))
|
||||
|
||||
|
||||
|
|
|
@ -11,3 +11,17 @@ var user_data := "" ## User defined data, set in the frame properties.
|
|||
func _init(_cels: Array[BaseCel] = [], _duration := 1.0) -> void:
|
||||
cels = _cels
|
||||
duration = _duration
|
||||
|
||||
|
||||
func get_duration_in_seconds(fps: float) -> float:
|
||||
return duration * (1.0 / fps)
|
||||
|
||||
|
||||
func position_in_seconds(project: Project, start_from := 0) -> float:
|
||||
var pos := 0.0
|
||||
for i in range(start_from, project.frames.size()):
|
||||
var frame := project.frames[i]
|
||||
if frame == self:
|
||||
break
|
||||
pos += frame.get_duration_in_seconds(project.fps)
|
||||
return pos
|
||||
|
|
|
@ -404,10 +404,10 @@ func _sort_cel_indices_by_frame(a: Array, b: Array) -> bool:
|
|||
|
||||
|
||||
func _is_playing_audio() -> void:
|
||||
var layer := Global.current_project.layers[layer] as AudioLayer
|
||||
var audio_length := layer.audio.get_length()
|
||||
var final_frame := audio_length * Global.current_project.fps
|
||||
if frame < final_frame:
|
||||
cel_texture.texture = preload("res://assets/graphics/icons/icon.png")
|
||||
var frame_class := Global.current_project.frames[frame]
|
||||
var layer_class := Global.current_project.layers[layer] as AudioLayer
|
||||
var audio_length := layer_class.audio.get_length()
|
||||
if frame_class.position_in_seconds(Global.current_project) < audio_length:
|
||||
cel_texture.texture = preload("res://assets/graphics/misc/musical_note.png")
|
||||
else:
|
||||
cel_texture.texture = null
|
||||
|
|
|
@ -19,8 +19,9 @@ func _ready() -> void:
|
|||
|
||||
|
||||
func _update_tooltip() -> void:
|
||||
var duration := Global.current_project.frames[frame].duration
|
||||
var duration_sec := duration * (1.0 / Global.current_project.fps)
|
||||
var frame_class := Global.current_project.frames[frame]
|
||||
var duration := frame_class.duration
|
||||
var duration_sec := frame_class.get_duration_in_seconds(Global.current_project.fps)
|
||||
var duration_str := str(duration_sec)
|
||||
if "." in duration_str: # If its a decimal value
|
||||
duration_str = "%.2f" % duration_sec # Up to 2 decimal places
|
||||
|
|
|
@ -89,11 +89,10 @@ func _play_audio() -> void:
|
|||
if not layer.visible:
|
||||
return
|
||||
var audio_length := audio_player.stream.get_length()
|
||||
var final_frame := audio_length * Global.current_project.fps
|
||||
if Global.current_project.current_frame < final_frame:
|
||||
var seconds_per_frame := 1.0 / Global.current_project.fps
|
||||
var playback_position := Global.current_project.current_frame * seconds_per_frame
|
||||
audio_player.play(playback_position)
|
||||
var frame := Global.current_project.frames[Global.current_project.current_frame]
|
||||
var frame_pos := frame.position_in_seconds(Global.current_project)
|
||||
if frame_pos < audio_length:
|
||||
audio_player.play(frame_pos)
|
||||
else:
|
||||
audio_player.stop()
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue