Games Help needed, Err: _x2internaltilelayer cannot be cast to _x2objectslayer

fredo

Well-Known Member
Licensed User
Longtime User
While working on @Gunther 's Starting-List I'm stuck at Listpoint 13:

The error occurs when initializing x2tilemap (the Tilemap example was used as a basis).




The goal is to create a turn-based game using a tile map.

Since this is the first attempt in game development, the mistake will probably be due to a lack of knowledge in the handling of the X2 Game Engine.

Despite the many examples and instructional videos, it has not yet been possible to adequately capture the interaction of the modules involved.

The error occurs in the "X2.b4xlib" as well as in the classes used here. The classes are used to better understand the processes under the bonnet.

A test project is included, so advanced experts may have a better idea of how to apply a help term.
 

Attachments

  • Gametest1.zip
    399.3 KB · Views: 356

Erel

B4X founder
Staff member
Licensed User
Longtime User
LayerTiles1 is a tiles layer.
TileMap.PrepareObjectsDef should only be called with objects layers.

Relevant code from Mario example that handles the tiles layer:
B4X:
Public Sub Tick (GS As X2GameStep)
   mMario.Tick(GS) 'run first as mario updates the world position
   TileMap.DrawScreen(Array("Tile Layer 1", "Tile Layer 2"), GS.DrawingTasks) '<-----
End Sub

Public Sub DrawingComplete
   TileMap.DrawingComplete
End Sub
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…