Health bar lags when moving along with the camera

somersetjc

  • Posts: 40
So I am making a game with a few playable characters and when playing as the most recent character that I made there is a noticeable delay when the health bar is following the camera and it appears to lag behind. This is not happening with any other character and the code between characters is mostly the same. I think it might be lag but I am not sure.  By the way, the way I am making the camera follow the camera is by always setting the x and y values to the camera. At first, I tried anchoring it but it was just disappearing so I did that instead. If anybody knows what to do that would be very much appreciated.

JeffreyDriver

  • *
  • Posts: 2166
What first springs to mind is the difference between 'always' events, and 'drawing' events. I may be wrong, but 'always' events are carried out 100 times per second, whereas 'drawing' events are carried out according to the FPS, which I think is usually 60, but can degrade according to a number of factors, such as number of actors colliding.
Current Projects:
The Grand Grimoire Chronicles Episode 1 now on Kongregate!.
I always appreciate useful feedback. Thank you.
www.jeffreydriver.co.uk

merrak

  • *
  • Posts: 2521
@somersetjc: Can you upload a playable demo and attach the code in question?

...I may be wrong, but 'always' events are carried out 100 times per second, whereas 'drawing' events are carried out according to the FPS...

Your numbers are correct.

The timing of drawing events shouldn't be considered reliable.

somersetjc

  • Posts: 40
I have attached a playable flash demo and what do you mean by attach the code in question?

merrak

  • *
  • Posts: 2521
There's a camera icon at the bottom right of the code editor. You can use it to take a screenshot of your code.

somersetjc

  • Posts: 40
If you want to see what I mean choose Sergent Gary Pumpkinface in the character select and go to one of the levels in the flash demo in my previous reply. I have attached screenshots of the events for the health bar and sergeant gay pumpkinface. And for reference, I have also attached a screenshot of the events of one of the other characters that does not have this issue. Keep in mind that both characters have behaviors as well.

CmdrWhitey13

  • Posts: 503
I cant help but to wonder that some of your coding could be simplified to ease  the strain on the machine.

Example be for if Frozen, set animation to rice-r for self.

It would shrink the repeat in the code.

somersetjc

  • Posts: 40
I made the scenes before i made the new character but when I made a new scene and try it out then it worked for some reason. I am not sure why.

JeffreyDriver

  • *
  • Posts: 2166
The health actor didn't lag for me.

Anchor your health actor to the screen and set the position to X0, Y0. That'll stick it in the top-left corner.
Current Projects:
The Grand Grimoire Chronicles Episode 1 now on Kongregate!.
I always appreciate useful feedback. Thank you.
www.jeffreydriver.co.uk