in my game, I got crash some times , when launch my game menu screen show up, when I press play game, I can play my game, when game is over, the first screen (( menu )) show up, but when I play again in Corona simulation is fine,
in my Iphone first time get crash . but when I quit the game then re launch it, I can play many time, but some time I got crash ,
I think about it, may be because I use (( BeebeGames )) with (( director 1.2)) file ??
because I do not know how to remove the Button listener , this is my menu screen codes.
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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | module(..., package.seeall) --------------------------------------------------------------- -- IMPORTS --------------------------------------------------------------- --------------------------------------------------------------- -- GROUPS --------------------------------------------------------------- --function new() local localGroup = display.newGroup() local ui = require ("ui") --------------------------------------------------------------- -- DISPLAY OBJECTS --------------------------------------------------------------- local background = display.newImage("images/bgscreen1.png") local title = display.newText("Shark Game", 0, 0, native.systemFontBold, 20) --------------------------------------------------------------- -- BUTTONS --------------------------------------------------------------- ----------------------------------- -- FUNCTIONS ----------------------------------- local function bt01t ( event ) if event.phase == "release" then director:changeScene("screen3") end end -- local function bt02t ( event ) if event.phase == "release" then director:changeScene("screen2") end end -- ----------------------------------- -- UI OBJECTS ----------------------------------- local bt01 = ui.newButton{ default = "images/startgame.png", over = "images/startgame.png", onEvent = bt01t, id = "bt01" } -- local bt02 = ui.newButton{ default = "images/instruction.png", over = "images/instruction.png", onEvent = bt02t, id = "bt02" } -- ----------Frame update --------------------------------------------------------------- -- SLIDE --------------------------------------------------------------- ----------------------------------- -- IMAGE ----------------------------------- ----------------------------------- -- LISTENER ----------------------------------- --------------------------------------------------------------- -- INIT VARS --------------------------------------------------------------- local function initVars () ----------------------------------- -- Inserts ----------------------------------- localGroup:insert(background) localGroup:insert(title) localGroup:insert(bt01) localGroup:insert(bt02) ----------------------------------- -- Positions ----------------------------------- title.x = 350 title.y = 80 -- -- bt01.x = 85 bt01.y = 80 -- bt02.x = 85 bt02.y = 200 -- ----------------------------------- -- Colors ----------------------------------- title:setTextColor( 180,180,180) ----------------------------------- -- Listeners ----------------------------------- end --------------------------------------------------------------- -- CLEAN --------------------------------------------------------------- function clean ( event ) print("1 cleaned") end --------------------------------------------------------------- -- NEW --------------------------------------------------------------- function new() ----------------------------------- -- Initiate variables ----------------------------------- initVars() ----------------------------------- -- MUST return a display.newGroup() ----------------------------------- return localGroup end |
seems like you have all the stuff, but just not in the right place.
try putting everything inside the function
like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | local localGroup = display.newGroup() function new() -- all code here cleanUp = function () -- cancel all timers -- cancel all transition in process end return localGroup end -- close the fuction and you're done |
views:1448 update:2011/10/13 9:25:17