Zurück   Flashforum > Flash > ActionScript > Spielkonzepte und Spieleprogrammierung

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 10-09-2007, 08:07   #1 (permalink)
Neuer User
 
Registriert seit: Oct 2001
Beiträge: 166
objekte fliegen aus zufall in einem raum? as3?

Hallo Zusammen,

hat jemand zufällig ein script oder einen ansatz script in as3, wo objekte (movie clips oder sprites etc.) aus zufall in einem definierten Raum (viereckig) in diesem herumfliegen und am rand wieder abprallen und umdrehen? Ich muss die anzahl der Objecte scriptgesteuert befüllen können und ganz wichtig auch die Geschwindigkeit muss regulierbar oder sogar dynamisch steigerbar sein.

Ich bin in as3 noch überhaupt nicht so fitt... in as2 wäre das kein problem für mich.

Wäre super wenn mir da jemand helfen könnte.

liebe grüße
mikolo ist offline   Mit Zitat antworten
Alt 10-09-2007, 08:20   #2 (permalink)
FlashLove@FirstSight
 
Benutzerbild von FLASHStyler
 
Registriert seit: Feb 2003
Beiträge: 2.460
Zeig doch mal was du an AS2 Code dafür hast...
__________________
www.johannes-erhardt.com | blog | xing me baby
FLASHStyler ist offline   Mit Zitat antworten
Alt 10-09-2007, 08:24   #3 (permalink)
Neuer User
 
Registriert seit: Oct 2001
Beiträge: 166
glaubst mir wohl nicht

hier der code... des hab ich mal für eine fliegende navigation gemacht für flashplayer 6....noch

da kleben dann auch die buttons an der mouse wenn man in die nähe kommt.

HTML-Code:
stop();
//*************************
//initialising variables
//*************************
stageRight = 540;
stageBottom = 457;
// (aus irgendeinem grund sind es 40 mehr als di spielwiese????)
//*************************
//constrain movement to the stage
//*************************
MovieClip.prototype.checkStage = function() {
	radius = this._width/2;
	left = this._x-radius;
	top = this._y-radius;
	right = this._x+radius;
	bottom = this._y+radius;
	if (left<0) {
		this._x = 0+radius;
		this.speedX *= -1;
	} else if (right>stageRight) {
		this._x = stageRight-radius;
		this.speedX *= -1;
	}
	if (top<-40) {
		this._y = -40+radius;
		this.speedY *= -1;
	} else if (bottom>stageBottom) {
		this._y = stageBottom-radius;
		this.speedY *= -1;
	}
};
function starte_navifly() {
	//trace("bin in starte_navifly");
	//*************************
	//setting clips on stage 
	//*************************
	x_array_positionen = new Array("", "116.1", "154.2", "133.6", "91.2", "136.2", "175.6", "205.7");
	y_array_positionen = new Array("", "28.9", "65.5", "101.5", "136.8", "173.8", "210.8", "246.2");
	maxClips = 6;
	while (i<=maxClips) {
		i++;
		
		newClip = this.attachMovie("button"+i, "button"+i, i+100);
		newClip._x = x_array_positionen[i];
		newClip._y = y_array_positionen[i];
		////Geschwindigkeit der fliegenden Buttons
		newClip.speedX = Math.random(6)-2;
		newClip.speedY = Math.random(6)-2;
		//newClip.speedX = 20;
		//newClip.speedY = 20;
		//trace (newClip.speedX);
		//trace (newClip.speedY);
		newClip.id = i;
		//initialising variables
		startX = this._x;
		startY = this._y;
		minDif = 6;
		maxDif = 50;
		friction = 4;
		newClip.onEnterFrame = function() {
			//mouse distance
			diffX = this._xmouse;
			diffY = this._ymouse;
			diff = Math.sqrt((diffX*diffX)+(diffY*diffY));
			//different action depending on mouse distance
			welcher_button = _root.welcher_button;
			if (_root.move == "ja") {
				if (hitTest(_root._xmouse, _root._ymouse, false) && (this._name == "button"+welcher_button)) {
					///wird noch nicht gebraucht
					_root.var_hittest = "1";
					/////////
					if (diff<minDif) {
						this._x = _xmouse;
						this._y = _ymouse;
					} else if (diff>maxDif) {
						diffX = startX-_x;
						diffY = startY-_y;
						///wird noch nicht gebraucht
						_root.var_hittest = "0";
						/////////
					}
				} else {
					diffX = startX-_x;
					diffY = startY-_y;
				}
				//movement fuer alle objekte...bleibt kleben je nach friction
				this._x += diffX/friction;
				this._y += diffY/friction;
				////movement fuer alle Objekte auf der bühne....ständige bewegung
				this._x += this.speedX;
				this._y += this.speedY;
			} else {
				//trace("navipunkte müssen auf position gebracht werden...und delete enterframe");
				button1._x = 116.1;
				button1._y = 28.9;
				button2._x = 154.2;
				button2._y = 65.5;
				button3._x = 133.6;
				button3._y = 101.5;
				button4._x = 91.2;
				button4._y = 136.8;
				button5._x = 136.2;
				button5._y = 173.8;
				button6._x = 175.6;
				button6._y = 210.8;
				button7._x = 205.7;
				button7._y = 246.2;
				//delete this.onEnterFrame();
			}
			////stage check
			this.checkStage();
			//trace(this._name);
		};
		newClip.onRollover = function() {
			//trace(this._name);
			if (this._name == "button1") {
				_root.welcher_button = "1";
			}
			if (this._name == "button2") {
				_root.welcher_button = "2";
				_root.mc_schmetterling_ani.gotoAndPlay("ani"+_root.welche_ani);
			}
			if (this._name == "button3") {
				_root.welcher_button = "3";
			}
			if (this._name == "button4") {
				_root.welcher_button = "4";
			}
			if (this._name == "button5") {
				_root.welcher_button = "5";
			}
			if (this._name == "button6") {
				_root.welcher_button = "6";
			}
			if (this._name == "button7") {
				_root.welcher_button = "7";
			}
		};
		newClip.onRelease = function() {
			if (this._name == "button1") {
				_root.gehe_zu_movie = "mc_wir_ueber_uns";
				_root.move = "no";
				gehe_zu_movie = "mc_wir_ueber_uns";
				bin_in_movie = _root.bin_in_movie;
				_root.movie_wechsel(bin_in_movie, gehe_zu_movie);
			}
			if (this._name == "button2") {
				_root.gehe_zu_movie = "mc_kollektion";
				_root.move = "no";
				gehe_zu_movie = "mc_kollektion";
				bin_in_movie = _root.bin_in_movie;
				_root.movie_wechsel(bin_in_movie, gehe_zu_movie);
			}
			if (this._name == "button3") {
				_root.gehe_zu_movie = "mc_accessoires";
				_root.move = "ja";
				gehe_zu_movie = "mc_accessoires";
				bin_in_movie = _root.bin_in_movie;
				_root.movie_wechsel(bin_in_movie, gehe_zu_movie);
			}
			if (this._name == "button4") {
				_root.gehe_zu_movie = "mc_franchise";
				_root.move = "no";
				gehe_zu_movie = "mc_franchise";
				bin_in_movie = _root.bin_in_movie;
				_root.movie_wechsel(bin_in_movie, gehe_zu_movie);
			}
			if (this._name == "button5") {
				_root.lade_laender();
				_root.gehe_zu_movie = "mc_fachhaendler";
				_root.move = "no";
				gehe_zu_movie = "mc_fachhaendler";
				bin_in_movie = _root.bin_in_movie;
				_root.movie_wechsel(bin_in_movie, gehe_zu_movie);
			}
			if (this._name == "button6") {
				_root.gehe_zu_movie = "mc_impressum";
				_root.move = "no";
				gehe_zu_movie = "mc_impressum";
				bin_in_movie = _root.bin_in_movie;
				_root.movie_wechsel(bin_in_movie, gehe_zu_movie);
			}
			if (this._name == "button7") {
				_root.gehe_zu_movie = "mc_kontakt";
				_root.move = "ja";
				gehe_zu_movie = "mc_kontakt";
				bin_in_movie = _root.bin_in_movie;
				_root.movie_wechsel(bin_in_movie, gehe_zu_movie);
			}
		};
	}
}
starte_navifly();
mikolo ist offline   Mit Zitat antworten
Antwort

Lesezeichen

Themen-Optionen
Ansicht

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks sind an
Pingbacks sind an
Refbacks sind an



Alle Zeitangaben in WEZ +1. Es ist jetzt 18:22 Uhr.

Domains, Webhosting & Vserver von Host Europe
Unterstützt das Flashforum!
Adobe User Group


Copyright ©1999 – 2012 Marc Thiele