menu button does not work

I’ve got a menu bottom that changes my scene back to the menu and it works on the simulator but does not work on my Samsung galaxy s5

hi ,

it is diffecult to know the error like that. you need to give more info such as related code… i assume you are using composer.

regards

local storyboard = require( “storyboard” )
local ragdogLib = require(“ragdogLib”);
local networksLib = require(“networksLib”);
local scene = storyboard.newScene()
local platform = system.getInfo(“platformVersion”)
– include Corona’s “widget” library
local widget = require “widget”
local globals = require( “main” )
local score = require( “score” )
local chartboost = require( “plugin.chartboost” )
local _W = display.contentWidth
local _H = display.contentHeight

physics.start()
– physics.setDrawMode ( “hybrid” ) – Uncomment in order to show in hybrid mode
physics.setGravity( 0, 9.8 * 2)

physics.start()

– Audio for slash sound (sound you hear when user swipes his/her finger across the screen)
local slashSounds = {slash1 = audio.loadSound(“slash1.wav”), slash2 = audio.loadSound(“slash2.wav”), slash3 = audio.loadSound(“slash3.wav”)}
local slashSoundEnabled = true – sound should be enabled by default on startup
local minTimeBetweenSlashes = 150 – Minimum amount of time in between each slash sound
local minDistanceForSlashSound = 50 – Amount of pixels the users finger needs to travel in one frame in order to play a slash sound

– Audio for chopped fruit
local choppedSound = {chopped1 = audio.loadSound(“chopped1.wav”), chopped2 = audio.loadSound(“chopped2.wav”)}

– Audio for bomb
local preExplosion = audio.loadSound(“preExplosion.wav”)
local explosion = audio.loadSound(“explosion.wav”)

– Adding a collision filter so the fruits do not collide with each other, they only collide with the catch platform
local fruitProp = {density = 1.0, friction = 0.3, bounce = 0.2, filter = {categoryBits = 2, maskBits = 1}}
local catchPlatformProp = {density = 1.0, friction = 0.3, bounce = 0.2, filter = {categoryBits = 1, maskBits = 2}}

– Gush filter should not interact with other fruit or the catch platform
local gushProp = {density = 1.0, friction = 0.3, bounce = 0.2, filter = {categoryBits = 4, maskBits = 8} }

– Will contain all fruits available in the game
local avalFruit = {}

– Slash line properties (line that shows up when you move finger across the screen)
local maxPoints = 4
local lineThickness = 8
local lineFadeTime = 150
local endPoints = {}
local endPoints = {}
local path = {}
local i =1;local j =1
local traced = 1
– Whole Fruit physics properties
local minVelocityY = 950
local maxVelocityY = 1100

local minVelocityX = -100
local maxVelocityX = 100

local minAngularVelocity = 100
local maxAngularVelocity = 200

– Chopped fruit physics properties
local minAngularVelocityChopped = 100
local maxAngularVelocityChopped = 200

– Splash properties
local splashFadeTime = 2500
local splashFadeDelayTime = 5000
local splashInitAlpha = .5
local splashSlideDistance = 50 – The amoutn of of distance the splash slides down the background

local main;
– Contains all the available splash images
local splashImgs = {}

– Gush properties
local minGushRadius = 2
local maxGushRadius = 10
local numOfGushParticles = 2
local gushFadeTime = 500
local gushFadeDelay = 500

local minGushVelocityX = -350
local maxGushVelocityX = 350
local minGushVelocityY = -350
local maxGushVelocityY = 350

– Timer references
local bombTimer
local fruitTimer

– Game properties
local fruitShootingInterval = 1000
local bombShootingInterval = 5000

– Groups for holding the fruit and splash objects
local splashGroup
local fruitGroup

local sampleVar = true

local temp =0
local lives = 5
local saveButton
local highscore
local score1 = 0
local scoreText;

local sceneGroup;

function scene:createScene( event )
_G.displayGameOver = displayGameOver;
_G.explodeBomb = explodeBomb;
local group = self.view
sceneGroup = self.view;
main();
end
local function startGame(group)

shootObject(“fruit”, group)

bombTimer = timer.performWithDelay(bombShootingInterval - 4500, function(event) shootObject(“bomb”, group) end, 0)
fruitTimer = timer.performWithDelay(fruitShootingInterval, function(event) shootObject(“fruit”, group) end, 0)

end
– Your Chartboost app id and signature for iOS
local yourAppID = “xxxx”
local yourAppSignature = “yyyy”

– Change the appid/sig for Android
if system.getInfo( “platformName” ) == “Android” then
yourAppID = “5564555343150f48f674ab34”
yourAppSignature = “97acfd17b55c802cb5e495b5568f07f846b772ce”
end

print( "Chartboost plugin version: "… chartboost.getPluginVersion() )

– Initialise ChartBoost
chartboost.init {
appID = yourAppID,
appSignature = yourAppSignature,
listener = chartBoostListener
}

function chopFruit(fruit)

if (sampleVar == true) then
score.add(1)

playRandomChoppedSound()

createFruitPiece(fruit, “top”)
createFruitPiece(fruit, “bottom”)

createSplash(fruit)
createGush(fruit)
– score.save()
fruit:removeSelf()

else

end

end
if score == nil then score = 0 end
local function drawSlashLine(event)

– Play a slash sound
if(endPoints ~= nil and endPoints[1] ~= nil) then
local distance = math.sqrt(math.pow(event.x - endPoints[1].x, 2) + math.pow(event.y - endPoints[1].y, 2))
if(distance > minDistanceForSlashSound and slashSoundEnabled == true) then
playRandomSlashSound();
slashSoundEnabled = false
timer.performWithDelay(minTimeBetweenSlashes, function(event) slashSoundEnabled = true end)
end
end

– Insert a new point into the front of the array
table.insert(endPoints, 1, {x = event.x, y = event.y, line= nil})

– Remove any excessed points
if(#endPoints > maxPoints) then
table.remove(endPoints)
end

for i,v in ipairs(endPoints) do
local line = display.newLine(sceneGroup, v.x, v.y, event.x, event.y)
line.strokeWidth = lineThickness
transition.to(line, {time = lineFadeTime, alpha = 0, strokeWidth = 0, onComplete = function(event) line:removeSelf() end})
end

if(event.phase == “ended”) then
while(#endPoints > 0) do
table.remove(endPoints)
end
end
end

function explodeBomb(bomb, listener)

bomb:removeEventListener(“touch”, listener)

– The bomb should not move while exploding
bomb.bodyType = “kinematic”
bomb:setLinearVelocity(0, 0)
bomb.angularVelocity = 0

– Shake the stage
local stage = display.getCurrentStage()

local moveRightFunction
local moveLeftFunction
local rightTrans
local leftTrans
local shakeTime = 50
local shakeRange = {min = 1, max = 25}

moveRightFunction = function(event) rightTrans = transition.to(stage, {x = math.random(shakeRange.min,shakeRange.max), y = math.random(shakeRange.min, shakeRange.max), time = shakeTime, onComplete=moveLeftFunction}); end
moveLeftFunction = function(event) leftTrans = transition.to(stage, {x = math.random(shakeRange.min,shakeRange.max) * -1, y = math.random(shakeRange.min,shakeRange.max) * -1, time = shakeTime, onComplete=moveRightFunction}); end

moveRightFunction()

local linesGroup = display.newGroup()

sceneGroup:insert(linesGroup);

– Generate a bunch of lines to simulate an explosion
local drawLine = function(event)

local line = display.newLine(bomb.x, bomb.y, _W * 2, _H * 2)
line.rotation = math.random(1,360)
line.strokeWidth = math.random(15, 25)
linesGroup:insert(line)
end
local lineTimer = timer.performWithDelay(100, drawLine, 0)

– Function that is called after the pre explosion
local explode = function(event)

audio.play(explosion)
blankOutScreen(bomb, linesGroup);
timer.cancel(lineTimer)
stage.x = 0
stage.y = 0
transition.cancel(leftTrans)
transition.cancel(rightTrans)

end

– Play the preExplosion sound first followed by the end explosion
audio.play(preExplosion, {onComplete = explode})

timer.cancel(fruitTimer)
timer.cancel(bombTimer)

end

function main()

display.setStatusBar( display.HiddenStatusBar )

setUpBackground(sceneGroup)
–livesLabel = display.newText("lifeCounter: ", _W*0.3,_H*0.3, native.systemFont, 16)

–livesText = display.newText(“Lives: 0”, _W *0.3, _H*0.3, “Pacifico”, 22)
–livesText:setTextColor(1, 1, 1)
–livesText.text = ("Lives: " )…lives

–score.save()

pauseAndResume (sceneGroup)
setUpCatchPlatform(sceneGroup)
initGroups(sceneGroup)
initFruitAndSplash(sceneGroup)

–scene:createScene()
Runtime:removeEventListener(“touch”, drawSlashLine)
Runtime:addEventListener(“touch”, drawSlashLine)

print(sceneGroup);
startGame(sceneGroup)
chartboost.show( “interstitial” )

scoreText = score.init({
fontSize = 32,
font = “Pacifico”,
x = _W * 0.5,
y = _H * 0.15,
maxDigits = 5,
leadingZeros = true,
filename = “scorefile2.txt”,
})

end

function displayLives()

livesText.text = ("Lives: " )…lives
lives = lives - 1

end

local newLine = function(event)

if event.phase==“began” then

elseif event.phase==“moved” then
for i=1,3 do
if event.target.name==i then
temp=temp+1
–here you can do your action to the object(like remove or score)
print(“touch”…temp)
end
end

elseif event.phase==“ended” then

end

return true
end
–[[
for i=1,3 do
local myCircle = display.newCircle(sceneGroup, 100*i, 100, 9 )
myCircle:setFillColor(128,128,128)
myCircle.name=i
myCircle:addEventListener(“touch”,newLine)

end]]
function resetscore()

score.set (0)
– body
end
function removereset()
saveButton:removeSelf()
– body
end
function displayGameOver()
print(“showing”);
– Will return a group so that we can set the alpha of the entier menu
group = display.newGroup()

sceneGroup:insert(group);

– Dim the background with a transperent square
function loadScore( event )
if event.phase == “ended” then
–[[ local prevScore = score.load2()
if prevScore then
score.set(prevScore)
end]]
storyboard.gotoScene(“menu”, “fade”);
end
return true
end

–[[
score.init({
fontSize = 32,
font = “Pacifico”,
x = _W * 0.67,
y = _H * 0.49,
maxDigits = 5,
leadingZeros = true,
filename = “scorefile.txt”,
})
]]

saveButton = widget.newButton({
width = 200,
height = 64,
x = display.contentCenterX,
y = display.contentHeight - 64,
label = “Load Score”,
labelColor = { default = { 1, 1, 1 }, over = { 0, 0, 0 } },
fontSize = 32,
font = “Pacifico”,
onEvent = loadScore
})

local gameOverbg = display.newImageRect(group, “bg.png”, _W,_H)
gameOverbg.x = _W * 0.5
gameOverbg.y = _H * 0.5
group:insert(gameOverbg
)
local gameOverboard = display.newImageRect( group,“gameoverboard.png”, 357,187)
gameOverboard.x = _W * 0.5
gameOverboard.y = _H * 0.5
group:insert(gameOverboard)

local gameOver = display.newImageRect(group, “gameover.png”, 168,52)
gameOver.x = _W * 0.4
gameOver.y = _H * 0.37
group:insert(gameOver)

highscore = display.newImageRect(group, “highscore.png”, 168,52)
highscore.x = _W * 0.45
highscore.y = _H * 0.52
group:insert(gameOver)

local replayButton = widget.newButton
{
width = 130,
height = 42,
defaultFile = “replayButton.png”,
overFile = “replayButtonover.png”,
label = “”,
onRelease = function(event) print(“done”); group:removeSelf(); main() ; resetscore() ;removereset(); end
}
group:insert(replayButton)

replayButton.x = _W * 0.62
replayButton.y = _H * 0.64

group:insert(saveButton);

local currHighscore = ragdogLib.getSaveValue(“gameHardScore”) or 0;
local currScore = tonumber(scoreText.text);
if currScore > currHighscore then
currHighscore = currScore;
ragdogLib.setSaveValue(“gameHardScore”, currHighscore, true);
end
local highscoreText = display.newText(group, currHighscore, _W * 0.67, _H * 0.49, “Pacifico”, 32);

local currentScoreText = display.newText(group, currScore, _W * 0.67, _H * 0.39, “Pacifico”, 32);

networksLib.addScoreToLeaderboard(currScore, 3);
– local prevScore = score.load()
– local scoresave = score.get()

– if prevScore == 0 then
– score.save()
–elseif
– scoresave > prevScore then
– score.save()
– end
–local prevScore = score.load()

–if prevScore == 0 then
– score.save()

–end

–if prevScore > 0 then

– if prevScore < score.get() then
– networksLib.addScoreToLeaderboard(Score);
– end

–scene.view:insert(group);

group:insert(scoreText);
scoreText.isVisible = false;

local prevScore = score.load2()

if prevScore == nil then

prevScore = 0
end

if score.get() > prevScore then
score.save3()
end

–local function scoresavefirsttime()
– if score.load == nil then
– score.save2()
– end
–end

–function scoresave3()

–if score.get() > prevScore then
– score.save()
–end

–scoresavefirsttime()

return group
end

function scene:exitScene()
Runtime:removeEventListener(“touch”, drawSlashLine)
local removeAll;

removeAll = function(group)
if group.enterFrame then
Runtime:removeEventListener(“enterFrame”, group);
end
if group.touch then
group:removeEventListener(“touch”, group);
Runtime:removeEventListener(“touch”, group);
end
for i = group.numChildren, 1, -1 do
if group[i].numChildren then
removeAll(group[i]);
else
if group[i].enterFrame then
Runtime:removeEventListener(“enterFrame”, group[i]);
end
if group[i].touch then
group[i]:removeEventListener(“touch”, group[i]);
Runtime:removeEventListener(“touch”, group[i]);
end
end
end
end

removeAll(self.view);
end
scene:addEventListener( “createScene”, scene )
scene:addEventListener( “enterScene”, scene )
scene:addEventListener( “destroyScene”, scene )
scene:addEventListener(“exitScene”, scene);

return scene

That’s my code I’ve posted it all because some people said it’s because I haven’t put them in groups the right way ?

Hi , 

i am trying to help here if I can   :slight_smile: … this to much to understood and even i can test it by copy paste to see the error

  •  I advice to convert your code to composer as stoyrpard is going to depricated,.

  •  can you make shorter sample of your issue so we can all see the error and try to help

  • when you paste code in forum … you can use

    [lua] .code … . [/lua]  

 so you have the code shown properly…

thanks

Abdul

There’s A few things I’ve noticed , the menu button works on the Samsung galaxy s3 but not on the s5 , and also the button will change to a different scene but not the scene it was previously on does that make a difference ?

Please don’t dump your entire module in a post unless you’ve specifically been asked to.  Just post the code relevant to the problem at hand.  In this case, the code involving your back button.

Please use the <> button in the button bar in the same row as B I U S X2 X2 and so on.   Click that button and paste your code in the box that shows up.

Rob

sorry some people said it was how i set out my groups so i thought you needed the whole code , because the button works , because if i change the scene to a scene i havnt entered yet for example a different game mode ive not yet played , it changes but because ive just come from the menu it wont let me go back to the menu ,

but here is the menu button 

 function loadScore( event ) if event.phase == "ended" then storyboard.gotoScene("menu", "fade"); end return true end

saveButton = widget.newButton({ width = 200, height = 64, x = display.contentCenterX, y = display.contentHeight - 64, label = "Load Score", labelColor = { default = { 1, 1, 1 }, over = { 0, 0, 0 } }, fontSize = 32, font = "Pacifico", onEvent = loadScore })

the load score function is before the other one but it pasted in here the wrong way round ,

                                                      

                                                                      ---->gameHard

my game goes like this-----    main---->menu---->gameNormal    ,  then if the menu button is pressed it goes back to the menu 

                                                                      ---->gameEasy

so when i press the menu button on one of the game modes , it wont back to the menu because it was the scene it just came from 

is there a fix for this  ? , would changing to composer fix this

also the game works perfect on a samsung galaxy s3 but not on the new s5

Well your code looks about right.  But you might want to try:

function loadScore( event ) &nbsp;&nbsp;&nbsp; if event.phase == "ended" then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; storyboard.removeScene("menu") &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; storyboard.gotoScene("menu", "fade"); &nbsp;&nbsp;&nbsp; end &nbsp;&nbsp;&nbsp; return true end

Ok I will try it now , also would using a cut scene help ? For example go from menu---->cutscene----> game—>cutscene2---->menu. And so on ?, do you think that would sort the problem I’m having ?

Bump

Cut scenes are helpful, but perhaps in your menu.lua, just before you call composer.gotoScene(“game1”) call composer.removeScene(“game1”) if you always want a fresh restart.  It’s okay to call removeScene if the scene has never been gone to in the first place.

Rob

I’ve done the changes you said and it hadn’t changed ?

Is there any other reason it could happen ?

Can you restate your problem?  Perhaps some screen shots or a video demoing the issue?

Rob

The problem is that my game is set up like this main.lua----> menu.lua-----> (then you select a game mode) —>gameHard -->gameEasy---->the back to menu but it won’t change to menu cause I was just on the menu

But it will change to another game mode from the game mode it’s currents on if you get me

Let me try this again. In menu.lua just before you call composer.gotoScene() call composer.removeScene() with the same scene name. For example:

composer.removeScene(“somescene”)
composer.gotoScene(“somescene”)

So from menu if you’re going to gameEasy call those two lines. When you are going back to your menu, use “menu” in both lines.

hi ,

it is diffecult to know the error like that. you need to give more info such as related code… i assume you are using composer.

regards

local storyboard = require( “storyboard” )
local ragdogLib = require(“ragdogLib”);
local networksLib = require(“networksLib”);
local scene = storyboard.newScene()
local platform = system.getInfo(“platformVersion”)
– include Corona’s “widget” library
local widget = require “widget”
local globals = require( “main” )
local score = require( “score” )
local chartboost = require( “plugin.chartboost” )
local _W = display.contentWidth
local _H = display.contentHeight

physics.start()
– physics.setDrawMode ( “hybrid” ) – Uncomment in order to show in hybrid mode
physics.setGravity( 0, 9.8 * 2)

physics.start()

– Audio for slash sound (sound you hear when user swipes his/her finger across the screen)
local slashSounds = {slash1 = audio.loadSound(“slash1.wav”), slash2 = audio.loadSound(“slash2.wav”), slash3 = audio.loadSound(“slash3.wav”)}
local slashSoundEnabled = true – sound should be enabled by default on startup
local minTimeBetweenSlashes = 150 – Minimum amount of time in between each slash sound
local minDistanceForSlashSound = 50 – Amount of pixels the users finger needs to travel in one frame in order to play a slash sound

– Audio for chopped fruit
local choppedSound = {chopped1 = audio.loadSound(“chopped1.wav”), chopped2 = audio.loadSound(“chopped2.wav”)}

– Audio for bomb
local preExplosion = audio.loadSound(“preExplosion.wav”)
local explosion = audio.loadSound(“explosion.wav”)

– Adding a collision filter so the fruits do not collide with each other, they only collide with the catch platform
local fruitProp = {density = 1.0, friction = 0.3, bounce = 0.2, filter = {categoryBits = 2, maskBits = 1}}
local catchPlatformProp = {density = 1.0, friction = 0.3, bounce = 0.2, filter = {categoryBits = 1, maskBits = 2}}

– Gush filter should not interact with other fruit or the catch platform
local gushProp = {density = 1.0, friction = 0.3, bounce = 0.2, filter = {categoryBits = 4, maskBits = 8} }

– Will contain all fruits available in the game
local avalFruit = {}

– Slash line properties (line that shows up when you move finger across the screen)
local maxPoints = 4
local lineThickness = 8
local lineFadeTime = 150
local endPoints = {}
local endPoints = {}
local path = {}
local i =1;local j =1
local traced = 1
– Whole Fruit physics properties
local minVelocityY = 950
local maxVelocityY = 1100

local minVelocityX = -100
local maxVelocityX = 100

local minAngularVelocity = 100
local maxAngularVelocity = 200

– Chopped fruit physics properties
local minAngularVelocityChopped = 100
local maxAngularVelocityChopped = 200

– Splash properties
local splashFadeTime = 2500
local splashFadeDelayTime = 5000
local splashInitAlpha = .5
local splashSlideDistance = 50 – The amoutn of of distance the splash slides down the background

local main;
– Contains all the available splash images
local splashImgs = {}

– Gush properties
local minGushRadius = 2
local maxGushRadius = 10
local numOfGushParticles = 2
local gushFadeTime = 500
local gushFadeDelay = 500

local minGushVelocityX = -350
local maxGushVelocityX = 350
local minGushVelocityY = -350
local maxGushVelocityY = 350

– Timer references
local bombTimer
local fruitTimer

– Game properties
local fruitShootingInterval = 1000
local bombShootingInterval = 5000

– Groups for holding the fruit and splash objects
local splashGroup
local fruitGroup

local sampleVar = true

local temp =0
local lives = 5
local saveButton
local highscore
local score1 = 0
local scoreText;

local sceneGroup;

function scene:createScene( event )
_G.displayGameOver = displayGameOver;
_G.explodeBomb = explodeBomb;
local group = self.view
sceneGroup = self.view;
main();
end
local function startGame(group)

shootObject(“fruit”, group)

bombTimer = timer.performWithDelay(bombShootingInterval - 4500, function(event) shootObject(“bomb”, group) end, 0)
fruitTimer = timer.performWithDelay(fruitShootingInterval, function(event) shootObject(“fruit”, group) end, 0)

end
– Your Chartboost app id and signature for iOS
local yourAppID = “xxxx”
local yourAppSignature = “yyyy”

– Change the appid/sig for Android
if system.getInfo( “platformName” ) == “Android” then
yourAppID = “5564555343150f48f674ab34”
yourAppSignature = “97acfd17b55c802cb5e495b5568f07f846b772ce”
end

print( "Chartboost plugin version: "… chartboost.getPluginVersion() )

– Initialise ChartBoost
chartboost.init {
appID = yourAppID,
appSignature = yourAppSignature,
listener = chartBoostListener
}

function chopFruit(fruit)

if (sampleVar == true) then
score.add(1)

playRandomChoppedSound()

createFruitPiece(fruit, “top”)
createFruitPiece(fruit, “bottom”)

createSplash(fruit)
createGush(fruit)
– score.save()
fruit:removeSelf()

else

end

end
if score == nil then score = 0 end
local function drawSlashLine(event)

– Play a slash sound
if(endPoints ~= nil and endPoints[1] ~= nil) then
local distance = math.sqrt(math.pow(event.x - endPoints[1].x, 2) + math.pow(event.y - endPoints[1].y, 2))
if(distance > minDistanceForSlashSound and slashSoundEnabled == true) then
playRandomSlashSound();
slashSoundEnabled = false
timer.performWithDelay(minTimeBetweenSlashes, function(event) slashSoundEnabled = true end)
end
end

– Insert a new point into the front of the array
table.insert(endPoints, 1, {x = event.x, y = event.y, line= nil})

– Remove any excessed points
if(#endPoints > maxPoints) then
table.remove(endPoints)
end

for i,v in ipairs(endPoints) do
local line = display.newLine(sceneGroup, v.x, v.y, event.x, event.y)
line.strokeWidth = lineThickness
transition.to(line, {time = lineFadeTime, alpha = 0, strokeWidth = 0, onComplete = function(event) line:removeSelf() end})
end

if(event.phase == “ended”) then
while(#endPoints > 0) do
table.remove(endPoints)
end
end
end

function explodeBomb(bomb, listener)

bomb:removeEventListener(“touch”, listener)

– The bomb should not move while exploding
bomb.bodyType = “kinematic”
bomb:setLinearVelocity(0, 0)
bomb.angularVelocity = 0

– Shake the stage
local stage = display.getCurrentStage()

local moveRightFunction
local moveLeftFunction
local rightTrans
local leftTrans
local shakeTime = 50
local shakeRange = {min = 1, max = 25}

moveRightFunction = function(event) rightTrans = transition.to(stage, {x = math.random(shakeRange.min,shakeRange.max), y = math.random(shakeRange.min, shakeRange.max), time = shakeTime, onComplete=moveLeftFunction}); end
moveLeftFunction = function(event) leftTrans = transition.to(stage, {x = math.random(shakeRange.min,shakeRange.max) * -1, y = math.random(shakeRange.min,shakeRange.max) * -1, time = shakeTime, onComplete=moveRightFunction}); end

moveRightFunction()

local linesGroup = display.newGroup()

sceneGroup:insert(linesGroup);

– Generate a bunch of lines to simulate an explosion
local drawLine = function(event)

local line = display.newLine(bomb.x, bomb.y, _W * 2, _H * 2)
line.rotation = math.random(1,360)
line.strokeWidth = math.random(15, 25)
linesGroup:insert(line)
end
local lineTimer = timer.performWithDelay(100, drawLine, 0)

– Function that is called after the pre explosion
local explode = function(event)

audio.play(explosion)
blankOutScreen(bomb, linesGroup);
timer.cancel(lineTimer)
stage.x = 0
stage.y = 0
transition.cancel(leftTrans)
transition.cancel(rightTrans)

end

– Play the preExplosion sound first followed by the end explosion
audio.play(preExplosion, {onComplete = explode})

timer.cancel(fruitTimer)
timer.cancel(bombTimer)

end

function main()

display.setStatusBar( display.HiddenStatusBar )

setUpBackground(sceneGroup)
–livesLabel = display.newText("lifeCounter: ", _W*0.3,_H*0.3, native.systemFont, 16)

–livesText = display.newText(“Lives: 0”, _W *0.3, _H*0.3, “Pacifico”, 22)
–livesText:setTextColor(1, 1, 1)
–livesText.text = ("Lives: " )…lives

–score.save()

pauseAndResume (sceneGroup)
setUpCatchPlatform(sceneGroup)
initGroups(sceneGroup)
initFruitAndSplash(sceneGroup)

–scene:createScene()
Runtime:removeEventListener(“touch”, drawSlashLine)
Runtime:addEventListener(“touch”, drawSlashLine)

print(sceneGroup);
startGame(sceneGroup)
chartboost.show( “interstitial” )

scoreText = score.init({
fontSize = 32,
font = “Pacifico”,
x = _W * 0.5,
y = _H * 0.15,
maxDigits = 5,
leadingZeros = true,
filename = “scorefile2.txt”,
})

end

function displayLives()

livesText.text = ("Lives: " )…lives
lives = lives - 1

end

local newLine = function(event)

if event.phase==“began” then

elseif event.phase==“moved” then
for i=1,3 do
if event.target.name==i then
temp=temp+1
–here you can do your action to the object(like remove or score)
print(“touch”…temp)
end
end

elseif event.phase==“ended” then

end

return true
end
–[[
for i=1,3 do
local myCircle = display.newCircle(sceneGroup, 100*i, 100, 9 )
myCircle:setFillColor(128,128,128)
myCircle.name=i
myCircle:addEventListener(“touch”,newLine)

end]]
function resetscore()

score.set (0)
– body
end
function removereset()
saveButton:removeSelf()
– body
end
function displayGameOver()
print(“showing”);
– Will return a group so that we can set the alpha of the entier menu
group = display.newGroup()

sceneGroup:insert(group);

– Dim the background with a transperent square
function loadScore( event )
if event.phase == “ended” then
–[[ local prevScore = score.load2()
if prevScore then
score.set(prevScore)
end]]
storyboard.gotoScene(“menu”, “fade”);
end
return true
end

–[[
score.init({
fontSize = 32,
font = “Pacifico”,
x = _W * 0.67,
y = _H * 0.49,
maxDigits = 5,
leadingZeros = true,
filename = “scorefile.txt”,
})
]]

saveButton = widget.newButton({
width = 200,
height = 64,
x = display.contentCenterX,
y = display.contentHeight - 64,
label = “Load Score”,
labelColor = { default = { 1, 1, 1 }, over = { 0, 0, 0 } },
fontSize = 32,
font = “Pacifico”,
onEvent = loadScore
})

local gameOverbg = display.newImageRect(group, “bg.png”, _W,_H)
gameOverbg.x = _W * 0.5
gameOverbg.y = _H * 0.5
group:insert(gameOverbg
)
local gameOverboard = display.newImageRect( group,“gameoverboard.png”, 357,187)
gameOverboard.x = _W * 0.5
gameOverboard.y = _H * 0.5
group:insert(gameOverboard)

local gameOver = display.newImageRect(group, “gameover.png”, 168,52)
gameOver.x = _W * 0.4
gameOver.y = _H * 0.37
group:insert(gameOver)

highscore = display.newImageRect(group, “highscore.png”, 168,52)
highscore.x = _W * 0.45
highscore.y = _H * 0.52
group:insert(gameOver)

local replayButton = widget.newButton
{
width = 130,
height = 42,
defaultFile = “replayButton.png”,
overFile = “replayButtonover.png”,
label = “”,
onRelease = function(event) print(“done”); group:removeSelf(); main() ; resetscore() ;removereset(); end
}
group:insert(replayButton)

replayButton.x = _W * 0.62
replayButton.y = _H * 0.64

group:insert(saveButton);

local currHighscore = ragdogLib.getSaveValue(“gameHardScore”) or 0;
local currScore = tonumber(scoreText.text);
if currScore > currHighscore then
currHighscore = currScore;
ragdogLib.setSaveValue(“gameHardScore”, currHighscore, true);
end
local highscoreText = display.newText(group, currHighscore, _W * 0.67, _H * 0.49, “Pacifico”, 32);

local currentScoreText = display.newText(group, currScore, _W * 0.67, _H * 0.39, “Pacifico”, 32);

networksLib.addScoreToLeaderboard(currScore, 3);
– local prevScore = score.load()
– local scoresave = score.get()

– if prevScore == 0 then
– score.save()
–elseif
– scoresave > prevScore then
– score.save()
– end
–local prevScore = score.load()

–if prevScore == 0 then
– score.save()

–end

–if prevScore > 0 then

– if prevScore < score.get() then
– networksLib.addScoreToLeaderboard(Score);
– end

–scene.view:insert(group);

group:insert(scoreText);
scoreText.isVisible = false;

local prevScore = score.load2()

if prevScore == nil then

prevScore = 0
end

if score.get() > prevScore then
score.save3()
end

–local function scoresavefirsttime()
– if score.load == nil then
– score.save2()
– end
–end

–function scoresave3()

–if score.get() > prevScore then
– score.save()
–end

–scoresavefirsttime()

return group
end

function scene:exitScene()
Runtime:removeEventListener(“touch”, drawSlashLine)
local removeAll;

removeAll = function(group)
if group.enterFrame then
Runtime:removeEventListener(“enterFrame”, group);
end
if group.touch then
group:removeEventListener(“touch”, group);
Runtime:removeEventListener(“touch”, group);
end
for i = group.numChildren, 1, -1 do
if group[i].numChildren then
removeAll(group[i]);
else
if group[i].enterFrame then
Runtime:removeEventListener(“enterFrame”, group[i]);
end
if group[i].touch then
group[i]:removeEventListener(“touch”, group[i]);
Runtime:removeEventListener(“touch”, group[i]);
end
end
end
end

removeAll(self.view);
end
scene:addEventListener( “createScene”, scene )
scene:addEventListener( “enterScene”, scene )
scene:addEventListener( “destroyScene”, scene )
scene:addEventListener(“exitScene”, scene);

return scene

That’s my code I’ve posted it all because some people said it’s because I haven’t put them in groups the right way ?

Hi , 

i am trying to help here if I can   :slight_smile: … this to much to understood and even i can test it by copy paste to see the error

  •  I advice to convert your code to composer as stoyrpard is going to depricated,.

  •  can you make shorter sample of your issue so we can all see the error and try to help

  • when you paste code in forum … you can use

    [lua] .code … . [/lua]  

 so you have the code shown properly…

thanks

Abdul