@@ -33,12 +33,13 @@ function create() {
3333
3434 layer = map . createLayer ( 'Tile Layer 1' ) ;
3535
36- // layer.debug = true;
37-
3836 layer . resizeWorld ( ) ;
3937
38+ game . physics . startSystem ( Phaser . Physics . ARCADE ) ;
39+
4040 // Here we create our coins group
4141 coins = game . add . group ( ) ;
42+ coins . enableBody = true ;
4243
4344 // And now we convert all of the Tiled objects with an ID of 34 into sprites within the coins group
4445 map . createFromObjects ( 'Object Layer 1' , 34 , 'coin' , 0 , true , false , coins ) ;
@@ -48,10 +49,12 @@ function create() {
4849 coins . callAll ( 'animations.play' , 'animations' , 'spin' ) ;
4950
5051 sprite = game . add . sprite ( 260 , 100 , 'phaser' ) ;
51- sprite . anchor . setTo ( 0.5 , 0.5 ) ;
52+ sprite . anchor . set ( 0.5 ) ;
53+
54+ game . physics . arcade . enable ( sprite ) ;
5255
5356 // This adjusts the collision body size.
54- sprite . body . setRectangle ( 16 , 16 , 25 , 15 ) ;
57+ sprite . body . setSize ( 32 , 32 , 16 , 16 ) ;
5558
5659 // We'll set a lower max angular velocity here to keep it from going totally nuts
5760 sprite . body . maxAngular = 500 ;
@@ -67,8 +70,8 @@ function create() {
6770
6871function update ( ) {
6972
70- game . physics . collide ( sprite , layer ) ;
71- game . physics . overlap ( sprite , coins , collectCoin , null , this ) ;
73+ game . physics . arcade . collide ( sprite , layer ) ;
74+ game . physics . arcade . overlap ( sprite , coins , collectCoin , null , this ) ;
7275
7376 sprite . body . velocity . x = 0 ;
7477 sprite . body . velocity . y = 0 ;
@@ -85,10 +88,9 @@ function update() {
8588
8689 if ( cursors . up . isDown )
8790 {
88- game . physics . velocityFromAngle ( sprite . angle , 300 , sprite . body . velocity ) ;
91+ game . physics . arcade . velocityFromAngle ( sprite . angle , 300 , sprite . body . velocity ) ;
8992 }
9093
91-
9294}
9395
9496function collectCoin ( player , coin ) {
@@ -99,6 +101,6 @@ function collectCoin(player, coin) {
99101
100102function render ( ) {
101103
102- game . debug . physicsBody ( sprite . body ) ;
104+ game . debug . body ( sprite ) ;
103105
104106}
0 commit comments