HTML and CSS Reference
In-Depth Information
<title>Platformer</title>
<script src='js/jquery.min.js'></script>
<script src='js/underscore.js'></script>
<script src='js/quintus.js'></script>
<script src='js/quintus_input.js'></script>
<script src='js/quintus_sprites.js'></script>
<script src='js/quintus_scenes.js'></script>
<script src='js/quintus_anim.js'></script>
<script src='js/quintus_platformer.js'></script>
<script src='js/quintus_editor.js'></script>
<script src='platform.js'></script>
<style>
* { padding:0px; margin:0px; }
</style>
</head>
<body>
</body>
</html>
Next open up the platform.js file in the same directory; at the top of the file, add the Editor module and
remove the controls call. (Controls will be enabled later by the editor.)
$(function() {
var Q = window.Q
= Quintus()
.include('Input,Sprites,Scenes,Anim,Platformer,Editor')
.setup('quintus', { maximize: true });
Next, to support loading the editor and different levels, the bottom of the same file needs to be modified with
a regular expression to optionally load a different level file into the game and set up the editor into the game.
The lines of code that need to be changed are shown here (the first block should be added above the
Q.scene call, and the remaining changes are inside the Q.scene callback):
var match = window.location.search.match(/level=([^\&]+)/),
levelFile = 'level.json';
if(match) {
levelFile = match[1] + '.json';
}
Q.scene('level',new Q.Scene(function(stage) {
stage.insert(new Q.Repeater({ asset: 'background-wall.png',
speedX: 0.50, y:-225, z:0 }));
var tiles = stage.insert(new Q.TileLayer({ sheet: 'block',
x: -100, y: -100,
tileW: 32,
tileH: 32,
dataAsset: levelFile,
z:1 }));
stage.collisionLayer(tiles);
 
Search WWH ::




Custom Search