More iOS issues

Previous topic - Next topic

AlienMenace

Hello,

I have an app running perfectly on my PC but have run into a couple of snafus when running it on my iPhone.
I am using the following code to try and load the previously used settings:

file$=PLATFORMINFO$("DOCUMENTS")+"/test.ini"
file_exist=DOESFILEEXIST(file$)

IF file_exist
   INIOPEN file$
   Ffx_mode=INIGET$("Main", "fx_mode")
   Fselect=INIGET$("Main", "select")
   Fvisible=INIGET$("Main", "visible")
   Fcolor=INIGET$("Main", "color")
   Fmute=INIGET$("Main", "mute")
ENDIF

and here is the code I am using on GLB_ON_QUIT:

   file_exist=DOESFILEEXIST(file$)
   IF file_exist THEN KILLFILE file$
   INIOPEN file$
   INIPUT "Main", "fx_mode", Ffx_mode
   INIPUT "Main", "select",Fselect
   INIPUT "Main", "visible", Fvisible
   INIPUT "Main", "color", Fcolor
   INIPUT "Main", "mute", Fmute
   INIOPEN ""

Works as expected on my PC but broken on the iPhone.

The next problem involves the SOUNDPLAYING command. I want to loop a sound
and since there is no built-in command to do this, I've done it this way:

IF Fmute=0 AND SOUNDPLAYING(sound_channel)=0 THEN sound_channel=PLAYSOUND(703,0.0,1)

This works fine on the PC but on the iphone, the return value of SOUNDPLAYING seems
to always return 0 so it restarts the sound each loop resulting in an annoying humming noise.

This also works as expected on my PC but is broken on the iPhone.
Thanks in advance for the help.
Apps published: 3

Kitty Hello

Ha!!! You can't INIOPEN an ini file that does not exist. Stupid, but that's the way.

AlienMenace

#2
Sorry, I really don't understand your reply...

How exactly are you suppose to create the ini file in the first place then? I based this on the code example from the helpfile which says "Calling INIOPEN on a .ini file that does not exist will cause it to be created."

Any thoughts on why SOUNDPLAYING is not working correctly?
Apps published: 3

MrTAToad

You check to see if the INI file is present, and if not, create an empty one (OPENFILE and then CLOSE it straight away).

SOUNDPLAYING does seem like a bug :)

AlienMenace

I added the following:

   file_exist=DOESFILEEXIST(file$)

   IF file_exist THEN KILLFILE file$

   OPENFILE(1, file$, 0)
   CLOSEFILE 1

Still does not seem to work.
Apps published: 3

quangdx

I've been using this to get a sound to loop,
it works for me on PC, Mac and iOS
Code (glbasic) Select

IF SOUNDPLAYING(channel)
ELSE
channel=PLAYSOUND(1,0,1)
ENDIF

Asobi tech - the science of play.
Spare time indiegame developer.

spicypixel

Quote from: quangdx on 2011-May-13
I've been using this to get a sound to loop,
it works for me on PC, Mac and iOS
Code (glbasic) Select

IF SOUNDPLAYING(channel)
ELSE
channel=PLAYSOUND(1,0,1)
ENDIF


You could put...
Code (glbasic) Select
IF NOT SOUNDPLAYING(channel) THEN channel=PLAYSOUND(1,0,1)

little neater unless you put the ENDIF to do something else when it was playing.
http://www.spicypixel.net | http://www.facebook.com/SpicyPixel.NET

Comps Owned - ZX.81, ZX.48K, ZX.128K+2, Vic20, C64, Atari-ST, A500.600.1200, PC, Apple Mini-Mac.

Kitty Hello

@AlienMenace - please post what the debug console shows then.

quangdx

Quote from: spicypixel on 2011-May-13
Quote from: quangdx on 2011-May-13
I've been using this to get a sound to loop,
it works for me on PC, Mac and iOS
Code (glbasic) Select

IF SOUNDPLAYING(channel)
ELSE
channel=PLAYSOUND(1,0,1)
ENDIF


You could put...
Code (glbasic) Select
IF NOT SOUNDPLAYING(channel) THEN channel=PLAYSOUND(1,0,1)

little neater unless you put the ENDIF to do something else when it was playing.

The code is like that to allow easy expandability later,
but once the program is finished I would go through the code and optimise it,
with things like your suggestion.
Thanks.
Asobi tech - the science of play.
Spare time indiegame developer.

AlienMenace

Thanks for the help guys. I switched everything over to playmusic which did enable me to use AAC files which really cuts down the final size of the package. I do understand that I may not have implemented this the most eloquent way but it still should have worked, right?

The other issue is the bigger issue for me. I have not been able to write an ini file on the iphone. Currently I have this:

global file$
local file_exist

file$=PLATFORMINFO$("DOCUMENTS")+"/test.ini"
file_exist=DOESFILEEXIST(file$)

// CODE AT THE START TO LOAD SAVED VALUES
IF file_exist
   INIOPEN file$
   Ffx_mode=INIGET$("Main", "fx_mode")
   Fselect=INIGET$("Main", "select")
   Fvisible=INIGET$("Main", "visible")
   Fcolor=INIGET$("Main", "color")
   Fmute=INIGET$("Main", "mute")
ENDIF

// CODE I AM USING IN SUB GLB_ON_QUIT TO WRITE A NEW SET OF VALUES
local file_exist

file_exist=DOESFILEEXIST(file$)
IF file_exist THEN KILLFILE file$
OPENFILE(1,file$, FALSE)
CLOSEFILE 1

   INIOPEN file$
   INIPUT "Main", "fx_mode", Ffx_mode
   INIPUT "Main", "select",Fselect
   INIPUT "Main", "visible", Fvisible
   INIPUT "Main", "color", Fcolor
   INIPUT "Main", "mute", Fmute
   INIOPEN ""

Can anybody see what I am doing wrong here?
Thank you!
Apps published: 3

MrTAToad

Ah - the GLB_ON_QUIT thing should have given it away.  First of, make sure that AUTOPAUSE TRUE is used.  It would also be a good idea to check to see if GLB_ON_QUIT is actually being called (its quite possible that its not).

ampos

#11
I have this code on my app and is working:

Code (glbasic) Select
datpat$=PLATFORMINFO$("DOCUMENTS")+"/datos.ini"
INIOPEN datpat$
record=INIGET$("puntos","record")


and in the game_over function:

Code (glbasic) Select
INIPUT "puntos","record",record
KEYWAIT;END


Note that there is no file_exist or anything else, just this sentences related to iniput. Even I noticed I forgot the iniclose...

Check that your record-thing is working OUTSIDE glb_onquit. Once you have it working, move inside glb_on_quit.

If file does not exist, iniget should return "no_data", and iniopen should create the file.
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

ampos

Quote from: Kitty Hello on 2011-May-12
Ha!!! You can't INIOPEN an ini file that does not exist. Stupid, but that's the way.

INIOPEN creates the file if it does not exists, or perhaps the thing that create the file is really the iniput thing, but I can promise that I have created a non-existent file just with iniopen+iniput.
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

MrTAToad

Unfortunately INIOPEN is a bit inconsistent across the different platforms - it works without the need for an empty file on Windows, Linux etc, but on webOS and Android, you do need the check.

ampos

My app works the same on WebOS and iOS. In both platform, you dont need the check. "The last angel" app is the example. I use iniopen, iniput and iniwrite to write the language preferences.
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE