Skip to content

Commit 21b47b3

Browse files
committed
Added putTile support.
1 parent 041bbd4 commit 21b47b3

1 file changed

Lines changed: 10 additions & 29 deletions

File tree

plugins/TilemapWalker.js

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -241,16 +241,21 @@ Phaser.Plugin.TilemapWalker.prototype = {
241241

242242
},
243243

244+
putTile: function (index) {
245+
246+
this.map.putTile(index, this.location.x, this.location.y, this.locationLayer);
247+
248+
},
249+
244250
getTileFromLocation: function (x, y) {
245251

246-
return this.map.getTile(this.location.x + x, this.location.y + y, this.locationLayer);
252+
return this.map.getTile(this.location.x + x, this.location.y + y, this.locationLayer, true);
247253

248254
},
249255

250256
getTile: function () {
251257

252-
// Get the current tile the walker is on
253-
return this.map.getTile(this.location.x, this.location.y, this.locationLayer);
258+
return this.map.getTile(this.location.x, this.location.y, this.locationLayer, true);
254259

255260
},
256261

@@ -266,7 +271,7 @@ Phaser.Plugin.TilemapWalker.prototype = {
266271
var hw = Math.floor(width / 2);
267272
var hh = Math.floor(height / 2);
268273

269-
// For now we assume that center = bottom middle
274+
// For now we assume that center = bottom middle tile
270275

271276
if (this.facing === Phaser.Tilemap.NORTH)
272277
{
@@ -546,35 +551,11 @@ Phaser.Plugin.TilemapWalker.prototype = {
546551

547552
};
548553

554+
// Original from http://jsfiddle.net/MrPolywhirl/NH42z/ - tided up and de-globalised by Richard Davey
549555
var rotateMatrix = function (matrix, direction) {
550556

551-
// Number.prototype.mod = function (n) {
552557
direction = ((direction % 360) + 360) % 360;
553-
// }
554-
555-
// direction = direction.mod(360) || 0;
556-
557-
var deepCopy = function (obj) {
558-
if (Object.prototype.toString.call(obj) === '[object Array]') {
559-
var out = [],
560-
i = 0,
561-
len = obj.length;
562-
for (; i < len; i++) {
563-
out[i] = arguments.callee(obj[i]);
564-
}
565-
return out;
566-
}
567-
if (typeof obj === 'object') {
568-
var out = {}, i;
569-
for (i in obj) {
570-
out[i] = arguments.callee(obj[i]);
571-
}
572-
return out;
573-
}
574-
return obj;
575-
}
576558

577-
// var ret = deepCopy(matrix);
578559
var ret = matrix;
579560

580561
var transpose = function (m) {

0 commit comments

Comments
 (0)