Closed stalker57241 closed 1 year ago
I haven't checked if the project works with Godot 4.0 beta versions yet. I definitely will update this project once Godot 4.0 comes out, but I am not sure about the beta versions. Have you tried to adapt it?
I readed, that after beta release will be no fundamental changes in GDScript 2.0 and other things on this level. Beta 2 and next versions will only close bugs of beta 1, while They don't make it more stable. (Now Godot 4.0 beta 1 sometimes self-closes, but It's not serious problem for me). About adaptation - From OS clicking throw window and making it transparent goes to get_tree().root
and DisplayServer. Tweens disappeared like node and became a Reference, like class Timer(get_tree().create_timer()...
).
About code: I only make Canvas half-working:
# This is canvas.gd
extends Node2D
#
# This is the main scene the app utilizes.
#
@export var avoid_duration: float # (float, 0, 1.2, 0.01)
var sprite_position_id: String = "TopLeft"
@onready var Fw: Sprite2D = $Flower
# @onready var Up: Tween = create_tween()
func _ready() -> void:
initialize_window()
func initialize_window() -> void:
# Initializes the app window.
# Do not forget to allow "Per Pixel Transparency" from project settings
# under Project -> Project Settings -> Display -> Window -> Per Pixel
# Transparency menu, otherwise transparent background will not work.
var win: Window = get_tree().root
var ss: Vector2 = win.get_size()
win.set_size(ss - Vector2(1, 1))
win.position = Vector2(0, 0)
win.always_on_top = true
# If window size covers the whole screen, you'll get a black background. In
# order to prevent that, the window size is set to `ss - Vector2(1, 1)`.
win.borderless = true
## win.set_window_per_pixel_transparency_enabled(true)
# For better results, it is advised to enable the two settings above, from
# the project settings instead of here.
get_tree().get_root().set_transparent_background(true)
Fw.global_position = GlobalStash.overlay_positions[sprite_position_id]
update_click_polygon()
func update_click_polygon() -> void:
# Updates the area which is clickable, meaning that the inputs do not pass
# through the window outside the specified area.
DisplayServer.window_set_mouse_passthrough(Fw.get_click_polygon())
func _on_Flower_avoid_triggered() -> void:
# Triggered checked `trigger_avoid` signal of the `Flower` scene. This controls
# the next position the `Flower` is going to move to.
var ids: Array = GlobalStash.overlay_positions.keys()
var new_id: String = ids[(ids.find(sprite_position_id) + 1) % ids.size()]
avoid_click(Fw, new_id)
func avoid_click(object: Object, id: String) -> void:
# When the `Flower` is clicked, it moves to the next position it
# is supposed to move.
sprite_position_id = id
# Up.remove_at(Fw, "global_position")
# Up.interpolate_property(object, "global_position",
# object.global_position, GlobalStash.overlay_positions[id],
# avoid_duration, Tween.TRANS_SINE, Tween.EASE_OUT, 0)
# Up.start_tween()
func _on_Updater_tween_started(object: Object, key: NodePath) -> void:
# This is for debugging purposes.
var msg: String = "Started -> {0}{1}".format({0: object.name, 1: key})
print(msg)
func _on_Updater_tween_completed(object: Object, key: NodePath) -> void:
# This is for debugging purposes.
var msg: String = "Ended -> {0}{1}".format({0: object.name, 1: key})
print(msg)
func _on_Updater_tween_step(object: Object, _key: NodePath, _elapsed: float,
_value: Object) -> void:
# Updates the clickable area (polygon), which is the `Flower` area, checked each
# step of interpolation.
if object == Fw:
update_click_polygon()
So, now I found Godot 4.0 beta 2, where they add exporting of custom resources avaible. But changes only allows improve already created code and don't cracks already written code.
Thank you for the information! I will start working on this issue in a few days, and hopefully, release a new version that works fine with the most recent version of Godot in less than a week. I, unfortunately, can't focus on this issue right away since I am participating in Ludum Dare 51; but, if you ever need further assistance, don't hesitate to send a DM to Beez#1616 on Discord.
Okay, I understand. I'm found this project after completing a game "Outcore: Desktop adventure", that uses desktop on... I think 120%. From that time I think if it avaible on Unity it's completable on Godot too, because It worked on windows and coded on C#, more than at Unity, I think. Unity - because one of games uses it with js. So, for me It's like challenge. So, I think, I'll look here again if I need help. Maybe write some code for this repository...
I'm done it. Only algorithm of avoiding click I can't understand. I make drag'n'drop interaction in fork.
What about realization for Godot 4.0 beta 1?