theeggman85
04-27-2006, 11:35 PM
In my game, you can click 1 of 2 movie-clip ships. The first ship has this on it:
on(release){
_root.shipType = 1;
_root.play();
}
and the second has this on it:
on(release){
_root.shipType = 2;
_root.play();
}
then when it plays, it eventually hits a frame on another scene that has:
_root.spawnspeed = 3000;
_root.speed = 4;
if(_root.shipType = 1){
_root.bulletSpeed = 20;
_root.bulletSpawn = 700;
_root.attachMovie("ship1", "ship", 0);
}
if(_root.shipType = 2){
_root.bulletSpeed = 20;
_root.bulletSpawn = 700;
_root.attachMovie("ship2", "ship", 0);
}
and then after that frame is a stop command. The problem is no matter which ship is clicked, it always attaches the second one. The first is exported as ship1, and the second as ship2. Does anyone know what is happening here? Also, when I push spacebar, it should shoot a bullet, but instead the ship disappears. the shooting used to work when i didn't attach the ship with actionscript, but when I dragged the ship onto the stage it did. Here is the shooting code.
onClipEvent(enterFrame){
this.onEnterFrame = function () {
if (Key.isDown(Key.SPACE)) {
if (!fired) {
fireBullet();
}
}
}
function allowFire () {
fired = false;
}
function fireBullet() {
_root.attachMovie("bullet", "bullet" + b, b);
_root["bullet" + b]._x = this._x;
_root["bullet" + b]._y = this._y - 30;
fired = true;
setTimeout(allowFire, _root.bulletSpawn);
}
}
Thanks if you can help!
on(release){
_root.shipType = 1;
_root.play();
}
and the second has this on it:
on(release){
_root.shipType = 2;
_root.play();
}
then when it plays, it eventually hits a frame on another scene that has:
_root.spawnspeed = 3000;
_root.speed = 4;
if(_root.shipType = 1){
_root.bulletSpeed = 20;
_root.bulletSpawn = 700;
_root.attachMovie("ship1", "ship", 0);
}
if(_root.shipType = 2){
_root.bulletSpeed = 20;
_root.bulletSpawn = 700;
_root.attachMovie("ship2", "ship", 0);
}
and then after that frame is a stop command. The problem is no matter which ship is clicked, it always attaches the second one. The first is exported as ship1, and the second as ship2. Does anyone know what is happening here? Also, when I push spacebar, it should shoot a bullet, but instead the ship disappears. the shooting used to work when i didn't attach the ship with actionscript, but when I dragged the ship onto the stage it did. Here is the shooting code.
onClipEvent(enterFrame){
this.onEnterFrame = function () {
if (Key.isDown(Key.SPACE)) {
if (!fired) {
fireBullet();
}
}
}
function allowFire () {
fired = false;
}
function fireBullet() {
_root.attachMovie("bullet", "bullet" + b, b);
_root["bullet" + b]._x = this._x;
_root["bullet" + b]._y = this._y - 30;
fired = true;
setTimeout(allowFire, _root.bulletSpawn);
}
}
Thanks if you can help!