JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/phaser/2.6.1/phaser.min.js"></script>
JavaScript
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload:preload, create: create,update: update, render:render });
function preload() {
game.load.image('circle', 'https://s13.postimg.org/xjhlzmiev/disc_png.png');
game.load.image('rect', 'http://s10.postimg.org/6fa6mgrd5/motif.jpg');
}
function create() {
this.projectile=game.add.sprite(100,350,"circle")
this.projectile.touch=function(){
alert('touch')
}
this.axe=game.add.sprite(200,200,'rect')
this.axe.width=300
this.axe.height=10
this.point=game.add.sprite(200,200)
this.point.width=10
this.point.height=10
//game.physics.arcade.enable(this.projectile);
//game.physics.arcade.enable(this.axe); //game.physics.startSystem(Phaser.Physics.ARCADE)
game.physics.startSystem(Phaser.Physics.P2JS);
game.physics.p2.enable([ this.axe, this.projectile, this.point], true);
this.projectile.body.static = true;
this.point.body.static = true;
game.physics.p2.createRevoluteConstraint(this.axe, [ 0, 0 ], this.point, [ 0, 0 ]);
this.projectile.body.setCircle(this.projectile.width/2);
}
function update(){
this.axe.body.angle += 1; //game.physics.arcade.collide(this.axe,this.projectile,this.projectile.touch,null,this)
}
function render(){
game.debug.body(this.projectile);
game.debug.body(this.axe)
}