ForumsProgramming ForumHUD out of place - ideas?

1 3500
Annihalation
offline
Annihalation
479 posts
Nomad

So I'm working on a game using Flash CS3 in AS2 because I'm too lazy to relearn programming and switch to AS3, and I've got myself in a weird situation. I have a HUD in game that is near the bottom of the screen, like almost every other game in existence, and the stage is focused on the main character at all times. So the character moves, the HUD follows him along with the camera. Here is my code:

[quote]onClipEvent (load) {
moveSpeed = 5;
radius = 8;
}
onClipEvent (enterFrame) {
ang = this._rotation *(Math.PI/180);
if (Key.isDown (65)) {
this._rotation -= 7;
}if (Key.isDown (87)) {
this._x += Math.cos(ang) * moveSpeed;
this._y += Math.sin(ang) * moveSpeed;
_root._x -= Math.cos(ang) * moveSpeed;
_root._y -= Math.sin(ang) * moveSpeed;
_root.cursor._x += Math.cos(ang) * moveSpeed;
_root.cursor._y += Math.sin(ang) * moveSpeed;
}if (Key.isDown (68)) {
this._rotation += 7;
}
}[quote]

The code works fine, but the HUD sorta lags behind... like, the character moves and the HUD sorta slips a little but fixes itself later. Anyone know how I can sync it better?

  • 1 Reply
Annihalation
offline
Annihalation
479 posts
Nomad

I solved it people, I just moved the code all into the same event handler and it has perfect sync if you ever have any laggy/awkward objects, just put them on similar event handlers.

Showing 1-1 of 1