Wallpaper Help needed

walterf25

Expert
Licensed User
Longtime User
Hello all, i'm playing around with the wallpaper library and i'm trying to create an Aquarium Live Wallpaper, i have an image of a bubble and would like to create an effect where the bubbles start from the bottom of the screen and continue all the way up to the top of the screen, so far this is the code i have, i'm able to draw the bubbles on the canvas, but can not figure how to make the bubbles move up at different speeds.

any and all help will be greatly appreciated, i have the concept in my head but can not put it into code, help please

B4X:
Sub lwm_Tick (Engine as LWEngine)
for i = 0 to bubbles.lenght -1
Engine.canvas.DrawBitmap(bubbles(i), null, rc(i))   'rc = rect
rise(ii) = bubbley + bubblespeed(ii)
rc(i).Initialize(bubblex(i), bubble(i)-10, bubblex(i), rise(ii)-10)     'here's where i substract 10 to the top and bottom of the rect every iteration so make bubbles move up, but nothing happens.
Engine.Canvas.DrawBitmap(bubbles(i), null, rc(i))
ii = ii + 1
if ii > 29 then ii = 0
Engine.RefreshAll
next

Hope someone can shed some light for me.

Thank you all
Walter
 

walterf25

Expert
Licensed User
Longtime User
Help needed

Ok, i got the bubbles moving up, but they leave a trace of the bottom bubbles, how what do i do so that the bubbles move up without leaving a trace below them, any ideas?

below is a screen shot and the code i used

B4X:
Sub lwm_Tick (Engine as LWEngine)
for i = 0 to bubbles.lenght -1
'Engine.canvas.DrawBitmap(bubbles(i), null, rc(i))   got rid of this line!
rc(i).Initialize(bubblex(i), bubble(i)-10, bubblex(i), rise(ii)-10)     'here's where i substract 10 to the top and bottom of the rect every iteration so make bubbles move up, but nothing happens.
Engine.Canvas.DrawBitmap(bubbles(i), null, rc(i))
bubbley() = bubbley(i) - 10
rise(ii) = rise(ii) + bubblespeed(i) - 10
Engine.Refresh(rc(i))
ii = ii + 1
if ii > 29 then ii = 0
Engine.RefreshAll
next

this moves the bubbles up but as mentioned above, they leave a trace.

here's a snapshot

bubbles2.jpg

thanks all!
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
You need to erase the previous bubble, try this code:
B4X:
Engine.Canvas.DrawRect(rc(i), Color.Transparent, True, 1)
rc(i).Initialize(bubblex(i), bubble(i)-10, bubblex(i), rise(ii)-10)
Engine.Canvas.DrawBitmap(bubbles(i), null, rc(i))
Best regards.
 
Upvote 0
Top