Topic: Game Programming /
What I'm doing wrong here?
Okay so I’m finished learning the Shootorial and I’ve started adding my own stuff to it.
One of the things I wanted was an adjustable shooting speed.
I made it like this:
________________________________________________________________
_root.speedButOff.onPress = function()
{
root.speedButOff.visible = false;
root.speedButOn.visible = true;
shootSpeed = 4;
}
_root.speedButOn.onPress = function()
{
root.speedButOn.visible = false;
root.speedButOff.visible = true;
shootSpeed = 0;
}
[…]
function onEnterFrame()
{
shootLimiter += 1;
if (Key.isDown(Key.SPACE) && shootLimiter > 8)
{
shootLimiter = shootSpeed;
var missile = _root.attachMovie(“Missile”, “Missile” + _root.getNextHighestDepth(), root.getNextHighestDepth());
missile.x = x + 50;
missile.y = _y + 2;
_root.soundFX.attachSound(“MissleShoot”);
_root.soundFX.start();
}
________________________________________________________________
The buttons are only for test purpose for easy enabling.
This doesn’t work, even though my logic says it should.
When I change the shootSpeed to 4 in onLoad() it works, but when I do it like this, it doesn’t.
Any advice?
|