Disable AutoDim mode in Cocos2d

How to stop the screen from automatically dimming after you have not received any user touches in cocos2d?

+3
source share
3 answers
    [UIApplication sharedApplication].idleTimerDisabled = YES;

add this to your appDelegate, this will not allow the device to sleep when the application is running.

+8
source
[UIApplication sharedApplication].idleTimerDisabled = YES;

To save the battery, you should turn off the idle timer only when necessary (for example, when the user is playing, but not when viewing the menu).

So it’s better to put this code in the function of onEnteryour game layer, and then add

    [UIApplication sharedApplication].idleTimerDisabled = NO;

to your onExit function

+7
source

The code above should work, but try writing it differently like this:

id myApplication = [UIApplication sharedApplication];
    [myApplication setIdleTimerDisabled:YES];
0
source

Source: https://habr.com/ru/post/1793772/


All Articles