看看这个例子
link
然后击中
运行代码
按钮:
var config = {
type: Phaser.AUTO,
width: 800,
height: 600,
backgroundColor: '#1b1464',
parent: 'phaser-example',
physics: {
default: 'matter'
},
scene: {
preload: preload,
create: create
}
};
var game = new Phaser.Game(config);
function preload ()
{
this.load.image('ball', 'assets/sprites/shinyball.png');
}
function create ()
{
this.matter.world.setBounds();
var ballA = this.matter.add.image(420, 100, 'ball', null, { shape: 'circle', friction: 0.005, restitution: 0.6 });
var ballB = this.matter.add.image(400, 200, 'ball', null, { shape: 'circle', friction: 0.005, restitution: 0.6 });
this.matter.add.constraint(ballA, ballB, 100, 0.2);
this.matter.add.mouseSpring();
}