I can't believe I am re-writing this.. I cba to write it all again.
I shall do in-brief. *skips to questions*
Can/How can I do levels using "require("level1") etc?
How can you stop requiring something? (my main menu is a .lua itself)
another thing - offtopic, forum based:
how can I find posts/threads I have made? I am used to vbullitin but can't find here :/
I guess I will refresh the page until I find out.
Is your question "how can i go to a specific lua file via a level selector" ?
There are countless ways of doing this, however I will provide an example using the director class :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
| function new()
local localGroup = display.newGroup()
local function goToLevel(event)
local target = event.target
director:changeScene(target.scene, "fade")
localGroup:removeSelf()
localGroup = nil
return true
end
local levels = {}
--Add two level images to the level table
levels[1] = display.newImage("level1.png")
levels[1].scene = "level1" --Assign the level button a level name (with the .lua ommitted)
localGroup:insert(levels[1])
levels[2] = display.newImage("level2.png")
levels[2].scene = "level2" --Assign the level button a level name (with the .lua ommitted)
localGroup:insert(levels[2])
--Add event listeners for all level buttons
for i = 1, #levels do
levels[i]:addEventListener("touch", goToLevel)
end
return localGroup
end |
^ This is why corona is the best.
Thank you, only thing that I am gutted about is that apps do not build to my phone (I believe ansca dropped the hardware) so I can only simulate it and not test truly.
My friend has a mac which I hope to build the app on later :)