/** * Generated from the Phaser Sandbox * * //phaser.io/sandbox/JAsHPCMn * * This source requires Phaser 2.6.2 */ var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render }); function preload() { game.load.baseURL = 'http://examples.phaser.io/assets/'; game.load.crossOrigin = 'anonymous'; game.load.image('phaser', 'sprites/phaser-dude.png'); game.load.image('chaos', 'pics/hotshot-chaos_in_tokyo.png'); } function create() { phaser = game.make.sprite(0, 0, 'phaser'); phaser.anchor.set(0.5,0.5) chaos = game.make.sprite(0, 0, 'chaos'); // stretch image to stage size chaos.scale.set(game.width/chaos.width, game.height/chaos.height); // make bitmap data size of graphic bmd = game.make.bitmapData(chaos.width, chaos.height); // add bitmapdata to stage game.add.sprite(0,0,bmd) // draw on mouse move game.input.addMoveCallback(move, this); } function move(pointer, x, y) { // move our brush phaser.x=x phaser.y=y // draw our brush mask bmd.alphaMask(chaos, phaser) // this also works.. it's what alphaMask actually does // see http://www.html5gamedevs.com/topic/9451-bitmap-data-alphamasks/?p=55995 //bmd.draw(phaser).blendSourceAtop().draw(chaos).blendReset(); } function update() { } function render() { }