为什么跳跃和下降动画没有播放?移相器

问题描述

我的一些动画不起作用,我像这样创建了这两个,但它们没有显示

控制台上有一些消息,例如 -2330,我在空中但没有下降消息。

此处的存储库链接https://github.com/Ceci007/prince-fantasy-rpg

this.anims.create({
      key: 'jump',frames: this.anims
        .generateFrameNumbers('player',{ frames: [16,17,18,19,20,21] }),frameRate: 10,repeat: -1,});

    this.anims.create({
      key: 'fall',{ frames: [22,23,24] }),});

这里也是更新方法中的玩家移动功能

if (this.cursors.left.isDown) {
        this.player.body.offset.x = 50;
        this.player.setScale(-1,1);
        this.player.body.setVeLocityX(-80);
        this.player.anims.play('left',true);
      } else if (Phaser.Input.Keyboard.JustDown(this.cursors.up) 
      && (this.player.body.touching.down || this.player.body.onFloor())) {
        this.player.body.setVeLocityY(-2330);
        
        console.log(this.player.body.veLocity.y);
        if (this.player.body.veLocity.y < 0) { 
          this.player.anims.play('jump',true);
          console.log("I'm in the air");
        }
        else if (this.player.body.veLocity.y >= 0 && !(this.player.body.touching.down ||
          this.player.body.onFloor())) {
            this.player.anims.play('fall',true);
            console.log("I'm falling");
        }
      } 
      else if (this.cursors.right.isDown) {
        this.player.body.offset.x = 0;
        this.player.setScale(1,1);
        this.player.body.setVeLocityX(80);
        this.player.anims.play('right',true);
      } else if (this.spaceBar.isDown) {
        this.player.anims.play('attack',true);
        if (this.player.body.facing === 13
          && this.player.anims.currentFrame.index === 14) {
          this.player.body.setVeLocityX(-80);
        } else if (this.player.body.facing === 14
          && this.player.anims.currentFrame.index === 14) {
          this.player.body.setVeLocityX(80);
        }
        if (this.player.anims.currentFrame.index === 3
          || this.player.anims.currentFrame.index === 9
          || this.player.anims.currentFrame.index === 14) {
          if (this.playingSound === false
            && this.model.soundOn === true) {
            this.playingSound = true;
            this.sound.play('swing1',{ volume: 0.4 });
          }
        } 
        else {
          this.playingSound = false;
          this.player.setVeLocityX(0);
        }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)