Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

How to insert multiple levels?
Started by woowmkmk Feb 07 2017 11:50 AM

2 replies to this topic
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

woowmkmk

[GLOBAL: userInfoPane.html]
woowmkmk
  • Observer

  • 2 posts
  • Corona SDK

First, congratulations to the creator of Level Director, his software is helping me a lot.

 

I'm trying to create a simple infinite runner. But I do not know how to load several levels in a row in the same scene. What I try to do are small levels, which are loaded randomly creating the map

 

Thank you in advance and forgive me for my English.



[TOPIC: post.html]
#2

retrofitProductions

[GLOBAL: userInfoPane.html]
retrofitProductions
  • Contributor

  • 321 posts
  • Corona SDK

Hi, it looks like you are trying to 'stitch' levels together which I've not really come across before.

For endless runner type games, normally you would dynamically create the objects from the assets in some kind of random order, but you're trying to add complete chunks of a map.

It is possible to load multiple levels at once, but this could get messy as you then don't have overall control of a single level, but multiple, and physics are now spread across multiple display groups e.g.

local myLevel1 = {}
local myLevel2 = {}
local world = display.newGroup() 

myLevel1= LD_Loader:new()
myLevel1:loadLevel("Level01",world)

myLevel2= LD_Loader:new()
myLevel2:loadLevel("Level02",world)

--assuming levels are 480 wide, parallax enabled, place them side by side.
myLevel1:move(-240,0)
myLevel2:move(240,0)

-- note 'myLevel1.level.view.x = -240' is also possible but physics won't move.

Nice concept though, but adding multiple display groups is tricky, as newly added groups will display on top, which might not be expected.



[TOPIC: post.html]
#3

retrofitProductions

[GLOBAL: userInfoPane.html]
retrofitProductions
  • Contributor

  • 321 posts
  • Corona SDK

A slightly different version from above, but this will allow 'world' to be manipulated correctly e.g. world.x = 100

local myLevel1 = {}
local myLevel2 = {}
local world = display.newGroup() 

myLevel1= LD_Loader:new()
myLevel1:loadLevel("Level01")

myLevel2= LD_Loader:new()
myLevel2:loadLevel("Level02")

myLevel1:move(-240,0)
myLevel2:move(240,0)
world:insert(myLevel1.level.view)
world:insert(myLevel2.level.view)




[topic_controls]
[/topic_controls]