I seem to be having trouble detecting the change when android rotates from portrait/landscape. Is there a proper way to detect this? I’d have expected this to change -
You’re right - this method really does work. I’d looked at this before and dismissed it. The reason, I think, is because even if you do all that, this -
Director::getInstance()->getVisibleSize().width
still reports the pre-rotate figure. I reckon that’s probably a bug in cocos unless there’s a really good reason for it not adjusting with the screen…?
I’m not sure why you’re assuming that’s a bug, Cocos2d-x just doesn’t update the OpenGL view’s size to match the device’s resolution on rotation changes. That seems like an uncommon use case, most games lock to an orientation (portrait or landscape), so there’s no need to ever handle that situation. For people who need that functionality, and it seems like you do, update the OpenGL view size like in the applicationScreenSizeChanged() method of the example thread.