Hi folks, I’m trying to load few images from an enterFrame function: I’ve got a boolean variable that it is initialized @ false; then, I set it @true inside the enterFrame function. when that variable is true, I load 5 images, but the app performances get worst each frame after frame (obviously this is due to the fact that these 5 images are loaded every millisecond).
The code I’m using is the following:
if(romaHasBeenChoosen==true)then roma[1] = display.newImageRect("immagini/sfondoROMA/bgColor.png", 712 , 150) roma[1].x = \_W/2 roma[1].y = \_H/2 - 250/2 roma[2] = display.newImageRect("immagini/sfondoROMA/bassa1.png",592 , 240) roma[2].x = \_W/2+500/2 roma[2].y = \_H/2-158/2 roma[3] = display.newImageRect("immagini/sfondoROMA/bassa2.png",592 , 240) roma[3].x = roma[2].x+1183/2 roma[3].y = \_H/2 -158/2 roma[4] = display.newImageRect("immagini/sfondoROMA/bassa3.png",592 , 240) roma[4].x = roma[3].x+1183/2 roma[4].y = \_H/2 -158/2 roma[5] = display.newImageRect("immagini/sfondoROMA/nuvolaRoma.png", 202, 98) roma[5].x = \_W/2 - 800/2 roma[5].y = \_H/2 -250/2 roma[5].xScale = 0.8 roma[5].yScale = 0.8 roma[5].alpha = 0.9 end local function cambioScenario() if(immaginiCambioScenario[1].x\<0)then if(landscapeToShowAfterChange==3)then Runtime:removeEventListener("enterFrame", moveRoma) Runtime:removeEventListener("enterFrame", moveUnderWater) Runtime:removeEventListener("enterFrame", moveNewYork) if(dubaiHasBeenChoosen==true)then for i=1, 16 do newYork[i]:removeSelf() newYork[i] = nil end newYorkHasBeenChoosen = false underWaterHasBeenChoosen = false romaHasBeenChoosen = true end end end end Runtime:addEventListener(“enterFrame”, cambioScenario)
Is there another way to load these images outside an enterFrame function?
Thanks!