cocos2d game reset problem - cocos2d-iphone

I have a cocos2d game, and after I exit the game and start it again, it starts at the exact same point it was before closing.why this is happening??and not only this, my game is landscapemode but when i start it again from simulator it comes in potrait mode,not it landscapemode like first time.
Is there any way to prevent this?
Anyone will come to rescue me???

From iOS 4.0, there are new options for "info.plist" file.
If you do not want to add multi-tasking(running in background), just add it.
You can add the option by just clicking and checking in your game project's "info.plist".
And rotation setting is on your "RootViewController.m" file.
You can change your app direction by just changing return value.
I hope your game will work well.

Related

Sending mouse and keyboard input to a unity3d game (Rust)

I would like a python option but that doesn't seem likely, I looked into c++ but I'm not intimately familiar and the methods I tried were not working. I need to be able to move the mouse(which I have been able to do) inside the game (which never works), and to press and or hold keys, AutoHotKey doesn't work for moving the mouse inside of popup dialogs only for controlling recoil and such. I have permission from the admin, I admin on one of his other servers, I'm not looking to release hacks for the game, its just a project I dabbled with for a while and would like to see out.
Does anyone have experience with this or ideas as to how I can simulate input from mouse or keyboard?
i have expeience in ahk and game bot making
https://www.youtube.com/user/FloowSnaake/videos

Multiplayer Spawning in UE4 blueprint

i want to create a local multiplayer game for 2-4 players.
It seems like i have made a mistake or it is a bug. I tried different tutorials but i dont get my mistake. I posted the same question in the answer hub of unreal, but i didn´t get a response. Here ist my gamemode and the spawning function:
GamemodeSpawning
My Pawn is called Physics Ball BP. The default spawn in the gamemode is disabled. The default value of the variable "Max Player Amount" is 2. "Player Start Array" contains the PlayerStarts. The PlayerStarts have the tag "0" and "1". This is my viewport before the start:
Viewport
This is my viewport if i press Play: ViewportPlaying
I think i just missed something basic, but i cant figure out what i´ve done wrong. I hope you can help me.
best regards chris
Not sure if you did it on purpose but you uploaded the same screenshot of your viewport twice. Maybe edit your post, and upload the right ones.
But maybe the problem your having is because you forgot to plug your Index variable into the Player Int variable in the Spawn Actor node?

How to alternate between two scenes in cocos2d-x?

I'm creating a game using Cocos2d-x. I'm currently creating a gameover menu, in that menu I need to be able to switch to both my menuscene and my gamescene (When I say switch to gamescene I only really only mean "to restart" the game). But circular dependencies stop me from being able to do this.
MenuScene needs to be able to useGameScene::create() in order to switch to the gamescene and the gameover menu needs to be able to use both of GameScene::create() or its restart funtion and MenuScene::create() which is giving me circular dependency problems
I can't separate my gameover menu to it's own file as I still need the GameScene dependency and GameScene would need gameover.
I can't combine them as GameScene then needs to depend on MenuScene
So my question is: How do I alternate between two scenes in cocos2d-x c++.
I read somewhere about pushing and popnig scenes in Director, but I don't really understand how that works, or if I could use that for my purpose.
Thank you in advance!
EDIT:
Now that I think about it, could I not just push mMenuScene to Director before switching to GameScene? That should work if I understand that push/pop mechanic correctly.
I think you might have a misconception of how complex this is, using the way I provided below you can and should definitely split your game over scene into its own file.
The scene replace is easy enough, just use the code below:
Including your file:
#include "MainGameScene.h"
Creating and switching scenes in your onClickListener:
auto gameOverScene = GameOverScene::createScene();
// use code below for hard replace
Director::getInstance()->replaceScene(gameOverScene );
// or use code below for transition fade replace
Director::getInstance()->replaceScene(TransitionFade::create(1, gameOverScene , Color3B(255, 255, 255)));
As for the restart functionality. I usually provide a callback to my game over scene that I call when the restart button has been clicked. Not that I ever swap out my scene completely for a mobile game over scene, but I still do it the same way regardless. So lets do steps (This assumes you seperated your game over scene into it's own file named GameOverScene :) ).
Store a function pointer in your GameOverScene.h to your reset method in MainGameScene:
std::function<void()> _resetCallback;
Set your function pointer from the main game scene, before running with the GameOverScene.
auto gameOverScene = GameOverScene::createGameOverScene();
gameOverScene->setResetCallback(std::bind(&MainGameScene::reset, this));
When your reset button is clicked, call the _resetCallback
void GameOverScene::onResetClicked(Ref* sender)
{
_resetCallback();
}
This should provide you with all the functionality you need to set up a what you want as well as remove the circular dependency that you have. I have used this way many times before and it always works. Let me know if this solution works for you.

Player Disconnect Issue GKMatch and Gamekit

i am working with cocos2d game with GameKit. I am creating match with 2 player using GKMatch. All thing is working fine for me but When one player enters the background state or pressing home button , then player is disconnected. I want to run GKMatch instance in background also. Please help me.
Thanks in advance.
I don't think that's possible, after all "background" means the player stopped playing.
While the programming guide might not mention that explicity, it does one thing, namely automatically logging in the player when the application enters foreground, which to me indicates there's simply no player GKMatch could be connected with while the app is in the background.

how to reset game in cocos2d

My question in the previous post was-
I have a cocos2d game, and after I
exit the game and start it again, it
starts at the exact same point it was
before closing.why this is
happening??and not only this, my game
is landscapemode but when I start it
again from simulator it comes in
portrait mode,not it landscapemode like
first time.
Is there any way to prevent this?
Anyone will come to rescue me???
I found a solution.Is it good??
when I exit the game(by pressing the back button in iPhone simulator) this problem occurred. Now I found that if I press back button the following function is called-
(void)applicationWillResignActive:(UIApplication *)application
So I set (divide by zero) or something like this in -(void)applicationWillResignActive function so that when this function called the application crashes. Then if I restart the application everything comes from beginning(reset) which I want. Is it good solution or anything better?
*my applicationDidFinishLaunching was not called again when application is restart from simulator.
You should configure the Info.plist to indicate that you does not want your application run in Background.
The key is
UIApplicationExitsOnSuspend
If you need more detail you should look at this tutorial
If you have iOS 4.0 or higher, multitasking is causing your problem.