-
Content Count
25 -
Joined
-
Last visited
About What?
-
Rank
Member
-
nocaoper reacted to a post in a topic: What's with the constant use of "this"?
-
Does it work with tiles that aren't a power of 2?
- 32 replies
-
- slopes
- sloped tiles
- (and 6 more)
-
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.
-
Ashish reacted to a post in a topic: Loading a new tilemap while the game is already running?
-
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.
-
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.
-
horkoda reacted to a post in a topic: Dynamically loading tilemaps.
-
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
-
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
-
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.
-
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.
-
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?
-
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 -
-
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.
-
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.