Author Topic: Sleep problem  (Read 6419 times)

Offline ggindlesperger

  • Mr. Drawsprite
  • **
  • Posts: 63
    • View Profile
Sleep problem
« on: 2010-Sep-26 »
Is there any known Sleep command problem when compiling for iPhone? I don't remember having issues with it in the past, but I have not tried using it since I have the latest build of GLBasic. Now it does not seem to work at all on the iPhone/iPod. When I compile and run within the IDE it works just like it should, but when I send it to the iPod there is no pause at all rather I make it Sleep 200 or Sleep 2000.

Any thoughts on this? Been trying different situations and sleep seems to always work in the IDE, but never on the iPhone/iPod anymore.

Thanks Much,
Gary

Offline Nobiag

  • Mr. Drawsprite
  • **
  • Posts: 58
    • View Profile
Re: Sleep problem
« Reply #1 on: 2010-Sep-26 »
I have the same problem, but i found it seems to only occur on older ipods/iphones. On my iPhone 4 the sleep command works without any problems, on iPod Touches 8gb/32gb it doesn't work.

Offline ggindlesperger

  • Mr. Drawsprite
  • **
  • Posts: 63
    • View Profile
Re: Sleep problem
« Reply #2 on: 2010-Sep-26 »
The ones I am having the problem with are a 3rd gen 8 gig and a 3rd gen 32 gig. Any other way to easily make the program pause without requiring user input to continue?

MrTAToad

  • Guest
Re: Sleep problem
« Reply #3 on: 2010-Sep-26 »
For the time being, use GETTIMERALL() and calculate the amount of time you want to wait for, with something like :

Code: (glbasic) [Select]
finishTime%=GETTIMERALL()
WHILE ABS(GETTIMERALL()-finishTime%)<1000
WEND

Offline ggindlesperger

  • Mr. Drawsprite
  • **
  • Posts: 63
    • View Profile
Re: Sleep problem
« Reply #4 on: 2010-Sep-26 »
Thanks alot for that piece of code. I will try it out. Looks like that should do the trick.

Gary

Offline BlueSteel

  • Mc. Print
  • *
  • Posts: 39
  • Jack of ALL codes .. master of none :(
    • View Profile
    • Coding Monkeys
Re: Sleep problem
« Reply #5 on: 2010-Sep-26 »
I rtoo have a sleeep problem..

I don't get enough of it.. lol

MrTAToad

  • Guest
Re: Sleep problem
« Reply #6 on: 2010-Sep-26 »
Dont we all :)

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4159
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: Sleep problem
« Reply #7 on: 2010-Sep-26 »
I'll sleep when I'm dead. Until then I'll code (pausing for the odd cup of cold tea and some pizza) :P
I came. I saw. I played.

MrTAToad

  • Guest
Re: Sleep problem
« Reply #8 on: 2010-Sep-26 »
True - I wonder even if the SLEEP command isn't sleeping per say on the offending machines, it does still relinquish control back to the operating system.

Offline ggindlesperger

  • Mr. Drawsprite
  • **
  • Posts: 63
    • View Profile
Re: Sleep problem
« Reply #9 on: 2010-Sep-27 »
More to the mystery...The same app has Sleep commands scattered throughout and they all work but the one section. So I started looking at what the difference is. Here is what I found. All of my Sleep commands that are within a loop such as an IF or WHILE loop work fine. The ones that do not are the ones that are out on their own. Here is basically what I am doing in the section that does not work.

I draw and move a sprite to a certain point. I want the sprite to change to another sprite, sleep, then change back and continue to move. The effect is to produce a face winking. When I run in the IDE it is perfect. When I run it on the iPod there is no pause at all no matter what highly ridiculous number I can put in for Sleep. These sleep commands are not within any kind of loop. That is the only difference I can see between the ones that work and the ones that do not.

Hope this helps,
Gary

Offline Scott_AW

  • Mr. Polyvector
  • ***
  • Posts: 214
    • View Profile
    • SAW Game Design
Re: Sleep problem
« Reply #10 on: 2010-Sep-27 »
Good thing to know.
Current Project, Orbital Contract Defense
http://gamejolt.com/games/adventure/code-name-ocd/9887/

BlackShadow now open source/resource(requires duke3d)
http://gamejolt.com/games/adventure/black-shadow-3d/9885/

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10759
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Sleep problem
« Reply #11 on: 2010-Sep-27 »
What OS version is that iPod ignoring sleep?

Offline ggindlesperger

  • Mr. Drawsprite
  • **
  • Posts: 63
    • View Profile
Re: Sleep problem
« Reply #12 on: 2010-Sep-29 »
The version is 4.1 . Real weird. I've never had the problem before. Even in the same program. The Sleep commands that were not working were not in a loop. I know most things are in a loop in one way or another, but these commands were used for an intro screen and only execute once. Ran fine in the GLBasic IDE when compilied and ran. Once on the iPod it did not pause at all. Went so fast you never saw the sprite change.

Hope this helps. I used a work around for the time being.

Gary

Offline msx

  • Prof. Inline
  • *****
  • Posts: 773
    • View Profile
Re: Sleep problem
« Reply #13 on: 2011-Jan-05 »
Is there any solution for this problem?

Offline Slydog

  • Prof. Inline
  • *****
  • Posts: 932
  • KodeSource
    • View Profile
    • KodeSource
Re: Sleep problem
« Reply #14 on: 2011-Jan-05 »
If not, you could create your own temporary function, using the above code.
And to get around the problem of relinquishing control back to the OS, a simple 'SHOWSCREEN' should help I think.

Code: (glbasic) [Select]
FUNCTION Pause%: delay%
  LOCAL time_start% = GETTIMERALL()
  WHILE ABS(GETTIMERALL() - time_start) < delay
    SHOWSCREEN
  WEND
ENDFUNCTION
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]