JSFiddle - React, Tailwind, and code Playground

by Vincent Roumier

HTML

<script src="http://cdnjs.cloudflare.com/ajax/libs/phaser/2.0.6/phaser.min.js"></script>

JavaScript

var game = new Phaser.Game(600, 800, Phaser.AUTO, '', {
    preload: preload,
    create: create,
    update: update
});

var sprite;

function preload() {
    game.stage.backgroundColor = '#fff4d9';
    game.load.image('ball', 'ball.png');
}


function create() {
    game.physics.startSystem(Phaser.Physics.P2JS);
    //Create a ball
    ball = game.add.sprite(50, 150, 'ball');
    game.physics.enable([ball], Phaser.Physics.P2JS);
    ball.body.debug = true;
    ball.body.static = true;
    //Create a group and a the ball to it
    var group = game.add.group();
    group.add(ball);
    //move the group
    group.x = 100;
    
    //Create a sprite that will collide with the body
    var coll = game.add.sprite(50,50,"ball");
    game.physics.enable([coll], Phaser.Physics.P2JS);
    coll.body.velocity.y = 50;
}


function update() {}