kurhlaa

Members
  • Content Count

    154
  • 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. 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?
  2. 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)?
  3. kurhlaa

    Prevent pushing other object

    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
  4. kurhlaa

    Prevent pushing other object

    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); }
  5. 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)?
  6. kurhlaa

    Prevent pushing other object

    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?
  7. kurhlaa

    Prevent pushing other object

    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
  8. kurhlaa

    Prevent pushing other object

    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.
  9. 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); } }
  10. kurhlaa

    Nested Group Error

    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
  11. kurhlaa

    Update tween END value

    @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.
  12. kurhlaa

    Update tween END value

    @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
  13. kurhlaa

    Update tween END value

    @prob, can you show an example with updateTo ? Given lab's sample has calculation functions inside tween definition. In my case I do not have anything to calculate. During the game I just get a number and need to move there an object, for example in 100ms, or 10px per frame. In my code example I use setTimeout to simulate an action which happens later. Maybe you know how to achieve a movement to the location in other way?
  14. kurhlaa

    Update tween END value

    Hello! I try to use a tween and I need to set it's end value dynamically, and new value can't be precalculated - it is just a new integer. I try this code in labs.phaser.io: 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, duration: 100, paused: true }); setTimeout(function() { // NewX can't bet precalculated var NewX = 500; tween.updateTo('x', NewX, true); tween.play(); }, 1000); } function update() {} .. but nothing happens, box is not moving after 1s. How do I make it to move to the NewX position?
  15. Server-side physics calculations are necessary for multiplayer games to prevent cheating. Network lag - yes, but that's on a different layer than physics calculations; partly solvable with methods like prediction and correcting of wrong predictions. But that doesn't depend on the framework's language, you can implement server-side in Javascript or even Assembler and still have issues with the network lag that's just another task. I'm not very experienced in game frameworks, but most tutorials I see talk about taking a javascript engine, add node.js plus some magic and run in on a server-side, but I still believe javascript is not for the server-side for fast performance games like FPS. So somewhen you could say "hey, I have a C++ project which allows you to run thousands of simultaneous games on a single server".