moin,
ich hab mal versucht so ein fake-3d-planetensystem zu programmieren... aber verzweiffle schon wieder mal an einem simplen mathematischen denkfehler...
anbei mein script:
PHP-Code:
setToMitte = function () {
_global.faktor = 100;
_global.mittelXPos = Stage.width/2;
_global.mittelYPos = Stage.height/2;
};
setToMitte();
//
createPlanet = function (myName, myXPos, myYPos, myZPos) {
this.attachMovie("mc", myName, myZPos);
this[myName].name = myName;
this[myName].myXPos = myXPos;
this[myName].myYPos = myYPos;
this[myName].myZPos = myZPos;
//
this[myName].onRelease = function() {
setToMitte();
// IRGENWIE LÄUFT DIE FORMEL NICH
//_global.mittelXPos = (_global.mittelXPos-this.myXPos*(this.myZPos/_global.faktor))+plusX;
//_global.mittelYPos = (_global.mittelYPos-this.myYPos*(this.myZPos/_global.faktor))+plusY;
};
//
this[myName].onEnterFrame = function() {
mainSpeed = 4;
// 3D bewegung
newXPos = _global.mittelXPos+(this.myXPos+(_global.mittelXPos-_xmouse))*this.myZPos/_global.faktor;
myXDIF = newXPos-this._x;
this._x += myXDIF/mainSpeed;
//
newYPos = _global.mittelYPos+(this.myYPos+(_global.mittelYPos-_ymouse))*this.myZPos/_global.faktor;
myYDIF = newYPos-this._y;
this._y += myYDIF/mainSpeed;
// Scalierung
newScale = this._yscale=this.myZPos/(_global.faktor/100);
myScaleDIF = newScale-this._yscale;
this._xscale = this._yscale += myScaleDIF/mainSpeed;
//
};
};
//
createPlanet("mc1", 100, 100, 50);
createPlanet("mc2", -200, 600, 80);
createPlanet("mc3", 300, 100, 120);
diese erzeugt drei "planeten"... die der mouse fake-3D-mäßig folgen. ich möchte aber jetzt noch zusätzlich daß der planet der geklickt wird in die mitte spring also der mittelpunkt verschoben wird...
ABER ICH KRIEGS NICHT HIN!
Hätte doch in Mathematik besser aufpassen sollen. kann mir jemand helfen?