Android Example Raindrop/Snow effect

Hi all,
Just a small sharing.
Using a timer to make a raindrop or snow effect.I don't know whether it's the correct way to do this. =D
B4X:
Sub Timer_rain_Tick
    Dim image As ImageView
    image.Initialize("")
    'image.Bitmap =LoadBitmap(File.DirAssets, "drop.png")
    image.Bitmap =LoadBitmap(File.DirAssets, "snow.png")
    Dim left As Int =Rnd(0,100)
    Panel1.AddView(image,(left*Panel1.Width)/100,-20%x,16dip,16dip)
    Dim a As Int = Rnd(0,10)
    If a >5  Then 'If there is already an image/logo in screen, make it randomly fall from front/back
        image.SendToBack
    Else
        image.BringToFront
    End If
    image.SetLayoutAnimated(5000,image.Left,120%y,image.Width,image.Height)
    image.SetVisibleAnimated(5000,False)
    Sleep(5000)
    image.RemoveView
End Sub
 

Attachments

  • Screenshot_2017-12-12-09-14-57-481_b4a.rain.png
    Screenshot_2017-12-12-09-14-57-481_b4a.rain.png
    38.9 KB · Views: 1,303
  • Screenshot_2017-12-12-09-20-51-513_b4a.rain.png
    Screenshot_2017-12-12-09-20-51-513_b4a.rain.png
    59.2 KB · Views: 976
  • rain.zip
    9.1 KB · Views: 560

ilan

Expert
Licensed User
Longtime User
I have never programmed games but...

You should use, in these cases, a bitmap (many drops) to scroll (I don't remember the technical name of this feature, just because ... see the first line), or not?

you mean parallax Scrolling. this is ok only for the background but if you want to have more control on your drops like add wind (see my code) or show splash animation you have to do it with drop objects.
 

ilan

Expert
Licensed User
Longtime User
so if we are already in the mood of animations (and for me animation has a lot to do with gaming) while i follow this thread i am also working on my new B4i app.
so its an educational app for kids with lots (i really mean a lot) of images.

so the app has about 8 categories and each category can have about 20-30 images.
now after making the first category my .../File/ Folder looks messy (and i dont mean the soccer player)
so because we dont have an Atlas reader in b4i i thought why not make by myself. so i did it.

First Tests are successfully! now it looks much, much cleaner in my File/ Folder. And reading the bitmaps from the atalas is super easy.

only 1 simple line:

B4X:
Dim bmp As Bitmap = iAtlas.getBitmap("profession","worker1")

as you can tell the lib is called iAtlas and i will share it soon ;)

now our b4i apps will look much cleaner.

(i have blurred some parts of the image because this project is still top secret :p)
 

Attachments

  • atlas1.png
    atlas1.png
    29 KB · Views: 312
  • Simulator Screen Shot - iPhone 8.png
    Simulator Screen Shot - iPhone 8.png
    48.6 KB · Views: 346

ilan

Expert
Licensed User
Longtime User
@ilan if I were you I would back up your project right away. You've stored it on a broken harddrive! (see folder pathname). ;) :D:D

so the story is this. about 1 year ago my hd on my laptop died.
it was split into 4 partitions. i was lucky that all b4x stuff was on a partition that i could read from so i bought an SSD and a 2.5" HD to USB connector and transferred everything to my new SSD. i named that folder "Broken HD" as you already mentioned.

so what have i learned from this event? backup, backup, backup. and have i backuped?? the answer is NO. and thanks you for bring back those memories where i was very frustrated and now i am again motivated to backup all my data before it happens again. the thing is i need a new HD to do that and as i know myself i will buy only one when the current will die so i guess we will talk about that topic somewhen in the future so check from time to time the CHIT-CHAT Forum for the topic "HELP MY HD DIED, WHAT SHOULD I DO KNOW :(((" ;)
 
Top