It’s Wednesday and time for another FAQ session. Here are some frequently asked questions (FAQ) about display objects.
1. Why is my iOS App file larger with Daily Builds compared to building with the release build (894)?
Starting with build 900, PNGCRUSH is no longer called for iOS “developer” builds. This was added to speed up build times but it does mean that the PNG images will not be compressed, which will increase the size of your app. Building for AdHoc or Distribution has not changed and calls PNGCRUSH as before.
2. How can I load images that are larger than the device’s screen size, without it scaling down the image?
display.newImage will scale images to fit the screen dimensions of the device. You can set the “isFullResolution” flag to true to disable the automatic scaling.
The display.newImageRect does not automatically scale down images when loaded. For this API you must specify the width and height of the image, so that is another way to load an image larger than the device’s screen size.
Be aware that devices have a maximum resolution that can be loaded which is typically 2048 x 2048.
3. If I put code like display.newRect(0, 0, 80, 40), at coordinates 0,0, my rectangle will appear cropped at top-left of the mobile screen.
The object should not be chopped because when a newRect is created, it’s created with a TopLeft reference. So 0,0 will position the top left corner of the rect at the top left of the screen. It may look chopped if you have the status bar visible. You can turn off the status bar as follows:
Most display objects are created using a TopLeft reference point. After the object has been created, the reference point changes to Center reference. Here is one way to center the rect on the screen.
The following will NOT correctly center the rect, but position the TopLeft corner of the rect in the center of the screen.
The TopLeft reference for creating display objects apply to all objects except for display.newCircle and The display.newGroup. display.newCircle is created with Center reference and display.newGroup is empty and has no reference point until objects are inserted. Once objects are inserted into a group, it has a TopLeft reference.
4. setReferencePoint is not working when I use display.topCenterReferencePoint. What’s wrong?
The parameter for setReferencePoint must be spelled correctly and with the proper capitalization or it won’t work. The correct value to set the Top Center reference point is, display.TopCenterReferencePoint (with a capital “T”). Unfortunately the API doesn’t give you a warning or error message when the parameter is incorrect. This is on our list to fix in the future.
That’s it for today’s questions. I hope you enjoyed it and even learned a few things.