Jump to content

Steph

Members
  • Content Count

    16
  • Joined

  • Last visited

About Steph

  • Rank
    Member

Recent Profile Visitors

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

  1. Hi Roberto257, I am facing exactly the same issue. Did you ever find a solution?
  2. Hello everyone. I have built a game using Phaser. On game over, the players high score is recorded in a variable (this.inputScore). To submit their high score to the server, the player clicks a button that takes them to an Index.html page where there is a form they fill in. To avoid cheating, I want the high score variable to be passed from the game's JavaScript file (Game.js) to an input value on the form as a read only value. I have created a function (assignValue) inside the Game.js file to execute this task, but because of it's scope I cannot get the function to be read by the Index.html f
  3. I have actually just done a work around for this by simply adding a tween rather than using sprite frames to achieve the effect I was after. Code is below for those interested. However, if anyone has a solution to my original question it would be great to know. Thanks. killFlies: function(player, fly){ if (player.body.touching.down) { this.bounce(); this.stompSound.play(); this.deadFly = this.add.sprite(fly.x, fly.y, "deadFly"); this.deadFly.anchor.setTo(0.5,0.5); this.deadFlyTween = this.game.add.tween(this.deadFly).to({x:+50, y: 550}, 800, Phaser.Easing.
  4. I have an endless runner with flies that are enemies flying towards the player. The player jumps into the air and onto the top of the fly to kill it. I would like to enable gravity on the fly on overlap so that it falls to the ground when it dies. However, my problem is that when the fly falls sometimes it overlaps with the player sprite on decent causing the overlapCallback function (killFlies) to be called more than once. How can I have an enemy sprite like this die and adhere to gravity yet not have the overlapCallback function triggered again when it's falling? Any ideas? Is there any way
  5. Actually I have just solved this issue. The solution is to add the tween to the individual sprites and not the whole pool. Silly me.
  6. I have created an endless runner where the player is collecting sweets as he runs. The sweets are taken from a pool of sprites and they spawn randomly between a maximum and minimum distance above each platform. All is working fine. I would like to add a simple tween to the sweets so that they gently bob up and down instead of just being totally static. I have managed to produce this effect with the first line of code shown below. HOWEVER, as the game progresses and the sweets are recycled, the tween is making the sweets gradually spawn lower and lower on the screen which is not what I wan
  7. I have figured it out. For those interested here is the code: var Jumper = function() {}; Jumper.Play = function() {}; Jumper.Play.prototype = { preload: function() { this.load.image( 'hero', 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/836/dude.png' ); this.load.image( 'pixel', 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/836/pixel_1.png' ); }, create: function() { // background color this.stage.backgroundColor = '#6bf'; // scaling this.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; this.scale.maxWidth = this.game.width; this.scale.maxHeight =
  8. I am re-posting this question as I have managed to set up the code on Codepen with makes it easier for people to look at. I am creating an endless runner, please see my code here: https://codepen.io/clownhead/pen/BqyqOm At the moment when the left arrow key is pressed the player moves left, the camera follows him so he does not go off screen and the ground tiles below the player are destroyed as they move out of the world bounds on the right and are recreated just before they move into the world bounds on the left. This allows him to keep running forever without running out of ground
  9. Thanks quiphop for your suggestions and explanation. I appreciate it very much!
  10. Thanks quiphop for your response. I am new to phaser (and still learning Javascript). What do you mean by extending the tileSprite please?
  11. I have a background image and a separate ground image that I want to loop as long as the character is moving forward. When the character stops, the background and ground should not be moving. So basically I am creating an endless runner. For similar games it is often suggested to add this.game.background.tilePosition.x -= 1to the update function. This is not what I am looking for as it makes the background constantly move regardless of whether the character is moving. At the moment my background and ground images are repeating, but they are restricted to this.game.world.setBounds(0, 0, 1280, 8
  12. @ThatGirlDee yes I did. The text was not showing because it was being rendered AFTER the game's background image in PlayState.create. So the timer was there, but it was being hidden by the background image. I simply moved the timer code to the end of PlayState.create and it is now showing. See below: PlayState.create = function () { this.game.world.setBounds(0, 0, 2560, 800); background1 = this.game.add.sprite(0, 0, 'background'); background2 = this.game.add.sprite(1280, 0, 'background2'); this.game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; this.game.scale.setMinMax(4
  13. I am trying to add a simple countdown timer to a Phaser game. When the timer ends I want the game to restart. After adding the timer code there are no errors in the console but I can't get the timer to appear on the screen. Where I am going wrong please? I am new to Phaser and am still learning Javascript - any help would be greatly appreciated! Please see my code below (for clarity, I have only pasted the relevant code, not the whole thing). Thanks for any help in advance. PlayState = {}; PlayState.init = function () { //.... }; PlayState.preload = function () { //.... }; PlayState.cre
×
×
  • Create New...