2017-07-14 55 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;