Hello,
I'm trying to use cocos.tiles.RectMapLayer in this context:
- A cocos.scene.Scene construct with:
- A cocos.layer.scrolling.ScrollableLayer containing:
1. A background image: cocos.sprite.Sprite
2. A "ground" layer: cocos.tiles.RectMapLayer (built from
cocos.tiles.load and tmx file)
3. A "subjects" layer: cocos.tiles.RectMapLayer (manually built)
4. A "top" layer: cocos.tiles.RectMapLayer (built from
cocos.tiles.load and tmx file)
The "subjects" layer is built manually:
def get_subjects_layer(self) -> cocos.tiles.RectMapLayer:
# TODO: hardcoded values: use TMX infos
cells = self.generate_subjects_cells(width=70, height=40, tile_width
=8, tile_height=8)
return cocos.tiles.RectMapLayer(
id='subject',
tw=8, # hardcoded values: use TMX infos
th=8, # hardcoded values: use TMX infos
cells=cells,
)
def generate_subjects_cells(
self,
width: int,
height: int,
tile_width: int,
tile_height: int,
) -> typing.List[typing.List[cocos.tiles.RectCell]]:
cells = [[None] * height for x in range(width)] # type:
typing.List[typing.List[cocos.tiles.RectCell]]
for n in range(width * height):
i = n % width
j = height - (n // width + 1)
# TODO: Give here the tile
cells[i][j] = cocos.tiles.RectCell(i, j, tile_width, tile_height
, properties={}, tile=None)
return cells
My goal is to add some sprites to "subjects" layer. But, i can see what
cocos.tiles.RectMapLayer.cells, so cocos.tiles.Cell require a
cocos.tiles.Tile. How can i use my sprites with a cocos.tiles.RectMapLayer ?
Regards,
Bux.
--
You received this message because you are subscribed to the Google Groups
"cocos2d discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/cocos-discuss.
For more options, visit https://groups.google.com/d/optout.