I didnt know if i was going to have time or internet access to post anything up being that i was out of town, but i have managed to have some time…
I have definitely seen a huge increase in the time available to play the game before memory problems shut it down!
I have a few types of levels but the one i think that is causing the most problems is a memory type of game(which to me feels very poorly made). In the level I’m going to show you is you have to press the colors in order according to the directions! This is just a basic version, but i dont think this is the most proficient way of doing this.
module(..., package.seeall)
function new()
local localGroup = display.newGroup()
--hide the status bar
display.setStatusBar(display.HiddenStatusBar)
--start physics
local physics = require("physics");
physics.start();
local background = display.newImage("images/notebookpaper.png", 320, 480)
background.x = \_W/2
background.y = \_H/2
background.xScale = 1
background.yScale = 1
-- the question that stays throughout the level
local question = display.newText("press the colors in order", 0, 0, native.systemFont, 30);
question.xScale = .75
question.yScale = .75
question.x = \_W/2
question.y = 100
question.rotation = 0
question:setTextColor(50,50,50)
local question2 = display.newText("Blue Green Red", 0, 0, native.systemFont, 30);
question2.xScale2= .75
question2.yScale2 = .75
question2.x = \_W/2
question2.y = 140
question2.rotation = 0
question2:setTextColor(0,0,255)
-- the four circles that will be pressed
local redcircle = display.newCircle( \_W/2 + 40 , \_H/2 , 40)
redcircle:setFillColor(238,0,0)
local bluecircle = display.newCircle( 50, \_H - 50, 30)
bluecircle:setFillColor(0,0, 255)
local greencircle = display.newCircle ( \_W/2, \_H/2 +100, 50)
greencircle:setFillColor(127,255,0)
local orangecircle= display.newCircle ( \_W/4, \_H/2 + 20, 39)
orangecircle:setFillColor(255,165,0)
-- When the Blue button is touched...
function changeStage1(e)
if(e.phase == "began") then
--remove the listener for the blue circle since no longer used
bluecircle:removeEventListener("touch", changeStage1)
-- the question2 is set to no longer visible so you cant see order
question2.alpha = 0
question2.isVisible = false
-- green circle listener is added
greencircle:addEventListener("touch", changeStage2)
end
return true
end
bluecircle:addEventListener("touch", changeStage1)
function changeStage2(e)
if(e.phase == "began") then
-- when green is touched it removes greens listener
greencircle:removeEventListener("touch", changeStage2)
-- and adds red circle's listener
redcircle:addEventListener("touch", changeStage3)
end
return true
end
function changeStage3(e)
if(e.phase == "began") then
--when red is touched, it removes red listener
redcircle:removeEventListener("touch", changeStage3)
-- the background is needed so when the user touches anywhere else
-- except the correct color button it goes back to the start
background:removeEventListener("touch", wronganswer)
question:removeSelf()
question = nil
-- removing the circles
redcircle:removeSelf()
redcircle = nil
bluecircle:removeSelf()
bluecircle = nil
orangecircle:removeSelf()
orangecircle = nil
greencircle:removeSelf()
greencircle = nil
background:removeSelf()
background = nil
director:changeScene("level 2");
end
return true
end
-- function if user hits wrong answer
function wronganswer(e)
if(e.phase == "began") then
background:removeEventListener("touch", wronganswer)
question:removeSelf()
question = nil
question2:removeSelf()
question2 = nil
redcircle:removeSelf()
redcircle = nil
bluecircle:removeSelf()
bluecircle = nil
orangecircle:removeSelf()
orangecircle = nil
greencircle:removeSelf()
greencircle = nil
background:removeSelf()
background = nil
director:changeScene("fail");
end
end
end
background:addEventListener("touch", wronganswer)
localGroup:insert(background)
localGroup:insert(question)
localGroup:insert(question2)
localGroup:insert(redcircle)
localGroup:insert(bluecircle)
localGroup:insert(greencircle)
localGroup:insert(orangecircle)
return localGroup;
end
[import]uid: 24708 topic_id: 13438 reply_id: 51396[/import]