Le vendredi 9 septembre 2016 19:00:27 UTC+2, Robert Haddon a écrit :
>
> I'm wondering if this is problem. I'm adding a layer as a child to another
> layer.
> class Hexagons(cocos.layer.ScrollableLayer):
> is_event_handler = False #: enable director.window events
>
> def __init__(self):
> super().__init__()
> hex_resource = cocos.tiles.load('large_hex.tmx')
> hex_layer = hex_resource['hex_layer']
> self.add(hex_layer)
>
>>
>>> Thanks!
>>>
>>
Hello,
As Claudio said, it's hard to tell without enough code.
When I read that you tried to add 2 ScrollableLayers to a ScrollingManager,
one showing just your background image and the other one containing an
empty hexagonal tileset, and you don't see the hexagons, I can think of a
couple of possible problems:
1. Your background image is *above* your hexagons, so you won't see
them. Make sure you add the different layers with a *z value* in the
order required (lower z value for the background).
2. As Claudio explained, cocos only supports hexagonal orientation with
'flat at the top'. Make sure your empty tmx map has this kind of
orientation.
If you try to highlight the cells using the method set_cell_color, you will
run into a problem if the cell does not contain any sprite. The method
set_cell_color just changes the color of the underlying sprite for this
cell. In order to make it work, you would need to use a fully-transparent
hexagon with the color you want to use for the highlight in Tiled. In your
on_mouse_motion function, instead of changing the color, you could change
the cell opacity with set_cell_opacity. Use a semi-transparent opacity, and
you will see a yellowish color in that cell.
Dan.
--
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.