Very nice usage of the Tiled map properties!
I've made some changes and I hope that you are fine with me adding the updated version to the examples pack:
- Using custom types instead of modifying BodyWrapper class.
- The switch movements is done with joints. I started with a revolute joint but it didn't behave as I wanted so I've added a motor joint to make the movement.
- Antialising + angle interval of 1 + rotating objects has an impact on the performance (until the caches are built). I've made some changes to make it lighter.
- Other small changes.
The only change that was required after testing it on B4A and B4i is to slightly decrease the tile size as the right and top lines were missing:How much changes have you had to do from b4j to b4i? (In the code it self)
Dim TileSizeMeters As Float = (X2.ScreenAABB.Height - 0.1) / TileMap.TilesPerColumn
TileMap.Initialize(X2, File.DirAssets, "map.json", Null)
Note that you shouldn't pass ivForeground to TileMap.Initialize. You should instead pass Null:
Public Sub Tick (GS As X2GameStep) TileMap.DrawScreen(Array("Tile Layer 1", "Tile Layer 2"), GS.DrawingTasks) End Sub Public Sub DrawingComplete TileMap.DrawingComplete End Sub
BTW, the thin lines do not look too good in B4A. You will get better results with more thick lines.
You are not using a tile layer at all in this example. The object layer is not related.
It is also very optimized as the tiles themselves are drawn once and the complete drawn map is reused between frames when possible.i also created a tiled lib for b4i and there i can draw any number of tile layers i want.
but your code is much simpler
It is better to start a new thread and post more information. You can use Canvas and most examples use canvas for some of the graphics (like the rotating blocks and the score text). You need to be efficient. That means create the graphic once and add it to the graphic cache.need to do is using a canvas but the question is how the performance on b4i will be. i have tried to use canvas in b4i and the result is very bad this is why i use spritekit for my ios games.
Deadlock with more than 1000 balls. But the wheel is still spinning...
If world.AllBodies.Size < 50 Then Dim template As X2TileObjectTemplate = TileMap.GetObjectTemplateByName(ObjectLayer, "ball") template.BodyDef.Position = X2.ScreenPointToWorld(X, Y) TileMap.CreateObject(template) Else Log("maximum balls number reached") End If
The reason that the wheel keeps spinning is that it is a kinematic body. Kinematic bodies behave like infinite mass bodies and are not affected by collisions.