• Content Count

  • Joined

  • Last visited

About mattasaurus

  • Rank

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. In the Phaser 3 examples we have an example extending Phaser.Scene like so (\scenes\scene from class.js): var MyScene = new Phaser.Class({ Extends: Phaser.Scene, // [...] using ES6 we might say instead: class MyScene extends Phaser.Scene { From what I see, I think that these are functionally very similar. But I could easily have missed or misunderstood something. Are these the same in effect (or almost the same)? If there are differences, what are the significant differences? Is one preferred over the other (assuming ES6 is an option)?
  2. Just wanted to remark that this is pretty cool, makes me happy to see tile based and RPG type games getting some love.
  3. 'characters' refers to a spritesheet that I created in preload(): this.load.spritesheet('characters', '/maps/characters.png', { frameWidth: 32, frameHeight: 32 }); m.gid is the gid of the object from the object layer, you've got one in your posted JSON and I would guess there is always one (or at least for tile-based objects). I parseInt() these gids, you may want/need to also. charTilesetRaw.firstgid comes from the tileset, that I have previously added to the tilemap as a dynamic layer: var charTilesetRaw = map.tilesets.filter(t => === 'characters')[0]; The firstgid property comes from Tiled, I didn't do anything special to add it or make it accessible.
  4. This is one noob to another and may not be the best possible answer. I think you'll need to be more explicit in making your object layer into images. Note that Tiled object layers (including your JSON above) don't say anything about tilesets. They're just data objects that don't necessarily have anything to do with images at all. If you want to turn them into images you'll have to write some code. (It is interesting to me that you even got the green cross with the above.) In my case I put static stuff in the tile layers, and monsters in the object layer. Monsters are converted to sprites. Here's a snippet of what I'm doing that may help you get on a track: charObjects .filter(m => m.gid !== playerGid) .forEach(function (m) { // again, spritesheet frame uses same indexing as tiled, except tiled has the gid offset. var monsterSprite = scene.add.tileSprite(m.x + 16, m.y - 16, 32, 32, 'characters', m.gid - charTilesetRaw.firstgid); var spriteTile = sceneLayers[backgroundLayerName].tilemapLayer.getTileAtWorldXY(monsterSprite.x, monsterSprite.y); monsters.push({ name: charTilesData[m.gid].name, x: spriteTile.x, y: spriteTile.y, sprite: monsterSprite }); }); important, my charObjects here is not the raw data that came directly out of Tiled, but rather a descendant of that object layer data that has already been processed for my purposes. Obviously a lot of context is left out here, but you can see the basic idea of making a sprite based on the object data using `scene.add.tileSprite()`. Details likely different for you. Phaser's x/y is different than Tiled's. "in Phaser 3 all Game Objects are positioned based on their center by default. " In that link Rich talks about using setOrigin() to change this. In my case I just applied an offset to the sprite creation as you can see above (+16/-16). (That hardcoding is only temporary, btw.) Anyway, I hope this helps somewhat.
  5. Thinking out loud here. You can add an onComplete callback to a tween. Ideally, you would reach your event and use it to add a callback to the currently running tween in the timeline. The callback would then stop the timeline or tweens in the timeline or just killAll(). I don't know how to detect the currently running tween in a timeline. Didn't go hunting myself, but you can see how the timeline works here: You could have your event attach your onComplete callback to all of the the tweens in the timeline. Hacky but might work OK.
  6. I'm setting up a Timeline and I'm doing something wrong. I want to do this: var oc = function () { playerMoving = false; }; var timeline = scene.tweens.createTimeline({ onComplete: oc }); but this doesn't work (onComplete is null when inspecting in the debugger and doesn't trigger). I see that createTimeline() accepts a config, uses TimelineBuilder.js, and seems to apply that config. Seems something like the above should work. I was able to force my callback into the timeline like this: var oc = function () { playerMoving = false; }; var timeline = scene.tweens.createTimeline(); timeline.setCallback('onComplete', oc, [timeline], timeline); but this is a hack, it can't be the right way. I'm probably missing something really simple, can anybody point it out?
  7. @elleniaw If you end up having to write your own, I thought Niklas's was very readable, shows a way to dig into Tiled properties and do extra stuff with them.
  8. Thanks PixelPicoSean. I too am merging my tilesets.
  9. In Tiled (1.1.3) you can make a layer that includes multiple different embedded tilesets. The resulting JSON has an array in the tilesets property. See complete example . I can't get this to load in Phaser. I've tried several things, but anything after the first tileset throws an error one way or another. Here's the latest attempt: function preload() { this.load.tilemapTiledJSON('map', '/maps/phaserTest.json'); this.load.image('phaserTestImg', '/maps/phaserTest.png'); this.load.image('Door0', '/maps/Door0.png'); this.load.image('Floor', '/maps/Floor.png'); this.load.image('Wall', '/maps/Wall.png'); } function create() { var map = this.add.tilemap('map'); var tileset = map.addTilesetImage('Wall', undefined, 16, 16, 0, 0, 1); var tileset2 = map.addTilesetImage('Door0', undefined, 16, 16, 0, 0, 2); var tileset3 = map.addTilesetImage('Floor', undefined, 16, 16, 0, 0, 3); var layer = map.createStaticLayer(0, tileset); var layer2 = map.createStaticLayer(1, tileset2); var layer3 = map.createStaticLayer(2, tileset3); //debugger; var graphics =; //[...] (I've also tried using map.createStaticLayer with the string name of the layer from Tiled JSON, this is just the latest failed experiment.) My guess is this isn't supported and I have to create my maps differently in Tiled, but I am brand new to Phaser and I might just be missing something obvious. Back in 2013, Rich seemed to say it wasn't supported but 2013 is quite a long time ago and I know a lot has changed with tileset handling since then. So my questions: 1) Can you make a map in Tiled that has multiple (embedded) tilesets in a single layer, and use that JSON from Phaser successfully? If so, can I get a hint on how to do this correctly? 2) If this isn't supported, what is the best alternate approach in Phaser 3? Two things that occur to me are making a Tiled map that has a separate layer for each tileset, or combining lots of little tilesets together into a mechagodzilla tileset so I can lay out a whole bunch of features in a single layer. Or something different. Opinions?