AidanDaniel97

Members
  • Content Count

    3
  • Joined

  • Last visited

About AidanDaniel97

  • Rank
    Newbie

Contact Methods

  • Twitter
    AidanDaniel97

Recent Profile Visitors

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

  1. So I managed to fix this - even though I am unsure if this is a conventional way of doing it! I used good old maths to find the distance of the two points, then calculated the time it would take if the player was going a certain speed and then set it to the tween's speed! Worked perfectly distance = Math.hypot(this.destX - this.playerSprite.x, this.destY - this.playerSprite.y); speed = this.speed; time = distance / speed; //Add tween this.tween = game.add.tween(this.playerSprite).to({ x: this.destX, y: this.destY },time);
  2. So I have a multiplayer game set up, I had originally coded it so when the player clicks on an X,Y coordinate the server would move the player towards that coordinate on every update. I decided this would be too laggy if the server was under load and opted to use tweening instead. I have one issue though... when I click on a coordinate I have the player sprite tween and play an animation but if I click somewhere far away then it speeds up the animation and the sprite gets there quicker? example: I click 20px away from the player and it plays the whole animation and gets there in the correct amount of time I click 300px away and it speeds through the animation and really quickly moves to the coordinate is there any way to stop this? I tired to use game.tweens.frameBased but that has not worked? I also removed physics but that didn't help either
  3. hey all, So I have been playing around with animations on my multiplayer game and have made a character walk left, all is fine, but when I try walking right it gives me an error (listed below)? I have loaded the sprite in and everything is fine and I can even make the sprite walk by adding frame 0 into the array... this.playerSprite.animations.add('left', [1,2,3,4,5,6,7,8], 12, true); //Works! this.playerSprite.animations.add('right', [10, 11, 12, 13, 14, 15, 16, 17], 12, true); //Doesnt work! this.playerSprite.animations.add('right', [0,10, 11, 12, 13, 14, 15, 16, 17], 12, true); //Works?! Then I get the error: phaser.js:47587 Uncaught TypeError: Cannot read property 'x' of undefined(…) when it does not work? It is just strange that walking left is fine, walking right is fine with the 0 frame and then take it out and it give an error! Any help would be great, thanks! Edit: Swapped the left and right animation with each other and kept the 0 in the right walk animation and I got the error again, is this something happening to my load order? Edit 2: I fixed this, it was an issue with stopping the animation and playing a new one.