Отскакивая тело от стен другого тела. Phaser3 - PullRequest
0 голосов
/ 23 октября 2019

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>

Существует код, согласно которому мяч возводится в квадрат и отскакивает от его стен. Как мне повернуть этот квадрат?

Я готов принять предложения по реализации этого примера на других движках фазера

...