Create a gist now

Instantly share code, notes, and snippets.

@zeroeth /tmx.html
Last active Aug 29, 2015

What would you like to do?
tmx starter game
<html>
<head>
<script src='http://cdn.html5quintus.com/v0.2.0/quintus-all.js'></script>
<style>
canvas { background-color: #5e81a2; }
</style>
</head>
<body>
<script>
// This game uses spritesheet.png from:
// http://opengameart.org/content/platform-tileset-nature
var Q = Quintus()
.include("Sprites, Scenes, Anim, Input, 2D, Touch, UI, TMX")
.setup({maximize: true})
.controls()
.touch();
// Give us a player from the same tilesheet
Q.Sprite.extend("Player",
{
init: function(properties)
{
// Same name as in the tiled editor
properties.sheet = "Tiles_32x32";
// Square in the tile set
properties.frame = 51;
this._super(properties);
this.add("2d");
this.add("platformerControls");
}
});
// Load TMX File as a scene
Q.scene("level1", function(stage)
{
Q.stageTMX("level1data.tmx", stage);
var player = Q("Player").first();
});
// Load assets and launch the first scene to start the game
//
Q.loadTMX("level1data.tmx" , function()
{
Q.stageScene("level1");
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment