B4A Library SD: ScratchCard

I created a new view / panel that simulates the effect of scratch cards.
Create a panel from code that design and you can hook other views that will be visible after the user has passed the finger on the surface.

It has all the properties of a panel and also returns the native panel.

SD_Scratchcard

Author: Star-Dust
Version: 0.01
  • PanelScratchCard
    • Events:
      • Click
      • LongClick
      • Touch (Action As Int, Coordinate As String)
    • Fields:
      • ACTION_DOWN As Int
      • ACTION_MOVE As Int
      • ACTION_UP As Int
      • thickness As Int
    • Functions:
      • AddToParent (Parent As Panel, Left As Int, Top As Int, Width As Int, Height As Int) As String
      • AddView (View As View, Left As Int, Top As Int, Width As Int, Height As Int) As String
      • BringToFront As String
      • Class_Globals As String
      • DesignerCreateView (Base As Panel, Lbl As Label, Props As Map) As String
      • Initialize (Callback As Object, EventName As String) As String
      • Invalidate As String
      • IsInitialized As Boolean
        Verifica se l'oggetto sia stato inizializzato.
      • LoadLayout (layoutFile As String) As String
      • Panel As Panel
      • RemoveAllViews As String
      • RemoveView As String
      • RemoviewAt (Index As Int) As String
      • RequestFocus As String
      • SendToBack As String
      • SetBackgroundImage (Bitmap As Bitmap) As String
      • SetColorAnimated (Duration As Int, FromColor As Int, ToColor As Int) As String
      • SetLayout (Left As Int, Top As Int, Width As Int, Height As Int) As String
      • SetLayoutAnimated (Duration As Int, Left As Int, Top As Int, Width As Int, Height As Int) As String
      • Scratch (Enabled As Boolean)
        Default is Enabled
    • Properties:
      • Color
      • Elevation As Float
      • enabled As Boolean
      • Height As Int
      • Left As Int
      • Parent As Panel [read only]
      • Tag As Object
      • Top As Int
      • Visible As Boolean
      • Width As Int
Video1.gif


B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim PA As PanelScratchCard
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("Layout1")
    PA.Initialize(Me,"Pa")
    PA.AddToParent(Activity,0,0,100%x,100%y)
    PA.LoadLayout("Layout2")
    PA.SetBackgroundImage(LoadBitmap(File.DirAssets,"b4a_bubble.png"))
End Sub

Sub PA_Touch (Action As Int, Coordinate As String)
    Dim C() As String = Regex.Split("|",Coordinate)
    Dim X As Int = C(0)
    Dim Y As Int = C(1)
End Sub
 

Attachments

  • sample1.zip
    15.8 KB · Views: 362
  • SD_Scratchcard 0.01.zip
    5.8 KB · Views: 368
Last edited:

EduardoElias

Well-Known Member
Licensed User
Longtime User
@Star-Dust good work! can you tell me when using your library how i find out when the user have already scratched most of the image?

Idea is to give the prize when the user already can see the image scratched no need to scratch 100%. Anyways I cant see how to detect from your library if the user completed everything.

Thank you for any cluet !
 

Star-Dust

Expert
Licensed User
Longtime User
@Star-Dust good work! can you tell me when using your library how i find out when the user have already scratched most of the image?

Idea is to give the prize when the user already can see the image scratched no need to scratch 100%. Anyways I cant see how to detect from your library if the user completed everything.

Thank you for any cluet !
At the moment there is no such function, I will see in the future if it can be possible to achieve it
 
Top