C_S

Members
  • Content count

    2
  • Joined

  • Last visited

  1. Keep moving after swipe

    Hi I want the player to initiate movement to left or right after a swipe. This movement should continue until the next time the screen is touched. I need quite specific information on how to implement this because although Phaser is easy to learn and documentation is good, I seem to be a slow learner and have not been able to make use of several forum entries and even tutorials on this topic. This is why I chose to use the swipe.js plug-in by flogvit (https://github.com/flogvit/phaser-swipe). Using this plug-in, I am only able to either "teleport" the player to the end coordinates instantaneously or - when I set player velocity - move it an all too tiny bit into the desired direction. I tried to have a tween executed but this didn't work out - is my command wrong or did I place it badly - or both? case this.swipe.DIRECTION_LEFT: game.add.tween(player).to({player.body.x: 50}, 500, Phaser.Easing.Linear.None, true);) I am absolutely fine with using neither tween nor the plug-in. Any specific (I need to see actual code) help is greatly appreciated.
  2. Hi I want to know how I can resize a Phaser game to exactly the current size of the browser window. I modified the My First Phaser Game example as follows: var game = new Phaser.Game(window.innerWidth * window.devicePixelRatio, window.innerHeight * window.devicePixelRatio, Phaser.AUTO, '', { preload: preload, create: create, update: update }); function preload() { game.scale.scaleMode = Phaser.ScaleManager.RESIZE; and did relative positioning of the ground element: var ground = platforms.create(0, game.world.height - 64, 'ground'); The result is that I am unable to see the ground because it is too low I also positioned a platform this way and it does not move up when I make the browser window smaller, although this should cause game.world.height to decrease. I figured that I have to make the game keep track of the window size changes, so I put the following into the update function: game.world.width = window.innerWidth * window.devicePixelRatio; game.world.height = window.innerHeight * window.devicePixelRatio; That did not change the situation. My goal is for all game elements to be positioned in relation to the bottom boundary of the game. Also, I need the game to adjust its height to the extent of what is seen in the browser window. Code attached. Any ideas? index.html