ciao a tutti,
ho realizzato un mc che con l'avvicinarsi del cursore si sposta per non essere toccato, però vorrei dargli anche un senso di prospettiva, di profondità al movimento, cioè quando l'oggetto va in alto contemporaneamente si rimpicciolisce e quando scende ritorna allo stato originario, lo script è questo, ma cosa devo aggiungere al codice?:
Stage.scaleMode = 'noScale';
k = .95;
mc.onEnterFrame = function() {
dx = this._x-_xmouse;
dy = this._y-_ymouse;
if (this.hitTest(_xmouse, _ymouse, true)) {
a = Math.atan2(dy, dx);
this.vx += (Math.cos(a)*250-dx)/5;
this.vy += (Math.sin(a)*250-dy)/5;
}
this.vx *= k;
this.vy *= k;
this._x += this.vx;
this._y += this.vy;
if (this._x+this._width/2>=bordi._x+bordi._width/2) {
this.vx=-this.vx, this._x=bordi._x+bordi._width/2-this._width/2;
}
if (this._x-this._width/2<=bordi._x-bordi._width/2) {
this.vx=-this.vx, this._x=bordi._x-bordi._width/2+this._width/2;
}
if (this._y+this._height/2>=bordi._y+bordi._height/2) {
this.vy=-this.vy, this._y=bordi._y+bordi._height/2-this._height/2;
}
if (this._y-this._height/2<=bordi._y-bordi._height/2) {
this.vy=-this.vy, this._y=bordi._y-bordi._height/2+this._height/2;
}
};

Rispondi quotando