JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://raw.githubusercontent.com/photonstorm/phaser-examples/master/examples/_site/phaser/phaser.2.2.2.box2d.min.js"></script>
JavaScript
var Menu = function (game) { };
Menu.prototype = {
preload: function () { },
create: function () { }
};
var TheGame = function (game) { };
var keyboard, player, flag, jumpTimer = 0, ground, onGround = false, MovesTxt, Moves = 3, Pointer, JointsGroup = [], clickableArea, restart_txt;
TheGame.prototype = {
preload: function () {
this.load.image("player", "img/box2d/player.png");
this.load.image("restart", "img/box2d/Restart_btn.png");
this.load.image("flag", "img/box2d/flag.png");
},
create: function () {
this.physics.startSystem(Phaser.Physics.BOX2D);
this.physics.box2d.debugDraw.joints = true;
this.physics.box2d.gravity.y = 500;
this.physics.box2d.restitution = 0.8;
this.physics.box2d.setBoundsToWorld();
MovesTxt = this.add.text(20, 20, "click and use your arrow key to make the ball hang\n M O V E S : " + Moves, { font: "12px Arial", fill: "#FFFFFF", align: "center" });
MovesTxt.fixedToCamera = true;
player = this.add.sprite(this.game.world.centerX, this.game.world.height - 10, "player");
flag = this.add.sprite(this.game.world.centerX - 100, this.game.world.centerY - 150, "flag");
player.name = "player";
player.debug = false;
this.physics.box2d.enable(player);
player.checkWorldBounds = true;
player.body.setCircle(10);
keyboard = this.input.keyboard.createCursorKeys();
//player.body.setBodyContactCallback(ground, this.playerCollision, this);
this.game.input.onDown.add(this.MouseClicked, this);
},
update: function () {
this.Movements();
if (Moves == 0) {
...