Not NaNo Day 4 – Part 2

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.

cocos2d hex scrolling fixed mouse.gif
Scrolling with the selection indicator following the mouse. The bug around the vertical offset of the selection still exists, however.

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.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s