Well, another problem just occured.
I’ll try my best to describe it:
In main.lua i set the following variable:
storyboard.currentLevel = 1
in game.lua i use the following function to load my “mapdata”:
local map = require ('level'..storyboard.currentLevel) for i,v in pairs{sensors=addSensor, walls=addWall} do for \_, data in ipairs(map[i]) do v(unpack(data)) end end
(the important part should only be the first line here)
Now whenever you lose or win the game the following function gets called:
local function restart() if fileExists('level'..storyboard.currentLevel + 1 .. ".lua") then storyboard.currentLevel = storyboard.currentLevel + 1 else storyboard.currentLevel = 1 end storyboard.gotoScene( "menu", "zoomInOutFade", 500 ) end
This leads to to next level by triggering the following function in menu.lua:
local function onPlayBtnRelease() -- go to level1.lua scene storyboard.gotoScene( "game", "zoomInOutFade", 500) return true -- indicates successful touch end
On the Simulator everything works as expected. The game iterates through all the levels (16) and when you finished level 16, it goes back to level 1.
However if I do test on Android Device (HTC ONE if that matters), it behaves kinda strange.
Some levels are loaded twice, and after some levels it occasionally resets to level 1. As I said this only occurs on device, not in the simulator.
The Github link is a different one this time:
https://github.com/paranoiax/Instablix
Hope you can help me out again.
best regards.