przemoo83 Posted October 9, 2015 Share Posted October 9, 2015 Is there any easy way to achieve this effect in P2? Something similar to moveToPointer() in arcade? Link to comment Share on other sites More sharing options...
spiritabsolute Posted October 13, 2016 Share Posted October 13, 2016 I was also interested in it! I was beginning to wonder why I use P2JS? How to understand whether I need P2JS. It may be better to use arcade? Link to comment Share on other sites More sharing options...
rhennig Posted October 19, 2016 Share Posted October 19, 2016 Arcade is faster. If you need better performance (maybe for mobile, old computers or very complex games) stay with arcade (in good computers and/or in simple games you dont will feel any difference). But, arcade works only with rectangles so, if you need to collide with balls or something complexer you possible will dont have a good effect with arcade. I have a simple game made with P2JS and an older version made with arcade, you can see the difference between the ball collision with the basket. P2JS http://funs2.com/funs2/games/freethrow/ Arcade http://funs2.com/funs2/games/freethrowarcade/ I changed my P2JS code to make it have a similar effect as moveToPointer() example (http://phaser.io/examples/v2/arcade-physics/move-to-pointer). You can see it running here (http://funs2.com/funs2/games/pointer_example/). create : function() { this.canmove=false; this.baskball = this.game.add.sprite(this.game.world.centerX,this.game.world.centerY+(this.game.world.centerY/2),'ball'); this.game.physics.startSystem(Phaser.Physics.P2JS); this.game.physics.p2.gravity.y = 0; this.game.physics.p2.enable(this.baskball); this.baskball.body.setCircle(30); this.baskball.anchor.setTo(0.5, 0.5); this.baskball.body.moves = false; this.baskball.body.allowGravity = false; this.baskball.body.static = true; this.input.onDown.add(this.move, this); }, move : function() { this.baskball.body.velocity.x=this.game.input.activePointer.worldX-this.baskball.x; this.baskball.body.velocity.y=this.game.input.activePointer.worldY-this.baskball.y; this.canmove = true; }, update : function() { if (this.canmove == true) { this.baskball.x = this.game.input.activePointer.worldX; this.baskball.y = this.game.input.activePointer.worldY; } } spiritabsolute 1 Link to comment Share on other sites More sharing options...
Recommended Posts