JSFiddle - React, Tailwind, and code Playground
HTML
<script src="//cdnjs.cloudflare.com/ajax/libs/phaser/2.0.4/phaser.min.js"></script>
<div id="gameContainer" width="100%" height="100%"></div>
JavaScript
(function () {
var game = new Phaser.Game(400, 400, Phaser.CANVAS, 'gameContainer', { preload: preload, create: create, update: update });
var img1, img1BMD;
function preload()
{
game.stage.backgroundColor = 0x888888;
}
function create()
{
img1BMD = game.make.bitmapData(200, 200);
img1BMD.circle(50,50,25,'rgba(255,0,0,1)');
img1BMD.circle(100,50,25,'rgba(255,255,0,1)');
img1BMD.circle(150,50,25,'rgba(0,255,0,1)');
img1BMD.circle(75,95,25,'rgba(0,255,255,1)');
img1BMD.circle(125,95,25,'rgba(0,0,255,1)');
img1BMD.circle(100,140,25,'rgba(255,0,255,1)');
img1BMD.update();
img1 = game.add.sprite(100,100,img1BMD);
img1.inputEnabled = true;
img1.events.onInputDown.add(clicky, this);
}
function clicky(img, pointer)
{
var posX,posY;
posX = pointer.x - img.x;
posY = pointer.y - img.y;
img1BMD.update();
console.log("x:"+posX, "y:"+posY, img1BMD.getPixel(posX,posY));
console.log("x:"+posX, "y:"+posY, img1BMD.getPixel32(posX,posY));
}
function update()
{
}
})();