Этап 3: Phycis.group vs Phys c .staticGroup проблемы - PullRequest
0 голосов
/ 07 апреля 2020

Я пытаюсь создать простой платформер, я добавил несколько платформ в физическую группу, это работает, но когда игрок находится на платформе, он не срабатывает, как пол, и я не могу с него спрыгнуть.

В противном случае я попытался сделать это с группой c, это работает отлично, но у моих платформ есть анимация движения, а с группой c, тело не следует спрайту ... (следует с группой).

Мой код:

 //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'); 

Не могли бы вы помочь мне, пожалуйста?

Извините за мой английский sh, я прилагаю все усилия.

...