valentinaCom Posted October 20, 2014 Report 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 Quote Link to comment Share on other sites More sharing options...
CtlAltDel Posted October 20, 2014 Report Share Posted October 20, 2014 http://lmgtfy.com/?q=take+picture+with+webcam+html5 Quote Link to comment Share on other sites More sharing options...
rich Posted October 20, 2014 Report 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;} Quote Link to comment Share on other sites More sharing options...
rich Posted October 20, 2014 Report Share Posted October 20, 2014 Just to add you can get the Webcam plugin from here: https://github.com/photonstorm/phaser-plugins Quote Link to comment Share on other sites More sharing options...
CtlAltDel Posted October 20, 2014 Report Share Posted October 20, 2014 damn Quote Link to comment Share on other sites More sharing options...
valentinaCom Posted November 4, 2014 Author Report Share Posted November 4, 2014 thank you! That's realy simple! Quote Link to comment Share on other sites More sharing options...
owen Posted November 4, 2014 Report Share Posted November 4, 2014 That looks amazingly easy! I'm going to have to write a new game based on that feature now! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.