Hi,
I am referring to this Tutorial, where you have one bitmap for the looks and another one in the background to determine which area has been clicked.
I succeeded in editing the code, so that it resizes to any screen-size, but I'm totally unsure how to add areas where I can change parts of the graphic when clicking a certain area.
There are so many ways, but I don't really know what route to take.
It's importan for me to be able to position the buttons pixelperfect but still not having to create different graphics for every possible screen-size.
I would like to scale the whole thing, like I already implemented in the code.
I am referring to this Tutorial, where you have one bitmap for the looks and another one in the background to determine which area has been clicked.
I succeeded in editing the code, so that it resizes to any screen-size, but I'm totally unsure how to add areas where I can change parts of the graphic when clicking a certain area.
There are so many ways, but I don't really know what route to take.
It's importan for me to be able to position the buttons pixelperfect but still not having to create different graphics for every possible screen-size.
I would like to scale the whole thing, like I already implemented in the code.
B4X:
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim bmp As Bitmap
Dim bmp1 As Bitmap ' Placeholder for resized Bitmap
Dim Panel1 As Panel
Dim Label1 As Label
Dim Canvas1 As Canvas ' Canvas to draw resized image to
Dim DestRect As Rect ' Size of Fullscreen
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1")
bmp.Initialize(File.DirAssets, "CircMenuMap32bit.png")
'Canvas1.Initialize(Activity)
'Canvas1.DrawColor(Colors.ARGB(255,200,20,20))
' Define FullScreen Rect
DestRect.Initialize(0,0,Activity.Width, Activity.Height)
' Create empty Fullsize-Bitmap
bmp1.InitializeMutable(Activity.Width, Activity.Height)
' Init Canvas with size of new Bitmap
Canvas1.Initialize2(bmp1)
' Draw orginal Bitmap as new Resized Bitmap on Canvas
' Thats where the resizing takes place
Canvas1.DrawBitmap(bmp, Null, DestRect)
' Resize Panel to Fullscreen
' Panel is where the normal images is drawn onto
Panel1.Width = -1
Panel1.Height = -1
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Panel1_Touch (Action As Int, X As Float, Y As Float)
If action = activity.ACTION_DOWN Then
Dim c As Int
c = bmp1.GetPixel(x,y)
Select c
Case Colors.RGB(255,0,0)
label1.Text = "Clicked on Recycle"
Case Colors.RGB(255,255,0)
label1.Text ="Clicked on Film roll"
Case Colors.RGB(0,255,0)
label1.Text ="Clicked on Rubik cube"
Case Colors.RGB(0,255,255)
label1.Text ="Clicked on Old Radio"
Case Colors.RGB(0,0,255)
label1.Text ="Clicked on Record player"
Case Colors.RGB(255,0,255)
label1.Text ="Clicked on Box with stuff"
Case Colors.RGB(255,192,192)
label1.Text ="Clicked on Old TV"
Case Colors.RGB(255,255,192)
label1.Text ="Clicked on Folder with pictures"
Case Colors.RGB(192,255,192)
label1.Text ="Clicked on Ladybug"
Case Colors.RGB(255,255,255)
label1.Text ="Clicked on Big Button"
Case Else
label1.Text =""
End Select
Return
End If
End Sub