Форум 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=115328)

darkvam 26.08.2008 20:32

Нумерованная переменная
 
здравствуйте. боюсь что я опять с глупым вопросо, но всё же задам его.
Можно ли переменную типа, num нумеровать как мувиклипы?

вот код:

Код:

        //Стрельба;
        if (Key.isDown(Key.SPACE)) {
                shootreload++;
                if (shootreload>=_global.shootreload) {
                        plazmanum += 1;
                        _root.attachMovie("PlazmaShip", "PlazmaShip"+plazmanum, this.getNextHighestDepth(), {_x:tank._x, _y:tank._y});
                        _root["PlazmaShip"+plazmanum]._rotation = tank._rotation;
                        _root["PlazmaShip"+plazmanum].gotoAndPlay(2);
                        shootreload = 0;
                        lasttankrot = tank._rotation;
                }
        } else {
                shootreload = 10;
        }
        _root["PlazmaShip"+plazmanum].onEnterFrame = function() {
                if (this._currentframe<5) {
                        this._rotation = tank._rotation;
                        this._x = tank._x;
                        this._y = tank._y;
                } else {
                        this._x += 15*Math.cos(lasttankrot*(Math.PI/180));
                        this._y += 15*Math.sin(lasttankrot*(Math.PI/180));
                        if (this._x>1024 || this._x<0 || this._y>678 || this._y<0) {
                                this.unloadMovie();
                        }
                }
        };

в данном случае я создаю пули, и для каждой пули выполняется действие передвижения относительно того угла поворота коробля при котором был произведён выстрел (переменная lasttankrot). Дело в том, что эта переменная не должна быть одна и должна быть привязана к определённому мувиклипу пули в котором сейчас выполняется действие.
(наверное опять ничего не понятно? если так, то спрашивайте и я попытаюсь сказать умнее, извините меня за мой корявый язык.)

BBOY Ильич 26.08.2008 21:10

попробуйте так
Код:

//Стрельба;
        if (Key.isDown(Key.SPACE)) {
                shootreload++;
                if (shootreload>=_global.shootreload) {
                        plazmanum += 1;
                        _root.attachMovie("PlazmaShip", "PlazmaShip"+plazmanum, this.getNextHighestDepth(), {_x:tank._x, _y:tank._y});
                        _root["PlazmaShip"+plazmanum]._rotation = tank._rotation;
                        _root["PlazmaShip"+plazmanum].gotoAndPlay(2);
                        shootreload = 0;
                        _root["PlazmaShip"+plazmanum].lasttankrot = tank._rotation;
                }
        } else {
                shootreload = 10;
        }
        _root["PlazmaShip"+plazmanum].onEnterFrame = function() {
                if (this._currentframe<5) {
                        this._rotation = tank._rotation;
                        this._x = tank._x;
                        this._y = tank._y;
                } else {
                        this._x += 15*Math.cos(this.lasttankrot*(Math.PI/180));
                        this._y += 15*Math.sin(this.lasttankrot*(Math.PI/180));
                        if (this._x>1024 || this._x<0 || this._y>678 || this._y<0) {
                                this.unloadMovie();
                        }
                }
        };

Код:

if (this._x>1024 || this._x<0 || this._y>678 || this._y<0) {
может все-таки лучше использовать Stage.width и Stage.height?

darkvam 26.08.2008 22:05

BBOY Ильич
большое спасибо, помогло!)))

а как можно использовать Stage.width и Stage.height? извините за вопрос конечно, но всё же)))

BBOY Ильич 26.08.2008 22:16

я так понимаю, 1024 и 678 (может все же 768?) являются размерами сцены. А что будет, если я потяну за краешек окошка? Правильно. Сцена станет больше, а цифры не изменятся... А Stage.width и Stage.height всегда будут возвращать точные размеры окна.

darkvam 27.08.2008 05:36

BBOY Ильич
всё правильно! ещё раз спасибо большое)))


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

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