And okay I'll give it a shot
The first reason why your app crashes was because there were just two letters ("Bl") at line 13. The Zen doesn't know what to do with that and quits reading the script (: the app crashes).
What I meant with my other comments is the following:
Look at line 61 in MAIN.lua, there is your check for the button press. When that happens it loads "stop.wav" to variable "stop". Then it plays the file; "stop: play()" and then it closes the variable again; "stop:close()".
The problem is that the file "stop.wav" doesn't exist: it isn't included in the app's folder and that will create an error when trying to play a file that the script couldn't find, and thus the app will crash at that point.
As for closing all other files:
With this LUA scripting we need to close all the sounds and images we used in an application in order to remove them from the Zen's memory, so that there's room left for other games (with it's own sounds and images) to load properly. We usually do this when the app closes, because after that you wouldn't need them anyway.
To sum it up, we load the images and sounds we are going to use at the start of an app at the top of the script (for example "makeday = wav.load("sounds/makeday.wav")", which is on line 27 in your MAIN.lua),
then use them somewhere else in the script: "makeday: play()" ,
and at the end when the app needs to close, we also close all the sounds and images we used: "makeday:close()"
In your buttonpress-check at line 61 all those three commands are right after each other. This is not really a problem (given that the specified file exists, like I said above), but we generally like to keep all the "load()" and "close()" commands together to make it easy to add/remove certain sounds and also to make it easy to check if we forgot to close one.
(Note that there are situations where one needs to load or close a file somewhere else in the script, but for an app like this, it's not really needed.)
This closing of files is missing from your app. You can place all the closing commands under the button-check on line 61, but you can also just place them at the bottom of the script, from line 71 and further. This whole closing of files will not give immediate errors while running your app, but can cause troubles on the Zen because the files will stay in the memory and take up space that might be needed for other apps.
I hope you were referring to this, otherwise I was just rambling about stuff you already knew .
this is a link to my personal homepage which I haven't
|Thread Tools||Search this Thread|
All times are GMT -5. The time now is 06:37 PM.