Storyboard.hideOverlay: accessing parent functions issue - lua

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

Related

Game programming in Xcode and Sprite-builder. Display while computer "thinks"

I am working on an app for a physical boardgames I have produced in the past. Everything is working fine (for now). But the app "freezes up" when the code for the computer "thinking" kicks in.
This is understandable, the computer needs time to make it's turn.
My question is. Is there any way I can simultaneously set an animation to run (like a progress icon), while the computer continues to "think" over it's turn?
Thank You.
You can't make something like a progress bar which indicates exactly when the computer will finish 'thinking' exactly because the computer does not know when it will be done.
However, you can create an animation that will run as long as the computer 'thinks'.
In your Gameplay file in Spritebuilder, create the animation that you want shown while the user waits. Chain this animation timeline to itself. Let's call the default timeline animation 'default' and the 'computer is thinking' timeline animation 'think'.
Inside the method you use to start the computer's turn, add a line of code that warns cocos2d to run the 'think' animation sequence; it would also be good to make any user interaction with the game impossible at this time (example below is given in Swift):
animationManager.runAnimationsForSequenceNamed("think")
self.userInteractionEnabled = false
Since the 'think' timeline was chained to itself, it will run in an infinite loop, only stopping once cocos2d receives an instruction to break that timeline and start executing another one, so, just inside the method you execute once the computer's turn is over, add these two lines in order to stop the 'think' animation from running and to enable user interaction once again:
animationManager.runAnimationsForSequenceNamed("default")
self.userInteractionEnabled = true
Not knowing where you are building your actual game in, using different threads is the way to go. What are you building your game in? Which language, framework, platform?

App crashes transitioning scenes swift sprite kit

I am building an app that has a main scene and a restart scene. The main game scene uses sprite kit physics to have an object controlled by the user float across the screen. When it rashes into an obstacle the app transitions to the end scene using:
self.presentScene.restartscene.
This works just fine. then the restart scene has a restart button. when this is clicked the app transitions back to the game scene using:
self.presentscene.gamescene
i know this presents the original scene because i did an ns log to make sure. The problem is when this original scene is presented again the scene changes colors multiple times alternates very quickly between one and two nodes on the screen and then crashes. I have no idea the cause. i have had this problem before and i know other people have. no one has given me a definite answer. i hope one of you guys will. Thank you. help needed badly!!!!!!!
Try to navigate between scenes this way:
let nextScene = GameScene(fileNamed: "SceneNameHere")!
scene?.view?.presentScene(nextScene)
Also please check your code on startup in the gamescene.
May be you are using some global flags to store value for win/fail/restart conditions and your scenes simply open together one by one (it is hard to say without checking actual code).
You need to remove the original seen from view after transitioning away from it. Use this code:
myView.removeFromParentViewController()
Hope this helps :)

SpriteBuilder timeline autoplay animation not running

I am trying to understand SpriteBuilder.
I am facing problem of autoplay animation; it behaves strangely. I am sure I am missing some steps.
It is running in one case while in other when I load the .ccb file it is not running.
How can I track why autoplay animation is not running in .cbb file when I load it? What am I doing wrong?
And in the same way, the code of
[self.animationManager runAnimationsForSequenceNamed:#"WaitingForOpponent"];
is also not working in the same way. though it works some time.
EDIT
Actually, I found it; it stops working when I get invitation via Game Centre for playing game. In short, if I get UIAlertView from Game Centre all animations of sprite builder stops working.
But I don't know how to tackle that situation.
Thanks.
Well i got the answer how you can achieve it, actually when you get Game centre Push Notification cocos2d: animation stopped
** message
and after that you get message **cocos2d: animation started with frame interval: 4.00.
but it is not actually starting animation
what i did in applicationDidBecomeActive i put that code [super applicationDidBecomeActive:application]; and it solved my problem :)

How to implement a loading screen using storyboard?

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.

Completely reload a gamepage in monogame

I am trying to completely reload a gamepage in monogame - simply by touching a sprite on the page. I cannot find any solution for this.
In Android, I can call finish for the gameactivity, and then recreate a new one. How can I do that in monogame?
I am using WP8.0 SDK, monogame with XNA 4 framework.
I'm not familiar with Android development, or specifically what you mean by "gamepage", but typically this type of thing is handled with "states" in game development. You can have a playing state, paused state, Main Menu state, etc, and you just pass the game object to each state class and have it override the update/draw methods with its own information.
So, in your case, you would be in the playing state of the game, and if the sprite is touched, you might want to go back to the main title, you can pass the game object to the Title Screen State. The Title SCreen can have a call to LoadContent() which will reload all assets (effectively restarting the game completely).
Not sure if that helps. =X

Resources