In a Corona app using the storyboard library, what are the best practices for adding a loading screen between scenes? I'm guessing it should go somewhere in scene:enterScene() but I'm not sure how to make it work with Corona's rendering process. As I understand it, if I do the following, the loading screen would never be displayed since Corona waits until the code path has finished and then draws everything at once.
function scene:enterScene( event )
showLoadingScreenOverlay()
loadEverything()
hideLoadingScreenOverlay()
end
Is the correct approach to create a new storyboard scene for the loading screen itself? If so, how can I load the other content in the background while the loading scene is displayed?
In your case, you should be using loadScene():
http://docs.coronalabs.com/api/library/storyboard/loadScene.html
This will only call the createScene part of your new scene2...
Then what you could do is update loading progress in the createScene of scene2, and verify every x milliseconds in your original scene1 the loading progress. When it is 100%, just call goToScene in scene1 and it will load scene2 instantly.
Related
So Ive been wondering if this is possible to do, as it is important for my game.
Basically I have a menu.lua file (game plays only from this one file) but before the game loads up, I initiate this code which loads up a new lua file (tutorial.lua)
storyboard.showOverlay("tutorial", {effect="fromRight", isModal=true, time=50})
Now when I use this code to get back to menu.lua, the game does nothing.
storyboard.hideOverlay({"fromTop"})
The reason why is because my game begins from calling beginGame() from menu.lua. So I would like to ask if I can somehow call beginGame() from menu.lua once storyboard.hideOverlay code complete from within tutorial.lua
Cheers.
Corona no longer supports Storyboard implementation., So start using Corona Composer library. Corona Docs
In composer refer this to start the game when overlay hides. hideOverlay
I want to load Collada files dynamically in SceneKit at runtime. I have used copySceneKitAssetst to generate the .DAE file and put it my server. The app can download it from the server and use this file to init a SCNScene (refer to http://www.the-nerd.be/2014/11/07/dynamically-load-collada-files-in-scenekit-at-runtime/).
There is no error when executing "./copySceneKitAssets" and the models can be rendered properly. I have called [scnView prepareObject:gameScene shouldAbortBlock:NULL] before setting gameScene to the scnView.scene.
The problem is that the first time scnView renders the gameScene, its very slow (a few seconds). Even the main thread is blocked during this period which means UIs cannot refresh,h and sometimes the app is killed by iOS.From the second time it renders the scene,it's very fast and main thread works well.But if we delete the App and reinstall it,the problem comes again.
Any help is appreciated.
I think prepareObjects(_:withCompletionHandler) (defined on SCNSceneRenderer) is worth a look. It loads resources on a background thread.
does anyone know if there is a way to tell if the launch storyboard executed? Or is there a way to detect if the launch image was displayed?
Basically my app consists of just one view controller with some views (all created programmatically), plus the launch storyboard which I added to the project recently which seems to be working OK.
The reason why it would be useful for me to know if the launch storyboard happened is that my app is a game which basically consists of a big 2D scene that you can zoom into and pan around using the usual touch gestures. When the game starts for the first time it starts fully zoomed-out and centered on the scene: so that is what the launch image matches. But the player pans around and zooms-in on various things, so when they press the home button they could be zoomed into any part of the picture. So when they touch the app's icon to relaunch, if the launch storyboard happens it needs to put their pan/zoom position back to the initial centered zoomed-out position (otherwise as soon as the app gets going it would appear to the user to suddenly snap from the initial position represented in the launch image to where they were, not giving a smooth user experience).
What I do at the moment is -- if applicationDidEnterBackground: method gets called I assume that when the user relaunches the app, by touching the icon, that the launch storyboard will be executed. But the launch storyboard doesn't always happen after it hibernated via applicationDidEnterBackground:, especially if it is only a few minutes since the user pressed the home button.... and those times when the launch storyboard does not happen I need not inconvenience the player and put them back to the initial zoomed-out centered position, I could just let them carry on at the position they were.
I've not used storyboards before, but as I understand it launch storyboard are a special case where you can't make any connections to code because your app's not actually running yet, so I can't think of a way to set a variable, for example, to show the story board happened.
Anyone got any ideas?
Cheers,
Jon
Just use the viewDidLoad method provided by the UIViewController.
Just override the method in your ViewController and then you can perform the task you want when your View(Storyboard) is loaded.
Example:
#implementation MyViewController:UIViewController
-(void)viewDidLoad{
//Insert your code here
}
#end
I am building an app that contains a MKMapView. The first time user goes over this view, it takes a while for it to load, and things such as animating pin drops also don't work well as a result of it. It takes a bit for the location to stabilize if i choose another location from the simulator options.
Is there any way to load MKMapView very fast? May be run in background or what?I am confused? What do you guys do to load Map Faster?
put a splash screen on while it loads, and catch the event of the loading finishing is the delegate method mapViewDidFinishLoadingMap:
don't forget to set your ViewController (or other implementing object) as the delegate of the MKMapView object.
There are many iOS games where you can see that first is shown launch image, and then after certain amount of time, the preloader is added. Just after about a second, or maybe even two, and that is a noticeable delay. I was wondering why is that, and I am thinking that something like this is happening:
launch image is shown because view is not ready yet
now, about second or two later, the view is ready, launch image is removed, scene is initialized
then, preloader is added to the scene (or this is done directly in view controller) and after resources are loaded, the completition handler is called which removes preloader, and user now can use the interface
And because of the part while view is being initialized, the preloader can't be shown immediately right when a launch image is shown ? But if there is no view object yet, how is launch image shown? I think I am missing something...
So, the question is, at which point the launch image is presented/removed in app startup sequence exactly ? After which event/method execution? I suppose its removed after something like -viewWillAppear is executed for the first time? I hope this make some sense..
Your app's launch image is displayed as soon as your launch your app. Hence the name. It is removed when the appDelegate appDidFinishLaunching: method runs.
If you want to manually set a longer display time for your launch image, you can add this code to the appDidFinishLaunching: method
sleep(4);
4 being the number of seconds.