How do I load game levels dynamically?

Get help using Construct 2

Post » Mon Jan 30, 2012 12:28 am

I am creating a game where number of levels can be unlimited. In order to do so, I decided to have a solid introduction and an ending. The levels in between would be loaded with javascript. If a new level is developed, all that's needed is to load a new .js file like so

<script type="text/javascript" src="game_start.js"></script>
<script type="text/javascript" src="level_1.js"></script>
<script type="text/javascript" src="level_2.js"></script>
<script type="text/javascript" src="level_3.js"></script>
...
<script type="text/javascript" src="game_end.js"></script>

So how can I do that?
B
3
Posts: 5
Reputation: 285

Post » Mon Jan 30, 2012 3:42 pm

You can't, you have to keep everything inside Construct 2. However, you can add a new level in Construct 2 and export and upload the project again, and it will download and use the new version of the game with the update. You can read more about detecting updates in the tutorial on offline support.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Mon Jan 30, 2012 7:06 pm

You could either create all the layouts (levels) and then use an event to only use a selection of them

Or (if you havn't built it all already) you could use a tile based map where you generate the maps using an array and then read that array from a txt file or something using AJAX or CallJS- more about this in the How to forum post
B
14
S
3
G
5
Posts: 41
Reputation: 3,490

Post » Tue Jan 31, 2012 3:45 am

Thanks a lot guys! Seems like a lengthy approach, I'd rather stick with creating all the levels inside Construct 2. Afterall it's a job security, right?! :)
B
3
Posts: 5
Reputation: 285

Post » Wed Aug 01, 2012 1:46 am

@Ashley and @All, Good to know this.
B
28
S
4
G
3
Posts: 70
Reputation: 4,879

Post » Wed Aug 01, 2012 1:50 am

@jwjb - FYI This is an old thread and it's now out of date. New features in Construct 2 give you more options. See this tutorial for some tips.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Wed Aug 01, 2012 1:51 am

@jwjb: this is an old thread.
Since lots of features have been added.
You can load JSON datas in arrays for example through AJAX. (check the manual)

You can also have Project files included with the exported application.

Edit: Hahaha ninja'd by Ash :DKyatric2012-08-01 01:52:06
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Wed Aug 01, 2012 2:20 am

@Ashley, Very cool and thanks for pointing me in the right direction with the link and all.

@Kyatric, Same goes for you, thanks again.
B
28
S
4
G
3
Posts: 70
Reputation: 4,879


Return to How do I....?

Who is online

Users browsing this forum: armaldio, ETgirl79 and 21 guests