Objects that display current lives dissapears after returning to scene

I have created a repository on github:

https://github.com/sdktester15/help-with-lua

This is the new link to go to, thank you very much for all your help.

When adding objects to a scene, don’t forget to insert them into a scene group, that is self.view or scene.view

display.newImageRect(self.view, "heart.png", 50, 50)

That way when you leave the scene, they will disappear automatically.

You can create these images in scene:create(), but do reset them on scene:show() with a “will” phase. That is set alpha = 0 to each of them and immediately after that set alpha = 1 to the correct amount of them (livesCount).

In the will phase, should I use a timer.performWithDelay to set them back to alpha = 1?

For example:

local function resetLives()

      lives.alpha = 1

end

lives.alpha = 0

timer.performWithDelay(50, resetLives, 1)

No, you don’t need a timer for that action.

They are not showing when the code is run.

lives.alpha = 0 lives.alpha = 1

This is what I did.

Do I have to insert them to the scene group through sceneGroup:insert?

lives is an array, not a group. To change their alpha, iterate over the array and assign alpha to each of them individually. 

The exact same thing occurred.

for i=1, livesCount do lives[i].alpha = 0 lives[i].alpha = 1 end
for i=1, #lives do lives[i].alpha = 0 end for i=1, livesCount do lives[i].alpha = 1 end

I meant this.

It still does not work, I used your exact code and then I tried this:

for i=1, livesCount do lives[i].alpha = 0 end for i=1, livesCount do lives[i].alpha = 1 end

Do you have some background images that can overlap the lives, e.g. are you reinserting anything on scene:show()

Right now it’s guessing, you can upload your code somewhere and we can see.

Can I send you a private message containing all my code through the corona messenger?

Do you have any screen sharing software or program?

You can, but it’s better to upload it to say github. That way it’s easier to see the code and help you.

I have never uploaded code to github, it will take me a while, could you kindly wait for me, please? Once I post on github, I will send you the link, thank you so much.

Sure. Working with github and source versioning in general is a must have skill anyway.

https://gist.github.com/sdktester15/a113811289e1c322fb5c3c3fd6e811ae

This is the link that should direct you to my level1.lua code.

Also, I have another question, how can I create a scoring system that gives the user 10 points every time they jump over an object?