Hi everyone…
I just copy the code that comes on the sample app from corona
Frame Animation 2
where you have 3 circles moving all the time, and bouncing off the walls of the app.
it works perfect
I put that in my app story board, and I can go from one scene to another
I put all the functions above my code, before the createScene function
and the Runtime I put it in the enterScene function
– Runtime:addEventListener( “enterFrame”, collection );
Before going to another scene I stop or remove the Runtime like this
local function homeButton ()
Runtime:removeEventListener( “enterFrame”, collection );
storyboard.gotoScene(“home”)
end
and it works…
--------------------------------- PROBLEM -------------------------
How to I insert the circles in to a group?
because when I go to another scene, I still see the circles in the other scene
in this code
local function newBall( params ) local xpos = display.contentWidth\*0.5 local ypos = display.contentHeight\*0.5 circle = display.newCircle( xpos, ypos, params.radius ); circle:setFillColor( params.r, params.g, params.b, 255 ); circle.xdir = params.xdir circle.ydir = params.ydir circle.xspeed = params.xspeed circle.yspeed = params.yspeed circle.radius = params.radius return circle end
I add the insert group
group:insert(circle)
and I can remove 1 circle, but not the 3 of them
thanks for your help
------------ SORRY -------
one more question
why do they have
for _,ball in ipairs( collection ) do
I usually see
for i = 1, 5 do
I don’t understand the pairs
and the
_,ball