首页 > 解决方案 > 从另一个身体的墙壁上弹起一个身体。Phaser3

问题描述

var config = {
    type: Phaser.AUTO,
    width: 800,
    height: 600,
    backgroundColor: '#1b1464',
    parent: 'phaser-example',
    physics: {
        default: 'matter',
        matter: {
            debug: true
        }
    },
    scene: {
        preload: preload,
        create: create
    }
};

var game = new Phaser.Game(config);

function preload ()
{
    this.load.image('red', 'assets/sprites/columns-red.png');
}

function create ()
{
    this.matter.world.setBounds(100, 0, 600, 400, 1).disableGravity();
    console.log(this.matter.world.walls.bottom)

    var circ = this.matter.add.image(200, 50, 'red');

    //  Change the body to a Circle with a radius of 48px
    circ.setBody({
        type: 'circle',
        radius: 48
    });

    //  Just make the body move around and bounce
    circ.setVelocity(6, 3);
    circ.setAngularVelocity(0.01);
    circ.setBounce(1);
    circ.setFriction(1, 0, 0);
}
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="//cdn.jsdelivr.net/npm/phaser@3.19.0/dist/phaser.js"></script>
    <script src="//cdn.jsdelivr.net/npm/phaser@3.19.0/dist/phaser.min.js"></script>
</head>

有一个代码,根据该代码,球被摆正并从墙壁反弹。我怎样才能旋转这个正方形?

我已准备好接受在其他移相器引擎上实施此示例的建议

标签: phaser-framework

解决方案


推荐阅读