Jump to content


  • Content Count

  • Joined

  • Last visited

About What?

  • Rank

Recent Profile Visitors

824 profile views
  1. I think the problem was that I was trying to add the tilemap before it finished loading. The solution was using the "onLoadComplete" event to add the tilemap after it was loaded in. You also need to start the loading with "load.start()" to make it load in the first place.
  2. https://github.com/Theodeus/tuna I've been trying to get Phaser to play with the Tuna library and I'm stumped. I've never dealt with audio before. It doesn't help that "Phaser" is a type of effect the library supports, which makes searching impossible.
  3. This seems like a simple question. How do I make it so everything is drawn behind a retrofont? I tried bringToTop() but it didn't work.
  4. I think I finally found the solution. Here's my code: var run = run || {};run.Game = function(){};run.Game.prototype = { create: function() { newMapName = ''; x = 0; this.load_map('testmap'); }, update: function() { x += 1; if(x > 60 && x <= 61) { //destroy the first tilemap and add a new one map.destroy(); foreground.destroy(); this.load_map('testmap2'); console.log(newMapName); } if(x > 120 && x <= 121) { //destroy the second tilemap map.destroy(); foreground.destroy(); this.load_map('testmap'); console.log(newMapName); } }, new_map
  5. I would use that, but you say that the only physics engine it supports right now is P2, and I'm using arcade.
  6. Update, I got something working. This script loads tilemap #1, destroys it after a second, loads tilemap #2, and then destroys that. var run = run || {};run.Game = function(){};run.Game.prototype = { preload: function() { //load the tilemaps this.load.tilemap('testLevel', 'assets/tile/testmap.json', null, Phaser.Tilemap.TILED_JSON); this.load.tilemap('testLevel2', 'assets/tile/testmap2.json', null, Phaser.Tilemap.TILED_JSON); }, create: function() { x = 0; //create the first tilemap this.new_map('testLevel'); }, update: function() { x += 1; if(x > 60 && x < 120) { //d
  7. Whenever I use it anywhere I get this error: TypeError: this.game is nullHow do I use it properly? In the docs it says it nulls the game reference, but that's the point, right? I'm just using map.destroy(). "Map" is defined like this: map = this.game.add.tilemap('testLevel');EDIT: After success in another file, I'm guessing that the error is happening because something else is depending on the map to still exist, but I'm not sure.
  8. So far from just researching and trying things out, It doesn't seem possible to display multiple tilemaps at the same time. It still seems like I should be able to destroy the old map and on the next line replace it with a new one, though. It's just that when I use the destroy() method, I get an error that says "this.game is null". I don't really know how to use it properly I guess.
  9. I'm trying to make a metroid-style game, and I want a new tilemap to be loaded whenever the player crosses the screen bounds. What's the best way to do this?
  10. What?

    Tilemap opacity?

    Heh. I was looking in the wrong part of the docs. Thanks anyway.
  11. In my game I want a single tilemap loaded for each room as the player enters them. I made a function that loads a tilemap, where the name of it is the parameter: new_room: function(name) { this.load.tilemap(name, 'assets/tile/' + name + '.json', null, Phaser.Tilemap.TILED_JSON); map = this.game.add.tilemap(name); foreground = map.createLayer('foreground'); map.setCollisionBetween(1, 100000, true, 'foreground'); },The name of the tilemap I'm trying to load is "second", but it's not working: "Phaser.Cache.getTilemapData: Invalid key: "second"" phaser.min.js:16"Phaser.TilemapParser.parse -
  12. I had no idea about that last one. That explains a lot of frustration I've had with callback functions.
  13. I'm curious; is it possible to change the opacity of a tilemap? I was thinking about game mechanics where some parts of the level disappear to reveal hidden passages, like in Yoshi's Island for the SNES.
  14. Ok. I'm guessing that what gsko suggested was the correct way to write it. I'm still a bit of a novice at scripting. Thanks.
  • Create New...