Jump to content


  • Content Count

  • Joined

  • Last visited

About Pau

  • Rank
    Advanced Member

Recent Profile Visitors

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

  1. Hello, In this game: https://pablomonteserin.com/apuntes/web/js/canvas/phaser/ex/coches/8-colisiones-con-matter/index.html the matter collision is not working. the players must to collision with the borders of the road, but it is not working. I am using matter collision. This is the Javascript code: class Escena extends Phaser.Scene { preload() { resize(); this.load.tilemapTiledJSON('level1', '/apuntes/assets/phaser/coches/map-wahab-2-capas.json'); this.load.image('nombreDelTilesetEnPhaser', '/apuntes/assets/phaser/coches/tiles.png'); this.load.image('car1', '
  2. Hello, I would like to create a interactive zone which is relative to an existing sprite. For example, this code is working: var marcoObjs = this.add.sprite(x, y, 'marcoObjs'); var puerta1 = this.add.zone(50, 50, 100, 100) puerta1.setInteractive(); this.add.graphics().lineStyle(2, 0xff0000).strokeRectShape(puerta1); But i want the puerta1 object to be relative positioned to marcoObjs object. So if marcoObjs x,y coordinates change, puerta1 coordinates must change too. I tried this way, but is not working: var marcoObjs = this.add.sprite(x, y, 'marcoObjs'); var puerta1 = mar
  3. Hello onlycape, Thank you very much for your help, and for your fast reply . I tried to integrate your code in mine, but it is giving me the next error: "objectCar.entraEnArea1 is not a function". I tried to give the car object (coche) a property name called "love", but it says that the value is undefined. If i try to make it without a group, it gives to me the same error. I would like to make it with a group, anyways. function create() { map = this.make.tilemap({key:'level1'}); tileset = map.addTilesetImage('nombreDelTilesetEnTiled', 'nombreDelTilesetEnPhaser'); carre
  4. Ah! Sorry about my wrong explanation I want the event to trigger each time the car pass across the goal zone. With your code it only trigger one time. Thank you
  5. Hello, I want to trigger the "goal" function just one time, when one of the elements of the "players" group enter in the the overlappingArea. Now, the "goal" function is triggering multiple times, while one of the player's group is over the overllapping area. How can i trigger just one time, when the player enter in the zone? this.physics.add.overlap(players, overlappingArea, goal); Thank you in advance
  6. Thank you! Is Working player1.setDrag(100,100)
  7. Sorry, it is not working for me This is the whole code, maybe it helps Thank you in advance: var velocity=0; var juego; var config = { type: Phaser.AUTO, width: 960, height: 640, scene: { preload: preload, create: create, update: update }, physics: { default: 'arcade', arcade: { debug: true, gravity: { y: 0 } } } } var game = new Phaser.Game(config); function preload() { resize() window.addEventListener("resize", resize, false); this.load.image('car1', '../img/F1_amarillo_32x64.png'); this.load.image('car2', '../img/F1_azul_32x64.png'); this.load
  8. Hello! I am making a car racing game. You can play the prototype in this link: https://pablomonteserin.com/apuntes/web/js/canvas/phaser/ex/coches/cars-foro-phaser-2/ My problem is when when the car i am controlling with the keyboard collisions with another car. The second car starts moving and never stops. I tried to put some friction, but it is not working. This is the important part of the code: coches = this.physics.add.group(); player1 = coches.create(300,100,'car1'); player2 = coches.create(300,200,'car2'); player3 = coches.create(300,300,'car3'); player4 = coches.create(3
  9. Sorry, i believe that the explanation of my problem wasn't clear. I think that if the car rotates from its top-left corner it will be a wrong behaviour when you are playing. So i want it to rotate from its 0.5,0.5 position. The problem is when i import the position of the elements from tiled editor. I have prepared this example: https://pablomonteserin.com/apuntes/web/js/canvas/phaser/ex/coches/cars-foro-phaser/ In the example i have two cars. Both are right positioned in the tiled editor. In the tiled editor, both are just after the whilte line, in its center. But when
  10. I am making a car racing game. When i rotate the car, it doesen't rotate well. It is rotating in a weird way. I did set the origin to the 0,0 with following code in order to make it match with the tiled editor origin. But, after that, the rotation is wrong. player1 = this.physics.add.sprite(500, 500, 'car1').setOrigin(0 , 0) Before start rotating: After be rotating for a while: I put the game code in the attachment. Thank you in advance. cars.zip
  11. Thank you ol-web! The variables i don't put var in front has global scope. That's right in my game.
  12. Hello, I have design this car path with tiled editor: but when i load it in phaser i see this: It's like the tile rotation i made in tiled is no working in phaser. This is the code i use to load it the tilemap: function preload(){ this.load.tilemapTiledJSON('level1', 'map.json'); this.load.image('nombreDelTilesetEnPhaser', '../img/tiles.png'); } function create(){ map = this.make.tilemap({key:'level1'}); tileset = map.addTilesetImage('nombreDelTilesetEnTiled', 'nombreDelTilesetEnPhaser'); backgroundLayer = map.createStaticLayer('background', tiles
  13. Thank you! your explanation solved my problem. I share my on code-explanation. function preload(){ this.load.tilemapTiledJSON('level1', 'map.json'); this.load.image('tilesetNameInPhaser', 'tiles.png'); } function create(){ map = this.make.tilemap({key:'level1'}); tileset = map.addTilesetImage('tilesetNameInTiled', 'tilesetNameInPhaser'); backgroundLayer = map.createStaticLayer('background', tileset,0,0); } Thank you!
  14. Thank you for your help Vexen :D, At last, i solve it, but using a lot of code. Your solution is better. Thank you
  15. Hello, I am trying to load a tilemap mad with tiled, but i am getting this error in the console: Error: No data found in the JSON tilemap from Tiled matching the tileset name: "gameTiles" This is the code i am using in phaser: function preload(){ this.load.tilemapTiledJSON('level1', 'map.json'); this.load.image('gameTiles', 'tiles.png'); //this.load.spritesheet('gameTiles', '../img/tiles.png', { frameWidth: 32, frameHeight: 32 }); } function create(){ map = this.make.tilemap({key:'level1'}); tileset = map.addTilesetImage('gameTiles'); backgroundLayer = map.createStat
  • Create New...