Pau

Members
  • Content Count

    35
  • Joined

  • Last visited

Everything posted by Pau

  1. Sorry, these solutions are not working for me. I think it was my fault, because i posted so few lines of code. In the following code you can see what i have made trying to implement your proposals: function nuevaColumna() { var columna = this.physics.add.group({ gravityY: 0 }); var hueco = Math.floor(Math.random() * 5) + 1; for (var i = 0; i < 8; i++) { //El agujero son dos casillas, por eso ponemos hole +1 if (i != hueco && i != hueco + 1) { var cubo = columna.create(800, i * 60 + 10, 'pipe',{ gravityY: 0 }); cubo.allowGravity = false; } } columna.setVelocityX(-200); I have attached the whole "game" too, in order to prevent misunderstandings. Thank so much for your help. exercise.zip
  2. Hello, I am making a kind of flappy bird. I want the pipes to move only horizontally. They have physics, so i can use the setVelocityX method. But they are falling down because of the gravity. I can change the position changing the x value of the pipe in the update method, but i would like to use the setVelocityX, it is more clear. var columna = this.physics.add.group(); ... columna.setVelocityX(-200); Thanks!
  3. yHello! How can i move a group of sprites horizontally using? I want to make a kind of setVelocityX for each element of a group individually. Is posible? This is may group declaration: malos = this.physics.add.group(); malo1 = malos.create(30,30,'gnu'); malo2 = malos.create(0,100,'gnu'); malo3 = malos.create(30,200,'gnu'); malo4 = malos.create(0,300,'gnu'); malo5 = malos.create(30,400,'gnu'); Looking the api, a kind of setVelocityX doesent exists as action. https://phaser.io/phaser3/api/actions Thank you!
  4. Thanks! It is PlayAnimation Phaser.Actions.PlayAnimation(malos.getChildren(), 'right') https://phaser.io/phaser3/api/actions
  5. I have created a group like this: malos = this.physics.add.group(); malo1 = malos.create(30,30,'gnu'); malo2 = malos.create(0,100,'gnu'); malo3 = malos.create(30,200,'gnu'); malo4 = malos.create(0,300,'gnu'); malo5 = malos.create(30,400,'gnu'); Which is the less code method to assign an animation to all the elements of the group. I am looking for something like this: malos.anims.play('right', true); Thanks!
  6. Pau

    checkWorldBounds

    Ah! I found it! I change this line: this.physics.world.setBoundsCollision(true, true, true, false); for this: this.physics.world.setBoundsCollision(true, true, true, true);
  7. Pau

    checkWorldBounds

    Thanks for you help, but i still doing something wrong I am creating multiple blocks each certain amount of time. That is the difference with your code. I have tryied to create a group of elements too, and still doesen't work. The alert message appears at the beggining of the game or after a time, but never at the right moment. Can please help me? Thanks var timedEvent=0; var group; var config = { type: Phaser.AUTO, width: 800, height: 600, scene: { preload: preload, create: create }, physics: { default: 'arcade', arcade: { debug: true, gravity: { y: 200 } } } }; var game = new Phaser.Game(config); var juego; function preload(){ // this.load.crossOrigin = "anonymous"; // this.load.setBaseURL("https://pablomonteserin.com/apuntes/web/js/canvas/phaser/ex/fall-down-game/"); this.load.image('sky', 'img/background.png'); this.load.image('c0', 'img/c0.png'); this.load.image('c1', 'img/c1.png'); this.load.image('c2', 'img/c2.png'); this.load.image('c3', 'img/c3.png'); } function create(){ this.add.sprite(0, 0, 'sky'); this.physics.world.setBoundsCollision(true, true, true, false); timedEvent = this.time.delayedCall(0, onEvent, [], this); this.physics.world.on("worldbounds", function (body) { alert("great") console.log("worldbounds", body); }); } function onEvent(){ candyTimer = 0; var aleatorio = Math.floor(Math.random()*3); var dropPos = Math.floor(Math.random()*590); var block = this.physics.add.image(dropPos, 100, 'c'+aleatorio).setInteractive(); block.setVelocity(0, 200); block.on('pointerdown', clickCandy); block.setCollideWorldBounds(true); block.body.onWorldBounds = true; block.setBounce(0.1, 0.1); timedEvent = this.time.delayedCall(1000, onEvent, [], this); } function clickCandy(){ this.destroy(); } envio.zip
  8. Pau

    checkWorldBounds

    Hello! How do you check if an object is out of the world bound using Phaser3? I am looking for this Phaser3 equivalent code: block.checkWorldBounds = true; block.events.onOutOfBounds.add(lose, this); block is an image: block = this.physics.add.image(dropPos, 100, 'c'+aleatorio).setInteractive(); block.setVelocity(0, 200); Thanks!