Hi, guys.
In my Gideros project, I made a folder called "images" and filled it with about 264 images. I then clicked "sort", so they are arranged in numerical order (of filename).
Their names are of the following style (but might change):
0000.png
0010.png
0020.png
0024.png
0029.png
0030.png
.
.
2700.png
All of them are images that fill the entire screen. The app is an e-book. When it starts, it will display 0000.png (the book's cover).
What is the best way to write the following three functions?
[Load the next image from the "/images/" folder into memory.]
[Now, display it and load the next image from the "/images/" folder into memory.]
[Display the previous image (which is, hopefully, still in memory) again.]
Thanks very much.
Platypus
Kate's Catalogue of Travelling Theatre Centres :Meet Kate. Grey is her favourite colour. Maths is her favourite subject. Decency is her favourite type of behaviour.
She definitely does not like jewellery or modelling, but loves aeroplanes and other machines made of aluminium.
Comments
Hello and welcome, have you checked The E-book Template?
That would cut your dev time, the page management work is already done so you can focus on your art + texts.
Website: http://www.castlegateinteractive.com
https://play.google.com/store/apps/developer?id=Castlegate+Interactive
Thanks, guys. Yeah, I have been analysing both of those (both the e-book and that webpage) during the past few days (plus numerous Gideros resources, posts on this forum and many other Lua resources), but I cannot decide upon (Well,.. I cannot even recognise) the simplest solution to use.
In that e-book template (which is absolutely wonderful), each page is a separate scene and a separate Lua file, which is probably necessary for an interactive e-book.
Mine has hundreds of pages, but it is not interactive at all. It is just a folder full of screen-sized images.
I need to be able to reuse the code for all future books I release, and I always need to be able to insert pages easily. That's why I name them in multiples of ten.
e.g. It's easy to insert "0725.png" between the following files:
.
.
0710.png
0720.png
0730.png
.
.
Isn't there some kind of one-line solution?
(Attention Beginners - The following is not valid code.)
Some kind of code like:
current = 0720
Function
LoadFile "images/(>current).png"
current = (>current)
End
...or something equally short and sweet? I really hope there is. I want the computer to do the computing.
Meet Kate. Grey is her favourite colour. Maths is her favourite subject. Decency is her favourite type of behaviour.
She definitely does not like jewellery or modelling, but loves aeroplanes and other machines made of aluminium.
loadfile?
dofile?
read?
readfile?
require?
io.open?
io.read?
io.getElements?
How about this:
(From @atilim's code on
http://www.giderosmobile.com/forum/discussion/comment/90#Comment_90 )
local f = io.open("images/", "....(Something?)....")
local t = f:read("*all")
f:close()
?
Meet Kate. Grey is her favourite colour. Maths is her favourite subject. Decency is her favourite type of behaviour.
She definitely does not like jewellery or modelling, but loves aeroplanes and other machines made of aluminium.
Somewhere in main lua
I don't think there is a need to store all of them in memory, it might not be feasible.
That is why I suggested the directory method as it wouldn't matter how many images you inserted, the software would automatically find it during the directory search.
Website: http://www.castlegateinteractive.com
https://play.google.com/store/apps/developer?id=Castlegate+Interactive
Website: http://www.castlegateinteractive.com
https://play.google.com/store/apps/developer?id=Castlegate+Interactive
Meet Kate. Grey is her favourite colour. Maths is her favourite subject. Decency is her favourite type of behaviour.
She definitely does not like jewellery or modelling, but loves aeroplanes and other machines made of aluminium.