Android Question Gameview draw a Line

Erel

B4X founder
Staff member
Licensed User
Longtime User
Here:
B4X:
Sub Globals
   Dim gv As GameView
   Dim cvs As Canvas
   Private px, py As Int
End Sub

Sub Activity_Create(FirstTime As Boolean)
   gv.Initialize("gv")
   Activity.AddView(gv, 0, 0, 100%x, 100%y)
   Dim bgd As Bitmap
   bgd.InitializeMutable(gv.Width, gv.Height)
   Dim bd As BitmapData
   bd.Bitmap = bgd
   bd.DestRect.Initialize(0, 0, gv.Width, gv.Height)
   gv.BitmapsData.Add(bd)
   cvs.Initialize2(bgd)
End Sub

Sub gv_Touch (Action As Int, X As Float, Y As Float)
   cvs.DrawLine(px, py, X, Y, Colors.Red, 2dip)
   px = X
   py = Y
   gv.Invalidate
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…