1.sprite开启物理系统
this.sp1 = new Phaser.Sprite(game, 400, 400, 'yellow_png');this.group.addChild(this.sp1);game.physics.enable([this.sp0, this.sp1], Phaser.Physics.ARCADE);this.sp0.body.velocity = new Phaser.Point(600, 500);this.sp1.body.velocity = new Phaser.Point(-120, -150);this.sp0.body.collideWorldBounds = true;this.sp1.body.collideWorldBounds = true;
2.sprites overlap collide seperate的检测
http://www.html5gamedevs.com/topic/9522-phaserarcade-collide-and-overlap-difference-and-separation/
关于overlap()无法正常工作
在update(){}中检测:
update() {this.game.physics.arcade.overlap(this.sp0, this.sp1, () => { console.log('overlap'), this });this.game.physics.arcade.separate(this.sp0.body, this.sp1.body, () => { console.log('separate') }, this);this.game.physics.arcade.collide(this.sp0, this.sp1, () => { console.log('collide'), this });
}
- overlap
3.group没有x,y,position属性,设置的x,y,position属性无效。
https://github.com/photonstorm/phaser/issues/38
办法:为group添加容器,设置容器的位置。