|
metadata
I’ve begun creating a game based on the as2 shootorials, and have run into an issue.
the ship shoots while holding spacebar, and is able to move any direction except for up and left… that is, after moving in any direction, the ship can shoot… except while holding up and left arrows.
if holding space bar to shoot, then pressing up and left, it only goes the first direction pressed, but not diagonally as it should.
Any help would be helpful. thanks.
|
|
metadata
this is the ship class:
`class ship extends MovieClip
{
var velocity;
function onLoad() //When a ship is first put on the stage:
{
velocity = 5;
}
function onEnterFrame() //actions performed each frame:
{
if( Key.isDown(Key.SPACE))
{
var projectile = _root.attachMovie("projectiles", "projectile"+_root.getNextHighestDepth(), _root.getNextHighestDepth());
projectile._x = _x;
projectile._y = _y;
}
if( Key.isDown(Key.RIGHT) )
{
_x = _x + velocity;
}
if( Key.isDown(Key.LEFT) )
{
_x = _x - velocity;
}
if( Key.isDown(Key.UP) )
{
_y = _y - velocity;
}
if( Key.isDown(Key.DOWN) )
{
_y = _y + velocity;
}
}
}`
|
|
metadata
That’s an issue with some (most) keyboards, nothing you can fix with code.
Don’t use SPACE in combination with arrow keys.
|