mirror of
https://github.com/photonstorm/phaser
synced 2025-02-16 22:18:29 +00:00
TilemapLayers now render tiles correctly, with our without debugging overlay. Collision working well across single and index ranges.
This commit is contained in:
parent
7917eac255
commit
896e9af9f5
18 changed files with 3500 additions and 194 deletions
|
@ -50,6 +50,8 @@ New features:
|
|||
* Added support for margin and spacing around a frame in Loader.spritesheet.
|
||||
* Added Device.vibration to check if the Vibration API is available or not.
|
||||
* Added Device.trident and Device.tridentVersion for testing IE11.
|
||||
* Added Device.silk for detecting a Kindle Fire and updated desktop OS check to exclude Kindles (thanks LuckieLordie)
|
||||
|
||||
|
||||
New Examples:
|
||||
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 148 KiB |
BIN
examples/assets/maps/CommandoMap1-1BG_bank.png
Normal file
BIN
examples/assets/maps/CommandoMap1-1BG_bank.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7 KiB |
2890
examples/assets/maps/CommandoMap1-1BG_map.tmx
Normal file
2890
examples/assets/maps/CommandoMap1-1BG_map.tmx
Normal file
File diff suppressed because it is too large
Load diff
39
examples/assets/maps/commando.json
Normal file
39
examples/assets/maps/commando.json
Normal file
File diff suppressed because one or more lines are too long
BIN
examples/assets/maps/commando.png
Normal file
BIN
examples/assets/maps/commando.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7 KiB |
|
@ -1,7 +1,7 @@
|
|||
{ "height":18,
|
||||
"layers":[
|
||||
{
|
||||
"data":[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 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 1, 1, 1, 1, 1, 1, 1, 1],
|
||||
"height":18,
|
||||
"name":"Tile Layer 1",
|
||||
"opacity":1,
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<property name="bob" value="eat's cheese"/>
|
||||
</properties>
|
||||
<data encoding="base64">
|
||||
AQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAQAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAACQAAAAEAAAABAAAAAQAAAAEAAAABAAAACQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAA
|
||||
</data>
|
||||
</layer>
|
||||
<layer name="Tile Layer 2" width="50" height="18" visible="0">
|
||||
|
|
140
examples/wip/commando.js
Normal file
140
examples/wip/commando.js
Normal file
|
@ -0,0 +1,140 @@
|
|||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.tilemap('map', 'assets/maps/commando.json', null, Phaser.Tilemap.TILED_JSON);
|
||||
game.load.tileset('tiles', 'assets/maps/commando.png', 32, 32);
|
||||
game.load.image('phaser', 'assets/sprites/arrow.png');
|
||||
|
||||
}
|
||||
|
||||
var cursors;
|
||||
var map;
|
||||
var layer;
|
||||
var sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
map = game.add.tilemap('map');
|
||||
|
||||
// map.setCollisionByIndexRange(80, 97); // mario
|
||||
// map.setCollisionByIndexRange(14, 18); // mario
|
||||
// map.setCollisionByIndex(1); // newtest
|
||||
|
||||
layer = game.add.tilemapLayer(0, 0, 800, 600, 'tiles', map, 0);
|
||||
// layer.debug = true;
|
||||
|
||||
layer.resizeWorld();
|
||||
|
||||
sprite = game.add.sprite(260, 100, 'phaser');
|
||||
sprite.anchor.setTo(0.5, 0.5);
|
||||
|
||||
sprite.body.setSize(16, 16, 8, 8);
|
||||
|
||||
// We'll set a lower max angular velocity here to keep it from going totally nuts
|
||||
sprite.body.maxAngular = 500;
|
||||
|
||||
// Apply a drag otherwise the sprite will just spin and never slow down
|
||||
sprite.body.angularDrag = 50;
|
||||
|
||||
game.camera.follow(sprite);
|
||||
|
||||
cursors = game.input.keyboard.createCursorKeys();
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
/*
|
||||
if (cursors.left.isDown)
|
||||
{
|
||||
game.camera.x -= 1;
|
||||
}
|
||||
else if (cursors.right.isDown)
|
||||
{
|
||||
game.camera.x += 1;
|
||||
}
|
||||
|
||||
if (cursors.up.isDown)
|
||||
{
|
||||
layer.scrollY -= 4;
|
||||
}
|
||||
else if (cursors.down.isDown)
|
||||
{
|
||||
layer.scrollY += 4;
|
||||
}
|
||||
*/
|
||||
game.physics.collide(sprite, layer);
|
||||
|
||||
sprite.body.velocity.x = 0;
|
||||
sprite.body.velocity.y = 0;
|
||||
sprite.body.angularVelocity = 0;
|
||||
|
||||
// sprite.body.acceleration.x = 0;
|
||||
// sprite.body.angularAcceleration = 0;
|
||||
|
||||
if (cursors.left.isDown)
|
||||
{
|
||||
// sprite.body.acceleration.x = -200;
|
||||
sprite.body.angularVelocity = -300;
|
||||
// sprite.body.angularAcceleration -= 200;
|
||||
}
|
||||
else if (cursors.right.isDown)
|
||||
{
|
||||
// sprite.body.acceleration.x = 200;
|
||||
sprite.body.angularVelocity = 300;
|
||||
// sprite.body.angularAcceleration += 200;
|
||||
}
|
||||
|
||||
if (cursors.up.isDown)
|
||||
{
|
||||
game.physics.velocityFromAngle(sprite.angle, 300, sprite.body.velocity);
|
||||
}
|
||||
else
|
||||
{
|
||||
// game.physics.velocityFromAngle(sprite.angle, sprite.body.velocity, sprite.body.velocity);
|
||||
}
|
||||
|
||||
/*
|
||||
sprite.body.velocity.x = 0;
|
||||
sprite.body.velocity.y = 0;
|
||||
|
||||
sprite.angle = sprite.angle + 1;
|
||||
|
||||
if (cursors.up.isDown)
|
||||
{
|
||||
sprite.body.velocity.y = -900;
|
||||
}
|
||||
else if (cursors.down.isDown)
|
||||
{
|
||||
sprite.body.velocity.y = 900;
|
||||
}
|
||||
|
||||
if (cursors.left.isDown)
|
||||
{
|
||||
sprite.body.velocity.x = -900;
|
||||
// sprite.scale.x = -1;
|
||||
}
|
||||
else if (cursors.right.isDown)
|
||||
{
|
||||
sprite.body.velocity.x = 900;
|
||||
// sprite.scale.x = 1;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
// game.debug.renderSpriteBody(sprite);
|
||||
// game.debug.renderSpriteBounds(sprite);
|
||||
|
||||
// game.debug.renderText(sprite.x, 32, 32);
|
||||
// game.debug.renderText(sprite.y, 32, 48);
|
||||
|
||||
// game.debug.renderText(layer.scrollX, 32, 32);
|
||||
// game.debug.renderText(layer.scrollY, 32, 48);
|
||||
|
||||
}
|
|
@ -3,11 +3,11 @@ var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload:
|
|||
|
||||
function preload() {
|
||||
|
||||
// game.load.tilemap('map', 'assets/maps/mario1.json', null, Phaser.Tilemap.TILED_JSON);
|
||||
// game.load.tileset('marioTiles', 'assets/maps/mario1.png', 16, 16);
|
||||
game.load.tilemap('map', 'assets/maps/mario1.json', null, Phaser.Tilemap.TILED_JSON);
|
||||
game.load.tileset('tiles', 'assets/maps/mario1.png', 16, 16);
|
||||
|
||||
game.load.tilemap('map', 'assets/maps/newtest.json', null, Phaser.Tilemap.TILED_JSON);
|
||||
game.load.tileset('tiles', 'assets/maps/ground_1x1.png', 32, 32);
|
||||
// game.load.tilemap('map', 'assets/maps/newtest.json', null, Phaser.Tilemap.TILED_JSON);
|
||||
// game.load.tileset('tiles', 'assets/maps/ground_1x1.png', 32, 32);
|
||||
// game.load.image('phaser', 'assets/sprites/phaser-ship.png');
|
||||
// game.load.image('phaser', 'assets/sprites/mushroom2.png');
|
||||
// game.load.image('phaser', 'assets/sprites/wabbit.png');
|
||||
|
@ -28,11 +28,19 @@ function create() {
|
|||
|
||||
map = game.add.tilemap('map');
|
||||
|
||||
// map.setCollisionByIndexRange(80, 97); // mario
|
||||
map.setCollisionByIndex(1);
|
||||
map.setCollisionByIndexRange(80, 97); // mario
|
||||
map.setCollisionByIndexRange(14, 18); // mario
|
||||
|
||||
|
||||
|
||||
// map.setCollisionByIndex(1); // newtest
|
||||
|
||||
|
||||
|
||||
// Phaser.TilemapLayer = function (game, x, y, renderWidth, renderHeight, tileset, tilemap, layer) {
|
||||
layer = game.add.tilemapLayer(0, 0, 800, 600, null, map, 0);
|
||||
// Need to get the x,y values working (adjust cameraOffset values)
|
||||
layer = game.add.tilemapLayer(0, 0, 800, 600, 'tiles', map, 0);
|
||||
layer.debug = true;
|
||||
|
||||
// layer2 = game.add.tilemapLayer(0, 0, 400, 600, null, map, 0);
|
||||
// layer.cameraOffset.x = 400;
|
||||
|
@ -75,8 +83,8 @@ function create() {
|
|||
|
||||
function getIt() {
|
||||
|
||||
console.log('cam', game.camera.bounds);
|
||||
console.log('w', game.world.bounds);
|
||||
// console.log('cam', game.camera.bounds);
|
||||
// console.log('w', game.world.bounds);
|
||||
// console.log(layer.getTiles(sprite.body.x, sprite.body.y, sprite.body.width, sprite.body.height, true, true));
|
||||
|
||||
}
|
||||
|
|
|
@ -262,13 +262,16 @@ Phaser.GameObjectFactory.prototype = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Creates a new Tilemap Layer object.
|
||||
* Creates a new Tilemap Layer object. By default TilemapLayers are fixed to the camera.
|
||||
*
|
||||
* @method Phaser.GameObjectFactory#tilemapLayer
|
||||
* @param {number} x - X position of the new tilemapLayer.
|
||||
* @param {number} y - Y position of the new tilemapLayer.
|
||||
* @param {number} width - the width of the tilemapLayer.
|
||||
* @param {number} height - the height of the tilemapLayer.
|
||||
* @param {Phaser.Tileset|string} tileset - The tile set used for rendering.
|
||||
* @param {Phaser.Tilemap} tilemap - The tilemap to which this layer belongs.
|
||||
* @param {number|string} [layer=0] - The layer within the tilemap this TilemapLayer represents.
|
||||
* @param {Phaser.Group} [group] - Optional Group to add the object to. If not specified it will be added to the World group.
|
||||
* @return {Phaser.TilemapLayer} The newly created tilemaplayer object.
|
||||
*/
|
||||
|
|
|
@ -98,7 +98,7 @@ Phaser.Text = function (game, x, y, text, style) {
|
|||
this.fixedToCamera = false;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Point} cameraOffset - If this Sprite is fixed to the camera then use this Point to specify how far away from the Camera x/y it's rendered.
|
||||
* @property {Phaser.Point} cameraOffset - If this object is fixed to the camera then use this Point to specify how far away from the Camera x/y it's rendered.
|
||||
*/
|
||||
this.cameraOffset = new Phaser.Point();
|
||||
|
||||
|
|
|
@ -855,8 +855,8 @@ Phaser.Physics.Arcade.prototype = {
|
|||
body2.x += this._overlap;
|
||||
body2.velocity.x = this._velocity1 - this._velocity2 * body2.bounce.x;
|
||||
}
|
||||
body1.updateHulls();
|
||||
body2.updateHulls();
|
||||
// body1.updateHulls();
|
||||
// body2.updateHulls();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -977,8 +977,8 @@ Phaser.Physics.Arcade.prototype = {
|
|||
body2.x += body1.x - body1.preX;
|
||||
}
|
||||
}
|
||||
body1.updateHulls();
|
||||
body2.updateHulls();
|
||||
// body1.updateHulls();
|
||||
// body2.updateHulls();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1024,7 +1024,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
|
||||
if (localOverlapX >= body.deltaX())
|
||||
{
|
||||
console.log('m left overlapX', localOverlapX, body.deltaX());
|
||||
// console.log('m left overlapX', localOverlapX, body.deltaX());
|
||||
// use touching instead of blocked?
|
||||
body.blocked.left = true;
|
||||
body.touching.left = true;
|
||||
|
@ -1039,7 +1039,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
// Distance check
|
||||
if (localOverlapX <= body.deltaX())
|
||||
{
|
||||
console.log('m right overlapX', localOverlapX, body.deltaX());
|
||||
// console.log('m right overlapX', localOverlapX, body.deltaX());
|
||||
body.blocked.right = true;
|
||||
body.touching.right = true;
|
||||
body.touching.none = false;
|
||||
|
@ -1054,7 +1054,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
// Distance check
|
||||
if (localOverlapY >= body.deltaY())
|
||||
{
|
||||
console.log('m up overlapY', localOverlapY, body.deltaY());
|
||||
// console.log('m up overlapY', localOverlapY, body.deltaY());
|
||||
body.blocked.up = true;
|
||||
body.touching.up = true;
|
||||
body.touching.none = false;
|
||||
|
@ -1067,7 +1067,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
|
||||
if (localOverlapY <= body.deltaY())
|
||||
{
|
||||
console.log('m down overlapY', localOverlapY, body.deltaY());
|
||||
// console.log('m down overlapY', localOverlapY, body.deltaY());
|
||||
body.blocked.down = true;
|
||||
body.touching.down = true;
|
||||
body.touching.none = false;
|
||||
|
@ -1163,7 +1163,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
|
||||
if (body.overlapX >= body.deltaX())
|
||||
{
|
||||
console.log('left overlapX', body.overlapX, body.deltaX());
|
||||
// console.log('left overlapX', body.overlapX, body.deltaX());
|
||||
// use touching instead of blocked?
|
||||
body.blocked.left = true;
|
||||
body.touching.left = true;
|
||||
|
@ -1178,7 +1178,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
// Distance check
|
||||
if (body.overlapX <= body.deltaX())
|
||||
{
|
||||
console.log('right overlapX', body.overlapX, body.deltaX());
|
||||
// console.log('right overlapX', body.overlapX, body.deltaX());
|
||||
body.blocked.right = true;
|
||||
body.touching.right = true;
|
||||
body.touching.none = false;
|
||||
|
@ -1193,7 +1193,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
// Distance check
|
||||
if (body.overlapY >= body.deltaY())
|
||||
{
|
||||
console.log('up overlapY', body.overlapY, body.deltaY());
|
||||
// console.log('up overlapY', body.overlapY, body.deltaY());
|
||||
body.blocked.up = true;
|
||||
body.touching.up = true;
|
||||
body.touching.none = false;
|
||||
|
@ -1206,7 +1206,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
|
||||
if (body.overlapY <= body.deltaY())
|
||||
{
|
||||
console.log('down overlapY', body.overlapY, body.deltaY());
|
||||
// console.log('down overlapY', body.overlapY, body.deltaY());
|
||||
body.blocked.down = true;
|
||||
body.touching.down = true;
|
||||
body.touching.none = false;
|
||||
|
|
|
@ -224,6 +224,12 @@ Phaser.Device = function () {
|
|||
*/
|
||||
this.webApp = false;
|
||||
|
||||
/**
|
||||
* @property {boolean} silk - Set to true if running in the Silk browser (as used on the Amazon Kindle)
|
||||
* @default
|
||||
*/
|
||||
this.silk = false;
|
||||
|
||||
// Audio
|
||||
|
||||
/**
|
||||
|
@ -328,21 +334,33 @@ Phaser.Device.prototype = {
|
|||
|
||||
var ua = navigator.userAgent;
|
||||
|
||||
if (/Android/.test(ua)) {
|
||||
if (/Android/.test(ua))
|
||||
{
|
||||
this.android = true;
|
||||
} else if (/CrOS/.test(ua)) {
|
||||
}
|
||||
else if (/CrOS/.test(ua))
|
||||
{
|
||||
this.chromeOS = true;
|
||||
} else if (/iP[ao]d|iPhone/i.test(ua)) {
|
||||
}
|
||||
else if (/iP[ao]d|iPhone/i.test(ua))
|
||||
{
|
||||
this.iOS = true;
|
||||
} else if (/Linux/.test(ua)) {
|
||||
}
|
||||
else if (/Linux/.test(ua))
|
||||
{
|
||||
this.linux = true;
|
||||
} else if (/Mac OS/.test(ua)) {
|
||||
}
|
||||
else if (/Mac OS/.test(ua))
|
||||
{
|
||||
this.macOS = true;
|
||||
} else if (/Windows/.test(ua)) {
|
||||
}
|
||||
else if (/Windows/.test(ua))
|
||||
{
|
||||
this.windows = true;
|
||||
}
|
||||
|
||||
if (this.windows || this.macOS || this.linux) {
|
||||
if (this.windows || this.macOS || (this.linux && this.silk === false))
|
||||
{
|
||||
this.desktop = true;
|
||||
}
|
||||
|
||||
|
@ -378,11 +396,13 @@ Phaser.Device.prototype = {
|
|||
|
||||
this.worker = !!window['Worker'];
|
||||
|
||||
if ('ontouchstart' in document.documentElement || (window.navigator.maxTouchPoints && window.navigator.maxTouchPoints > 1)) {
|
||||
if ('ontouchstart' in document.documentElement || (window.navigator.maxTouchPoints && window.navigator.maxTouchPoints > 1))
|
||||
{
|
||||
this.touch = true;
|
||||
}
|
||||
|
||||
if (window.navigator.msPointerEnabled || window.navigator.pointerEnabled) {
|
||||
if (window.navigator.msPointerEnabled || window.navigator.pointerEnabled)
|
||||
{
|
||||
this.mspointer = true;
|
||||
}
|
||||
|
||||
|
@ -399,37 +419,62 @@ Phaser.Device.prototype = {
|
|||
|
||||
var ua = navigator.userAgent;
|
||||
|
||||
if (/Arora/.test(ua)) {
|
||||
if (/Arora/.test(ua))
|
||||
{
|
||||
this.arora = true;
|
||||
} else if (/Chrome/.test(ua)) {
|
||||
}
|
||||
else if (/Chrome/.test(ua))
|
||||
{
|
||||
this.chrome = true;
|
||||
} else if (/Epiphany/.test(ua)) {
|
||||
}
|
||||
else if (/Epiphany/.test(ua))
|
||||
{
|
||||
this.epiphany = true;
|
||||
} else if (/Firefox/.test(ua)) {
|
||||
}
|
||||
else if (/Firefox/.test(ua))
|
||||
{
|
||||
this.firefox = true;
|
||||
} else if (/Mobile Safari/.test(ua)) {
|
||||
}
|
||||
else if (/Mobile Safari/.test(ua))
|
||||
{
|
||||
this.mobileSafari = true;
|
||||
} else if (/MSIE (\d+\.\d+);/.test(ua)) {
|
||||
}
|
||||
else if (/MSIE (\d+\.\d+);/.test(ua))
|
||||
{
|
||||
this.ie = true;
|
||||
this.ieVersion = parseInt(RegExp.$1, 10);
|
||||
} else if (/Midori/.test(ua)) {
|
||||
}
|
||||
else if (/Midori/.test(ua))
|
||||
{
|
||||
this.midori = true;
|
||||
} else if (/Opera/.test(ua)) {
|
||||
}
|
||||
else if (/Opera/.test(ua))
|
||||
{
|
||||
this.opera = true;
|
||||
} else if (/Safari/.test(ua)) {
|
||||
}
|
||||
else if (/Safari/.test(ua))
|
||||
{
|
||||
this.safari = true;
|
||||
} else if (/Trident\/(\d+\.\d+);/.test(ua)) {
|
||||
}
|
||||
else if (/Silk/.test(ua))
|
||||
{
|
||||
this.silk = true;
|
||||
}
|
||||
else if (/Trident\/(\d+\.\d+);/.test(ua))
|
||||
{
|
||||
this.ie = true;
|
||||
this.trident = true;
|
||||
this.tridentVersion = parseInt(RegExp.$1, 10);
|
||||
}
|
||||
|
||||
// WebApp mode in iOS
|
||||
if (navigator['standalone']) {
|
||||
if (navigator['standalone'])
|
||||
{
|
||||
this.webApp = true;
|
||||
}
|
||||
|
||||
if (navigator['isCocoonJS']) {
|
||||
if (navigator['isCocoonJS'])
|
||||
{
|
||||
this.cocoonJS = true;
|
||||
}
|
||||
|
||||
|
@ -534,8 +579,10 @@ Phaser.Device.prototype = {
|
|||
// Add it to the body to get the computed style.
|
||||
document.body.insertBefore(el, null);
|
||||
|
||||
for (var t in transforms) {
|
||||
if (el.style[t] !== undefined) {
|
||||
for (var t in transforms)
|
||||
{
|
||||
if (el.style[t] !== undefined)
|
||||
{
|
||||
el.style[t] = "translate3d(1px,1px,1px)";
|
||||
has3d = window.getComputedStyle(el).getPropertyValue(transforms[t]);
|
||||
}
|
||||
|
|
|
@ -122,14 +122,38 @@ Phaser.Tilemap.prototype = {
|
|||
|
||||
},
|
||||
|
||||
createTilemapLayer: function (x, y, renderWidth, renderHeight, tileset, layer) {
|
||||
/**
|
||||
* Sets collision values on a range of tiles in the set.
|
||||
*
|
||||
* @method Phaser.Tileset#createTilemapLayer
|
||||
* @param {number} x - X position of the new tilemapLayer.
|
||||
* @param {number} y - Y position of the new tilemapLayer.
|
||||
* @param {number} width - the width of the tilemapLayer.
|
||||
* @param {number} height - the height of the tilemapLayer.
|
||||
* @param {Phaser.Tileset|string} tileset - The tile set used for rendering.
|
||||
* @param {number|string} [layer=0] - The layer within the tilemap this TilemapLayer represents.
|
||||
* @param {Phaser.Group} [group] - Optional Group to add the object to. If not specified it will be added to the World group.
|
||||
*/
|
||||
createTilemapLayer: function (x, y, renderWidth, renderHeight, tileset, layer, group) {
|
||||
|
||||
return this.game.world.add(new Phaser.TilemapLayer(this.game, x, y, renderWidth, renderHeight, tileset, this, layer));
|
||||
if (typeof group === 'undefined') { group = this.game.world; }
|
||||
|
||||
return group.add(new Phaser.TilemapLayer(this.game, x, y, renderWidth, renderHeight, tileset, this, layer));
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets collision values on a range of tiles in the set.
|
||||
*
|
||||
* @method Phaser.Tileset#setCollisionByIndexRange
|
||||
* @param {number} start - The first index of the tile on the layer.
|
||||
* @param {number} stop - The last index of the tile on the layer.
|
||||
* @param {number} layer - The layer to operate on.
|
||||
*/
|
||||
setCollisionByIndexRange: function (start, stop, layer) {
|
||||
|
||||
if (typeof layer === "undefined") { layer = this.currentLayer; }
|
||||
|
||||
if (start > stop)
|
||||
{
|
||||
return;
|
||||
|
@ -137,21 +161,26 @@ Phaser.Tilemap.prototype = {
|
|||
|
||||
for (var i = start; i <= stop; i++)
|
||||
{
|
||||
this.setCollisionByIndex(i, layer);
|
||||
this.setCollisionByIndex(i, layer, false);
|
||||
}
|
||||
|
||||
// Now re-calculate interesting faces
|
||||
this.calculateFaces(layer);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets collision values on a tile in the set.
|
||||
*
|
||||
* @method Phaser.Tileset#setCollision
|
||||
* @method Phaser.Tileset#setCollisionByIndex
|
||||
* @param {number} index - The index of the tile on the layer.
|
||||
* @param {number} layer - The layer to operate on.
|
||||
* @param {boolean} [recalculate=true] - Recalculates the tile faces after the update.
|
||||
*/
|
||||
setCollisionByIndex: function (index, layer) {
|
||||
setCollisionByIndex: function (index, layer, recalculate) {
|
||||
|
||||
if (typeof layer === "undefined") { layer = this.currentLayer; }
|
||||
if (typeof recalculate === "undefined") { recalculate = true; }
|
||||
|
||||
for (var y = 0; y < this.layers[layer].height ; y++)
|
||||
{
|
||||
|
@ -170,14 +199,20 @@ Phaser.Tilemap.prototype = {
|
|||
}
|
||||
}
|
||||
|
||||
// Sets all tiles matching the given index to collide on the given faces
|
||||
// Recalculates the collision map
|
||||
|
||||
// Now re-calculate interesting faces
|
||||
this.calculateFaces(layer);
|
||||
if (recalculate)
|
||||
{
|
||||
// Now re-calculate interesting faces
|
||||
this.calculateFaces(layer);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Internal function.
|
||||
*
|
||||
* @method Phaser.Tileset#calculateFaces
|
||||
* @param {number} layer - The layer to operate on.
|
||||
*/
|
||||
calculateFaces: function (layer) {
|
||||
|
||||
var above = null;
|
||||
|
@ -185,9 +220,9 @@ Phaser.Tilemap.prototype = {
|
|||
var left = null;
|
||||
var right = null;
|
||||
|
||||
// console.log(this.layers[layer].width, 'x', this.layers[layer].height);
|
||||
// console.log(this.layers[layer].width, 'x', this.layers[layer].height);
|
||||
|
||||
for (var y = 0; y < this.layers[layer].height ; y++)
|
||||
for (var y = 0; y < this.layers[layer].height; y++)
|
||||
{
|
||||
for (var x = 0; x < this.layers[layer].width; x++)
|
||||
{
|
||||
|
@ -229,6 +264,14 @@ Phaser.Tilemap.prototype = {
|
|||
|
||||
},
|
||||
|
||||
/**
|
||||
* Internal function.
|
||||
*
|
||||
* @method Phaser.Tileset#getTileAbove
|
||||
* @param {number} layer - The layer to operate on.
|
||||
* @param {number} x - X.
|
||||
* @param {number} y - Y.
|
||||
*/
|
||||
getTileAbove: function (layer, x, y) {
|
||||
|
||||
if (y > 0)
|
||||
|
@ -240,6 +283,14 @@ Phaser.Tilemap.prototype = {
|
|||
|
||||
},
|
||||
|
||||
/**
|
||||
* Internal function.
|
||||
*
|
||||
* @method Phaser.Tileset#getTileBelow
|
||||
* @param {number} layer - The layer to operate on.
|
||||
* @param {number} x - X.
|
||||
* @param {number} y - Y.
|
||||
*/
|
||||
getTileBelow: function (layer, x, y) {
|
||||
|
||||
if (y < this.layers[layer].height - 1)
|
||||
|
@ -251,6 +302,14 @@ Phaser.Tilemap.prototype = {
|
|||
|
||||
},
|
||||
|
||||
/**
|
||||
* Internal function.
|
||||
*
|
||||
* @method Phaser.Tileset#getTileLeft
|
||||
* @param {number} layer - The layer to operate on.
|
||||
* @param {number} x - X.
|
||||
* @param {number} y - Y.
|
||||
*/
|
||||
getTileLeft: function (layer, x, y) {
|
||||
|
||||
if (x > 0)
|
||||
|
@ -262,6 +321,14 @@ Phaser.Tilemap.prototype = {
|
|||
|
||||
},
|
||||
|
||||
/**
|
||||
* Internal function.
|
||||
*
|
||||
* @method Phaser.Tileset#getTileRight
|
||||
* @param {number} layer - The layer to operate on.
|
||||
* @param {number} x - X.
|
||||
* @param {number} y - Y.
|
||||
*/
|
||||
getTileRight: function (layer, x, y) {
|
||||
|
||||
if (x < this.layers[layer].width - 1)
|
||||
|
@ -273,35 +340,6 @@ Phaser.Tilemap.prototype = {
|
|||
|
||||
},
|
||||
|
||||
/**
|
||||
* Internal function that calculates the tile indexes for the map data.
|
||||
*
|
||||
* @method Phaser.Tilemap#calculateIndexes
|
||||
*/
|
||||
calculateIndexes: function () {
|
||||
|
||||
/*
|
||||
for (var layer = 0; layer < this.layers.length; layer++)
|
||||
{
|
||||
this.layers[layer].indexes = [];
|
||||
|
||||
for (var y = 0; y < this.layers[layer].height ; y++)
|
||||
{
|
||||
for (var x = 0; x < this.layers[layer].width; x++)
|
||||
{
|
||||
var idx = this.layers[layer].data[y][x];
|
||||
|
||||
if (this.layers[layer].indexes.indexOf(idx) === -1)
|
||||
{
|
||||
this.layers[layer].indexes.push(idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the current layer to the given index.
|
||||
*
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
* @param {Phaser.Game} game - Game reference to the currently running game.
|
||||
* @param {number} x - The x coordinate of this layer.
|
||||
* @param {number} y - The y coordinate of this layer.
|
||||
* @param {number} renderWidth - Width of the layer.
|
||||
* @param {number} renderHeight - Height of the layer.
|
||||
* @param {number} renderWidth - Width of the renderable area of the layer.
|
||||
* @param {number} renderHeight - Height of the renderable area of the layer.
|
||||
* @param {Phaser.Tileset|string} tileset - The tile set used for rendering.
|
||||
* @param {Phaser.Tilemap} tilemap - The tilemap to which this layer belongs.
|
||||
* @param {number|string} [layer=0] - The layer within the tilemap this TilemapLayer represents.
|
||||
|
@ -26,7 +26,7 @@ Phaser.TilemapLayer = function (game, x, y, renderWidth, renderHeight, tileset,
|
|||
this.game = game;
|
||||
|
||||
/**
|
||||
* @property {HTMLCanvasElement} canvas - The canvas to which this BitmapData draws.
|
||||
* @property {HTMLCanvasElement} canvas - The canvas to which this TilemapLayer draws.
|
||||
*/
|
||||
this.canvas = Phaser.Canvas.create(renderWidth, renderHeight);
|
||||
|
||||
|
@ -59,12 +59,17 @@ Phaser.TilemapLayer = function (game, x, y, renderWidth, renderHeight, tileset,
|
|||
this.type = Phaser.TILEMAPLAYER;
|
||||
|
||||
/**
|
||||
* A layer that is fixed to the camera ignores the position of any ancestors in the display list and uses its x/y coordinates as offsets from the top left of the camera.
|
||||
* @property {boolean} fixedToCamera - Fixes this layer to the Camera.
|
||||
* An object that is fixed to the camera ignores the position of any ancestors in the display list and uses its x/y coordinates as offsets from the top left of the camera.
|
||||
* @property {boolean} fixedToCamera - Fixes this object to the Camera.
|
||||
* @default
|
||||
*/
|
||||
this.fixedToCamera = true;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Point} cameraOffset - If this object is fixed to the camera then use this Point to specify how far away from the Camera x/y it's rendered.
|
||||
*/
|
||||
this.cameraOffset = new Phaser.Point(x, y);
|
||||
|
||||
/**
|
||||
* @property {Phaser.Tileset} tileset - The tile set used for rendering.
|
||||
*/
|
||||
|
@ -90,6 +95,12 @@ Phaser.TilemapLayer = function (game, x, y, renderWidth, renderHeight, tileset,
|
|||
*/
|
||||
this.tileSpacing = 0;
|
||||
|
||||
/**
|
||||
* @property {boolean} debug - If set to true the collideable tile edges path will be rendered.
|
||||
* @default
|
||||
*/
|
||||
this.debug = false;
|
||||
|
||||
/**
|
||||
* @property {number} widthInPixels - Do NOT recommend changing after the map is loaded!
|
||||
* @readonly
|
||||
|
@ -505,17 +516,108 @@ Phaser.TilemapLayer.prototype.getTileXY = function (x, y, point) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the tiles within the given area.
|
||||
* Get all tiles that exist within the given area, defined by the top-left corner, width and height. Values given are in pixels, not tiles.
|
||||
* @method Phaser.TilemapLayer#getTiles
|
||||
* @memberof Phaser.TilemapLayer
|
||||
* @param {number} x - X position of the top left of the area to copy (given in tiles, not pixels)
|
||||
* @param {number} y - Y position of the top left of the area to copy (given in tiles, not pixels)
|
||||
* @param {number} width - The width of the area to copy (given in tiles, not pixels)
|
||||
* @param {number} height - The height of the area to copy (given in tiles, not pixels)
|
||||
* @param {number} x - X position of the top left corner.
|
||||
* @param {number} y - Y position of the top left corner.
|
||||
* @param {number} width - Width of the area to get.
|
||||
* @param {number} height - Height of the area to get.
|
||||
* @param {boolean} [collides=false] - If true only return tiles that collide on one or more faces.
|
||||
* @return {array} Array with tiles informations (each contains x, y, and the tile).
|
||||
*/
|
||||
Phaser.TilemapLayer.prototype.getTiles = function (x, y, width, height, collides, debug) {
|
||||
Phaser.TilemapLayer.prototype.getTiles = function (x, y, width, height, collides) {
|
||||
|
||||
if (this.tilemap === null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Should we only get tiles that have at least one of their collision flags set? (true = yes, false = no just get them all)
|
||||
if (typeof collides === 'undefined') { collides = false; }
|
||||
|
||||
// adjust the x,y coordinates for scrollFactor
|
||||
x = this._fixX(x);
|
||||
y = this._fixY(y);
|
||||
|
||||
if (width > this.widthInPixels)
|
||||
{
|
||||
width = this.widthInPixels;
|
||||
}
|
||||
|
||||
if (height > this.heightInPixels)
|
||||
{
|
||||
height = this.heightInPixels;
|
||||
}
|
||||
|
||||
var tileWidth = this.tileWidth * this.scale.x;
|
||||
var tileHeight = this.tileHeight * this.scale.y;
|
||||
|
||||
// Convert the pixel values into tile coordinates
|
||||
this._tx = this.game.math.snapToFloor(x, tileWidth) / tileWidth;
|
||||
this._ty = this.game.math.snapToFloor(y, tileHeight) / tileHeight;
|
||||
this._tw = (this.game.math.snapToCeil(width, tileWidth) + tileWidth) / tileWidth;
|
||||
this._th = (this.game.math.snapToCeil(height, tileHeight) + tileHeight) / tileHeight;
|
||||
|
||||
// This should apply the layer x/y here
|
||||
this._results.length = 0;
|
||||
|
||||
// var _index = 0;
|
||||
var _tile = null;
|
||||
// var sx = 0;
|
||||
// var sy = 0;
|
||||
|
||||
for (var wy = this._ty; wy < this._ty + this._th; wy++)
|
||||
{
|
||||
for (var wx = this._tx; wx < this._tx + this._tw; wx++)
|
||||
{
|
||||
if (this.layer.data[wy] && this.layer.data[wy][wx])
|
||||
{
|
||||
_tile = this.layer.data[wy][wx];
|
||||
|
||||
if (_tile)
|
||||
{
|
||||
// sx = this.tileWidth * this.scale.x;
|
||||
// sy = this.tileHeight * this.scale.y;
|
||||
|
||||
if (collides === false || (collides && _tile.collides))
|
||||
{
|
||||
// convert tile coordinates back to camera space for return
|
||||
var _wx = this._unfixX(wx * tileWidth) / this.tileWidth;
|
||||
var _wy = this._unfixY(wy * tileHeight) / this.tileHeight;
|
||||
|
||||
this._results.push({
|
||||
x: _wx * tileWidth,
|
||||
y: _wy * tileHeight,
|
||||
right: (_wx * tileWidth) + tileWidth,
|
||||
bottom: (_wy * tileHeight) + tileHeight,
|
||||
tile: _tile
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this._results;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all tiles that exist within the given area, defined by the top-left corner, width and height. Values given are in pixels, not tiles.
|
||||
* This function also draws to the context all of the debug areas.
|
||||
* @method Phaser.TilemapLayer#debugGetTiles
|
||||
* @memberof Phaser.TilemapLayer
|
||||
* @param {number} x - X position of the top left corner.
|
||||
* @param {number} y - Y position of the top left corner.
|
||||
* @param {number} width - Width of the area to get.
|
||||
* @param {number} height - Height of the area to get.
|
||||
* @param {boolean} [collides=false] - If true only return tiles that collide on one or more faces.
|
||||
* @return {array} Array with tiles informations (each contains x, y, and the tile).
|
||||
*/
|
||||
Phaser.TilemapLayer.prototype.debugGetTiles = function (x, y, width, height, collides) {
|
||||
|
||||
if (this.tilemap === null)
|
||||
{
|
||||
|
@ -616,7 +718,6 @@ Phaser.TilemapLayer.prototype.getTiles = function (x, y, width, height, collides
|
|||
this.context.fillRect(_tile.x * this.tileWidth, _tile.y * this.tileHeight, this.tileWidth, this.tileHeight);
|
||||
}
|
||||
|
||||
|
||||
// this.context.strokeRect(_tile.x * this.tileWidth, _tile.y * this.tileHeight, this.tileWidth, this.tileHeight);
|
||||
|
||||
// convert tile coordinates back to camera space for return
|
||||
|
@ -674,7 +775,7 @@ Phaser.TilemapLayer.prototype.updateMax = function () {
|
|||
|
||||
this.dirty = true;
|
||||
|
||||
console.log('updateMax', this._maxX, this._maxY, 'px', this.widthInPixels, this.heightInPixels, 'rwh', this.width, this.height);
|
||||
// console.log('updateMax', this._maxX, this._maxY, 'px', this.widthInPixels, this.heightInPixels, 'rwh', this.width, this.height);
|
||||
|
||||
}
|
||||
|
||||
|
@ -711,8 +812,12 @@ Phaser.TilemapLayer.prototype.render = function () {
|
|||
this._ty = this._dy;
|
||||
|
||||
this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
||||
this.context.fillStyle = 'rgba(0,255,0,0.3)';
|
||||
this.context.strokeStyle = 'rgba(0,255,0,0.9)';
|
||||
|
||||
if (this.debug)
|
||||
{
|
||||
this.context.fillStyle = 'rgba(0,255,0,0.3)';
|
||||
this.context.strokeStyle = 'rgba(0,255,0,0.9)';
|
||||
}
|
||||
|
||||
for (var y = this._startY, lenY = this._startY + this._maxY; y < lenY; y++)
|
||||
{
|
||||
|
@ -722,59 +827,58 @@ Phaser.TilemapLayer.prototype.render = function () {
|
|||
{
|
||||
var tile = this._column[x];
|
||||
|
||||
// var tile = this.tileset.tiles[this._column[x] - 1];
|
||||
|
||||
// if (tile && this.tileset)
|
||||
// {
|
||||
// this.context.drawImage(
|
||||
// this.tileset.image,
|
||||
// tile.x,
|
||||
// tile.y,
|
||||
// this.tileWidth,
|
||||
// this.tileHeight,
|
||||
// Math.floor(this._tx),
|
||||
// Math.floor(this._ty),
|
||||
// this.tileWidth,
|
||||
// this.tileHeight
|
||||
// );
|
||||
// }
|
||||
|
||||
if (tile && (tile.faceTop || tile.faceBottom || tile.faceLeft || tile.faceRight))
|
||||
if (tile && this.tileset)
|
||||
{
|
||||
this._tx = Math.floor(this._tx);
|
||||
this.context.drawImage(
|
||||
this.tileset.image,
|
||||
this.tileset.getTileX(tile.index),
|
||||
this.tileset.getTileY(tile.index),
|
||||
this.tileWidth,
|
||||
this.tileHeight,
|
||||
Math.floor(this._tx),
|
||||
Math.floor(this._ty),
|
||||
this.tileWidth,
|
||||
this.tileHeight
|
||||
);
|
||||
}
|
||||
|
||||
this.context.fillRect(this._tx, this._ty, this.tileWidth, this.tileHeight);
|
||||
|
||||
this.context.beginPath();
|
||||
|
||||
if (tile.faceTop)
|
||||
if (this.debug)
|
||||
{
|
||||
if (tile && (tile.faceTop || tile.faceBottom || tile.faceLeft || tile.faceRight))
|
||||
{
|
||||
this.context.moveTo(this._tx, this._ty);
|
||||
this.context.lineTo(this._tx + this.tileWidth, this._ty);
|
||||
this._tx = Math.floor(this._tx);
|
||||
|
||||
// this.context.fillRect(this._tx, this._ty, this.tileWidth, this.tileHeight);
|
||||
|
||||
this.context.beginPath();
|
||||
|
||||
if (tile.faceTop)
|
||||
{
|
||||
this.context.moveTo(this._tx, this._ty);
|
||||
this.context.lineTo(this._tx + this.tileWidth, this._ty);
|
||||
}
|
||||
|
||||
if (tile.faceBottom)
|
||||
{
|
||||
this.context.moveTo(this._tx, this._ty + this.tileHeight);
|
||||
this.context.lineTo(this._tx + this.tileWidth, this._ty + this.tileHeight);
|
||||
}
|
||||
|
||||
if (tile.faceLeft)
|
||||
{
|
||||
this.context.moveTo(this._tx, this._ty);
|
||||
this.context.lineTo(this._tx, this._ty + this.tileHeight);
|
||||
}
|
||||
|
||||
if (tile.faceRight)
|
||||
{
|
||||
this.context.moveTo(this._tx + this.tileWidth, this._ty);
|
||||
this.context.lineTo(this._tx + this.tileWidth, this._ty + this.tileHeight);
|
||||
}
|
||||
|
||||
this.context.stroke();
|
||||
// this.context.strokeRect(this._tx, this._ty, this.tileWidth, this.tileHeight);
|
||||
}
|
||||
|
||||
if (tile.faceBottom)
|
||||
{
|
||||
this.context.moveTo(this._tx, this._ty + this.tileHeight);
|
||||
this.context.lineTo(this._tx + this.tileWidth, this._ty + this.tileHeight);
|
||||
}
|
||||
|
||||
if (tile.faceLeft)
|
||||
{
|
||||
this.context.moveTo(this._tx, this._ty);
|
||||
this.context.lineTo(this._tx, this._ty + this.tileHeight);
|
||||
}
|
||||
|
||||
if (tile.faceRight)
|
||||
{
|
||||
this.context.moveTo(this._tx + this.tileWidth, this._ty);
|
||||
this.context.lineTo(this._tx + this.tileWidth, this._ty + this.tileHeight);
|
||||
}
|
||||
|
||||
// this.context.closePath();
|
||||
this.context.stroke();
|
||||
|
||||
// this.context.strokeRect(this._tx, this._ty, this.tileWidth, this.tileHeight);
|
||||
}
|
||||
|
||||
this._tx += this.tileWidth;
|
||||
|
|
|
@ -63,26 +63,11 @@ Phaser.TilemapParser = {
|
|||
return null;
|
||||
}
|
||||
|
||||
// Let's create some tiles
|
||||
var x = tileMargin;
|
||||
var y = tileMargin;
|
||||
//Phaser.Tileset = function (image, key, total, tileWidth, tileHeight, firstgid, tileMargin, tileSpacing) {
|
||||
return new Phaser.Tileset(img, key, total, tileWidth, tileHeight, 1, tileMargin, tileSpacing);
|
||||
|
||||
var tileset = new Phaser.Tileset(img, key, tileWidth, tileHeight, tileMargin, tileSpacing);
|
||||
|
||||
for (var i = 0; i < total; i++)
|
||||
{
|
||||
tileset.addTile(new Phaser.Tile(tileset, i, x, y, tileWidth, tileHeight));
|
||||
|
||||
x += tileWidth + tileSpacing;
|
||||
|
||||
if (x === width)
|
||||
{
|
||||
x = tileMargin;
|
||||
y += tileHeight + tileSpacing;
|
||||
}
|
||||
}
|
||||
|
||||
return tileset;
|
||||
// tileset.build();
|
||||
// return tileset;
|
||||
|
||||
},
|
||||
|
||||
|
|
|
@ -11,13 +11,16 @@
|
|||
* @constructor
|
||||
* @param {Image} image - The Image object from the Cache.
|
||||
* @param {string} key - The key of the tileset in the cache.
|
||||
* @param {number} total - The total number of tiles in the tilesheet.
|
||||
* @param {number} tileWidth - The width of the tile in pixels.
|
||||
* @param {number} tileHeight - The height of the tile in pixels.
|
||||
* @param {number} [tileMargin] - The margin around the tiles in the sheet.
|
||||
* @param {number} [tileSpacing] - The spacing between the tiles in the sheet.
|
||||
* @param {number} [firstgid=0] - The first index number (as specified by Tiled, otherwise set to zero)
|
||||
* @param {number} [tileMargin=0] - The margin around the tiles in the sheet.
|
||||
* @param {number} [tileSpacing=0] - The spacing between the tiles in the sheet.
|
||||
*/
|
||||
Phaser.Tileset = function (image, key, tileWidth, tileHeight, tileMargin, tileSpacing) {
|
||||
Phaser.Tileset = function (image, key, total, tileWidth, tileHeight, firstgid, tileMargin, tileSpacing) {
|
||||
|
||||
if (typeof firstgid === "undefined") { firstgid = 0; }
|
||||
if (typeof tileMargin === "undefined") { tileMargin = 0; }
|
||||
if (typeof tileSpacing === "undefined") { tileSpacing = 0; }
|
||||
|
||||
|
@ -31,6 +34,16 @@ Phaser.Tileset = function (image, key, tileWidth, tileHeight, tileMargin, tileSp
|
|||
*/
|
||||
this.image = image;
|
||||
|
||||
/**
|
||||
* @property {number} total - The total number of tiles in the tilesheet.
|
||||
*/
|
||||
this.total = total;
|
||||
|
||||
/**
|
||||
* @property {number} firstgid - The total number of tiles in the tilesheet.
|
||||
*/
|
||||
this.firstgid = firstgid;
|
||||
|
||||
/**
|
||||
* @property {number} tileWidth - The width of a tile in pixels.
|
||||
*/
|
||||
|
@ -44,33 +57,49 @@ Phaser.Tileset = function (image, key, tileWidth, tileHeight, tileMargin, tileSp
|
|||
/**
|
||||
* @property {number} tileMargin - The margin around the tiles in the sheet.
|
||||
*/
|
||||
this.margin = tileMargin;
|
||||
this.tileMargin = tileMargin;
|
||||
|
||||
/**
|
||||
* @property {number} tileSpacing - The margin around the tiles in the sheet.
|
||||
*/
|
||||
this.spacing = tileSpacing;
|
||||
this.tileSpacing = tileSpacing;
|
||||
|
||||
/**
|
||||
* @property {array} tiles - An array of the tile collision data.
|
||||
* @property {array} tiles - An array of the tile data.
|
||||
*/
|
||||
this.tiles = [];
|
||||
|
||||
this.build();
|
||||
|
||||
}
|
||||
|
||||
Phaser.Tileset.prototype = {
|
||||
|
||||
/**
|
||||
* Adds a Tile into this set.
|
||||
* Builds the tile data
|
||||
*
|
||||
* @method Phaser.Tileset#addTile
|
||||
* @param {Phaser.Tile} tile - The tile to add to this set.
|
||||
* @method Phaser.Tileset#build
|
||||
*/
|
||||
addTile: function (tile) {
|
||||
build: function () {
|
||||
|
||||
this.tiles.push(tile);
|
||||
var x = this.tileMargin;
|
||||
var y = this.tileMargin;
|
||||
|
||||
return tile;
|
||||
for (var i = this.firstgid; i < this.firstgid + this.total; i++)
|
||||
{
|
||||
// Can add extra properties here as needed
|
||||
this.tiles[i] = [x, y];
|
||||
|
||||
x += this.tileWidth + this.tileSpacing;
|
||||
|
||||
if (x === this.image.width)
|
||||
{
|
||||
x = this.tileMargin;
|
||||
y += this.tileHeight + this.tileSpacing;
|
||||
}
|
||||
}
|
||||
|
||||
// console.table(this.tiles);
|
||||
|
||||
},
|
||||
|
||||
|
@ -79,16 +108,37 @@ Phaser.Tileset.prototype = {
|
|||
*
|
||||
* @method Phaser.Tileset#getTile
|
||||
* @param {number} index - The index of the tile within the set.
|
||||
* @return {Phaser.Tile} The tile.
|
||||
* @return {object} The tile object.
|
||||
*/
|
||||
getTile: function (index) {
|
||||
|
||||
if (this.tiles[index])
|
||||
{
|
||||
return this.tiles[index];
|
||||
}
|
||||
return this.tiles[index];
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets a Tile from this set.
|
||||
*
|
||||
* @method Phaser.Tileset#getTileX
|
||||
* @param {number} index - The index of the tile within the set.
|
||||
* @return {object} The tile object.
|
||||
*/
|
||||
getTileX: function (index) {
|
||||
|
||||
return this.tiles[index][0];
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets a Tile from this set.
|
||||
*
|
||||
* @method Phaser.Tileset#getTileY
|
||||
* @param {number} index - The index of the tile within the set.
|
||||
* @return {object} The tile object.
|
||||
*/
|
||||
getTileY: function (index) {
|
||||
|
||||
return this.tiles[index][1];
|
||||
|
||||
},
|
||||
|
||||
|
@ -112,7 +162,6 @@ Phaser.Tileset.prototype = {
|
|||
* @method Phaser.Tileset#canCollide
|
||||
* @param {number} index - The index of the tile within the set.
|
||||
* @return {boolean} True or false depending on the tile collision or null if no tile was found at the given index.
|
||||
*/
|
||||
canCollide: function (index) {
|
||||
|
||||
if (this.tiles[index])
|
||||
|
@ -123,6 +172,7 @@ Phaser.Tileset.prototype = {
|
|||
return null;
|
||||
|
||||
},
|
||||
*/
|
||||
|
||||
/**
|
||||
* Checks if the tile at the given index exists.
|
||||
|
@ -147,7 +197,6 @@ Phaser.Tileset.prototype = {
|
|||
* @param {boolean} right - Should the tile collide on the right?
|
||||
* @param {boolean} up - Should the tile collide on the top?
|
||||
* @param {boolean} down - Should the tile collide on the bottom?
|
||||
*/
|
||||
setCollisionRange: function (start, stop, left, right, up, down) {
|
||||
|
||||
if (this.tiles[start] && this.tiles[stop] && start < stop)
|
||||
|
@ -159,6 +208,7 @@ Phaser.Tileset.prototype = {
|
|||
}
|
||||
|
||||
},
|
||||
*/
|
||||
|
||||
/**
|
||||
* Sets collision values on a tile in the set.
|
||||
|
@ -169,7 +219,6 @@ Phaser.Tileset.prototype = {
|
|||
* @param {boolean} right - Should the tile collide on the right?
|
||||
* @param {boolean} up - Should the tile collide on the top?
|
||||
* @param {boolean} down - Should the tile collide on the bottom?
|
||||
*/
|
||||
setCollision: function (index, left, right, up, down) {
|
||||
|
||||
if (this.tiles[index])
|
||||
|
@ -178,6 +227,7 @@ Phaser.Tileset.prototype = {
|
|||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
@ -186,7 +236,7 @@ Phaser.Tileset.prototype = {
|
|||
* @property {number} total - The total number of tiles in this Tileset.
|
||||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(Phaser.Tileset.prototype, "total", {
|
||||
Object.defineProperty(Phaser.Tileset.prototype, "XXXtotal", {
|
||||
|
||||
get: function () {
|
||||
return this.tiles.length;
|
||||
|
|
Loading…
Add table
Reference in a new issue