renlok

Members
  • Content count

    2
  • Joined

  • Last visited

  1. Minimap and tilemap issues

    OK thanks I striped the code down and was still getting the issue, so I made a issue over at github. https://github.com/photonstorm/phaser/issues/3081
  2. I am trying to make a simple prototype which involves a randomly generated tilemap which I have working and a minimap. But my problem I have is the tilemap within the minimap camera doesn't zoom. The player sprite works fine but the tiles display full size. I don't know if this is a known issues or I am doing something wrong. My code is let config = { width: 800, height: 600, resolution: 1, type: Phaser.WEBGL, parent: 'phaser-example', scene: { preload: preload, create: create, update: update, extend: { minimap: null, player: null, cursors: null } }, callbacks: { preBoot: function () { console.log('I get called before all of the Game systems are created, but after Device is available')}, postBoot: function () { console.log('I get called after all of the Game systems are running, immediately before raf starts')} } }; let game = new Phaser.Game(config); function preload () { this.load.image('tiles', 'assets/tileset.png'); this.load.atlas('atlas', 'assets/tileset.png', 'assets/tileset.json'); } let width = 40, height = 38; function create () { let map = new MapLoader(width, height); this.add.staticTilemap(map.getFlatMapData(), 0, 0, 32, 32, width, height, 0, 'tiles'); this.cursors = this.input.keyboard.createCursorKeys(); this.cameras.main.setBounds(0, 0, 32 * width, 32 * height); this.minimap = this.cameras.add(200, 10, 100, 100).setZoom(0.2); // Add player let playerLocation = map.getEmptySquare(); this.player = this.add.sprite(playerLocation.x * 32, playerLocation.y * 32, 'atlas'); this.player.displayOriginX = 0; this.player.displayOriginY = 0; } function update (time, delta) { if (this.cursors.left.isDown) { this.player.x -= 32; this.player.flipX = true; } else if (this.cursors.right.isDown) { this.player.x += 32; this.player.flipX = false; } if (this.cursors.up.isDown) { this.player.y -= 32; } else if (this.cursors.down.isDown) { this.player.y += 32; } // bounds check if (this.player.x < 0) { this.player.x = 0; } if (this.player.y < 0) { this.player.y = 0; } if (this.player.x > (width - 1) * 32) { this.player.x = (width - 1) * 32; } if (this.player.y > (height - 1) * 32) { this.player.y = (height - 1) * 32; } this.cameras.main.scrollX = this.player.x - 400; this.cameras.main.scrollY = this.player.y - 300; this.minimap.scrollX = Phaser.Math.Clamp(this.player.x - 80, 0, width * 32); this.minimap.scrollY = Phaser.Math.Clamp(this.player.y - 60, 0, height * 32); } Note the MapLoader & getflatdata just return an array numbers for the map which is working fine