kurhlaa

Members
  • Content Count

    157
  • Joined

  • Last visited

About kurhlaa

  • Rank
    Advanced Member

Recent Profile Visitors

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

  1. @b10b, what do you mean by "Then have each client be deterministic (bullets need only exist here)" ?
  2. @b10b, at the moment I already send a weapon's "fire" event itself, not the position of every single bullet at every frame. I also wish to avoid sending identical "fire" websocket messages tens of times per second from every player. So I'm interested to know how other projects deal with syncing every bullet. About feeling that it's "good" - agree.
  3. Hi, I have a strategical question. Imagine a standard multiplayer shooter. What are the ways to broadcast and sync the shooting events? I ask because I'm confused by the weapons like automatic rifles - they shoot many times per second, or can fire just 1 bullet, it depends on how long you press the mouse button down. If in a match there are 20 players, all of them have rifles and shoot constantly - does this mean, that each player sends tens of websocket messages every second, which means the server side broadcasts hundreds of them every second? And if there are hundreds of parallel matches - that feels like a huge network traffic generation. Are there smarter ways to sync shooting?
  4. Update: if I play a test long audio in a background - freezes disappear. Could it be that sound manager initializes something all the time, what can/should be done only once?
  5. Hello, I try to play multiple short sound files. The problem is that it looks like sound files are not being played from cache - when I replay the sound which wasn't played for some seconds I see a noticeable screen freezing, like lag. It feels like JavaScript removes it from cache after 1-2 seconds and then reads/loads the file again on replay. I tried to play sounds with 2 methods: 1. directly: this.sound.play("soundname"); 2. from the instance: var music = this.sound.add('soundname'); ... // After some delay during the game music.play(); but result is the same - freezing is very noticeable on almost all replays. Maybe it's not a cache problem, it just feels like that. What can I do to prevent freezing (or to stay sounds in memory)?
  6. What do I do if I have multiple players, they all can move and collide - but shouldn't be able to push each other? I can't set immovable for everybody, because then collisions do not work. I wish there is a physics switch in Phaser to disable energy exchanging, so when 2 objects collide - the second one doesn't feel that
  7. Can you please check this new example? I'm still doing something wrong, the wall is still moving. I see that during the collision touching.* is sometimes false. I've added collider instead of calling collide() manually and added checking for touch.left & touch.right .. var config = { type: Phaser.AUTO, parent: 'phaser-example', backgroundColor: '#0072bc', physics: { default: 'arcade', arcade: { debug: true } }, scene: { preload: preload, create: create, update: update } }; var cursors; var player; var game = new Phaser.Game(config); function preload () { this.load.image('block', 'assets/sprites/block.png'); this.load.image('flectrum', 'assets/sprites/flectrum.png'); } function create () { cursors = this.input.keyboard.createCursorKeys(); wall = this.physics.add.image(200, 300, 'flectrum'); player = this.physics.add.image(400, 300, 'block'); player.setCollideWorldBounds(true); this.physics.add.collider(wall, player, collideObjects, null, this); } function collideObjects() { wall.setVelocityX(0); player.setVelocityX(0); console.log('hit'); } function update () { player.setVelocity(0); if (cursors.left.isDown && !player.body.touching.left) { console.log(1, wall.body.touching); console.log(2, player.body.touching); player.setVelocityX(-300); } else if (cursors.right.isDown && !player.body.touching.right) { console.log(3, wall.body.touching); console.log(4, player.body.touching); player.setVelocityX(300); } if (cursors.up.isDown) player.setVelocityY(-300); else if (cursors.down.isDown) player.setVelocityY(300); }
  8. Hello, If I add lights to the scene with something like: this.lights.enable().setAmbientColor(0x555555); .. then enable lighting the needed objects with: object.setPipeline('Light2D'); Then later I wish to disable all scene lights (with being able to enable later again). I try with: this.lights.disable(); But this makes all light enabled objects invisible. Probably this is because pipeline is set to every object. The question of course is - how to just turn off lights globally, like in real world, so all images stay visible (just with default normal colors)?
  9. Simple modified version of labs example: var config = { type: Phaser.AUTO, parent: 'phaser-example', backgroundColor: '#0072bc', physics: { default: 'arcade', arcade: { debug: true } }, scene: { preload: preload, create: create, update: update } }; var cursors; var player; var game = new Phaser.Game(config); function preload () { this.load.image('block', 'assets/sprites/block.png'); this.load.image('flectrum', 'assets/sprites/flectrum.png'); } function create () { cursors = this.input.keyboard.createCursorKeys(); wall = this.physics.add.image(200, 300, 'flectrum'); player = this.physics.add.image(400, 300, 'block'); player.setCollideWorldBounds(true); } function update () { player.setVelocity(0); if (cursors.left.isDown) player.setVelocityX(-300); else if (cursors.right.isDown) player.setVelocityX(300); if (cursors.up.isDown) player.setVelocityY(-300); else if (cursors.down.isDown) player.setVelocityY(300); this.physics.world.collide(wall, player, function () { wall.setVelocityX(0); player.setVelocityX(0); console.log('hit?'); }); } if you try to move the box to the wall - box will "push" the wall left-right and so it will move too. How to prevent this?
  10. In my case both objects are able to move in general, not immovable. They can move, they can stop. I wish to disable "pushing". So both objects can move, collide, but can't push/affect each other
  11. Hello, In Arcade physics, if you move towards the other object - after the collision this object moves, so it's like you are pushing it. How to prevent pushing completely? I wish player stops after the collision completely (in collision direction only, X axis for example) and the other object does not move at all. (Player should be able to move in other directions of course). I've tried to manipulate "moves", "immovable", "isMoving", "blocked", "touching" params of both bodies, but no luck. Probably there is a special magic combination of them or other setting I haven't noticed.
  12. Hello, I've modified a little one labs example (first game). I have 1 ground platform and all stars falling on it, and a player. Plus collisions between everything, even between stars themselves. Player initially is in the middle of the screen and stars. If I move to the right - stars are moving, hitting each one and all joining the line; so you hit 1 and move it, then 2'nd star joins, then 3'rd, 4'th and so on. That's correct, you get all stars in a line next to each other. The issue appears when you move to the left - I'm able to join only 2 stars - all other acts like physicsless and player/stars just go through them. So you get max 2 stars in a row. Is this an arcade/collisions bug? What can I do to make collisions always be the same and objects do not go through each other? If I comment out the internals of my function collideElem - results for different directions are still different. I use it for stopping the star after a collision. Here is my testing code which is runnable at labs.phaser.io: var config = { type: Phaser.AUTO, width: 800, height: 600, physics: { default: 'arcade', arcade: { gravity: { y: 300 }, debug: false } }, scene: { preload: preload, create: create, update: update } }; var player; var stars; var platforms; var cursors; var game = new Phaser.Game(config); function preload () { this.load.image('sky', 'src/games/firstgame/assets/sky.png'); this.load.image('ground', 'src/games/firstgame/assets/platform.png'); this.load.image('star', 'src/games/firstgame/assets/star.png'); this.load.spritesheet('dude', 'src/games/firstgame/assets/dude.png', { frameWidth: 32, frameHeight: 48 }); } function create () { this.add.image(400, 300, 'sky'); platforms = this.physics.add.staticGroup(); platforms.create(400, 568, 'ground').setScale(2).refreshBody(); player = this.physics.add.sprite(300, 450, 'dude'); player.setCollideWorldBounds(true); this.anims.create({ key: 'left', frames: this.anims.generateFrameNumbers('dude', { start: 0, end: 3 }), frameRate: 10, repeat: -1 }); this.anims.create({ key: 'turn', frames: [ { key: 'dude', frame: 4 } ], frameRate: 20 }); this.anims.create({ key: 'right', frames: this.anims.generateFrameNumbers('dude', { start: 5, end: 8 }), frameRate: 10, repeat: -1 }); cursors = this.input.keyboard.createCursorKeys(); stars = this.physics.add.group({ key: 'star', repeat: 11, setXY: { x: 12, y: 0, stepX: 70 } }); this.physics.add.collider(player, platforms); this.physics.add.collider(stars, platforms); this.physics.add.collider(player, stars, collideElem, null, this); this.physics.add.collider(stars, stars, collideElem, null, this); } function collideElem(obj1, obj2) { obj2.body.setVelocityX(0); obj2.body.setVelocityX(0); } function update () { if (cursors.left.isDown) { player.setVelocityX(-160); player.anims.play('left', true); } else if (cursors.right.isDown) { player.setVelocityX(160); player.anims.play('right', true); } else { player.setVelocityX(0); player.anims.play('turn'); } if (cursors.up.isDown && player.body.touching.down) { player.setVelocityY(-330); } }
  13. According to the source code - function group.add() expects GameObject as param only, not groups or anything else. child.on tries to add an event listener for the GameObject, and probably there is no such functionality for the groups
  14. @blackhawx, the question is not about a delay my timeout is just to simulate an action which happens later. How will you set a "delay" if you don't know when user will press the button? Why 1000 and not 13729 ? And I need exactly this - move an object when a needed event happens, immediately. There shouldn't be a delay inside a tween itself. The question is how to move an object to the needed position.
  15. @blackhawx, thanks for links, I've tried searching and tween.updateTo should do what I need. But why this code sample doesn't work? var config = { type: Phaser.WEBGL, width: 800, height: 600, backgroundColor: '#2d2d2d', parent: 'phaser-example', scene: { preload: preload, create: create, update: update } }; var tween; var game = new Phaser.Game(config); function preload () { this.load.image('block', 'assets/sprites/block.png'); } function create () { var image = this.add.image(100, 300, 'block'); tween = this.tweens.add({ targets: image, //x: 100, duration: 1000, paused: true, }); setTimeout(function() { tween.updateTo('x', 500, true); tween.play(); }, 1000); } function update() {} .. I create a paused tween, because there is no need to run it in the beginning. Then after some time I update an 'x' value, call tween.play() and expect the box to move to the new location (x = 500). But the box is not moving. What am I missing? You can copy this code to the labs.phaser.io to play