You would also need to provide background images that are big enough to cover whatever device resolution and aspect ratio you want to support. You would have to write some position conversion code to keep things aligned with top/left/bottom/right if required (like for UI items), but that’s relatively trivial. You can be selective with what you scale too, like just the UI, or the game objects etc., depending on how you lay out your scenes. Depending on the aspect ratio of the device, you get more space in height or width, so it’s up to you to decide if you want to scale your objects or not (both X/Y by the same scale, so no strange aspect ratio of the graphics). Notes: Our design resolution is 1920x1080, and everything in this area is guaranteed to always be visible. Glview->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, ResolutionPolicy::FIXED_HEIGHT) If (aspectRatio setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, ResolutionPolicy::FIXED_WIDTH) Here’s what we came up with that works for our specific app: auto designResolutionSize = cocos2d::Size(1920, 1080) Īuto aspectRatio = frameSize.width / frameSize.height I’ve battled this specific issue too (and have the scars to prove it! ). Sprite->setPosition(director->getDesignOrigin() + Vec2(80, 100)) auto director = cocos2d::Director::getInstance() When designing your game inside your design area just add your point to Director::getDesignOrigin(). Please Note: the background image has to fit each aspect ratio. Different from Visible Origin for NO_BORDER and COMPLETE_DESIGN.Ĭaution! With original cocos2dx code it’s the other way around. And the Design Origin is the point where the design begins.Visible Origin is now always (0/0) for all ResolutionPolicies.Therefore I added the mentioned Director::getDesignOrigin() to get the origin of the design area. I had to change the visible rectangle to be able to make use of the black borders. Returns design origin coordinate of the OpenGL view in points.added function Director::getDesignOrigin().The value has to be set via GLView::setDesignResolutionSize() before. Returns design size of the OpenGL view in points.added function Director::getDesignSize().The entire application is visible in the center of the screen without distortion while maintaining the original aspect ratio of the application AND no borders appear.added new ResolutionPolicy::COMPLETE_DESIGN.Patch: ResolutionPolic圜ompleteDesign_ (2.4 KB) I wanted to do the same as you mentioned. I’m a little late, but maybe this is helpful I basically just want the scaling of SHOW_ALL mode but being able to draw on the borders.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |