Cocos2d android not pausing the game - cocos2d-android

i want to pause my game i used the following code but its not pausing when we return from any interrupt its shows the main menu screen.its starting from 1st again.
It is expected that if user gives any sort of interrupt during action phase of the game then after returning back from the interrupt game should pause at the exact location where interrupt occurred displaying pause screen with required options.
CCDirector.sharedDirector().pause();

I got this issue solved. The problem is with the screen orientation change. The game is in landscape mode, when the device sleeps the screen orientation automatically changes to portrait mode. This results in restarting the activity.
Adding android:configChanges="keyboard|keyboardHidden|orientation" to the activity in the manifest solves the issue.

Related

How to reset camera after error in EDSDK

I have following problem when I control camera through EDSDK: if camera fails to shoot after EdsSendCommand, for example if autofocus fails, then it will return "device is busy" error for any subsequent commands. Is there any way to bring camera back to working state except for physically turning it off and on again?
Try to send the camera button code to release busy event
My camera init
Private WithEvents MainCamera As EOSDigital.API.Camera
Cancel Busy
MainCamera.SendCommand(CameraCommand.PressShutterButton, 3)
MainCamera.SendCommand(CameraCommand.PressShutterButton, 0)

iOS app cpu usage decreases when press UIButton

I am creating a game for iOS. The game is written as a C++ library so that it can be ported to another platform. I am also using Swift and Objective C to call the game update, draw functions and process user input etc. in the view controller.
I am having and issue where the game begins to stutter when I press a UIButton to perform some action in the game. I have noticed even when the UIButton callback function is empty, the game still stutters.
The game idles at ~30% CPU usage. When I press the button, the cpu usage drops to ~15% for a few seconds, then gradually makes its way back up 30%. It's during this time that the game stutters.
It seems to me that when the button is pressed, the operating system is allocating fewer resources to the app, causing it to slow down.
To try and resolve this problem, I have put the game update function on a new thread to take some weight off the main thread. This did not work.
Any idea what could be causing this?

Opengl program not looping when window is focused

I'm having problems running my opengl 4 program. When the window is in focus, nothing appears to happen (even alt+f4 doesn't register until the window is out of focus).
If the window containing my program is in focus, then the main loop for my program stops executing (I checked using printf statements, within my while(true) loop, and the output stops completely when focused on the window). When the window is not focused, the program runs as expected (including mouse movements inside the window changing the camera direction).
I've narrowed it down to this line of code, which is executed within my mouse callback method
glfwSetCursorPos ( window, middleX, middleY);
If this is commented out, the program runs fine when in focus, but the mouse is no longer centred, so the camera logic no longer works.
I'm using 32 bit versions of glfw3 and glew.
This program has worked on other machines in the past. Is there any way to fix this without restructuring the code to poll the mouse input?
If you execute glfwSetCursorPos() inside your mouse callback, you can get to the situation that this creates a new mouse event, and after your callback exited, glfwPollEvents() will loop over the remaining events, so you effectively enter some endless loop here. You should just delay such actions after the input callbacks have been handled.
However, even with that approach, you will generate a new event for each frame, so that I suggest dropping the callback overhead alltogether and just quering the mouse position with glfwGetCursorPos() directly every frame.

Pause the particular scene in cocos2d-x

I am developing a game using cocos2d-x. I want to pause the particular scene, when user press the pause button.
Thanks.
You can pause a particular scene in two different ways
1.) Use CCDirector::sharedDirector()->stopAnimation(); to pause and CCDirector::sharedDirector()->startAnimation(); to resume.
2.) Use CCDirector::sharedDirector()->pause(); to pause and
CCDirector::sharedDirector()->resume(); to resume.

C++ Creating a Screen Saver for Windows

I have created an animation in C++ using OpenGL and SDL (it uses no Windows libraries) and wish to use it as a screen saver for a Windows system. I read one example: it describes that you simply have to change the .exe extension to .scr.
I have done that and ran the animation as a screen saver but I noticed that the animation did not run smoothly at all. As if there was a loss in the application performance.
The application I made creates the animation, sets it to full screen, hides the cursor and handles all keyboard input. How can I make my application run smoothly as a screen saver?
It's more than just renaming the file.
At the bare minimum you must support correct behavior in response to the following command line parameters (taken from Microsoft):
ScreenSaver - Show the Settings dialog box.
ScreenSaver /c - Show the Settings dialog box, modal to the
foreground window.
ScreenSaver /p <HWND> - Preview Screen Saver as child of window <HWND>.
ScreenSaver /s - Run the Screen Saver.
If multiple instances of your executable are being started and run as a full screen screen saver (the screen saver should only actually run if /s is specified), that may be the cause of your performance issues. You should verify that in e.g. Task Manager.
Hope that helps.