Phaser Iso Example Cube
Basic Phaser setup for testing
by markus636
HTML
<script src="https://rawgit.com/photonstorm/phaser/master/build/phaser.min.js"></script>
<script src="https://cdn.rawgit.com/lewster32/phaser-plugin-isometric/master/dist/phaser-plugin-isometric.min.js"></script>
JavaScript
// using canvas here just because it runs faster for the body debug stuff
var game = new Phaser.Game(800, 400, Phaser.CANVAS, 'test', null, true, false);
var BasicGame = function (game) { };
BasicGame.Boot = function (game) {
// nothing here
};
var isoGroup;
BasicGame.Boot.prototype =
{
preload: function () {
game.plugins.add(new Phaser.Plugin.Isometric(game));
game.load.atlasJSONHash('tileset', png, json);
game.physics.startSystem(Phaser.Plugin.Isometric.ISOARCADE);
game.iso.anchor.setTo(0.5, 0.1);
},
create: function () {
isoGroup = game.add.group();
// we won't really be using IsoArcade physics, but I've enabled it anyway so the debug bodies can be seen
isoGroup.enableBody = true;
isoGroup.physicsBodyType = Phaser.Plugin.Isometric.ISOARCADE;
var tileArray = [];
tileArray[0] = 'water';
tileArray[1] = 'sand';
tileArray[2] = 'grass';
tileArray[3] = 'stone';
tileArray[4] = 'wood';
tileArray[5] = 'watersand';
tileArray[6] = 'grasssand';
tileArray[7] = 'sandstone';
tileArray[8] = 'bush1';
tileArray[9] = 'bush2';
tileArray[10] = 'mushroom';
tileArray[11] = 'wall';
tileArray[12] = 'window';
var tiles = [
9, 2, 1, 1, 4, 4, 1, 6, 2, 2, 2,
2, 6, 1, 0, 4, 4, 0, 0, 2, 2, 2,
6, 1, 0, 0, 4, 4, 0, 0, 8, 8, 2,
0, 0, 0, 0, 4, 4, 0, 0, 0, 9, 2,
0, 0, 0, 0, 4, 4, 0, 0, 0, 0, 0,
0, 0, 0, 0, 4, 4, 0, 0, 0, 0, 0,
0, 0, 0, 0, 4, 4, 0, 0, 0, 0, 0,
0, 0, 0, 0, 4, 4, 0, 0, 0, 0, 0,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 7, 3, 3, 3, 3, 3, 3, 7, 3, 3,
7, 1, 7, 7, 3, 3, 7, 7, 1, 1, 7
];
var size = 32;
/**
It iterate on the array tiles[] and draws every tile according to its number in tileArray[]
*/
var i = 0, tile;
for...