Форум Flasher.ru

Форум Flasher.ru (http://www.flasher.ru/forum/index.php)
-   ActionScript 1.0/2.0 (http://www.flasher.ru/forum/forumdisplay.php?f=93)
-   -   Движение к мувиклипу (http://www.flasher.ru/forum/showthread.php?t=97948)

Load_er 03.07.2007 15:30

Движение к мувиклипу
 
можете ли поднинуть исходник оч нужно...я просто сам не знаю нак ето сделать во флеше...
есть квадратное поле.В каждом углу которого есть объект.
Каждый объект двидеться к другому обьекту по часовой стрелки причем он движется к нему всегда...
http://keep4u.ru/imgs/b/070703/39596dd6d1e35fb043.jpg
Тоесть красный всегда движиться по прямой к синему ниний к зеленому зеленый к желтому а желтый к красному...все должны двигаться с одинаковой скорости...
Если не трудно можно еще добавить что за каждым обьектом оставалась его траектория...

Север 03.07.2007 15:39

Матиматику расчитывай будт тебе клип... Сидеть и строить мат модель за тебя - в раздел Вакансии.

divinus 03.07.2007 16:54

Север, да ладно! какая тут математика? :)
держи простенький пример, если действительно надо, разберешься что к чему. (извини за "выразительность кода", писал 5 минут...)
Код:

var clips:Number = 200;// сколько клипов должно быть
///////////////////////////////////////////////////////////////////////////////
function draw_clip(inst_name:String, x_pos:Number, y_pos:Number, target:MovieClip):MovieClip {
        var target_path_mc = target;
        var temp_movie_clip_mc:MovieClip = target_path_mc.createEmptyMovieClip(inst_name, target_path_mc.getNextHighestDepth());
        temp_movie_clip_mc._x = x_pos;
        temp_movie_clip_mc._y = y_pos;
        temp_movie_clip_mc.lineStyle(1,random(16777215),100);
        temp_movie_clip_mc.beginFill(random(16777215),100);
        temp_movie_clip_mc.moveTo(0,0);
        temp_movie_clip_mc.lineTo(10,0);
        temp_movie_clip_mc.lineTo(10,10);
        temp_movie_clip_mc.lineTo(0,10);
        temp_movie_clip_mc.lineTo(0,0);
        temp_movie_clip_mc.endFill();
        return temp_movie_clip_mc;
}
function motor() {
        if ((this.this_index+1) == this.clips_array.length) {               
                len_x = this.clips_array[0]._x;
                len_y = this.clips_array[0]._y;
        } else {               
                len_x = this.clips_array[this.this_index+1]._x;
                len_y = this.clips_array[this.this_index+1]._y;
        }
        if (this._x>len_x) {
                if (Math.round(this._x-len_x)>1) {
                        this._x -= (this._x-len_x)/3;
                } else {
                        this._x = len_x;
                }
        } else {
                if (Math.round(len_x-this._x)>1) {
                        this._x += (len_x-this._x)/3;                       
                } else {
                        this._x = len_x;
                }
        }
        if (this._y>len_y) {
                if (Math.round(this._y-len_y)>1) {
                        this._y -= (this._y-len_y)/3;
                } else {
                        this._y = len_y;
                }
        } else {
                if (Math.round(len_y-this._y)>1) {
                        this._y += (len_y-this._y)/3;
                } else {
                        this._y = len_y;
                }
        }

}
var clips_array:Array = new Array();
for (var i = 0; i<clips; i++) {
        clips_array[i] = draw_clip("red"+random(300), random(500), random(500), _root);
}
for (var i = 0; i<clips_array.length; i++) {
        clips_array[i].clips_array = clips_array;
        clips_array[i].this_index = i;
        clips_array[i].onEnterFrame = _root.motor;
}



Часовой пояс GMT +4, время: 13:17.

Copyright © 1999-2008 Flasher.ru. All rights reserved.
Работает на vBulletin®. Copyright ©2000 - 2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Администрация сайта не несёт ответственности за любую предоставленную посетителями информацию. Подробнее см. Правила.