JSFiddle - React, Tailwind, and code Playground

by smatthews1999

HTML

<script src="//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, render: render });

		var ball;
        var result = 'drag test';
				
        function preload () {
			game.stage.backgroundColor = 'black';
			
			game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;
			game.scale.setScreenSize();
		
            game.load.image('ball', 'ball.png');
        }

		
        function create () {
       	    ball = game.add.sprite(50, 50, 'ball');
        	
        	ball.inputEnabled = true;
        	ball.input.enableDrag(true);

			ball.events.onDragStart.add(startDrag, this);
			ball.events.onDragStop.add(stopDrag, this);
			ball.events.onInputUp.add(inputUp, this);
        }

  		function inputUp() {
          result = 'Up';		
		}

		function startDrag() {
            result = 'isDragged:' + ball.input.isDragged;		
		}

		function stopDrag() {
          result = 'Stop';		
		}
		
		function render(){
			game.debug.text(result, 10, 20);
		}