-
God
controling duplicated movie clips
hi, i'm developing a shooting game, in which i am duplicating the bullet (ship) to shoot at a guy.
i have an array as you can see here.
Code:
for (i=1; i<=50; i++) {
_root.ship[i] = new shipparent();
duplicateMovieClip(_root.ship, "ship"+[i], i);
_root.ship2._x = _root.gun._x;
_root.ship2._y = _root.gun._y;
}
}
in stead of using ship2, i would like to use what ever is the next unused ship... and im not quite sure how to do this.
does any body else know?
thanks a bunch
-
Do you mean...
Code:
for (i=1; i<=50; i++) {
duplicateMovieClip(_root.ship, "ship"+i, i);
_root["ship"+i]._x = _root.gun._x;
_root["ship"+i]._y = _root.gun._y;
}
??
-
God
it didn't work... im not exactly sure why...
but i think it be better if i used a varible to control which ship to use...
i tried setting shipNum = 2
and then using this code but it didnt work...
for (i=1; i<=50; i++) {
_root.ship[i] = new shipparent();
duplicateMovieClip(_root.ship, "ship"+[i], i);
_root.ship[shipNum] ._x = this._x;
_root.ship[shipNum] ._y = this._y;
}
is there any way to do this?
-
try _root["ship"+ shipNum]._x instead. Also add shipNum++ inside your for loop.
this will give you essentially the same as the previous example. the last one should have worked.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|