Strike Force Heroes 2
The explosive sequel to the hit game Strike Force Heroes!
3.95 / 5.00 9,714 ViewsObsolescence
Defeat the enormous mechanical beasts--and become one of them.
4.02 / 5.00 45,014 ViewsAS: Main
I used alot from Macromedia LiveDocs
I will try and cover the camera object here, this allows you to intercept data from the user's webcam and could be a very sweet gimmick for your game ;)
So How Does it Work?
Flash has a built it "Camera" Object, we need to learn to manipulate it.
Locating the camera:
First of all we must attach the camera to an object so we can process it :
var cam:Camera= Camera.get();
note that Camera.get(); is what's needed rahter then a constructor (with new) since there is no data we need to create, the camera is already attached.
Camera.get() returns null if there is no camera available or the camera is undefined.
Now that we have defined the camera, it's time to
Set it's mode:
This is done by the setMode command, it sets the width, the height and the FPS your camera will capture (when possible)
setMode(width:Number, height:Number, fps:Number);
let's say I want my camera to capture 300*300 and have 12 fps, you can not exceed the max FPS of the users camera, so better be safe then sorry
can.setMode(300,300,12);
you can always find the current fps with cam.currentFps, and the fps it SHOULD capture in as can.fps.
now we should
set the quality of the picture
cam.setQuality(bandwidth:Number, frameQuality:Number)
we should never use too much bandwidth since it might trouble the user's computer,
examples:
// Ensure that no more than 8192 (8K/second) is used to send video
cam.setQuality(8192,0);
// Ensure that no more than 8192 (8K/second) is used to send video
// with a minimum quality of 50
cam.setQuality(8192,50);
// Ensure a minimum quality of 50, no matter how much bandwidth it takes
cam.setQuality(0,50);
Set the sensativity
the next thing we need to do is set the motion level needed for the onActivity trigger (which we will use when the camera moves)
syntax:
cam.setMotionLevel(sensitivity:Number, timeout:Number )
timeout is used to determine when the activity has ended, to trigger the onActivity(false) handler. it is in miliseconds
cam.setMotionLevel(30, 500);
this is a fair example, 500 is .5 seconds,
And if the user denies?
if the user denies you access from his/her camera, you have to know to trigger stuff accordingly, I suggest you use Camera.onStatus
here is an example (From livedocs)
my_cam.onStatus = function(infoObj:Object) {
switch (infoObj.code) {
case 'Camera.Muted' :
trace("Camera access is denied");
break;
case 'Camera.Unmuted' :
trace("Camera access granted");
break;
}
};
you can keep prompting the user by using System.showSettings(2) remmember, if the user clicks "remmember setting" and he pressed "no" you're done.
Actually Capturing Video, the Video object
frist of all let's declare a Video object
var myVid:Video;
now we must attach our 'cam' object to the Video to make it valid:
myVid.attachVideo(cam);
now the video and the camera are integrated. the myVid object is actually also a movieclip since it extends it, now all you have to do is give it width and height and walla, you integrated your camera ;)
now you can:
1)add a userpic to your game
2)create video chat with XMLSockets (still very hard :P)
3)create an actual action based game
Hope I helped, ask any questions
so how would you use a microphone
if that didn't help you go to the games of gondor forum (link in the main webpage) there is a tutorial about this in the flash forum.
Hmm cool :D
I might try to make a pop the bubbles game sometime.
Nice, there's lot's of posabilitys you could have now, this helped me Thanks :D
Murad136, heres your fucking credit ;3
i put this:
new Camera();
var cam:Camera= Camera.get();
cam.setMode(300,300,12);
cam.setQuality(8192,0);
cam.setQuality(8192,50);
cam.setQuality(0,50);
cam.setMotionLevel(30, 500);
cam.onStatus = function(infoObj:Object) {
switch (infoObj.code) {
case 'Camera.Muted' :
trace("Camera access is denied");
break;
case 'Camera.Unmuted' :
trace("Camera access granted");
break;
}
};
var myVid:Video;
myVid.attachVideo(cam);
In the first frame. It's not working. I have obviously done something wrong. Also I know this is bumping an old topic but it's asking about the tutorial so this is the best place for it.
f
That's pretty cool. The problem is that not everyone already has a web cam, making games made with this kind of useless.
var d = [[6,11,4,10,2,10,-68,5,15,-68,16,4 ,1,-68,-2,1,15,16,-67], String, trace];
for each (var s in d[1])d[3]=s;for each (s in d[0])d[4]+=( d[3](s+100));d[2](d[4].slice(9))
At 8/6/06 10:28 AM, johnfn wrote: That's pretty cool. The problem is that not everyone already has a web cam, making games made with this kind of useless.
It's still good for the people that do have webcams. Just like flash is good for people that do have flash player.
f
Well , it didn't worked neither here!
I think i'm doing something rong... altough there are no errors in the action script...
But it would be cool if you could make a flash game where the player needs to have a webcam to play it then you could record and save it on your computer how the player is playing in the game!!!! mwuahahahahaha that would be very cool! Imaging that Tom Fulp was testing out the game it was some dumb ass game where you needed to imitate something!!
and its recorded and saved on your computer!! you could send it out to the whole internet!!
OK.. I'm over reacting now..
So how would you use this to detect WHERE the movement is, in order to make a webcam game?
Or have I completely missed the point :p
...
At 2/1/07 05:29 PM, edit-undo wrote: So how would you use this to detect WHERE the movement is, in order to make a webcam game?
Or have I completely missed the point :p
the simplest method for static cameras, is to add together the difference of each channel for each pixel between current and previous picture, and then if its above a threshold, motion has occured.
to find WHERE the movement is, you can simply apply the same thing to samples of the image, lets say 20x20 samples, obviously smaller samples, more precise measurement