posiziona sullo stage il tuo fantasma e chiamalo con istanza
"ghost"
codice:
ghost._visible=0
// dim dello stage
Est=Stage.width
Sud=Stage.height
/*
creo funzione show_ghost() per:
- apparire in posizione random
creo funzione move_ghost() per:
- muoversi avanti in modalità random
- fare il flip orizzontale
- muoversi indietro in modalità random
*/
positivo=true
function move_ghost(){
if(positivo){
ghost.IncX=random(20)
ghost.IncY=random(20)
ghost.onEnterFrame=function(){
if(this._x < _level0.Est){
this._x+=this.IncX
}else{
this._xscale*=-1;
delete this.onEnterFrame;
_level0.positivo=!_level0.positivo;
_level0.move_ghost()
}
if(this._y < _level0.Sud){
this._y+=this.IncY
}else{
this._xscale*=-1;
delete this.onEnterFrame;
_level0.positivo=!_level0.positivo;
_level0.move_ghost()
}
}
}
if(!positivo){
ghost.IncX=random(20)*-1
ghost.IncY=random(20)*-1
ghost.onEnterFrame=function(){
trace(this._x + " / " + this._y)
if(this._x > 0){
this._x+=this.IncX
}else{
this._xscale*=-1;
delete this.onEnterFrame;
_level0.positivo=!_level0.positivo;
_level0.move_ghost()
}
if(this._y > 0){
this._y+=this.IncY
}else{
this._xscale*=-1;
delete this.onEnterFrame;
_level0.positivo=!_level0.positivo;
_level0.move_ghost()
}
}
}
}
function show_ghost(){
ghost._x=Math.random(Est)
ghost._y=Math.random(Sud)
ghost._visible=1
move_ghost()
}
show_ghost()
Ciao