Jump to content

Map not appearing


Thunderfist
 Share

Recommended Posts

My game isn't loading the map I made using tiled. The file, testroom1.json, is called properly, but something in my game.js is keeping the game from loading the map itself.

var RPG = RPG || {};

RPG.GameState = {
    
    init: function (currentLevel) {
        //Needed to keep track of the level
        this.currentLevel = currentLevel || currentLevel === 'testroom1';
        
        //movement speed constants
        this.PLAYER_SPEED = 90;
        
        //no gravity in top down games
        this.game.physics.arcade.gravity.y = 0;
        
        //keyboard cursors for input
        this.cursors = this.game.input.keyboard.createCursorKeys();
    },
    create: function () {
        this.Game.onscreenControls = this.game.plugins.add(Phaser.Plugin.OnscreenControls);
        
        this.loadLevel();
    },
    update: function () {
        
    },
    loadLevel: function () {
        //create the tilemap object
        this.map = this.add.tilemap(this.currentLevel);
        
        //Join the tile images to the .json data
        this.map.addTilesetImage('tileset', 'tilesheet');
        
        //create tile layers
        this.backgroundLayer = this.map.createLayer('backgroundLayer');
        //this.collisionLayer = this.map.createLayer('collisionLayer');
        
        //set background to the back of screen
        this.game.world.sendToBack(this.backgroundLayer);
        
        //Collision Layer... if only I made it earlier
        //this.map.setCollisionBetween(1, 16, true, 'collisionLayer');
        
        //resize the world to fit the layer
        //this.collisionLayer.resizeWorld();
    },
    gameOver: function () {
        this.game.state.start('Game', true, false, this.currentLevel);
    }
};

I never made the collision layer. I plan on doing that AFTER getting the map to appear first.

Does anyone have any advice on how to tackle this?

Link to comment
Share on other sites

I just tried that, and now my browser's console says that the .csv file isn't found. How do I find it?

 

UPDATE: I got the .csv file to be found. Now I'm getting an error about the onscreenControls.js that game.js is trying to use. It says 'cannot set property 'onscreenControls' of undefined. How do I deal with this?

Edited by Thunderfist
Link to comment
Share on other sites

Cannot read property 'loadTilesetImage' of undefined 

                  at Object.preload (game.js:20)

 

All that function is doing is trying to load the map terrains from the preload.js. I'm worried that I won't finish this project before May, and I'm still stuck on this part!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...