How to remove a table or array

I read this

http://docs.coronalabs.com/api/library/table/remove.html

To remove a table. I have this table

littleM = {}         for column = 1, 18 do             for row = 1, 8 do             littleM[column] = display.newImage( "buttonMute.png", 11 + (column\*50), 400 - (row\*40) )         end     end

In the enterScene. It creates all the images fine, good!

but when I go to another scene, all the images are there.

1.-  table.remove( littleM ) – in the exit Scene // It doesn’t work

2.- I tried this as a group, created a table and then insert –  table.insert( littleM ) //It doesn’t work

3.- I used the table.remove( littleM ) – in the DestroyScene // it doesn’t work

As you can see I’m trying to use the logic, using what I know so far, and it doesn’t work, there must be a way, please let me know how.

Thanks

Victor

Something like this will work…

for key,obj in pairs(littleM) do obj:removeSelf() obj = nil end

The other way would be to create a displayGroup, and then :insert each image to that group, and then call removeSelf() on the group. Note that you’d still need to nil the reference to littleM if you did this alternate approach.

Thank you…

but where do I put this code?

in the exitScene, or the destroyScene?

I also added the physics to the littleM and when I go to another scene, the image “floor” that has physics, removeSelf

and all the images “littleM” just goes down out of the view…

Are they still in memory, or they are removed from memory?

littleM = {}         for column = 1, 18 do             for row = 1, 8 do             littleM[column] = display.newImage( "buttonMute.png", 11 + (column\*50), 400 - (row\*40) )             physics.addBody( littleM[column], { density=0.2, friction=0.1, bounce=0.4 } )         end     end

Thanks

I’m not 100% sure how to answer given I don’t have much code to review and therefore not how to suggest where to put it… it would depend on what you are doing with the scenes. Normally you’d attach all display groups to the scene (and they would be shown/hidden) and only destroy them in the destroyScene event. It is hard to say what you are doing.

Oh, and calling removeSelf on the display object will destroy physics bodies and physics joints

The way many coders do it is to mark the littleM instance for destruction by moving it to another table i.e. tableOfDestruction and when you feel like it do this i.e. inside onExitScene() local destroyLittleBuggers() for key, obj in pairs(tableOfDestruction) do obj:removeSelf() obj = nil end this is a nice approach because its not always allowed to just destroy your littleM´s inside other chunks of code in these cases you just --------inside some chunk of code i.e a loop table.insert(tableOfDestruction, littleM[i]) --if you like to remove the instance later by putting it into the other table littleM[i]:removeSelf() --|| if you like to remove the instance littleM[i] = nil --|| if you like to release the placeholder/variable littleM[i] littleM[i].alpha = 0 – if you just like to hide it littleM[i]:RemoveEventListener(“someEvent”, littleM[i]) --if you made this kind of approach Hope this didn get too messy

Hi guys, gslender, and Hendrix000007.

I admire you a lot, I wish I knew programming like you…

When you explain things, I read them, and they look great.

But my mind is not “yet” to that level.

But if you have patience with me, I will learn, I promise you that.

This is the complete code for littleM

local storyboard = require( "storyboard" ) local widget = require "widget" local scene = storyboard.newScene() local physics = require("physics") physics.start() physics.setScale( 36) local littleM local buttonHome local buttonBack local function homeWorld()         storyboard.gotoScene( "mainMenu", "flip", 200 )         return true end local function buttonBackHandler()         storyboard.gotoScene( "physicsWorld", "fromLeft", 200 )         return true end -- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*[CREATE SCENE]\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- function scene:createScene( event )     local group = self.view          local yellowRectangle = display.newRect(0, 0, 1024, 768 )         group:insert ( yellowRectangle )             yellowRectangle.strokeWidth = 8             yellowRectangle:setFillColor(244, 234, 234)             yellowRectangle:setStrokeColor(255, 255, 0)          buttonHome = widget.newButton{     defaultFile="buttonHome.png",     onRelease = homeWorld     }     group:insert ( buttonHome )     buttonHome.x = 950     buttonHome.y = 710          buttonBack = widget.newButton{     defaultFile="buttonBack.png",     onRelease = buttonBackHandler     }     group:insert ( buttonBack )     buttonBack.x = 66     buttonBack.y = 710         end --------------------------------------------------------------ENTER SCENE---------- function scene:enterScene( event )     local group = self.view     local floor = display.newImage( "buttonSoundRed.png" )     group:insert ( floor )     floor.x = 512; floor.y = 710     physics.addBody( floor, "static", { friction=0.5 } )     littleM = {}         for column = 1, 4 do             for row = 1, 4 do             littleM[column] = display.newImage( "buttonMute.png", 350 + (column\*50), -400 - (row\*40) )             physics.addBody( littleM[column], { density=0.2, friction=0.1, bounce=0.4 } )         end     end              local bricks = {}         local n = 0         local function throwBrick()             n = n + 3             bricks[n] = display.newImage( "buttonPlay.png", -20, 140  - (n\*11) )             physics.addBody( bricks[n], { density=3.0, friction=0.5, bounce=0.05 } )             bricks[n].isBullet = true             bricks[n].angularVelocity = 1             bricks[n]:applyForce( 1600, 0, bricks[n].x, bricks[n].y )         end         local function start()             timer.performWithDelay( 300, throwBrick, 2 )         end         timer.performWithDelay( 3800, start ) end -------------------------------------------------------------------------------------- --------------------------------------------------------------EXIT SCENE---------- function scene:exitScene() for key,obj in pairs(littleM) do                obj:removeSelf()                obj = nil         end           end -------------------------------------------------------------------------------------- -- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*[DESTROY SCENE]\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- function scene:destroyScene( event )     local group = self.view                  if buttonHome then             buttonHome:removeSelf()             buttonHome = nil         end                  if buttonBack then             buttonBack:removeSelf()             buttonBack = nil         end end ---------------------------------------------------------------------------------- scene:addEventListener( "createScene", scene ) scene:addEventListener( "enterScene", scene ) scene:addEventListener( "exitScene", scene ) scene:addEventListener( "destroyScene", scene ) return scene

Thanks

Hi there

First of all, your physic bodies fall out off the screen because you didn´t specify a type of body:

your code inside the littleM chunk:

physics.addBody( littleM[column], { density=0.2, friction=0.1, bounce=0.4 } )

this will keep it on the screen :slight_smile:

physics.addBody( littleM[column], “static” , { density=0.2, friction=0.1, bounce=0.4 } )

and if you change it to “dynamic” it will respond to the physic world

Yes, the objects keeps falling, and falling…and falling :slight_smile:

To fix this you could do:

Inside your instantiating of littleM you could assign “the children” in the group a name like this:

local littleM = {}

        for column = 1, 18 do
            for row = 1, 8 do
            littleM[column] = display.newImage( “buttonMute.png”, (11 + (column*50)), (400 - (row*40)) )

             littleM[column].name = “littleManiacs” --<<HERE<<
            physics.addBody( littleM[column], “static”, { density=0.2, friction=0.1, bounce=0.4 } )
        end
    end

Now you can make an eventListener that keep track og the bodies that falls on the outside of your screen then it will be removed
i.e. like this:

enterFrameListener = function( event )
        if ( event.target.name == “littleManiacs” and event.target >= display.contentHeight + 50 ) then

            – do all the clean up routine like stoping physics, remove RuntimeListener and timers and so on

            – like your routine :slight_smile:

            killAllLittleM() --now you have, by doing this, checked if the actual object goes by the name littleManiacs

                                 – and wether the objects is inside the acceptable reach of your screen

        end

Runtime:addEventListener( “enterFrame”, enterFrameListener ) --remember to remove this type of listeners

                                                                                                      --when leaving the scene

Let us know how far you get with this and we will help you all the way man…this IS the fun part :slight_smile:

Please note that I haven´t tested this code, just dug it out of my head now so there may be some bugs LOL

    end

Heres a funny one you can play with:

local storyboard = require( “storyboard” )
local widget = require “widget”
local scene = storyboard.newScene()

local physics = require(“physics”)
physics.start()

local onTouch = function(event)
if event.phase == “began” then
  event.target.bodyType = “dynamic”
  timer.performWithDelay( 1000, function() event.target:removeSelf() end)
end
return true
end

local littleM = {}

        for column = 1, 18 do
            for row = 1, 8 do
            littleM[column] = display.newImage( “buttonMute.png”, (11 + (column*50)), (400 - (row*40)) )
            physics.addBody( littleM[column], “static”, { density=0.2, friction=0.1, bounce=0.4 } )
   littleM[column]:addEventListener(“touch”, onTouch)
        end
    end

Victor, back to your top post… is there a reason you did not do a

group:insert(littleM[column])

???

Hi guys. I’m 52…I wish I would have started this when I was 20…(but in 1980, there were no computers, sorry)

There is so much to learn, I’m just beginning to see things. This is a lot of fun…

Anyway…

Rob, thanks you very much, that solve the problem, it works!!!

I did not put

physics.addBody( littleM[column], "static", { density=0.2, friction=0.1, bounce=0.4 } )

Because I was just using

physics.addBody( littleM, "static", { density=0.2, friction=0.1, bounce=0.4 } )

So that means you also have to use the number on the table right? by the way the function I copy said “for i” and “for j” but it makes more sense to use column and rows.

but it works, thanks Rob.

As for the funny function, Hendrix000007 – IT’S really nice! Thanks. I can make something really good with it.

I need a little favor, maybe it’s too much for me now, but I guess I have to try.

The littleM removeSelf when I touch it, great!

How can I make the program have a “SCORE” that keeps track of the littleM that have been removed?

First you declare a variable like this that can hold the score:

local score = 0

Then you can make a function that increase and decrease the value of the score like this:

local scoreFunc = function(scoreValue)

  score = score + scoreValue

  return score

end

What you should consider is to maybe use something like this in your function that deals with the score like:

if score <= 0 then

 --action for dealing with death

elseif score >= 1000 then

–action when you win the game

end

This could be done like this:

local scoreFunc = function(scoreValue)

  if score <= 0 then
  --action for dealing with death
  elseif score >= 1000 then
  --action when you win the game
end

  score = score + scoreValue
  return score
end

So if we use the “funny code” I posted earlier you could just add this to the function:

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

  scoreFunc( 10 ) --adds 10 to the score
  event.target.bodyType = “dynamic”
  timer.performWithDelay( 1000, function() event.target:removeSelf() end)
end
return true
end

You could also put the if chunk inside a enterFrame RuntimeListener, then it will check if youre “in or out” every frame of the game.

This all depends on how you like the gameplay :slight_smile:

If you like I can send you a class I made, dealing with scores

…and remeber, youre not too old for this, Im 44 and started just 3 years ago with lua and Corona , I know what I´m going to do when I retire :slight_smile:

Thank you Hendrix,

I read the score = and function and Value, but I get confuse.

I read somewhere I need to put a “String” or local text first with … (two dots) or something

where I display the text “Your score is …”

and there it will be a text that changes the score. Something like that…

Also, where do I put the functions in the create, enter scene or before, outside the scenes.?

I have one app already on the app store “Piano For Kids - Level 1” two weeks there, is doing great!

I’m working now in my second app.

My goal is to have at least 10 app by the end of next year!

Thanks for your help

Victor

Actually Victor in 1980 the computer revolution was alive and well.  I’m also 52.  The pharmacist friend in my small home town of 2500 had built is own kit computer and with my limited programming built the first pharmacy database.  A couple of my friends had personal computers in their dorm rooms.  I was busy hacking my college’s main-frame to play multi-player games.  Admittedly things were much simpler then.  Your iPad has more computing power than the entire college campus had in 1980. 

I know Rob, 1980 in Mexico, in a little town call Tijuana, and very poor…

That’s why I said no computers.

My first experience with computers was on 1984. We bought a little “Atari” computer to make music. It was just the keyboard, no monitor, we used one old black and white tv, we could hardly see what was in there, but we made some good songs back then.

What youre describing is a static string concatenated with a score variable like this:

local myScoreText = “Your score is ”
local score = 0

local scoreHolder = display.newText( myScoreText … score, – + all the other text params you have )
Remember the two dots means concatenate in LUA, the result – if your score is i.e. 150:

Result:

Your score is 150

Thank you Hendrix, with your help I’m getting closer to answer a question I made 6 months ago

“How to keep track of the score?” I still don’t have the final answer but I’m getting close

I did a few things you told me, and I can see the “text” in the simulator – Your score is 0

but when I touch each image, is not adding any points.

Here is the complete code

local storyboard = require( "storyboard" ) local widget = require "widget" local scene = storyboard.newScene() local physics = require("physics") physics.start() physics.setScale( 36) local littleM local buttonHome local buttonBack local myScoreText = "Your score is " local score = 0 local function homeWorld() &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;storyboard.gotoScene( "mainMenu", "flip", 200 )&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;return true end local function buttonBackHandler() &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;storyboard.gotoScene( "physicsWorld", "fromLeft", 200 )&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;return true end local scoreFunc = function(scoreValue) &nbsp; if score \<= 0 then &nbsp; --action for dealing with death &nbsp; elseif score \>= 1000 then &nbsp; --action when you win the game end &nbsp; score = score + scoreValue &nbsp; return score end local onTouch = function(event) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if event.phase == "began" then &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;scoreFunc( 10 ) --adds 10 to the score &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;event.target.bodyType = "dynamic" &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;timer.performWithDelay( 1000, function() event.target:removeSelf() end) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return true end -- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*[CREATE SCENE]\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- function scene:createScene( event ) &nbsp;&nbsp; &nbsp;local group = self.view &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;local yellowRectangle = display.newRect(0, 0, 1024, 768 ) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;group:insert ( yellowRectangle ) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;yellowRectangle.strokeWidth = 8 &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;yellowRectangle:setFillColor(244, 234, 234) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;yellowRectangle:setStrokeColor(255, 255, 0) &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;buttonHome = widget.newButton{ &nbsp;&nbsp; &nbsp;defaultFile="buttonHome.png", &nbsp;&nbsp; &nbsp;onRelease = homeWorld &nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;group:insert ( buttonHome ) &nbsp;&nbsp; &nbsp;buttonHome.x = 950 &nbsp;&nbsp; &nbsp;buttonHome.y = 710 &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;buttonBack = widget.newButton{ &nbsp;&nbsp; &nbsp;defaultFile="buttonBack.png", &nbsp;&nbsp; &nbsp;onRelease = buttonBackHandler &nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;group:insert ( buttonBack ) &nbsp;&nbsp; &nbsp;buttonBack.x = 66 &nbsp;&nbsp; &nbsp;buttonBack.y = 710 &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;local scoreHolder = display.newText(myScoreText .. score, 100, 600, native.systemFont, 24) &nbsp;&nbsp; &nbsp;group:insert ( scoreHolder ) &nbsp;&nbsp; &nbsp;scoreHolder:setTextColor(255, 0, 0) &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; end --------------------------------------------------------------ENTER SCENE---------- function scene:enterScene( event ) &nbsp;&nbsp; &nbsp;local group = self.view &nbsp;&nbsp; &nbsp;local floor = display.newImage( "buttonSoundRed.png" ) &nbsp;&nbsp; &nbsp;group:insert ( floor ) &nbsp;&nbsp; &nbsp;floor.x = 512; floor.y = 710 &nbsp;&nbsp; &nbsp;physics.addBody( floor, "static", { friction=0.5 } ) &nbsp;&nbsp; &nbsp;littleM = {} &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;for column = 1, 4 do &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;for row = 1, 4 do &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;littleM[column] = display.newImage( "buttonMute.png", 350 + (column\*50), -400 - (row\*40) ) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;group:insert ( littleM[column] ) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;physics.addBody( littleM[column], "dynamic", { density=0.2, friction=0.1, bounce=0.4 } ) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;local bricks = {} &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;local n = 0 &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;local function throwBrick() &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;n = n + 3 &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;bricks[n] = display.newImage( "buttonPlay.png", -20, 140&nbsp; - (n\*11) ) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;group:insert ( bricks[n] ) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;physics.addBody( bricks[n], "dynamic", { density=3.0, friction=0.5, bounce=0.05 } ) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;bricks[n].isBullet = true &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;bricks[n].angularVelocity = 1 &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;bricks[n]:applyForce( 1600, 0, bricks[n].x, bricks[n].y ) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;local function start() &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;timer.performWithDelay( 300, throwBrick, 2 ) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;timer.performWithDelay( 3800, start ) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; --\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*GOOD\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*-- &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;local onTouch = function(event) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if event.phase == "began" then &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;event.target.bodyType = "dynamic" &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;timer.performWithDelay( 600, function() event.target:removeSelf() end) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return true &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;local littleM = {} &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;for column = 1, 18 do &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;for row = 1, 8 do &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;littleM[column] = display.newImage( "buttonMute.png", (11 + (column\*50)), (400 - (row\*40)) ) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;group:insert ( littleM[column] ) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;physics.addBody( littleM[column], "static", { density=0.2, friction=0.1, bounce=0.4 } ) &nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;littleM[column]:addEventListener("touch", onTouch) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end ----\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*---- &nbsp;&nbsp; &nbsp; end -------------------------------------------------------------------------------------- --------------------------------------------------------------EXIT SCENE---------- function scene:exitScene() &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;for key,obj in pairs(littleM) do &nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;obj:removeSelf() &nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;obj = nil &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end end -------------------------------------------------------------------------------------- -- --==\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*[DESTROY SCENE]\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*++-- -- function scene:destroyScene( event ) &nbsp;&nbsp; &nbsp;local group = self.view&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if buttonHome then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;buttonHome:removeSelf() &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;buttonHome = nil &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if buttonBack then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;buttonBack:removeSelf() &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;buttonBack = nil &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end end ---------------------------------------------------------------------------------- scene:addEventListener( "createScene", scene ) scene:addEventListener( "enterScene", scene ) scene:addEventListener( "exitScene", scene ) scene:addEventListener( "destroyScene", scene ) return scene

I really hope that you can help me solve this problem

6 months is a long time waiting for this moment.

Victor, one of the reasons why you haven’t gotten an answer to this it because the answer is “However you want to do it”.

Generally you have a variable that holds the score as a number.  There are multiple ways around moving that value around from scene to scene, but if you find the No more Globals post, using the mydata table is a good way.

Then how you display the score is 100% up to you.  You can use display.newText() to show the score just as a number.  You could output a label like “Score” and then the number.  You could use bitmap fonts to make the digits look cool. 

This is the simplest feature.  Having a number and adding more to it as the score goes up.

I will post you a file tomorrow with all tweaks so you see how its done

(it two hours past midnight here in Norway so I have to go to bed)

Good night Hendrix …

Hi Rob, I guess I’m not asking the right question. That’s why maybe, you said “However you want to do it”

I guess for now, out of the “multiple ways” of doing it, I will get 1, out of all of those… any one.

Sense I don’t know how to do non of them, any one will do just fine.

I guess I’m not getting the concept yet of “holding the score as a number”

and I got confuse with this “No more Globals post, using the mydata table is a good way.”

I guess like Hendrix said, one code but very simple with just the basic information to have a score

will help me a lot.

I look a the “ghost” something , a sample code, too advanced for me yet I don’t get it

some other sample codes, they have too much for me, right now.

Remember, I’m in pre-school Rob.

So any simple code, but in storyboard, like I mention before, 98% of the sample codes are in just main.lua

one file, and when I try do do that in storyboard, big problems, like the making an animation stop, still

un-resolved.

Thanks for your help Rob, if there is anything I can do for you, let me know please

Heres the code/project in a zip file

copy the link and paste it in a new browser window:

www.3claws.org/test15.zip

Check it out and you´ll get it :slight_smile:

You should read up on Robs exceptional explanation on the use of dynamic scaling for diff resolutions

He has written some real good stuff on ratios for each devices

Use newImageRect and NOT newImage - it do not support dynamic size