Howdy,
I’ve got a problem with my gun game here. Attached is the latest version, but with on simple problem: when you press left, the gun movie clip does not flip as it should. What I’ve done here is, inside of the Guy movie clip (the one containing the Guy and the Gun movie clips) I have two frames: one with both mc’s poiting left, and one with both mc’s pointing right. Here are the only pieces of code associated with those movie clips:
To rotate the Gun (make it follow the mouse):
guy.gun.onEnterFrame = rotate;
function rotate() {
radians = Math.atan2(_ymouse-this._y-guy._y, _xmouse-this._x-guy._x);
degrees = radians*180/Math.PI;
this._rotation = Math.round(degrees);
}
To make the Guy move and turn around:
guymoves = new Object();
Key.addListener(guymoves);
guymoves.onKeyDown = function() {
if (Key.isDown(37) and guy._x > 0) {
guy._x -= 10;
guy.gotoAndStop(2)
} else if (Key.isDown(39) and guy._x < 600) {
guy._x += 10;
guy.gotoAndStop(1)
}
};
I don’t get why it doesn’t work. Please help me out, because once I’ve figured this out, I can proceed with the next step of the game’s design…