2017-07-14 57 views
0

我是Phaser的新手,我需要你的帮助。我想让我角色的项目从墙上反弹。到目前为止,在建立()我有这样的事情:Phaser bounciness

game.physics.startSystem(Phaser.Physics.ARCADE); 
ball = game.add.group(); 
ball.enableBody = true; 
ball.setAll('body.collideWorldBounds', true); 

后来在更新():

fire.onDown.add(function() { 
var bullet = ball.create(Char1.x,Char1.y,'ball'); 
if(bullet){ 
    bullet.body.velocity.set(0,-400); 
} 

回答

2

确保您启用物理为你的子弹,然后设置弹跳像这样:

game.physics.arcade.enable(bullet) 

// set the bounce energy, 1 is 100% energy return 
bullet.body.bounce.set(1); 

而此行将使游戏世界bounceable:

bullet.body.collideWorldBounds = true;