美文网首页
物理引擎

物理引擎

作者: skoll | 来源:发表于2023-05-28 20:07 被阅读0次

Phaser Matter Collision Plugin
1 .使用这个插件,开发更加便捷
2 .https://blog.xiiigame.com/2018-10-14-Phaser2%E5%AE%98%E7%BD%91%E5%AE%9E%E4%BE%8B%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/#distance_to_pointer 计算物理角速度,两个物体连线的角度
3 .组和自身的碰撞关系

通过物理引擎

1 .可以实现惯性这种表现形式,比如车根据鼠标按键走,停下的时候需要一定的时间。感觉几乎所有的都需要加这个东西。确实真实了不少,按键停下就立马停止的一点也不好玩。
2 .它里面推荐的是matter.

this.matter.world.setBounds(0, 0, 3200, 600);
        this.cameras.main.setBounds(0, 0, 3200, 600);
//设置物理世界的边界

this.player = this.matter.add.sprite(1600, 200, 'ship')
            .setFixedRotation()
            .setFrictionAir(0.05)
            .setMass(30);
        this.cameras.main.startFollow(this.player, false, 0.2, 0.2);
//给主角加上物理属性

 if (this.cursors.left.isDown)
        {
            this.player.thrustBack(0.2);
            // this.player.flipX = true;
        }
        else if (this.cursors.right.isDown)
        {
            this.player.thrust(0.1);
            // this.player.flipX = false;
        }
    
        if (this.cursors.up.isDown)
        {
            this.player.thrustLeft(0.1);
        }
        else if (this.cursors.down.isDown)
        {
            this.player.thrustRight(0.1);
        }
//主角根据操作移动

相关文章

网友评论

      本文标题:物理引擎

      本文链接:https://www.haomeiwen.com/subject/lssxldtx.html