How do I bring the Corona window back to the desktop?
This is a common issue with Windows programs where the window will disappear if it’s on an external display and the program is restarted without the display. The program is not hung, just trying to display the window on a non-existent display. This can occur with the Corona Windows Simulator (this is not an issue with the Mac Simulator) and here are the steps for getting back the window:
- Right click on the Corona Simulator tab in the task bar
- Click on “move”
- Press an arrow key (left, right, up or down)
- Move the move until the missing window is visible on the display
- Left click to stop the move
That’s all there is to it. In the future we hope to automatically move the window when the external monitor goes away.
Why am I missing my high scores when I set them in Game Center?
Setting the High Score or Unlocking Achievements may take some time to propagate through Game Center’s servers. That means the new scores or achievements may not show up if viewed immediately after being set. We have noticed that it may take up to 24 hours for the new information to be returned using gameNetwork.show API. Setting the high score or unlocking achievements and then using gameNetwork.request to loadScores or loadAchievements seems to show the updated information sooner (on the order of seconds instead of hours), but you can’t count on the information being immediately available after it’s set. It’s always best to store the information locally if it needs to be displayed.
My app calls the gameNetwork.init API for GameCenter, which brings up the Game Center Sign-in dialog box. If the user presses “Cancel” instead of signing in, my app never prompts the user to sign in again. How can I bring back the Sign-in dialog?
If the user presses “Cancel” during the Game Center sign-in dialog, the Game Center “initCallback” will return with event.data = false, indicating a login failure. There is no way to bring back the sign-in dialog box without the user doing a “force quit” on the app or logging back in to Game Center using the native iOS Game Center app. They can also sign in using another Game Center app. Note: Calling gameNetwork.init after getting the false status will not bring back the sign-in dialog box.
Upon a successful sign-in or if the app is resumed and the user is still signed in to Game Center, the “initCallback” will return event.data = true. It’s only after getting this “true” status, should your app call any of the gameNetwork APIs
This behavior is not specific to Corona but the way Game Center works. We believe the sign-in dialog is not shown again because once the user cancels the sign-in, it indicates that they must not want to use Game Center with this app.
Why can’t I access some files on Android devices?
File access in Corona is based on the underlying Operating System, which will vary depending on the platform. On iOS devices, you can access files in the Resource directory (where main.lua is located) and the Documents and Temporary directories. On Android, accessing the Resource directory is limited because it’s not a real directory, but files enclosed in a zip file. Corona allows directly loading images and audio files using audio and image APIs, but has limited access to Resource files using the file I/O APIs. For this reason you can’t use the new Lua File System (LFS) to access files in the Resource directory or any Resource subdirectory on Android. File and subdirectory access to the Document and Temporary directories on Android devices is possible.
When using LFS to create, remove, and access directories, there are a few points to remember. First off, when accessing files or directories, you should provide a full path string (using system.pathForFile) and not rely on lfs.chdir or lfs.currentDir APIs. The concept of current directory is platform dependent and shouldn’t be relied on.
On all platforms, the Resource directory is read-only. You cannot write to files or create files or subdirectories in this directory.
Corona file access is limited to the platform’s file system “sandbox.” Sandboxing limits file accesses to the App’s workspace, which is isolated from the OS and other app’s files.
Adding subdirectories may help organize your app but there are limitations (as mentioned with Android) and some features may not be implemented on future platforms. The bottom line is to keep your file/directory implementation simple in case things change in the future.
LFS was implemented in Daily Build #2012.805. You can find more information about LFS here
How do I restart an audio stream file from the beginning?
Audio streams (audio loaded with audio.loadStream) always plays where it left off. If you need to play the streaming sound again, you must use audio.rewind or audio.seek(0) to start the audio from the beginning.
That’s it for today’s questions. I hope you enjoyed it and even learned a few things.
Posted by Tom Newman. Thanks for reading...