Reworking the junkmap
This commit is contained in:
@@ -102,23 +102,31 @@ var moonlightSettings = {
|
|||||||
'layers': {
|
'layers': {
|
||||||
'0 - NonCollide Base': {
|
'0 - NonCollide Base': {
|
||||||
'collides': false,
|
'collides': false,
|
||||||
'collisionBetween': [0, 0]
|
'collisionBetween': [0, 0],
|
||||||
|
'type': 'tiles'
|
||||||
},
|
},
|
||||||
'0 - Collide Base': {
|
'0 - Collide Base': {
|
||||||
'collides': true,
|
'collides': true,
|
||||||
'collisionBetween': [0, 9999]
|
'collisionBetween': [0, 9999],
|
||||||
|
'type': 'tiles'
|
||||||
},
|
},
|
||||||
'0 - NonCollide Overlay - Pathways': {
|
'0 - NonCollide Overlay - Pathways': {
|
||||||
'collides': false,
|
'collides': false,
|
||||||
'collisionBetween': [0, 9999]
|
'collisionBetween': [0, 9999],
|
||||||
|
'type': 'tiles'
|
||||||
},
|
},
|
||||||
'0 - Collide Overlay - Ground Objects': {
|
'0 - Collide Overlay - Ground Objects': {
|
||||||
'collides': true,
|
'collides': true,
|
||||||
'collisionBetween': [0, 9999]
|
'collisionBetween': [0, 9999],
|
||||||
|
'type': 'tiles'
|
||||||
},
|
},
|
||||||
'0 - NonCollide Overlay - Ground Objects': {
|
'0 - NonCollide Overlay - Ground Objects': {
|
||||||
'collides': false,
|
'collides': false,
|
||||||
'collisionBetween': [0, 9999]
|
'collisionBetween': [0, 9999],
|
||||||
|
'type': 'tiles'
|
||||||
|
},
|
||||||
|
'Lights': {
|
||||||
|
'type': 'objects'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'path': 'gfx/map.json'
|
'path': 'gfx/map.json'
|
||||||
@@ -596,7 +604,7 @@ var moonlightDialog = {
|
|||||||
|
|
||||||
// Create torch objects
|
// Create torch objects
|
||||||
// Light constructor
|
// Light constructor
|
||||||
var Light = function(game, x, y, radius, fade, color, flicker) {
|
var Light = function(game, x, y, key, frame, radius, fade, color, flicker) {
|
||||||
color = ( typeof color == undefined ? [255, 255, 255] : color );
|
color = ( typeof color == undefined ? [255, 255, 255] : color );
|
||||||
fade = ( typeof fade == undefined ? 0.25 : fade );
|
fade = ( typeof fade == undefined ? 0.25 : fade );
|
||||||
radius = ( typeof radius == undefined ? 64 : radius );
|
radius = ( typeof radius == undefined ? 64 : radius );
|
||||||
@@ -789,21 +797,23 @@ GameState.prototype.create = function()
|
|||||||
this.map_collision_layers = [];
|
this.map_collision_layers = [];
|
||||||
|
|
||||||
for (var ln in moonlightSettings['map']['layers']) {
|
for (var ln in moonlightSettings['map']['layers']) {
|
||||||
console.log("Preparing layer " + ln);
|
|
||||||
lp = moonlightSettings['map']['layers'][ln];
|
lp = moonlightSettings['map']['layers'][ln];
|
||||||
layer = this.map.createLayer(ln);
|
if ( lp['type'] == "tiles" ) {
|
||||||
console.log("Setting collisions on " + ln);
|
layer = this.map.createLayer(ln);
|
||||||
this.map.setCollisionBetween(
|
this.map.setCollisionBetween(
|
||||||
lp['collisionBetween'][0],
|
lp['collisionBetween'][0],
|
||||||
lp['collisionBetween'][1],
|
lp['collisionBetween'][1],
|
||||||
lp['collides'],
|
lp['collides'],
|
||||||
ln
|
ln
|
||||||
);
|
);
|
||||||
if ( lp['collides'] == true ) {
|
if ( lp['collides'] == true ) {
|
||||||
layer.debug = true;
|
layer.debug = true;
|
||||||
this.map_collision_layers.push(layer);
|
this.map_collision_layers.push(layer);
|
||||||
|
}
|
||||||
|
layer.resizeWorld();
|
||||||
|
} else if ( lp['type'] == "objects" ) {
|
||||||
|
this.map.createFromObjects(ln, ln, undefined, 0, true, false, undefined, Light);
|
||||||
}
|
}
|
||||||
layer.resizeWorld();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
player = this.add.sprite((3 * 32), (17 * 32), 'player');
|
player = this.add.sprite((3 * 32), (17 * 32), 'player');
|
||||||
@@ -844,8 +854,8 @@ GameState.prototype.create = function()
|
|||||||
|
|
||||||
this.shadowTexture = game.add.bitmapData(game.world.width, game.world.height);
|
this.shadowTexture = game.add.bitmapData(game.world.width, game.world.height);
|
||||||
// drop this lower to make the map darker
|
// drop this lower to make the map darker
|
||||||
//this.shadowTextureColor = 'rgb(50, 50, 50)';
|
this.shadowTextureColor = 'rgb(100, 100, 100)';
|
||||||
this.shadowTextureColor = 'rgb(255, 255, 255)';
|
//this.shadowTextureColor = 'rgb(255, 255, 255)';
|
||||||
|
|
||||||
// Create an object that will use the bitmap as a texture
|
// Create an object that will use the bitmap as a texture
|
||||||
this.shadowSprite = game.add.image(0, 0, this.shadowTexture);
|
this.shadowSprite = game.add.image(0, 0, this.shadowTexture);
|
||||||
|
|||||||
Reference in New Issue
Block a user