TheOathMan / Godot-Android-Live-Wallpaper

Make your Android Godot application run as a live wallpaper in the background.
MIT License
13 stars 3 forks source link

getting current screen index / horizontal scrolling #2

Open skeddles opened 1 month ago

skeddles commented 1 month ago

In android you can usually add multiple home screens to organize your icons onto, and swipe horizontally between them. Most versions allow you to set a static wallpaper that scrolls slightly with a parallax effect as you scroll between them.

example: EAcsX

Is there any way to get the current scroll position of the home screen, or the current screen, so I can emulate that effect with this plugin?

I took a look at your signals and static functions, but didn't see anything that seemed related. If it's not currently possible, then consider this a feature request

Anyway thanks for making this, seems like a great plugin, and everything else seems to be working!

TheOathMan commented 1 month ago

The plugin has an offset callback but was not implemented yet. Every time you scroll the home screen, the wallpaper plugin sends X and Y offset values range from 0.0 to 1.0, representing the current position of the home screen relative to the available space. It also sends other useful values for pixel perfect positioning.

I will implement it soon. It should be fairly straightforward implementation.

Thank you for letting me know you need this. Good luck.

skeddles commented 1 month ago

Thanks! Looking forward to it! I will make a parallax wallpaper with it as soon as it's implemented!

TheOathMan commented 1 month ago

Thanks! Looking forward to it! I will make a parallax wallpaper with it as soon as it's implemented!

Check out the new on_offset_changed signal. It should do what you want. Both a new release and a repo update have been uploaded.

skeddles commented 1 month ago

I tried it out but unfortunately could not get it working.

I deleted the livewallpaper addon folder and used the one from the releases tab, and restarted. I found the signal on the LiveWallpaper node and connected it, but it doesn't seem to be firing when I scroll my screen (my positions aren't changing and it's not showing in the log)

maybe I installed/used it wrong? I hope my phone isn't too old (android 11)

func _on_live_wallpaper_on_offsets_changed(Offset, OffsetStep, PixelOffset):
    consolelog('offset')
    $moveme.offset.x = (Offset.x-0.5) * 100
    $moveme2.offset.x = PixelOffset.x

my project: LospecWallpaperShoppe.zip video: https://drive.google.com/file/d/1kGyWCXPbTb_ogBjbMXOde6aNA6BIhlcC/view?usp=sharing

TheOathMan commented 1 month ago

It's a Godot issue. For some reason, in Godot 4.2.2.stable, the Engine can not register on_offset_changed signal, but when I tried your project in Godot 4.3.beta3, everything seems to be working. The little character moves as you scroll. I will investigate further and see what I can do.

TheOathMan commented 1 month ago

I found the Issue, Godot 4.2 can not handle 6 parameters for the signal coming from the android native calls, but Godot 4.3 can. I will just remove OffsetStep because its not necessary to the function of the signal.

TheOathMan commented 1 month ago

Now The Plugin tested with 4.2.2.stable works as well.

skeddles commented 1 month ago

yup, after updating to that version, and removing the offsetstep parameter, it seems to be working nicely!

Thanks so much for implementing this, it definitely opens a lot of options for us.

skeddles commented 1 month ago

i dont suppose there's a way to get a count of how many home screens the user has?

TheOathMan commented 1 month ago

Offsetstep parameter contain NumberOfHomeScreen÷1. So if x value is 0.333, that means there are 3 horizontal home screens.

The problem is, we removed that parameter because JNI breaks where there are too many parameters in 4.2.

TheOathMan commented 1 month ago

I'm adding a separate signal that sends home screen count

TheOathMan commented 1 month ago

try the new homescreen_count_updated(count_x:int,count_y:int) signals. It should receive home screen count when available.