Matthias Kannengiesser
Erfahrenes Mitglied
Hi Folks,
Hier was zum ausprobieren - hiermit lassen sich Spielfelder einfach umsetzen.
Beispiel:
http://www.flashangel.de/mx/fsconstrain.swf
Download:
http://www.flashstar.de/tutlist/
Hier was zum ausprobieren - hiermit lassen sich Spielfelder einfach umsetzen.
PHP:
MovieClip.prototype.panicMouse = function(distanz, tempo, besch){
var xdiff = this._parent._xmouse - this._x;
var ydiff = this._parent._ymouse - this._y;
var abstand = Math.sqrt(xdiff*xdiff + ydiff*ydiff);
if (abstand < distanz){
var winkel = Math.atan2(ydiff, xdiff);
if (besch) tempo = Math.min(tempo, besch*distanz/abstand);
this._x -= Math.cos(winkel)*tempo;
this._y -= Math.sin(winkel)*tempo;
}
}
MovieClip.prototype.constrainTo = function(cF){
var tb = this.getBounds();
if (typeof cF == "movieclip") cF = cF.getBounds(this._parent);
if (this._x + tb.xmin < cF.xmin) this._x = cF.xmin + tb.xmax;
if (this._x + tb.xmax > cF.xmax) this._x = cF.xmax + tb.xmin;
if (this._y + tb.ymin < cF.ymin) this._y = cF.ymin + tb.ymax;
if (this._y + tb.ymax > cF.ymax) this._y = cF.ymax + tb.ymin;
}
Beispiel:
http://www.flashangel.de/mx/fsconstrain.swf
Download:
http://www.flashstar.de/tutlist/