After rendering the scene, its contents are copied to the view. If the view and scene are the same size, the contents can be directly copied to the view. If they are different from each other, then the scene is scaled to fit the view. The scaleMode property determines how content is scaled.
The mailbox is created in the view, so it is not. This often requires the .aspectFit setting if you want to use a specific scene size and a universal coordinate system. If this is your case, the following should help you.
You need to find out how much standard .aspectFit is required in the add-on to remove the box with your current device and add it to your scene. You end up with a scene that is lighter a little larger or slightly wider than your original size, but the scene is at least the same size as the original size of the scene. Then you can move the anchorPoint to its original (0, 0) coordinates or (0.5, 0.5) depending on which coordinate system you want to use for your game.
The code for this is minimized and may change over time. If you want a quick fix, I created the Framework just for this purpose. It is small but portable :)
https://github.com/Tokuriku/tokuriku-framework-stash
Simply:
- Download the ZIP file for the repository
- Open the "SceneSizer" subfolder
- Drag SceneSizer.framework "lego block" into your project.
- Make sure the Framework is Embedded, Not Just Linked
- Import Framework somewhere in your
import SceneSizer code
And you're done, now you can call the sizer class with: SceneSizer.calculateSceneSize(#initialSize: CGSize, desiredWidth: CGFloat, desiredHeight: CGFloat) -> CGSize
The documentation is in a folder for clean and full use with a standard scene. Hope this helps!
source share