Search the Community
Showing results for tags 'body.blocked.down'.
-
Hey there, I am still struggling a lot with Phaser3 due to the documentation is still in work. I made two simple sprites, that collide, what I experience is that >body.blocked.down< nor the other properties (left, right, top) ever change. They are always: false. No matter if a collision happens or not. A bit of code: //These are the arcade configs: physics: { default: 'arcade', arcade: { gravity: {x: 0, y: 2000}, debug: true, overlapBias: 20 } } //TileA this.plat = this.physics.add.sprite(400, 1100, 'platform'); this.plat.displayWidth = 500; this.plat.body.allowGravity = false; this.plat.body.immovable = true; //TileB is a custom class which just extends this.physics.add.sprite this.minion = new tileB(this, 500, 200); //collision works well with: this.physics.world.collide(this.plat, this.minion); However, the body.blocked property is logged in my update of the custom (tileB) class - and it is always false. No matter if it's colliding. Here is the code of the tileB class: class tileB extends Phaser.Physics.Arcade.Sprite { constructor(config) { super(config.scene, config.x, config.y, 'minion'); this.scene.physics.world.enable(this); this.scene.add.existing(this); this.scene.layers.minions.add(this); this.controls = this.scene.input.keyboard.createCursorKeys(); //write controls class this.alive = true; this.body.maxVelocity.y = 1500; this.body.setSize(50, 100, false); this.body.setOffset(80, 60); this.scene.events.on('update', this.update, this); } update() { if(this.data.active) { console.log(this.body.blocked.down) if (this.controls.left.isDown) { this.setVelocityX(-200); this.anims.play('left', true); } else if (this.controls.right.isDown) { this.setVelocityX(200); this.anims.play('right', true); } else { this.setVelocityX(0); this.anims.play('turn'); } if (this.controls.up.isDown && this.body.blocked.down) { this.setVelocityY(-200); } } } } I have looked into the super mario example by @nkholski as he used body.blocked.down too. I had a hard time to find the point I am missing. Would be glad if someone helped me out nkholski's platformer boilerplate: Thanks in advance
-
Hello everybody, I'm doing a little game plateform for fun and for the ground management and for more speed, I wondered if was worth better not use (for optimization) : - Tilemap : But I feel that after a certain number of box it starts to slow down... (and i can use player.body.blocked.down to know il player is landing) OR - Objects that define the ground and far fewer (but i loose player.body.blocked.down to know il player is landing) And that's make -> And all mixed -> I manage this with tiled like that -> What is the best practice to design ground and manage ground collision to keep a max of fps ? thank for help and this great forum Here the sources.zip
-
- optimization
- ground management
-
(and 3 more)
Tagged with: