• Content count

  • Joined

  • Last visited

  1. Way 1: Handling all the movement on the client, sending x,y to the server every 100ms and doing some anticheat things on the server. (like transformice.com do) Way 2: Handling movement on the server, moving entity on the client like space_elevators said. Which way is better and why?
  2. How can i define collideCallback function without object2? Doesn't work this way: collide(sprites, null, callback)
  3. I didn't know collide function can work with only one object. Now everything is fine even if i scale sprites. Thank you.
  4. Scaling images doesn't actually fix the problem. Group collision: https://codepen.io/anon/pen/WjPxzL Sprite collision: https://codepen.io/anon/pen/QvYExY
  5. Yes, i can. Well, the docs says there can be only one body with P2 physics so i don't think i can use P2. "A game object can only have 1 physics body active at any one time, and it can't be changed until the object is destroyed." - Phaser.Physics.P2
  6. Is it possible to fix this with scaled and circle bodies? I'm pretty new to Phaser so i have no idea what to do with this situation.
  7. Maybe you just can't notice difference with small sprites.
  8. I want to collide a group with itself but it seems broken. sprite1 teleporting back to it's old position after colliding with sprite2. There's no problem with game.physics.arcade.collide(sprite, sprite2) but i need to collide more than 2 sprites. I don't want any knockback. Couldn't find anything in the docs, google etc. function create() { game.world.setBounds(0, 0, 1920, 1920); game.physics.startSystem(Phaser.Physics.ARCADE); sprites = game.add.group(); sprite = game.add.sprite(game.world.centerX, game.world.centerY, 'skin1'); sprites.add(sprite); game.physics.enable(sprite, Phaser.Physics.ARCADE); sprite.anchor.setTo(0.5, 0.5); sprite.scale.setTo(0.2, 0.2); radius = sprite.width / 2; sprite.body.setCircle( radius, (-radius + 0.5 * sprite.width / sprite.scale.x), (-radius + 0.5 * sprite.height / sprite.scale.y) ); sprite2 = game.add.sprite(game.world.centerX, game.world.centerY, 'skin1'); sprites.add(sprite2); game.physics.enable(sprite2, Phaser.Physics.ARCADE); sprite2.anchor.setTo(0.5, 0.5); sprite2.scale.setTo(0.2, 0.2); radius = sprite2.width / 2; sprite2.body.setCircle( radius, (-radius + 0.5 * sprite2.width / sprite2.scale.x), (-radius + 0.5 * sprite2.height / sprite2.scale.y) ); game.camera.follow(sprite, Phaser.Camera.FOLLOW_LOCKON, 0.1, 0.1); } function update() { game.physics.arcade.collide(sprites, sprites); sprite.body.velocity.y = 0; sprite.body.velocity.x = 0; if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) { sprite.body.velocity.x = -300; } else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) { sprite.body.velocity.x = 300; } if (game.input.keyboard.isDown(Phaser.Keyboard.UP)) { sprite.body.velocity.y = -300; } else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) { sprite.body.velocity.y = 300; } } function render() { game.debug.body(sprite); game.debug.body(sprite2); }
  9. Client and server must have the same X,Y values synchronously. In your way, server wants client to move to specific coordinates but have no idea where the sprite actually is. I'm handling everything on the server (includes collisions), client has one job to do: render game scene. I'm working on a real-time shooter game (like diep.io) so i can't have target X,Y (can i?). I need the exact coordinates of sprite.
  10. I think it wouldn't work that way, in your example client movements might be delayed if server sends new target before sprite reach old target.
  11. I'm working on a multiplayer game but player seems like teleporting when server sends new position. How can i make movement smooth? Here's my movement algorithm: Server (running every 1000/60ms): var updated = false; var speed = 300/60; if (this.player.cursors.up){ this.y -= speed; updated = true; } if (this.player.cursors.down){ this.y += speed; updated = true; } if (this.player.cursors.left){ this.x -= speed; updated = true; } if (this.player.cursors.right){ this.x += speed; updated = true; } if (updated){ ...broadcast new x,y.... } Client: var x = ..serverX..; var y = ..serverY..; sprite.x = x; sprite.y = y; sprite.nametag.x = x; sprite.nametag.y = y - 110; I want player to move 300 pixels a second. Is it possible to make it smooth? -- sprite.nametag is a Phaser.Text object.
  12. But the variable won't be cleared automatically, i think removing object would help a bit.
  13. Should i set variables to null after removing them? Is it a good practice? I have 2 states: load and play. I want to delete "Loading..." text when switching state to play but loadingText variable is always Phaser.Text object if i dont set it to null. My current code is: var loadingText; // load state loadingText = game.add.text(...); // ...end of load state game.world.remove(loadingText); game.state.start("play"); Should i set loadingText variable to null to free memory?
  14. Hello, im making a multiplayer html5 game with websocket like agar.io and diep.io. Which game engine should i use? which has better performance for multiplayer games?