Games Angry Birds Example

Gunther

Active Member
Licensed User
Longtime User
Why you used two different approaches to the set a drawtask in Angry Birds Example:

B4X:
Private Sub DrawRopes (gs As X2GameStep, angle As Float)
......
gs.DrawingTasks.Add(X2.MainBC.AsyncDrawLine(bcpoint.X, bcpoint.Y, HookPointLeft.X, HookPointLeft.Y, PulleyBrush, 5))
X2.LastDrawingTasks.Add(X2.MainBC.AsyncDrawLine(bcpoint.X, bcpoint.Y, HookPointRight.X, HookPointRight.Y, PulleyBrush, 5))

What is the reson behind not adding a second "gs.DrawingTasks.Add"?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Good question.

1. We want one of the lines to appear behind the bird and the other in front of it.
2. Game.Tick is called before all other bodies are drawn.
3. The tasks in X2.LastDrawingTasks are drawn after the tasks in gs.DrawingTasks.

I hope that it is clear.

Note that there are two related properties that you can set in tiled:

SS-2018-11-06_14.45.32.png


'draw first' means that the body task will be inserted at the beginning of gs.DrawingTasks (after the very first task which is the task that clears everything).
'draw last' means that the body task will be added to X2.LastDrawingTasks.
 
Top