Glitches in moving columns

Hey Guys

I have a problem with my game and when i exit and return to the game on the tablet it glitches. How can I fix this ?

function slidemove(event)
    
if event.phase == “began” then

        if gameStarted == false then
             player.bodyType = “dynamic”
             instructions.alpha = 0
             tb.alpha = 1
             addColumnTimer = timer.performWithDelay(925, addColumns, -1)
             moveColumnTimer = timer.performWithDelay(1.85, moveColumns, -1)
             gameStarted = true        
    end
end
end

function moveColumns()
        for a = elements.numChildren,1,-1 do
            if(elements[a].y >= display.contentCenterY) then
                if elements[a].scoreAdded == false then
                    mydata.score = mydata.score + 1
                    tb.text = mydata.score
                    elements[a].scoreAdded = true
                end
            end
            if(elements[a].y > -100) then
                elements[a].y = elements[a].y + 12
            else
                elements:remove(elements[a])
            end    
        end
end

function addColumns()
    
    height = math.random(display.contentCenterX - 300, display.contentCenterX + 300)

    topColumn = display.newRect(0,0,714,64)
    topColumn:setFillColor(100/255,203/255,219/255)

    topColumn.anchorX = 1
    topColumn.anchorY = 0.5
    topColumn.x = height + 30
    topColumn.y = display.contentWidth - 850
    topColumn.scoreAdded = false
    physics.addBody(topColumn, “static”, {density=1, bounce=0.1, friction=.2})
    elements:insert(topColumn)
    
    bottomColumn = display.newRect(0,0,714,64)
    bottomColumn:setFillColor(0.9, 0.16, 0.78)

    bottomColumn.anchorX = 0
    bottomColumn.anchorY = 0.5
    bottomColumn.x = height + 100
    bottomColumn.y = display.contentWidth - 850
    physics.addBody(bottomColumn, “static”, {density=0, bounce=0, friction=0})
    elements:insert(bottomColumn)

end    

Can you provide a better description of what it should be doing, what it’s really doing?  Perhaps some screen shots?

Rob

Cant share the file on here for some reason it only allows url so here are the screenshots

– Working, When you dont leave the game and return , or dont play for a while

https://drive.google.com/file/d/0B0WFwF6CXfkGTk5fanl1eHdoXzQ/view

–glitching , when you leave and return to the game, or play for a while

https://drive.google.com/file/d/0B0WFwF6CXfkGcGV0QUNpY1YyZzQ/view?usp=sharing

What am I doing in my code to cause this glitch or what i didn’t add

Schoolt25

Are you using a scene manager like Composer or Storyboard?

Rob

im using composer

Are you inserting your objects into the scene’s group?  The photo you show is symptomatic of display objects being created but not being inserted into the scene’s view group:  (i.e.   sceneGroup:insert( object )  ).  When you change scenes, it will remove objects inserted into the group, but when you don’t insert them, they get stuck on the screen.

Rob

Yes we already did

Can you provide a better description of what it should be doing, what it’s really doing?  Perhaps some screen shots?

Rob

Cant share the file on here for some reason it only allows url so here are the screenshots

– Working, When you dont leave the game and return , or dont play for a while

https://drive.google.com/file/d/0B0WFwF6CXfkGTk5fanl1eHdoXzQ/view

–glitching , when you leave and return to the game, or play for a while

https://drive.google.com/file/d/0B0WFwF6CXfkGcGV0QUNpY1YyZzQ/view?usp=sharing

What am I doing in my code to cause this glitch or what i didn’t add

Schoolt25

Are you using a scene manager like Composer or Storyboard?

Rob

im using composer

Are you inserting your objects into the scene’s group?  The photo you show is symptomatic of display objects being created but not being inserted into the scene’s view group:  (i.e.   sceneGroup:insert( object )  ).  When you change scenes, it will remove objects inserted into the group, but when you don’t insert them, they get stuck on the screen.

Rob

Yes we already did