craigguthrie
11-24-2002, 01:28 PM
hi , Im trying to get a ship class to get a "shot" class to fire a shot movie clip, but I have two seperate ships but want to use the shot class for them both, I have tried this:onClipEvent (load) {
if (String(_name) != "shot") {
cannonLength = 1;
turretpoint = _root["ship1"&&"ship2"]._rotation+_root["ship1"&&"ship2"]._rotation;
angle = (turretpoint/360)*2*Math.PI;
xcomponent = cannonLength*Math.sin(angle);
ycomponent = -cannonLength*Math.cos(angle);
_x = xcomponent+_root["ship1"&&"ship2"]._x;
_y = ycomponent+_root["ship1"&&"ship2"]._y;
xmove = (xcomponent/cannonLength)*10;
ymove = (ycomponent/cannonLength)*10;
}
}
but it doesnt work, could anyone also maybe tell me why my shot isnt unloading when it hits the ship? I currently have this code:
onClipEvent (enterFrame) {
if (String(_name) != "shot") {
_x += xmove;
_y += ymove;
if (_root["ship1||ship2"].hitTest(_x, _y, true)) {
_root.d++;
_root.attachMovie ("ground","d"+_root.d,(_root.d%100)+500);
_root["d"+_root.d]._x = _x;
_root["d"+_root.d]._y = _y;
_root["d"+_root.d]._xscale = 150;
_root["d"+_root.d]._yscale = 150;
unloadMovie (_root["ship1"||"ship2"]);
unloadMovie (this);
}
}
}
Much a ppreciated craig
if (String(_name) != "shot") {
cannonLength = 1;
turretpoint = _root["ship1"&&"ship2"]._rotation+_root["ship1"&&"ship2"]._rotation;
angle = (turretpoint/360)*2*Math.PI;
xcomponent = cannonLength*Math.sin(angle);
ycomponent = -cannonLength*Math.cos(angle);
_x = xcomponent+_root["ship1"&&"ship2"]._x;
_y = ycomponent+_root["ship1"&&"ship2"]._y;
xmove = (xcomponent/cannonLength)*10;
ymove = (ycomponent/cannonLength)*10;
}
}
but it doesnt work, could anyone also maybe tell me why my shot isnt unloading when it hits the ship? I currently have this code:
onClipEvent (enterFrame) {
if (String(_name) != "shot") {
_x += xmove;
_y += ymove;
if (_root["ship1||ship2"].hitTest(_x, _y, true)) {
_root.d++;
_root.attachMovie ("ground","d"+_root.d,(_root.d%100)+500);
_root["d"+_root.d]._x = _x;
_root["d"+_root.d]._y = _y;
_root["d"+_root.d]._xscale = 150;
_root["d"+_root.d]._yscale = 150;
unloadMovie (_root["ship1"||"ship2"]);
unloadMovie (this);
}
}
}
Much a ppreciated craig