Objects Still Present When Switching Scenes

Just to make sure I understand the problem.

It is the physics objects hanging around, not the display objects.  In other words the graphic doesn’t show up, but if you turn on the hybrid debug mode you still see the physics bodies.

Both scenes  use physics.

Is this correct?

Just a reminder.  Please don’t hijack threads (that is change their direction from the topic the original poster posted about).  This is against forum rules.

Victor, your problem is this:

File: …mbarba/Desktop/Music Theory Game - CORONA/wrong1.lua
Line: 69
Attempt to index global ‘litttleBees’ (a nil value)

I’m suspecting that line 69 is in your exitScene() function, but basically you make littleBee’s “local” in enterScene() which means that variable only exists in enterScene and no where else in the code.  The fix for this is to put:

local littleBees

at the top of your module, probably after you require storyboard and then  take the “local” off in enterScene()

Hi Rob, thank you for everything you’re doing, I know that you don’t have to do anything for me and I appreciate the time you’re taking to help me, I am very sorry if I have not been the best person in this forum, sorry for that, I will be better.

I recorded a video that explain the problem I have, I hope you can watch this video and help me out, if you want.

I have no “physics” in my code, and all the objects or images work fine, but I have a duplicate image every time I go back to the same scene, please watch the video, I hope I can find the answer for this problem.

Thanks

http://www.youtube.com/watch?v=OAzz_pL2vNI&feature=youtu.be

Victor, there are two things you can do.  Do one or the other but not both.

1.  Create your notes, bees, spiders etc.  in createScene() and then in enterScene, before you do the transition, reset it’s X and Y to it’s starting location.  This is the most efficient way.

2.  In each of your scenes where you have code like this:

local function buttonLearnLevel1()
        storyboard.gotoScene( “level1Q1”, “crossFade”, 1000 )   
    return true
end

change it to:

local function buttonLearnLevel1()

        storyboard.purgeScene(“level1Q1”)
        storyboard.gotoScene( “level1Q1”, “crossFade”, 1000 )   
    return true
end

This way takes more work and your scenes get re-created each time.

Hi Rob. – Still is not working.

When I push the button “Please try again” it calls the function

 

local function buttonLearnLevel1()

        storyboard.purgeScene(“level1Q1”)
        storyboard.gotoScene( “level1Q1”, “crossFade”, 1000 )  
    return true
end

 

 

So it’s purging the scene (by the way, purging is “Cutting or erasing” correct?)

and then it’s goes to the scene.

so when I press the “please try again” button – everything else from there stops working

the buttons don’t work anymore

– What do you think I’m doing wrong

I change this:

local function buttonLearnLevel1()
        storyboard.gotoScene( “level1Q1”, “crossFade”, 1000 )  
    return true
end

 

For this:

 

local function buttonLearnLevel1()

        storyboard.purgeScene(“level1Q1”)
        storyboard.gotoScene( “level1Q1”, “crossFade”, 1000 )  
    return true
end

 

 

 

Thanks

 

Victor

Victor, do you have a thread for this topic? Let’s post there.  I don’t want to derail this from the question @willgomolka99 is trying to get answered.

 

at the end the best solution in found is to “delete” the previus scene when entering the one selected :

this is my LEVEL1.lua  code

i put in every lvl the  remove scene comand.

the object must be NOT declared local.

When you put objects into the group that is himself local 

they will be deleted on exit screen or when called the removescene “command”


LVL1.lua


display.setStatusBar ( display.HiddenStatusBar )

local physics = require(“physics”)

local storyboard = require (“storyboard”)

local scene = storyboard.newScene()

function scene:createScene(event)

    previous_scene = storyboard.getPrevious()

    storyboard.removeScene( previous_scene )

    screenGroup = self.view

-------------Creation of the level ----------------------------------------    

     Asse1 = display.newImage(“Asse480x30viti.png”)

     screenGroup:insert(Asse1)

     physics.addBody( Asse1,“static”, WOODDATA )

     Asse1.x = Asse1.contentWidth/2

     Asse1.y = display.contentHeight /2 -100

     Asse1.rotation = 0

     Asse1.alpha = 1

     Asse1.isSleepingAllowed = ITEMSTATUS

.

.

.

end

Rob. – Victor, do you have a thread for this topic?

I don’t know how to do a new thread.

I don’t know how to go to the right place in the forum.

I don’t know where I can find those answers.

I don’t know how to ask a question in the “correct way” – I don’t know which is the correct way.

I don’t know a lot of things…

I feel that I am not welcome in this forum anymore, I’m just trying to learn, but I guess I’m causing you a lot of inconvenience.

I am really sorry Rob.

Tell me if it’s still okay to try to learn in here. And please forgive me for everything.

Victor

Hi Victor.  To the contrary, we want you (and everyone) to feel welcome.  We want you to learn and we want to encourage you to be successful in your endeavors.  However, at the end of the day, this is an Internet Forum and there are certain rules and expected decorum that all community members need to abide by.   We have spelled out some specific rules in the Newbie forum in one of the posts that stays at the top:

http://forums.coronalabs.com/topic/32657-welcome-to-our-forums-please-read-forum-rules-and-guidelines/

There are other expected rules known as “Netiquette” or Network Etiquette.  One of those rules, which is why we are here is called hijacking. This is where you post on a message about X but you start talking about Y.  This is considered rude because the person who started the topic wants to talk about X.  It’s always best to create your own topics when you have a question, if it’s not directly related to an existing topic.   Click the “Start New Topic” button at the top left of the page from a form message list screen to start  your own message.

start_new_topic.png

Even for your thread about adding sounds to buttons, that thread by the end had nothing to do with adding sounds to buttons.  This makes it hard for people to find topics too.  Readers see really long threads and won’t read to the end.

So please post away.  Google “Netiquette” and read about it.  We don’t have these rules to be a pain to you or discourage you, but to foster a healthy community and encourage you to post in ways where more people will respond and be involved in helping solve your problems.

Thank you Rob. I read the guidelines. I will be a good member.