I have been making my app for ages and has worked perfectly so far. I decided to add a level select into the app and works fin in the simulator, but if i install the app on my android it crashes as soon as I go into the level select.
Code for drawing screen:
-- BACKGROUND IMAGE
local backgroundImage = display.newImageRect( "mainmenu.png", 480, 320 )
backgroundImage.x = 240; backgroundImage.y = 160
menuGroup:insert( backgroundImage )
-- LOCKED BUTTONS
local lock1 = display.newImageRect("lock.png", 57, 57)
lock1.x = 110; lock1.y = 100
menuGroup:insert( lock1 )
local lock2 = display.newImageRect("lock.png", 57, 57)
lock2.x = 170; lock2.y = 100
menuGroup:insert( lock2 )
local lock3 = display.newImageRect("lock.png", 57, 57)
lock3.x = 230; lock3.y = 100
menuGroup:insert( lock3 )
local lock4 = display.newImageRect("lock.png", 57, 57)
lock4.x = 290; lock4.y = 100
menuGroup:insert( lock4 )
local lock5 = display.newImageRect("lock.png", 57, 57)
lock5.x = 350; lock5.y = 100
menuGroup:insert( lock5 )
-- DATA LOAD DATA FILE
local userdatafile = "save1.data"
local curlvl = loadValue( userdatafile )
local i = tonumber(curlvl)
local x
local lvl
local levelBtn = {}
-- EVENT FOR BUTTON CLICKS
local onlevelBtn = function(event)
director:changeScene( "loadlevel" .. event.target.myId)
end
-- LEVEL BUTTONS
while (i \> 0) do
levelBtn[i] = ui.newButton{
defaultSrc = "levelbtn.png",
defaultX = 57,
defaultY = 57,
overSrc = "levelbtn-over.png",
overX = 57,
overY = 57,
--onEvent = onlockBtn,
id = "LevelButton" .. i,
text = i,
font = "",
textColor = { 0, 0, 0, 255 },
size = 16,
emboss = false
}
levelBtn[i].myId = i
x = 50 + i \* 60;
levelBtn[i].x = x; levelBtn[i].y = 100
menuGroup:insert( levelBtn[i] )
levelBtn[i]:addEventListener("tap", onlevelBtn)
i = i - 1
end
I have noticed that when i remove the locked buttons from my app the level select works 100% just without the extra buttons. but as soon as i put them back in it crashes on the device just not the simulator.
I am really confused as to why this is happening. Does anyone have any idea?
Thnx,
Ultrasnofire [import]uid: 31078 topic_id: 27326 reply_id: 327326[/import]

[import]uid: 52491 topic_id: 27326 reply_id: 111109[/import]