B4J Question [BANano] [SOLVED] How does one use the .RequestAnimationFrame?

Mashiane

Expert
Licensed User
Longtime User
Ola

I'm trying out some examples of having this work to animate some divs and stuff.

On my logs, this is what shows

B4X:
[WARNING]: The method RequestAnimationFrame in requestanimationframe can not find '_methodname'!

This is my function:

B4X:
Sub animate(timeStamp As Double)
    Dim cat As BANanoElement
    Dim hat As BANanoElement
    cat.Initialize("#cat")
    hat.Initialize("#hat")
    '
    If (lastTime <> Null) Then
        angle = angle + (timeStamp - lastTime) * 0.001
    End If
  
    lastTime = timeStamp
    Dim sctop As String = (Sin(angle) * 40 + 40) & "px"
    Dim scleft As String = (Cos(angle) * 200 + 230) & "px"
    Dim shtop As String = (Sin(angle + cPI) * 40 + 40) & "px"
    Dim shleft As String = (Cos(angle + cPI) * 200 + 230) & "px"
    '
    Dim cstyle As Map = CreateMap("top":sctop, "left":scleft)
    cat.SetStyle(BANano.ToJson(cstyle))
    '
    Dim hstyle As Map = CreateMap("top":shtop, "left":shleft)
    hat.SetStyle(BANano.ToJson(hstyle))
  
    BANano.Window.RequestAnimationFrame(Me, "animate")
End Sub

This is my calling sub

B4X:
angle = 0
    lastTime = Null
  
    BANano.Window.RequestAnimationFrame(Me, "animate")

Thanks
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…