Yes, it’s the display.newContainer.
To explain the scenario of what i meant by interlinked.
If you have played the game mmm fingers. You’d have a more clear picture of what i’m about to say.
For example:- If have a simple a rotating obstacle. Its defined in a container and i set a unique name to that container.
Now if I want a more advanced form of that rotating obstacle. I create another container and add few more obstacles to it and check if it has a feasible path for player to pass through, again I set a unique name to that container.
Now that I have two different containers which are preset. I call them randomly and stack them on top of each other.
I know interlinked is not the right word, just that i want to make sure there is a feasible path for the player to pass through, which would be difficult to create if i just randomize all the obstacles.
So below is a module for creating moving obstacles.
I have just presented a simple obstacle here. Its a grip which has a enterFrame event added to make it move in a certain manner.
Some might have collision listeners as well( the non-physical kind https://docs.coronalabs.com/tutorial/games/nonPhysicalCollision/index.html
Since I am creating many containers. Can it run smoothly, I see that its running fine on the simulator. But can a mobile handle it.
I call atmost 60 containers.
local function createContainer(currentHeight) local container = display.newContainer(measure.cliffWidth, 0) container.x = measure.cliffStart container.y = currentHeight container.anchorX = 0 container.anchorY = 0 container.anchorChildren = false return container end function \_M.movingSingleGrip(currentHeight) local container = createContainer(currentHeight) local grip = display.newCircle(container,measure.cliff4,60,30) grip.type = "grip" grip.speed = 1 grip.isMoving = true local height = 120 -- takes one container space container.height = container.height + height container.numElements = 1 container.row = 1 container.name = "msg" function container:eachFrame() local circle = container[1] if circle.x \< measure.cliff2 then circle.speed = 1 elseif circle.x \> measure.cliff6 then circle.speed = -1 end circle.x = circle.x + circle.speed end eachFrame.add(container) return container end