iPhone AutoLock function

Previous topic - Next topic

Dark Schneider

I am sure this can be useful to many, it is typical in pro games to disable the iPhone autolock while you are playing, if not you are required to touch the screen, and it can affect how your app is used (forced touchs).

For use it, simply add the iOSAuxFunc.gbas to your GLBASIC project, and the iOSAuxFunc.m to your XCode project, for example to the Other Sources folder.

Included in the iOSAuxFunc is the EnableAutoLock() function, pass FALSE to disable it and TRUE to enable it again. There is no need to call EnableAutoLock(TRUE) on exit because the iOS devices do it by its own. The typical use is:

- Do not call at beginning.
- Call EnableAutoLock(FALSE) at start of GAMEPLAY.
- If paused, call EnableAutoLock(TRUE). When return to game call EnableAutoLock(FALSE).
- When gameplay ends (return to main menu, etc.), call EnableAutoLock(TRUE).

As summary, set AutoLock = OFF ( EnableAutoLock(FALSE) ) ONLY while playing, is the way iPhone games does it mainly.

[attachment deleted by admin]

bigsofty

Ha! Well done, I was just thinking about this functionality last night, thank you!  :booze:

Cheers,


Ian
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Crivens

Phew glad I found this. My latest game has this problem when dimming (didn't notice while testing as my phone dims after 5 minutes and I don't know anyone who can survive my game for that long). Will have to do an update.

Out of interest any idea how to do the same thing on Android and WebOS?

Cheers
Current fave quote: Cause you like musicians and I like people with boobs.

tatakamucher

i used too, its great  :D

Crivens

Just got round to using this and it works as advertised. Nice! Anyone found a WebOS or Android solution yet?

Only thing I found when I compiled it was this message:-
Code (glbasic) Select
*** Configuration: IPHONE ***
precompiling:
GPC - GLBasic Precompiler V.9.829 SN:48b9de4b - 3D, NET
Wordcount:4391 commands
compiling:
arch:
/cygdrive/q/Compiler/platform/iPhone/bin/arm-apple-darwin9-libtool: file: gpc_temp5.o has no symbols
/cygdrive/c/Program Files/GLBasic/Compiler/platform/iPhone/bin/arm-apple-darwin9-libtool: file: C:\Users\Crivens\AppData\Local\Temp\glbasic\output.obj(gpc_temp5.o) has no symbols


I've read on the forums this doesn't matter, but it's always nice to be rid of any problems. I assume it's something to do with the "(int value)" variable for the main function, mainly because my other iOS functions in other projects don't have variables and compile perfectly fine. Is there a better way to declare variables to stop the "has no symbols" message? It's not so bad with one function but would suck if you used a lot and had to scroll through messages.

Cheers
Current fave quote: Cause you like musicians and I like people with boobs.

Kitty Hello

in your files-pane, how many files do you see? There should be 6 of them. If there are only 5, delete the file that is reporting the warning.
Or: In file #6 (first is main program, which translates to gpc_temp0.cpp) write something like SUB summy:; ENDSUB.

mrplant

The Objective C code reads:

if (value) {
   [UIApplication sharedApplication].idleTimerDisabled = NO;
} else  {
   [UIApplication sharedApplication].idleTimerDisabled = NO;
   [UIApplication sharedApplication].idleTimerDisabled = YES;
}

Is there any reason for setting the value to NO then immediately to YES underneath - or is this just a remnant from testing?

Anyway - great routine  - very very useful for iOS apps.

cheers