As the last post was getting quite long, I decided to continue it in a second post.
I spent quite a bit of time refactoring the code I’d written around hex chunk generation and building plopping. The goal with chunk generation is so that scrolling the viewport can generate chunks that don’t exist just outside the viewport, so that the map can be seamless. I also added code to store the corners of the generated hex chunk. I’m not sure if I’ll need it, and I can always remove it if I don’t.
It didn’t quite work when I finished the day, but I did at least get the mouse to follow the hexes when I scrolled properly. I’m still not sure why it seems vertically offset in selecting hexes, and I had hoped that fixing this bug might have fixed that too.
The fix was relatively straight forward. I needed to offset the mouse’s coordinates against the changed viewport and world coordinates. I’m not sure why cocos2d requires this.