Door closing transition in Cocos2d - iphone

I'm trying to make the door closing transition like what we can see in Kingdom Rush. (Two doors coming from the left and the right)
What I'm thinking is two approaches:
The first one could be a custom transition getting input as a door image
For this approach, I could not find a way to do it although it is my preferable way
Second approach could be creating the door closing animation on the first scene and push the second scene with the same door closed on the second scene. After that do the door opening animation.
This approach is possible but I wonder if there will be a blink in the scene transition
Has anyone come across this issue?
Thanks in advance

i'd suggest the 2nd one.
it's rather easy to that...something like this:
make an animation in a separate class and in your scene just call the animation to close at the end of the scene and replace the next scene with :[[CCDirector sharedDirector]replaceScene:[NextScene scene]];
If your scene loads relatively fast..it won't blink at all..but if it does (for some reason) make another thread and add "big things" to the next scene in a background thread so that the scene loads instantly, and in the time you animate the doors load the rest .
To detect if the doors are closed...just set a NSUserDefaults BOOL to YES in 1st scene and in the 2nd check if the door is closed.
As for the animation itself just make 2 ccsprites outside the screen and then animate them on the screen.Also..because the sprites are already in memory when you leave the scene, you won't need to load anything in the next scene..so it's instant.

Take a look to the CCTransition.m file in cocos2d sources. There in flip transition classes you can find examples of CCOrbitCamera action usage. In case of scenes it flips them relatieve to their center. But all transitions are made relatieve to node's anchor point. So you can try out different variants.

Related

how can I implement a Unity fps sprinting animation?

I'm currently working on an FPS game and I have these hand models as well as weapons. But I want it so that if I press the W key (move forward) it plays the sprinting animation with the arms. I initially thought of coding it like, if(Input.getkeydown(keycode.w))animation.play or something like that. But I'm using the character controller which doesn't use that. It uses the Input.getaxisraw. How should I implement this with the character controller?
Thank you a ton in advance
You will need to implement a basic animator controller. You can define all your states (Idle, Crouch, Jump, Sprint, Aim) and define the transitions between them. You may then add parameters like floats, triggers and booleans as conditions to transition between these states.
In the above example, if you want to move to a crouch state, you would use
GetComponent<Animator>().SetBool("Crouch", true);
Or for another example, if you want to move from Run to Walk. The transition (The blue lines indicating the movement from one state to another) will have a condition to move from walk to run and back based on the float parameter "Speed". if Speed>x, move from walk to run. else move from run to walk. In this case you would set
GetComponent<Animator>().SetFloat("Speed", floatValueHere)
and the controller will take care of the animation transitions.
This is just a pointing to the right direction. you will need to watch a couple of videos on animator controllers Check Unity's simple 8 minute explanation here Hope this helps!

Switch between scenes but keep player position when comes back?

My game will switch between two scenes : scene A and scene B;
scene A is a world where the hero can walk around and trigger battles;
scene B is the battle scene;
when the battle finished, I want to turn back to scene A and hero should be in the position where it trigger battles. So I need to save scene A before I load scene B;
I tried the api LoadSceneMode.Additive; But it's just used to mix one scene to the current loaded scenes.
Could you help me plz?
Firstly DO NOT use "additive". Just use ordinary scene load.
Secondly you have the problem of "remembering" where the guy was when sceneA loads.
Your easiest approach to get you going .. learn about PlayerPrefs.
Just before you quite sceneA, save the hero's position. When you load sceneA, get the hero's position.
Alternately you can use one static class as a sort of global to keep track of the info. But to do that you have to learn about writing that sort of code.
Be aware that what you're doing is not that easy - Unity is a lot harder than it says on the box.
I encourage you to master PlayerPrefs in the first instance, because you will have to use it all the time anyway.

Activate Two Cameras At The Same Time

How do I activate 2 cameras at the same time? The first camera follows the character and the second camera follows the character more slowly. After a while we can't see the character with the second camera but the point is each camera renders a special game object. The second camera renders the back game object. So two cameras with each other make better scene moving. Is this possible?
I believe you are looking to implement a scene background parallax where the background appears to be moving across the scene slower than the forground.
Take a look at this video about separating your scene's layers. There is a quick fix solution in the first few minutes of the video, and a longer re-work that is a good idea to think about.
Parallax Scrolling

How to show 2 scenes on screen at the same time

How can I show 2 scenes on the screen at the same time on Sprite Kit Swift?
I need to first scene be placed of the second (I need one scene to be seen and atop of it appeared other scene, which has some sprites).
Or tell me, how developers make, for example, menu (with buttons like "restart", "results") to appear on other scene when player dies? And that time, also you can see the main scene with location (or with dead character)?
You do not need 2 scenes. However, you can accomplish what you are after with basing an node tree off of an SKNode. For your menu idea you could build it out of however many objects you'd like, but since it is based from an SKNode, you can animate it to your hearts content. No need for two scene, just build another node tree and animate the root. If that isn't enough answer, I could write some code to help you out if need be. Sorry watching the Netflix and feeling lazy.

Unity - LoadLevelAsync hiccups on scene switch

I am trying to make a loading animation while using LoadLevelAsync to load the next scene.
The loading animation is a loading circle that continuously rotates in the middle of the screen, and I use LoadLevelAsync("NextScene") in the code. The problem is that every time right before the scene switch happens the circle will freeze for a few milliseconds before the next scene appears.
I do know that the less things the next scene contains, the shorter the freeze is, but I thought that LoadLevelAsync's purpose was for letting the user experience no lag during scene transitions. My next scene contains a background sprite, some buttons, scripts, and a 3MB audio file. The screen will always freeze for half a second before showing the next scene.
I am using Unity 4.6.3 with Pro feature. I'm also testing the results on a device. I have also tried out the AsyncOperation.allowSceneActivation with Coroutines, and unfortunately they don't work.
If anyone has a solution, or has any suggestions on smooth scene transitions, I would greatly appreciate them.
Thanks in advance.