• Content Count

  • Joined

  • Last visited

  1. I've successfully created and loaded a tilemap using Tiled, but I'm having trouble handling collision between my player sprite and the tiles on my map. I've searched the forums, but unless I'm overlooking something, it seems like I'm doing everything that's recommended both on the forums and in the example code. I've also been referencing this tutorial: Here's what I'm working with: 'use strict';function Play() { this.player = null; this.enemy = null; = null; this.layer = null;}Play.prototype = { preload: function () { var Player = require('../entities/player'); this.player = new Player(; this.player.preload(); var Enemy = require('../entities/enemy'); this.enemy = new Enemy(; this.enemy.preload();'map1', 'assets/maps/map1.json', null, Phaser.Tilemap.TILED_JSON);'mapSprites', 'assets/maps/spritesheet.png'); }, create: function () {; this.player.create(); this.enemy.create(); ='map1');'Level', 'mapSprites'); this.layer ='Tile Layer 1');, 1000, true, 'Tile Layer 1'); this.layer.resizeWorld(); }, update: function () {, this.layer); this.player.update(); }};module.exports = Play;In my Player class, I'm setting gravity on the player and using velocity for movement in my update() function (eg, "velocity.x = this.playerSpeed"). This may be a silly question, and it doesn't seem like this is the case based on the tutorial I linked, but should the player sprite be contained within the tileset or be linked to it somehow in order for collision between the player and the tiles to happen?
  2. Take a look at this example: The important line is this: * 4, fadePicture, this);This creates an event that will trigger after 4 seconds, at which point it will called the fadePicture() function. Your code might look something like this: * 2, removeRabbit, this):Perhaps this might be a suitable solution. I'm not sure if this is the most efficient way to handle what you're asking, so hopefully someone else can correct me if it's not, however, this should be a good starting point. Take a look at the rest of the timing examples for some more insight: Scroll down or search for "Time".
  3. Forgive my ignorance, but why/how would one export a spritesheet as JSON?
  4. Yup, this line number inconsistency happens for me, too, in Chrome. Here's the actual lifespan declaration in the source, if anyone's interested: /** * If you would like the Sprite to have a lifespan once 'born' you can set this to a positive value. Handy for particles, bullets, etc. * The lifespan is decremented by game.time.elapsed each update, once it reaches zero the kill() function is called. * @property {number} lifespan - The lifespan of the Sprite (in ms) before it will be killed. * @default */ this.lifespan = 0;And here's where it's used to kill the sprite: /*** Automatically called by World.preUpdate. Handles cache updates, lifespan checks, animation updates and physics updates.** @method Phaser.Sprite#preUpdate* @memberof Phaser.Sprite*/Phaser.Sprite.prototype.preUpdate = function() { if (!this.exists || ( && ! { this.renderOrderID = -1; // Skip children if not exists return false; } if (this.lifespan > 0) { this.lifespan -=; if (this.lifespan <= 0) { this.kill(); return false; } }...};
  5. I'm currently modifying the tutorial project to continue learning Phaser and the basics of game development. I'm used to using frameworks like AngularJS and Backbone, which are quite easy to unit test. I've done some searching, but I haven't found any examples of how a unit-tested Phaser application might look. Are there any suggestions on how one might go about this? Are there any points or major differences to consider when testing a game versus testing, for example, an Angular or Backbone app? Does it even make sense to consider adding unit tests? (Typing the last question made me cringe, but given my success in searching for an example, I felt it necessary.)