Scrooler

Members
  • Content Count

    4
  • Joined

  • Last visited

  1. Hello! Have 3 virtual button for moving player. Use arcade physics. Phaser version: 3.10.0 How to make when holding down button with your finger, the player began to move. What you need to add the condition? Create: this.input.addPointer(2); this.jumpBtn = this.add.sprite(650, 950, 'jump').setScale(0.4).setScrollFactor(0).setInteractive(); this.leftBtn = this.add.sprite(100, 950, 'left').setScale(0.4).setScrollFactor(0).setInteractive(); this.rightBtn = this.add.sprite(250, 950, 'right').setScale(0.4).setScrollFactor(0).setInteractive(); this.jumpBtn.on('pointerdown', function (pointer,pointerdown) { }); this.leftBtn.on('pointerdown', function (pointer,pointerdown) { }); this.rightBtn.on('pointerdown', function (pointer,pointerdown) { }); function update () { if (cursors.left.isDown) { player.setVelocityX(-200); player.anims.play('left', true); } else if (cursors.right.isDown ) { player.setVelocityX(200); player.anims.play('right', true); } else { player.setVelocityX(0); player.anims.play('turn'); } if (cursors.up.isDown && player.body.touching.down ) { player.setVelocityY(-530); } }
  2. Hello! I'm found 'collision shapes parser from Tiled(full example)' for example, but there have only drawn shapes, without collision. Help me get collision into example for my Player. Code from Example: function create () { var map = this.add.tilemap('map'); var tileset = map.addTilesetImage('kenny_platformer_64x64'); var layer = map.createStaticLayer('Tile Layer 1', tileset); var graphics = this.add.graphics(); // Loop over each tile and visualize its collision shape (if it has one) layer.forEachTile(function (tile) { var tileWorldPos = layer.tileToWorldXY(tile.x, tile.y); var collisionGroup = tileset.getTileCollisionGroup(tile.index); if (!collisionGroup || collisionGroup.objects.length === 0) { return; } // You can assign custom properties to the whole collision object layer (or even to // individual objects within the layer). Here, use a custom property to change the color of // the stroke. if (collisionGroup.properties && collisionGroup.properties.isInteractive) { graphics.lineStyle(5, 0x00ff00, 1); } else { graphics.lineStyle(5, 0x00ffff, 1); } // The group will have an array of objects - these are the individual collision shapes var objects = collisionGroup.objects; for (var i = 0; i < objects.length; i++) { var object = objects[i]; var objectX = tileWorldPos.x + object.x; var objectY = tileWorldPos.y + object.y; // When objects are parsed by Phaser, they will be guaranteed to have one of the // following properties if they are a rectangle/ellipse/polygon/polyline. if (object.rectangle) { graphics.strokeRect(objectX, objectY, object.width, object.height); } else if (object.ellipse) { // Ellipses in Tiled have a top-left origin, while ellipses in Phaser have a center // origin graphics.strokeEllipse( objectX + object.width / 2, objectY + object.height / 2, object.width, object.height ); } else if (object.polygon || object.polyline) { var originalPoints = object.polygon ? object.polygon : object.polyline; var points = []; for (var j = 0; j < originalPoints.length; j++) { var point = originalPoints[j]; points.push({ x: objectX + point.x, y: objectY + point.y }); } graphics.strokePoints(points); } } }); Properties Player: player = this.physics.add.sprite(400, 300, 'Player', 14); player.setCollideWorldBounds(true); this.physics.add.collider(player, Layer);
  3. Hi All! I have a question. A Player who has collision. For each object I have to assign this.physics.add.collider(player, group); this.physics.add.collider(player, objectLayer); How to give collision globally ? Just give collider player and other object separately.
  4. Hello all! I'm make top down game in Phaser 3.9.0 and have a problem. I'm created map in Tiled ver. 0.18.2. and export it in .CSV. It turned out , 5 files = 5 layers. How all of them combine to a mp? My code. function preload () { this.load.image('tiles', 'assets/map/tileset/tilesheet.png'); this.load.tilemapCSV('map', 'assets/map/csv/world_ground.csv'); this.load.tilemapCSV('map', 'assets/map/csv/world_groundvariations.csv'); this.load.tilemapCSV('map', 'assets/map/csv/world_grass.csv'); //and other... } function create () { //MAP map = this.make.tilemap({key : 'map', tileWidth: 32, tileHeight: 32}); var tileset = map.addTilesetImage('tiles'); ground = map.createStaticLayer(0, tileset, 0, 0); grass = map.createStaticLayer(1,tileset,0,0); } Error: Cannot create tilemap layer, invalid layer ID given: 1 This is what is displayed on the screen. Only First Layer