valentinaCom Posted October 20, 2014 Share Posted October 20, 2014 hi I need to add in my game an option of taking a picture using the player webcam.I have a btn that when pressed, the camera needs to open so the player can take a picture and then add the pic to my canvas. any idea?thnx Link to comment Share on other sites More sharing options...
CtlAltDel Posted October 20, 2014 Share Posted October 20, 2014 http://lmgtfy.com/?q=take+picture+with+webcam+html5 Link to comment Share on other sites More sharing options...
rich Posted October 20, 2014 Share Posted October 20, 2014 Simple var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create });function preload () { game.load.script('webcam', '../plugins/WebCam.js');}var webcam;var bmd;var sprite;function create () { webcam = game.plugins.add(Phaser.Plugin.Webcam); bmd = game.make.bitmapData(800, 600); sprite = bmd.addToWorld(); webcam.start(800, 600, bmd.context); game.input.onDown.addOnce(takePicture, this);}function takePicture () { webcam.stop(); // bmd.context now contains your webcam image sprite.tint = Math.random() * 0xff0000;} Link to comment Share on other sites More sharing options...
rich Posted October 20, 2014 Share Posted October 20, 2014 Just to add you can get the Webcam plugin from here: https://github.com/photonstorm/phaser-plugins Link to comment Share on other sites More sharing options...
CtlAltDel Posted October 20, 2014 Share Posted October 20, 2014 damn Link to comment Share on other sites More sharing options...
valentinaCom Posted November 4, 2014 Author Share Posted November 4, 2014 thank you! That's realy simple! Link to comment Share on other sites More sharing options...
owen Posted November 4, 2014 Share Posted November 4, 2014 That looks amazingly easy! I'm going to have to write a new game based on that feature now! Link to comment Share on other sites More sharing options...
Recommended Posts