Hi !
I’m trying to create a simple platformer, i’ve added some platforms to a physics group, it’s work but when the player is on a platform, it’s not triggered like the floor and i can’t jump from it.
Otherwise, i tried to do it with static group, it’w work perfectly, but my platforms have tween, and width static group, the body doesn’t move… (it moves with group).
My code :
//LEVEL OBJECTS
//FallingPlatforms
this.fallingPlateforms = this.physics.add.group({
allowGravity: false,
immovable: true
});
// Let's get the spike objects, these are NOT sprites
const fallingPlateformsObjects = map.getObjectLayer('fallingPlateforms')['objects'];
//Rotation animation
this.anims.create({
key: 'fly',
frames: this.anims.generateFrameNumbers('fallingPlateformsOn'),
frameRate: 20,
repeat: -1
});
//Wind particules
const particles = this.add.particles('dust');
// Now we create spikes in our sprite group for each object in our map
fallingPlateformsObjects.forEach(fallingPlateformsObject => {
// Add new spikes to our sprite group, change the start y position to meet the platform
let fallingPlateform = this.fallingPlateforms.create(fallingPlateformsObject.x, fallingPlateformsObject.y, 'fallingPlateformsOn');
//Remove bottom collision
fallingPlateform.body.checkCollision.down = false;
fallingPlateform.body.immovable = true;
//Create emmiter for wind
let platformEmitter = particles.createEmitter({
speed: 150,
angle:90,
emitZone:{
type: 'random', // 'random', or 'edge'
source: new Phaser.Geom.Rectangle(-12, 0, 24), // Geom like Circle, or a Path or Curve
},
on: true,
blendMode: 'ADD',
scale: { start: 0.6, end: 0 },
alpha: { start: 0.1, end: 0 },
quantity:1,
lifespan: 400,
});
platformEmitter.setPosition(fallingPlateform.x, fallingPlateform.y+10);
platformEmitter.on = true;
//platformEmitter.startFollow(fallingPlateform);
//Create animation for mooving the
this.tweens.add({
targets: fallingPlateform,
y: fallingPlateform.y + 10,
duration: 2000,
yoyo: true,
repeat:-1,
delay:Phaser.Math.Between(0, 1000)
});
});
//play animation for all childrn of the group
this.fallingPlateforms.playAnimation('fly');
Could you help me please ?
Sorry for my english, i do m best.