On Thursday, September 8, 2016 at 5:39:11 PM UTC-7, Claudio Canepa wrote:
>
> I'm not sure I understand your goals...
>
> On Thu, Sep 8, 2016 at 6:43 PM, Robert Haddon <[email protected] 
> <javascript:>> wrote: 
>>
>> This appears to be a very uncommon pattern and I've been struggling to 
>> make it work.
>>
>> I have single hand-painted world map that I want to use for my game's 
>> background, but I also need a hexagonal tileset for the user to interact 
>> with, and I need it to scroll.  
>>
>
> You want
>   - the image to scroll
>   - highlight hexagonal areas, probably ones under the mouse cursor ? 
>
> Yes. 

>  
>
>> I'm not sure what the best solution is for this.  This is what I have 
>> tried:  
>>
>   1. Load my image as a tileset image into Tiled and produce a TMX file.  
>> Code-wise in cocos, this works fine but it looks awful because Tiled 
>> tilesets are rectangular and painting those cells over hex cells just 
>> doesn't work aesthetically.
>>
>
> Tiled (and cocos) supports hexagonal tilesets. If you break the image in 
> hexagons (an "hexagonal tileset"), and do the related map, then you can 
> accomplish what I interpret are your requirements. 
> I would write a script using pygame (or search a minitool ) to partition 
> the image into the hexagonal tileset,
> Caveat: theres two possible orientations for hexagons in an hexagonal map 
> ('flat at the top' or "corner at the top"), Currently cocos supports only 
> one of the orientations.
>
> You can see the test_tmx_hexmap.py as example for highlight tile under 
> cursor (in the repo or the distributed tarball/zip, subdir test/ )
>    
>
I have looked at this and in fact borrowed the highlight code from it. I 
think you might be right: I should just break my image up instead of trying 
something too tricky for my own good. 

>  
>
>>
>>   2. Add two ScrollableLayers to a ScrollingManager, one for the image 
>> and one for a TMX file with nothing but an empty hexagonal tileset defined.
>> I'm experiencing various problems here, depending on how I implement it:
>> The hexagons don't seem to paint--I have some on_mouse_motion code to 
>> highlight the cell under the mouse but it doesn't work when used in this 
>> way (no errors but nothing visible happens).  All I see is the background 
>> image.
>> I get 'pyglet.gl.lib.GLException: b'invalid operation' when loading the 
>> TMX
>>
>
>
> Can't tell without code. 
>
>>
>>
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!
>> .
>>
>
>  
>
>

-- 
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.

Reply via email to