Jeffrey's Noob Questions

This thread is for me to ask questions that i need help with. I will also update the main post for every solution contributed by other devs. So everyone can benefit from it [:

  1. How can i create a patch or update for an app?
    [lua]-- Replied by: peach pellen
    "Create the update, build it and set the version at 1.1, 2.0, etc., whatever you want.

Then you can upload it to Apple.

It’s a lot less effort than the first build ;)"[/lua]

  1. Is there a folder format for where i should put my pictures and save files in? Or i can just put everything in one folder with the .lua files?
    [lua]-- Replied by: peach pellen
    “One folder is fine - and an update is easy for the iPhone.”[/lua]

  2. If i update a new version, will it replace the save file that is already in the iPhone? My save file is generated when the player quits the game.
    [lua]-- Replied by: peach pellen
    “Add this;”


settings =
{
iphone = {
plist = {
UIApplicationExitsOnSuspend = false
}
}
}

“in build.settings”[/lua]

  1. Another question caught up while testing my game on my iphone. How do i make the game suspend when i press my home button?
    [lua]-- Replied by: peach pellen
    “For the updated version, I’m not actually certain - I believe it wont, no.”[/lua]

  2. How do i delete save file from my iphone after i am done testing with my own game?
    [lua]-- Replied by: peach pellen
    “When you delete your app from your phone the save file is also deleted. (This is why I BELIEVE updating keeps it intact, although again I am not certain on this point.)”[/lua] [import]uid: 74723 topic_id: 12588 reply_id: 312588[/import]

Hey there,

One folder is fine - and an update is easy for the iPhone.

Create the update, build it and set the version at 1.1, 2.0, etc., whatever you want.

Then you can upload it to Apple.

It’s a lot less effort than the first build :wink:

Peach [import]uid: 52491 topic_id: 12588 reply_id: 46077[/import]

Hi, thanks for the reply

If i update a new version, will it replace the save file that is already in the iPhone? My save file is generated when the player quits the game.

EDIT: Another question caught up while testing my game on my iphone. How do i make the game suspend when i press my home button? [import]uid: 74723 topic_id: 12588 reply_id: 46086[/import]

Add this;

[lua]settings =
{
iphone = {
plist = {
UIApplicationExitsOnSuspend = false
}
}
}[/lua]

in build.settings.

For the updated version, I’m not actually certain - I believe it wont, no. [import]uid: 52491 topic_id: 12588 reply_id: 46220[/import]

Thanks for the helpful reply. Appreciate it!

A new question: How do i delete save file from my iphone after i am done testing with my own game? [import]uid: 74723 topic_id: 12588 reply_id: 46376[/import]

No worries :slight_smile:

When you delete your app from your phone the save file is also deleted. (This is why I BELIEVE updating keeps it intact, although again I am not certain on this point.)

[import]uid: 52491 topic_id: 12588 reply_id: 46388[/import]

hello again [:

Is there anyone that can confirm whether an update will delete the save file on someone’s iphone if they bought my game? I really need it to keep the save file (RPG) when i do an update for bug fix or other stuff.

A new question: I don’t know if this is the right section though. Since corona simulator can’t test keyboards. Can anyone let me know if my understanding is correct?

*I’ve look through the sample code, just need confirmation [:

[lua]-- This will call the keyboard in iPhone automatically when the user taps it?
defaultField = native.newTextField( 10, 30, 180, tHeight, fieldHandler )

– If i change the above code to this by taking the listener out
– Will it still close the keyboard when i press return?
defaultField = native.newTextField( 10, 30, 180, tHeight )

– How do i save the text that is input by the user?[/lua]

EDIT: How much can i do in applicationExit event? Is there a time limit or how many functions i can call?

EDIT2: Globals declared in main.lua doesn’t need to have _G. while declaring in other files it needs to have _G. Is this true?

EDIT3: I read that globals are bad. How bad are global variables compared to functions?
[lua]-- a global array is more effiecient or an emulated class?
player = { name = “default”, str = 1, agi = 1, int = 1, health = 100 }[/lua]

Thanks in advance! [import]uid: 74723 topic_id: 12588 reply_id: 46396[/import]

@JeffreyQJr - yes, settings are saved when an app is updated. They are NOT saved if you delete and re-install the app. I use a file from the code exchange called settings.lua that saves everything in a SQL database for easy retrieval, and this has persisted after each updated to the app.

Also, you can have global functions and global variables (in fact functions are treated like 1st class variables I think). So there is no difference between the two.I pretty much make everything a local, some simple things that I may use throughout an app, I may make global, for example a title_font_name, copyfont_name vars, I may set them (based on platform) once in the main.lua as globals. But most stuff is local.

@PeachPellen - Can you explain what exactly UIApplicationExitsOnSuspend = false does? When you come back to the game will it be in the exact state that it was prior to the Suspend? Or do you have to reload everything from a save file and recreate it? Thanks!

[import]uid: 29520 topic_id: 12588 reply_id: 46416[/import]

Thanks for the reply.

I think i can answer what is “UIApplicationExitsOnSuspend = false” does. When someone click the home button on iPhone, the game will go on suspend instead of quiting it. And will resume (exact same state) when the user gets back in assuming the user didn’t off the phone.

EDIT: Can a F1 student sell app on the APP store? Will it violate my F1 visa? I really can’t find information anywhere… [import]uid: 74723 topic_id: 12588 reply_id: 46453[/import]

Is there a way to stop Runtime listeners in other functions?
The below code doesn’t remove the listener. Line 11 works, but what if i want to remove the listener in other functions?
[lua]local count = 1

local function stopNow()
print(“Stopped”)
Runtime:removeEventListener( “enterFrame”, stopEvent )
end

local function stopEvent( event )
if count == 100 then
stopNow()
–Runtime:removeEventListener( “enterFrame”, stopEvent )

end
count = count + 1
print(count)
end

Runtime:addEventListener( “enterFrame”, stopEvent )[/lua] [import]uid: 74723 topic_id: 12588 reply_id: 46921[/import]

It should work in any function you call once the Runtime listener is running, just like in line 11 :slight_smile:

In the above you seem to start the Runtime listener AFTER you attempt to stop it; that’s not the right order of things :wink: [import]uid: 52491 topic_id: 12588 reply_id: 46928[/import]

Hello JeffreyQJr,

Another trick, you could use timer to call another function. You could remove runtime event listener anywhere.

Why dont you come to Corona’s channel on IRC, there are many good people there who can help you [import]uid: 41267 topic_id: 12588 reply_id: 46936[/import]

Thanks for the reply all.

My mistake! I forgot to forward reference the stopEvent function, so it didn’t work! I will give IRC a try. Thanks for the headsup!

Here is the answer at line 3
[lua]local count = 1

local stopEvent – Fix

local function stopNow()
print(“Stopped”)
Runtime:removeEventListener( “enterFrame”, stopEvent )
end

function stopEvent( event )
if count == 100 then
stopNow()
–Runtime:removeEventListener( “enterFrame”, stopEvent )

end
count = count + 1
print(count)
end

Runtime:addEventListener( “enterFrame”, stopEvent )[/lua]

I will try to update the 1st post once i have time, in a hurry now. [import]uid: 74723 topic_id: 12588 reply_id: 46946[/import]