ClonkMobile

Members
  • Content Count

    5
  • Joined

  • Last visited

  1. Hi thyagoluciano, i managed it with the Code at the bottom but pay Attention this is not performance optimized Code var Enemy = function(game, x, y, name, frame) { Phaser.Sprite.call(this, game, x, y, name, frame); this.path = []; this.next_positX = 0; this.next_positY = 0;}Enemy.prototype = Object.create(Phaser.Sprite.prototype);Enemy.prototype.constructor = Enemy;Enemy.prototype.update = function(i) { this.moveOnTilemap();}Enemy.prototype.moveOnTilemap = function(i) { if (this.path) { this.x += this.speedX; this.y += this.speedY; if (this.speedX > 0 && this.x >= this.next_positX) { this.x = this.next_positX; this.nextTile(); } else if (this.speedX < 0 && this.x <= this.next_positX) { this.x = this.next_positX; this.nextTile(); } else if (this.speedY > 0 && this.y >= this.next_positY) { this.y = this.next_positY; this.nextTile(); } else if (this.speedY < 0 && this.y <= this.next_positY) { this.y = this.next_positY; this.nextTile(); } }}Enemy.prototype.nextTile = function() { if (this.path) { if (this.curTile < this.path.length) this.curTile++; if (this.path[this.curTile]) { this.next_positX = parseInt(this.path[this.curTile].x * GlobalGame.tileSquare); this.next_positY = parseInt(this.path[this.curTile].y * GlobalGame.tileSquare); } if (this.next_positX > this.x) { this.speedX = this.speed; this.angle = 0; } else if (this.next_positX < this.x) { this.speedX = -this.speed; this.angle = 180; } else { this.speedX = 0; } if (this.next_positY > this.y) { this.speedY = this.speed; this.angle = 90; } else if (this.next_positY < this.y) { this.speedY = -this.speed; this.angle = -90; } else { this.speedY = 0; } }}module.exports = Enemy;
  2. really nice work, thank you. As additional feature i would prefer support of the Tiled importer.
  3. Hey guys, is it possible that a p2 physics body collide/overlap with an arcade body ? Thanks Greets
  4. Hi, this will help you: http://www.html5gamedevs.com/topic/4760-best-way-to-recreate-old-physicsoverlap-using-p2/ interesting would be how to overlap an arcade with an p2 body.