tgelston
April 18th, 2003, 12:41 PM
I have a problem running a hitTest on a duplicated object - it doesnt work.
Here is what I have so far, all of this code is in the onload of a movie that is just holding my code-
//Makes the rocks
function dupRockFunction() {
var chance = Math.round(random(25));
if (chance == 11) {
rockdepth++;
_root.spaceRock = this.duplicateMovieClip("_root.rock"+rockdepth, rockdepth);
_root.spaceRock._y = random(400);
_root.spaceRock._xscale = random(50)+30;
_root.spaceRock._yscale = _root.spaceRock._xscale;
_root.spaceRock._rotation = random(360);
}
//Moves the rocks
function moveRemoveRockFunction() {
//moves clip to left
this._x -= rockSpeed;
//removes clip when off stage
if (this._x<20) {
this.removeMovieClip();
}
if (this.hitTest(_root.ship)) {
trace("Hello");
}
}
I call both functions in the enterframe section of the same MC
_root.spaceRock.onEnterFrame = moveRemoveRockFunction;
_root.rock.onEnterFrame = dupRockFunction;
Why doesnt that hittest work? if "this" works to move them across the stage why doesnt it also see the contact of the two MCs??
I am new to functions - slowly learning so if you see anything else major I should change please let me know.
Thanks,
T
Here is what I have so far, all of this code is in the onload of a movie that is just holding my code-
//Makes the rocks
function dupRockFunction() {
var chance = Math.round(random(25));
if (chance == 11) {
rockdepth++;
_root.spaceRock = this.duplicateMovieClip("_root.rock"+rockdepth, rockdepth);
_root.spaceRock._y = random(400);
_root.spaceRock._xscale = random(50)+30;
_root.spaceRock._yscale = _root.spaceRock._xscale;
_root.spaceRock._rotation = random(360);
}
//Moves the rocks
function moveRemoveRockFunction() {
//moves clip to left
this._x -= rockSpeed;
//removes clip when off stage
if (this._x<20) {
this.removeMovieClip();
}
if (this.hitTest(_root.ship)) {
trace("Hello");
}
}
I call both functions in the enterframe section of the same MC
_root.spaceRock.onEnterFrame = moveRemoveRockFunction;
_root.rock.onEnterFrame = dupRockFunction;
Why doesnt that hittest work? if "this" works to move them across the stage why doesnt it also see the contact of the two MCs??
I am new to functions - slowly learning so if you see anything else major I should change please let me know.
Thanks,
T