I’m currently messing around with the SpaceShooter template. Currently all levels have the same icon
How would I go about having a different icon for each level?
Thanks
Currently:
local function showLevels( event ) if levelsShown == false then if soundAllowed then audio.play( tapSound, {channel=1}) end levelsShown = true local function changeLevel( event ) currentLevel = event.target.id storyboard.gotoScene( "gameInfo", "slideDown", 400 ) end local scrollView = widget.newScrollView{ top = (\_H\*0.42), left = 480, width = 480, height = 100, scrollHeight = 0, scrollWidth = 0, hideBackground = true, leftPadding=0, rightPadding=10, verticalScrollDisabled=true, } overlayGroup:insert(scrollView) local i for i=1, amountOfLevels do local asteroid = display.newImageRect("images/asteroidGlow.png", 100,100) asteroid.x = 60+(105\*(i-1)); asteroid.y = 50 asteroid.id = i asteroid:addEventListener("tap",changeLevel) scrollView:insert(asteroid) local levelNumber = display.newEmbossedText(i, 0,0, "HelveticaNeue-Bold", 20) levelNumber.x = asteroid.x; levelNumber.y = asteroid.y-18; levelNumber:setFillColor(200/255) scrollView:insert(levelNumber) local score = "No Score" if levelScores[i] ~= nil and levelScores[i] ~= "0" then score = levelScores[i] end local scoreText = display.newEmbossedText(score, 0,0, "HelveticaNeue-Bold", 14) scoreText.x = asteroid.x; scoreText.y = asteroid.y+12; scoreText:setFillColor(200/255) scrollView:insert(scoreText) end
Hi @kmcqua200 and welcome to the forums. Please with your future posts, when posting code, please click on the blue <> button and paste your code into that block so that it’s formatted properly. The community will appreciate it.
Now to your question with more questions:
Do you have multiple asteroid images? How many? Are they single images or in an image sheet?
Do you want them random? randomized (i.e. random order, but only used once)? or nn a fixed order?
I would recommend getting rid of the for loop. Instead, do 5 separate display.newImageRect() calls and in each call, load each image in the order you want.
Hi @kmcqua200 and welcome to the forums. Please with your future posts, when posting code, please click on the blue <> button and paste your code into that block so that it’s formatted properly. The community will appreciate it.
Now to your question with more questions:
Do you have multiple asteroid images? How many? Are they single images or in an image sheet?
Do you want them random? randomized (i.e. random order, but only used once)? or nn a fixed order?
I would recommend getting rid of the for loop. Instead, do 5 separate display.newImageRect() calls and in each call, load each image in the order you want.