Can I switch scenes by swipe gesture or drag them? - cocos2d-iphone

Can I switch scenes by swipe gesture or drag them?
In my game, there are three main scenes, each of them has several layers which have some ui elements, these elements have some tap gesture.
This is my first time to ask question on stackoverflow, so this is the link of the picture:
enter link description here
I already know some ways to switch scenes, such as "replaceScene", or by some transitions ways, just like "CCTransitionMoveInT", so swiping scenes is feasible or not?
If not, why?
If yes, is it possible to cause memory increases that my gameApp crash?
Thanks men for your time.

Related

Rendering issue regarding imagery versus functionality

As I understand rendering textures in SDL2, everything is waiting behind the scenes and a texture appears after using the SDL_RenderPresent() function and vanishes with SDL_RenderClear(), which you use before advancing to the next frame.
I understand that as far as it goes for imagery, but what about functionality? I have two button textures linked to mouse events that I want to see and use at different times in different places. I've got them rendering during different enum states and each button does indeed appear and disappear on cue when the states change.
However, since both button textures are always "there" even while not being rendered, I can still mouse click on the invisible button that isn't being rendered at any given time. This doesn't seem to be an issue for mouse motion events, just mouse button events. How do I make a texture inactive as well as invisible when it's not being rendered?
I solved this one with some tinkering and a more experienced programmer named mbozzi's help to clue me in the right direction as to what was going on. The underlying issue was due to my completely decoupling the GUI logic and GUI rendering. Which is what we are always told to do: decouple everything, right? But I needed to couple the logic and rendering that I want to occur at the same time and place.
My event poll>>mouse input>>image rendering code was one giant loop. However, when I split that giant loop into separate mini event poll>>mouse input>>image rendering loops that each runs independently (but not concurrently, I just put them in their own different enum game states), that clears up the issue. So, if anyone has a similar problem with clicking invisible buttons, hopefully this will help.

realistic jump like all games in cocos2d iphone

i am new on game development so can any one guide me or help to make the jump in the game more realistic like monster inc run,mega run have in which user can jump or also make the long jump if it pressed long on screen. i tried the box2d code for making simple jump i am using this code
b2Vec2 impulse = b2Vec2([self body]->GetMass()*vert, [self body]->GetMass()*horz);
b2Vec2 impulsePoint = [self body]->GetWorldCenter();//GetWorldPoint(b2Vec2(5.0/100.0, -15.0/100.0));
[self body]->ApplyLinearImpulse(impulse, impulsePoint);
but it's not giving me the correct result i want the exact logic or technique which all the games have. Can any one suggest me the book,tutorial,or sample code so i can make my game more attractive with game play and also tell me how i can make the longer jump thing. i searched a lot but i didn't find any good tutorial or thing on the web so i decided to asked it here and sorry for my english i am not good with it.
I do not know Cocos2D, but I can suggest you how I've seen it done:
When the user starts pressing the button, you start applying a vertical force to the character, this force continues applying for a certain ammount of time (having the character achieve more height) or until the user stops pressing the button.
That way if its just a tap then the force applied is little, but if the button is pressed for longer the character jumps higher

Using replace scene to navigate

I have a question with regards to using replace scene in cocos2d.
Assume my game menu has the following structure:
Main Menu
Play
2.1 Strategy levels
2.2 Accuracy levels
Settings
Tutorial
Is the recommended method of navigation between the menus, "replace scene" or "push/pop"?
I've read in some places that its good to avoid push/pop in cocos2d. But my concern in using replace scene is that i have the impression that im just stacking up scenes instead of having a proper navigational flow.
Push and pop scene is going to stack your scenes. Each time you push a new scene, the old scene remains in memory and you need the exact same amount of popScene to get back to the initial scene.
So yes, using replaceScene is the standard and recommended method of switching scenes. While replaceScene removes the original scene from memory, there is a short time of overlap where both scenes remain in memory. So if you have two very memory intensive scenes, it is recommended to go through a temporary loading scene instead to allow the previous scene enough time to release its memory.
Note also that you cannot call replaceScene within the init method of a scene. That will cause CCDirector to crash.

Select underlying objects

Greetings!
I've made a program that lets you draw shapes. All shapes are contained in a vector. What I need help with is; when several shapes are stacked on top of each other, I want to cycle through them, top to bottom, if the user clicks repeatedly. I'm thinking something along the lines of:
Store every object under the mouse location where the user clicked in some sort of container
Keep track of which object was first in queue, and should be last (?) after the next click
Repeat step two until the user clicks somewhere that results in a different queue
This is more of a general programming question, rather than just C++, but any help would be greatly appreciated, and if that answer also provides a pretty solution in C++, all the better!
A popular approach to this is to assign each item a z-order. Items with higher z-order hide items with lower z-order if they overlap. In your case, you would just have to find all items below the cursor and rotate their z-orders when the user clicks.

What is the best way to set up menus with cocos2d?

I'm new to development and I have played around with a few tutorials. I wonder what the best way to set up a menu for a game with cocos2d?
I want a MainMenu with a Startbutton, SettingsButton, HighScoresButton and a little info/creditsButton in the corner.
How should I set this up?
Should I have the MainMenu as a Scene and the others as layers or just make all of them as separate Scenes?
The buttons that I add, should they be a plain button and then I add the textLabel on top or should I make them complete with textLabel?
I would like the buttons to "wiggle" like it is made of jello when i tap them, how do I do that?
As I said, I am new to this but I wanna learn as much as I can before school starts. I'm currently taking a summer class in iphone development so I get a head start for the next semester. I would like to see experienced game developers to help me out with this since i want to work with that when I get older, if they could also show me how to structure a game and the design.
Thank you so much.
David H
You've got several questions buried in there, so I'll address them in order...
First, to save on memory, you should break sections of your game, including menus, into separate scenes and switch between them using:
[[CCDirector sharedDirector] replaceScene: yourScene];
Alternatively you can use pushScene: and popScene, but these hold pushed scenes in memory and can be very costly depending on what you've got in the scene.
As for how to design your buttons, that's completely up to you and what fits best with the game. Some games look fine with text buttons. Others need a more stylized button that is best created with images. Remember, a CCMenuItem (button) is just a CCNode, so you can layer images and text in almost any way you wish.
Animating buttons is going to be a manual thing. I suggest subclassing the CCMenuItem, or CCMenuItemImage and overriding the selected and unselected methods to animate the underlying images.
We used cocos2d for our game The Selfish Birdbreeder. You can find the game and source here and dig around. I'm pretty certain we have a main menu.
http://pyweek.org/e/BirdBreeder/