Android Tutorial Android Live Wallpaper tutorial

walterf25

Expert
Licensed User
Longtime User
Live WallPaper

well off the top of my head i was thinking of using a GIF file, and then use the gif library, but since i'm not too familiar with this wallpaper library, i thought i would ask and see if get some examples first!

thanks,
Walter
 

NeoTechni

Well-Known Member
Licensed User
Longtime User

This should help
Files - Basic4android Wiki

Also, since your LWP just crashes inside my large app, but not on it's own
I've decided to just put it in it's own APK and have the larger app handle the updates.
 

walterf25

Expert
Licensed User
Longtime User
Live WallPaper

Hello, how do you make a live wallpaper that when you swipe from one screen to the left or the right you can see the live wallpaper kind of scroll also, so far the only ones i have been able to make are pretty much static, you do not see them move left or right to be able to see the details to the left or right, does anyone know?

thanks,
Walter
 

walterf25

Expert
Licensed User
Longtime User
Unexpected error

Hello Erel, i just installed basic4android version 2.0 on my new laptop, i have been working on some live wallpaper apps for the past few weeks, for some reason when i load the live wallpaper apps on my phone using my new laptop i get this error, i'm not sure what's going on, since this laptop is new i had to install the Android SDK latest version, i'm not sure if this has anything to do with this issue!


In the configure path menu i tried setting different platform levels, i tried android-8, android-10, android-12, android-13 and 14 and i still get the same error, i need to figure out what is giving me this error, the same app runs just fine on my old laptop, but i need to transfer everything to my new laptop.
I really need your help on this Erel!

thanks,
Walter
 

walterf25

Expert
Licensed User
Longtime User
Live WallPaper error

don't i feel stupid, thanks Erel, that solved the issue.
I know i should probably start another thread for this, but on your live wallpaper tutorial on the livewallpaperball app, is it possible to set an image as the background instead of just drawing a rectangle filled with color, and is it possible to add more than one smiley at a time?

Trying to figure out how to do multipple particles, i found a tutorial in java where you can simulate bubbles starting from the bottom of the screen and continue going up, is this possible with this library Erel?

thanks,
Walter
 

NeoTechni

Well-Known Member
Licensed User
Longtime User
If you mean building it into the library:
I feel that'd bloat the library.
That's something we can do, that shouldn't be in the library

If you mean can you make a wallpaper using the lib, to have that effect:
Yes
 

walterf25

Expert
Licensed User
Longtime User
Bubbles

yes, i mean building a live wallpaper with that effect, NeoTechni, would you mind sharing some code to accomplish this, i don't want the whole code, at least justs how to get started, so far i have only been able to create live wallpapers using various images loading them into an array and displaying them one after the next to create some sort of animation, but am not too happy with how that looks, i would like to create live wallpapers where i can add animation to static image.

I'd really appreciate it if you can point me in the right direction.

thanks
 

walterf25

Expert
Licensed User
Longtime User
Canvas

@ Erel, i changed the code in the
B4X:
Sub DrawBackground (Engine As LWEngine)
bmp.Initialize(File.DirAssets, "image1.jpg")
   Engine.canvas.drawcolor(backgroundcolor)
   Engine.RefreshAll
End Sub

to this

B4X:
Sub DrawBackground (Engine As LWEngine)
bmp.Initialize(File.DirAssets, "image1.jpg")
   Engine.Canvas.DrawBitmap(bmp, Null, Engine.Rect)
   Engine.RefreshAll
End Sub

but it doesn't draw the bitmap continuosly, what am i doing wrong?
 

walterf25

Expert
Licensed User
Longtime User
canvas

Never mind i have figured it out, Erel maybe you can point me in the right direction as to how to accomplish the bubbles effect, i would like to simulate bubbles starting from the bottom of the screen and go up all the way to the top, any ideas?
 

NeoTechni

Well-Known Member
Licensed User
Longtime User
Never mind i have figured it out, Erel maybe you can point me in the right direction as to how to accomplish the bubbles effect, i would like to simulate bubbles starting from the bottom of the screen and go up all the way to the top, any ideas?

Create a custom type that keeps track of the bubble's X/Y coordinate, speed, and which bubble graphic to use (I assume you'll want more than 1)
Use a list to store the bubbles.

When the X position of the wallpaper changes, draw the screen
When the timer ticks, increment the bubble's X/Y coordinates by the speed, draw the screen

I recommend using PNG's with anti-aliased transparency for the edges. But for weaker devices, GIF will do.

To draw the screen, just draw all the images centered at their X/Y coordinates (X-width/2, y-height/2)

If you need more help, feel free to PM me.
 

walterf25

Expert
Licensed User
Longtime User
Live Wallpaper Engine question

Hi Erel, is it possible to declare two different variables such
B4X:
dim lwm as LWManager
dim lwm1 as LWManager
and use both to draw views at different speeds, currently i'm working on a live wallpaper where i have 20 different jpg frames as the background, and i need to add for example a dragon fly, flying accross the screen, i'm using a sprite sheet for the dragon fly it contains about 7 frames, but i need to create the effect of the dragon fly moving it's wings faster than the background image, i tried using a different timer but that doesn't work because the lwm_tick is set to 42 milliseconds, and if i have a different timer to let's say tick every 5 milliseconds, still the lwm_tick sub will not see the variables inside the other timer change until every 42 milliseconds, can you or someone slap me in the face and show me how to do this?

thanks everyone,
Walter
 

NeoTechni

Well-Known Member
Licensed User
Longtime User
change the lwm tick time to half, and only increment the background every other frame. Update the dragon fly every frame.
 

NeoTechni

Well-Known Member
Licensed User
Longtime User
How do we use the Action parameter for touch events?

I get that 0=down, 1=up, 2=move for finger 1
But for finger 2, it's 261=down 262=up, and 2=move
for finger 3, it's 517=down 518=up, and 2=move
for finger 4, it's 773=down 774=up, and 2=move
for finger 5, it's 1029=down 1030=up, and 2=move
and so forth and so forth (I don't know the rest, do you?)

But them all using 2 for move, makes it impossible to tell which finger is moving

Hi Neo, how are you, is this the only way to do this, please tell me is not?

That'd be the easiest way
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…