Android Question effect of a starry

ivanomonti

Expert
Licensed User
Longtime User
I should make an effect of a starry sky, which is then compatible with ios, any suggestions
 

ivanomonti

Expert
Licensed User
Longtime User
examples,

but I believe that the battery consumption to go go!! :confused:

B4X:
'Class module
Sub Class_Globals
    Private bmp As Bitmap = LoadBitmap(File.DirAssets,"star.png")
    Private imw As ImageView
End Sub

'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize(pa As Panel)
    For i = 0 To 100
        Dim imw As ImageView
        imw.Initialize("")
        Private l,t,w,h As Float
        l = Rnd(0,pa.Width)
        t = Rnd(50,pa.Height/1.80)
        w = Rnd(8,42)
        h = w
        pa.AddView(imw,l,t,w,h)
        FitCenterStar(imw,bmp)
        pulse(imw)
    Next
End Sub

Sub FitCenterStar(iv As View, bmpT As Bitmap)
    Private bmp As Bitmap = bmpT
    Private cvs As Canvas
    cvs.Initialize(iv)
  
    Dim rectDest As Rect
    Dim delta As Int
    If bmp.Width / bmp.Height > iv.Width / iv.Height Then
        delta = (iv.Height - bmp.Height / bmp.Width * iv.Width) / 2
        rectDest.Initialize(0, delta,iv.Width, iv.Height - delta)
    Else
        delta = (iv.Width - bmp.Width / bmp.Height * iv.Height) / 2
        rectDest.Initialize(delta, 0, iv.Width - delta, iv.Height)
    End If
    cvs.DrawBitmap(bmp, Null, rectDest)
    iv.Invalidate
End Sub

Sub pulse(vi As View)
    Private ann As Animation
    ann.InitializeAlpha("pulse",0,1)
    ann.Duration = Rnd(500,2500)
    ann.RepeatCount = -1
    ann.RepeatMode = ann.REPEAT_REVERSE
    ann.Start(vi)
'End Sub
 
Upvote 0
Top