joshcawthorne

Members
  • Content Count

    6
  • Joined

  • Last visited

About joshcawthorne

  • Rank
    Newbie

Recent Profile Visitors

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

  1. Hi all, I'm using Phaser CE (latest edition), and looking to create a responsive game. At the moment, my canvas and sprites respond well to the window being resized whilst I use: game.scale.scaleMode = Phaser.ScaleManager.RESIZE; However, my scrolling tileSprite repeats itself on a big enough screen (see here: https://imgur.com/cuX4yir). Is it possible to have the tileSprite's height fill the screen, and the width automatically resize accordingly? Thanks!
  2. Hi all, I have code for a crystal count within my level at the moment, however when the player dies and the level resets, or when the player moves on to level 2 (in a new js file), the score resets as I've initiated it within level 1. Could someone please tell me how to create a variable that can be tracked and edited in every JS file, rather than just one? Thanks!
  3. Hi all, I'm trying to create a coin counter in my game, using a bitmap font. Everything displays fine, and the counter works, however when a player collects a new coin, rather than replacing the '0' with a '1', it shows a '1', but underneath you can still see a '0' visibly. I've tried several work around methods, including even doing an if statement checking how many coins and replacing it with plain text rather than replying on the var count, and using coinText.updateText();. Does anyone have any ideas? I'll leave my code sample below. var crystalCount = 0; var coinText; //Skip down to the update section coinText = this.game.add.bitmapText(20, 10, 'carrier_command', "Crystals:" + crystalCount, 12); coinText.updateText();
  4. You were right, I've been wracking my brain for days trying to sort this! Thanks so much for your help!
  5. I've been working on a Phaser game for a project at university. All of this is relatively new stuff to me, so I'm learning on the fly. I've managed to create a simple tilemap using Tiled, and got it to import to Phaser successfully. However, I can't make the player collide with the 'platform' layer, and I've tried just about everything I can find online. I've cut down my game code to just what's needed for you to (hopefully) point out my error, but it all runs without errors usually. I can also upload any JSON or Image files that might be needed. var SuddenGame = SuddenGame || {}; var char; var map; // GAMEPLAY STATE // SuddenGame.playState = function() {}; SuddenGame.playState.prototype = { init: function() { this.game.renderer.renderSession.roundPixels = true; }, create: function() { //Setup FPS Counter this.game.time.advancedTiming = true; //Stop game from pausing if a player tabs out this.stage.disableVisibilityChange = true; //Import and play background music music = this.game.add.audio('menumusic'); music.play('', 0, 1, true); //Create Dotted Background this.background = this.game.add.tileSprite(0, this.game.height - this.game.cache.getImage('background').height, this.game.width, this.game.cache.getImage('background').height, 'background' ); this.dots = this.game.add.tileSprite(0, this.game.height - this.game.cache.getImage('dots').height, this.game.width, this.game.cache.getImage('dots').height, 'dots' ); //Enable Physics Engine this.game.physics.startSystem(Phaser.Physics.ARCADE); //Add level one tilemap map = this.game.add.tilemap('levelone'); map.addTilesetImage('scifi_platformTiles_32x32', 'scifi_platformTiles_32x32'); backgroundTiles = map.createLayer('backgroundLayer'); Objective = map.createLayer('Objective'); Platform = map.createLayer('Platform'); this.game.add.existing(Platform); this.physics.arcade.enable(Platform); map.setCollisionBetween(1, 1000, true, 'Platform'); Platform.resizeWorld(); Platform.debug = true; this.char = this.add.sprite(50, 470, 'hero'); this.physics.arcade.enable(this.char); this.char.body.gravity.y = 1300; this.char.body.collideWorldBounds = true; this.char.scale.setTo(2, 2); //Create Player Animations var idle = this.char.animations.add('idle', [0]); var walk = this.char.animations.add('walk', [0, 1, 2, 1]); this.game.camera.follow(this.char); }, update: function() { this.game.physics.arcade.collide(char, Platform); this.physics.arcade.TILE_BIAS = 40; if (this.game.input.keyboard.isDown(Phaser.Keyboard.LEFT) && !this.char.body.touching.left) { this.char.body.velocity.x = -150; this.char.animations.play('backwalk', 10, true); } else if (this.game.input.keyboard.isDown(Phaser.Keyboard.RIGHT) && !this.char.body.touching.right) { this.char.body.velocity.x = 150; this.char.animations.play('walk', 10, true); } else if (this.game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) { this.char.animations.play('die', 10, true); } else { this.char.body.velocity.x = 0; this.char.animations.play('idle', 7, true); } if (this.game.input.keyboard.isDown(Phaser.Keyboard.SPACEBAR) && this.game.time.now > jumpTimer) { { this.char.animations.play('jump', 10); this.char.body.velocity.y = -1000; jumpTimer = this.game.time.now + 750; } } //if (this.cursors.up.isDown && !this.char.body.touching.down ) { if (this.game.input.keyboard.isDown(Phaser.Keyboard.SPACEBAR) && this.game.input.keyboard.isDown(Phaser.Keyboard.LEFT) && this.char.body.touching.left && this.game.time.now > jumpTimer) { this.char.body.velocity.y = -500; jumpTimer = this.game.time.now + 1; } if (this.game.input.keyboard.isDown(Phaser.Keyboard.SPACEBAR) && this.game.input.keyboard.isDown(Phaser.Keyboard.RIGHT) && this.char.body.touching.right) { this.char.body.velocity.y = -500; this.char.body.velocity.x = -2500; //jumpTimer = this.game.time.now + 1; } //More update code here }, render: function() { this.game.debug.text(this.game.time.fps || '--', 2, 14, "#00ff00"); } } Apologies if I've missed an extremely obvious mistake!