Hi all,
For learning purposes, I want to setup a Tower Defense B4A project and I'm seeking some help/examples to get me started. I've read the beginner guide and user guide thoroughly but I'm still puzzled by some concepts. I have a lot of questions so bare with me!
canvas: you use a canvas to draw on views correct? So for a test world/map I could create a panel and draw a canvas on that panel and have the background of that canvas filled by a color or bitmap correct? And If I wanted to create a path via walls I should start by placing the walls via a couple of canvas objects and place them on the panel (or imageview) as walls. Is that a smart way to go forward? Not sure as the bricks in the 'arkanoid' game doesn't seem to have canvasses declared for them.
What are the differences between an imageview and a panel for that matter? And when should I use which?
Next step is to create a movable object (the attacker) which moves in the shortest path possible to the target. By having collision detection in place the attacker walks into the walls, the attacker rotates a predetermined degree untill it can move forward again when there is no wall blocking.
Is this the correct way to start? Should I use gameview? Or some other library? Right now I started with gameview.
For learning purposes, I want to setup a Tower Defense B4A project and I'm seeking some help/examples to get me started. I've read the beginner guide and user guide thoroughly but I'm still puzzled by some concepts. I have a lot of questions so bare with me!
canvas: you use a canvas to draw on views correct? So for a test world/map I could create a panel and draw a canvas on that panel and have the background of that canvas filled by a color or bitmap correct? And If I wanted to create a path via walls I should start by placing the walls via a couple of canvas objects and place them on the panel (or imageview) as walls. Is that a smart way to go forward? Not sure as the bricks in the 'arkanoid' game doesn't seem to have canvasses declared for them.
What are the differences between an imageview and a panel for that matter? And when should I use which?
Next step is to create a movable object (the attacker) which moves in the shortest path possible to the target. By having collision detection in place the attacker walks into the walls, the attacker rotates a predetermined degree untill it can move forward again when there is no wall blocking.
Is this the correct way to start? Should I use gameview? Or some other library? Right now I started with gameview.
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.
Dim pnlColor As Panel
Dim wall, attacker As BitmapData
Dim size As Int
size = 30dip
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.
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")
If FirstTime Then
'Create the BitmapData objects.
'These objects will be drawn by the GameView
wall.Bitmap = LoadBitmap(File.DirAssets, "wall.png")
wall.DestRect.Initialize(10dip, 10dip, 100dip + size, 100dip + size)
'neerzetten van rode panel
pnlColor.Initialize("")
Activity.AddView(pnlColor, 10%x, 40dip, 80%x, 60%y)
Dim cdwColor As ColorDrawable
cdwColor.Initialize(Colors.Red, 5dip)
pnlColor.Background = cdwColor
End If
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Last edited: