webcam game

gius

Nuovo Utente
2 Lug 2009
2
0
0
salve a tutti,
ho da poco scoperto flash 8
io desidero costruire un piccolo webcam game con Flash 8,
stavo sperimentando un tutorial sul controllo con la webcam del movimento,
praticamente una sfera va da sinistra a destra
e desidererei che al movimento scomparisse,
con il manuale di ActionScript mi è parso questo il sistema migliore:

ball_mc.removeMovieClip()

ma non capisco come faccio ad inserirlo

var root:MovieClip = this;
//
// 1. Get your webcam on the screen
//
var video_vobj:Video;
var cam:Camera = Camera.get();
video_vobj.attachVideo(cam);
//
// 2. the activityLevel property
//
this.onEnterFrame = function() {
var actLevel:Number = cam.activityLevel;
root.act_txt.text = "activity level = "+actLevel;
};
cam.onActivity = function(isActive:Boolean) {
};
//
// 3. The BitmapData class
//
import flash.display.BitmapData;

var screenS = new BitmapData(cam.width, cam.height);

snap1_btn.onRelease = function() {
screenS.draw(video_vobj);
root.attachBitmap(screenS, 1);
};

var videoX:Number = video_vobj._x;
var videoY:Number = video_vobj._y;
var videoW:Number = video_vobj._width;
var videoH:Number = video_vobj._height;


snap2_btn.onRelease = function() {
screenS.draw(video_vobj);
var holder:MovieClip = root.createEmptyMovieClip("holder", 1);
holder.attachBitmap(screenS, 1);
holder._x = videoX;
holder._y = videoY;
holder._width = videoW;
holder._height = videoH;
};

release_btn.onRelease = function() {
root.holder.removeMovieClip()
};
//
// 4. Hit detection : Setup
//
var speed:Number = 2;
function moveBall() {
ball_mc._x += speed;
if (ball_mc._x>(videoX+30+videoW)) {
ball_mc._x = videoX-30;
ball_mc._y = videoY+random(videoH-60)+30;
}
}
ball_mc.onEnterFrame = moveBall;
//
// 5. Hit detection
//
var sizeDif:Number = videoW/cam.width;

var now = new BitmapData(cam.width, cam.height);
var before = new BitmapData(cam.width, cam.height);

function hitDetect() {

var ballX:Number = (ball_mc._x-videoX)/sizeDif
var ballY:Number = (ball_mc._y-videoY)/sizeDif

now.draw(video_vobj)

var valNow:Number = (now.getPixel(ballX, ballY) >> 16 & 0xFF);
var valBefore:Number = (before.getPixel(ballX, ballY) >> 16 & 0xFF);

if (valNow>valBefore+30 || valNow<valBefore-30) {
(trace "hit")
if (ball_mc._currentframe == 1)
ball_mc.gotoAndPlay(2)
}

before.draw(video_vobj)
}

var intervalID:Number = setInterval(hitDetect, 20);



potrebbe qualcuno gentilmente aiutarmi a capire?

grazie
 
Discussioni simili
Autore Titolo Forum Risposte Data
L webcam PHP 0
Beppe2 webcam con browser Windows e Software 1
S [VENDO] Sito web adult con webcam Compravendita siti e domini 0
A [Javascript] Salvataggio immagine da webcam Javascript 2
A [HTML] Invio Immagine da WebCam a Database MySQL IP Cam e Videosorveglianza 10
N webcam ip da remoto con linkem IP Cam e Videosorveglianza 0
francabbestia [Javascript] Scattare una foto da webcam quando avviene un evento Javascript 1
F WebCam Streaming sul mio sito Javascript 0
C carica foto da webcam su mysql tramite PHP PHP 2
B codice php x webcam PHP 1
B Aiuto script x webcam PHP 0
S Webcam "cotier" dall'esterno non funziona IP Cam e Videosorveglianza 7
S Webcam IP IP Cam e Videosorveglianza 1
Z Skype desktop in Windows 8: webcam nera Windows e Software 0
F webcam wifi ip IP Cam e Videosorveglianza 4
P script per avviare webcam Javascript 0
A Webcam HTML5 HTML e CSS 1
P Ip WebCam IP Cam e Videosorveglianza 30
P Webcam Discussioni Varie 7
F Salve, trasmettere la webcam online? HTML e CSS 0
M webcam ip su internet PHP 22
micio86 Webcam applet Java 0
micio86 Live webcam streaming Guadagnare col Sito 1
M Streaming da webcam su di un sito HTML e CSS 1
P joomla: visualizzazione webcam dopo pagamento [era:Creazione sito particolare. Aiuto] Joomla 5
K Acquisizione da webcam e scanner Flash 0
K Acquisizione da webcam e scanner PHP 2
C Cosa serve per una webcam? HTML e CSS 3
D WebCam sulla rete Lan Reti LAN e Wireless 0
WorldWideWeb Webcam su Zenwalk Linux e Software 0
G Power Point 2003 e WebCam Windows e Software 4
M Webcam Ip Discussioni Varie 0
M webcam e msn Hardware 0
S Aggiornare immagine webcam PHP 1
D meetty.com nuova free webcam chat Presenta il tuo Sito 1
WorldWideWeb Uso webcam nel proprio sito HTML e CSS 5
M Catturare istantanea da webcam Flash 0
G programmi webcam Windows e Software 2
N VIDEO da WEBCAM sul sito HTML e CSS 2
D sito con webcam Leggi, Normative e Fisco 1
D Come mettere una webcam con reload nel sito html HTML e CSS 3
T Programma per registrare da webcam Windows e Software 2
D SALVARE video di WEBCAM Discussioni Varie 3
P [PHP] Browser game, aiuto a tempo libero. Offerte e Richieste di Lavoro e/o Collaborazione 0
M Browser Game Offerte e Richieste di Lavoro e/o Collaborazione 1
C Html5 game HTML e CSS 1
S GAME per MOBILE - Collaborazione Offerte e Richieste di Lavoro e/o Collaborazione 2
W Contatti con game/app developers..come inziare? (Music Composer) Sviluppo app per iOS 1
T Programmazione di un browser game Programmazione 1
M Browser game Discussioni Varie 3

Discussioni simili